Twitch SDK (Internal)
ivideoencoder.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
13 
14 #include <vector>
15 #include <memory>
16 
17 namespace ttv
18 {
19  namespace broadcast
20  {
21  class IFrameWriter;
22  class VideoFrame;
23  class IVideoEncoder;
24  }
25 }
26 
27 
41 {
42 public:
43  virtual ~IVideoEncoder();
44 
45 public:
49  virtual std::string GetName() const = 0;
53  virtual bool SupportsBitRateAdjustment() const = 0;
57  virtual TTV_ErrorCode Initialize() = 0;
58  virtual TTV_ErrorCode Shutdown() = 0;
62  virtual TTV_ErrorCode SetFrameWriter(const std::shared_ptr<IFrameWriter>& frameWriter) = 0;
63  /*
64  * Called by the system to ensure the video parameters are valid for the encoder.
65  * @return
66  * - TTV_EC_SUCCESS - Video parameters are valid for this encoder.
67  * - TTV_EC_BROADCAST_INVALID_RESOLUTION - Resolution is not valid for this encoder.
68  * - TTV_EC_BROADCAST_INVALID_FPS - Frames per second is not valid for this encoder.
69  * - TTV_EC_INVALID_ARG - Some other parameter is an invalid value.
70  */
71  virtual TTV_ErrorCode ValidateVideoParams(const VideoParams& videoParams) const = 0;
72  /*
73  * Called by the system when the stream starts.
74  */
75  virtual TTV_ErrorCode Start(uint32_t streamIndex, const VideoParams& videoParams) = 0;
79  virtual TTV_ErrorCode SubmitFrame(const std::shared_ptr<VideoFrame>& videoFrame) = 0;
83  virtual TTV_ErrorCode Stop() = 0;
87  virtual TTV_ErrorCode GetSpsPps(std::vector<uint8_t>& sps, std::vector<uint8_t>& pps) = 0;
91  virtual TTV_ErrorCode ValidateFrame(const std::shared_ptr<VideoFrame>& videoframe) = 0;
96  virtual TTV_ErrorCode SetTargetBitRate(uint32_t kbps) = 0;
100  template <typename T> bool SupportsReceiverProtocol() const { return SupportsReceiverProtocol(T::GetReceiverTypeId()); }
104  virtual bool SupportsReceiverProtocol(IVideoFrameReceiver::ReceiverTypeId typeId) const = 0;
108  virtual std::shared_ptr<IVideoFrameReceiver> GetReceiverImplementation(IVideoFrameReceiver::ReceiverTypeId typeId) = 0;
109 };
bool SupportsReceiverProtocol() const
Definition: ivideoencoder.h:100
virtual TTV_ErrorCode Start(uint32_t streamIndex, const VideoParams &videoParams)=0
virtual TTV_ErrorCode ValidateVideoParams(const VideoParams &videoParams) const =0
virtual TTV_ErrorCode SetTargetBitRate(uint32_t kbps)=0
virtual TTV_ErrorCode ValidateFrame(const std::shared_ptr< VideoFrame > &videoframe)=0
virtual bool SupportsBitRateAdjustment() const =0
virtual TTV_ErrorCode Stop()=0
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
virtual TTV_ErrorCode SetFrameWriter(const std::shared_ptr< IFrameWriter > &frameWriter)=0
Definition: broadcasttypes.h:80
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
Definition: ivideoencoder.h:40
virtual TTV_ErrorCode Initialize()=0
virtual TTV_ErrorCode GetSpsPps(std::vector< uint8_t > &sps, std::vector< uint8_t > &pps)=0
virtual TTV_ErrorCode SubmitFrame(const std::shared_ptr< VideoFrame > &videoFrame)=0
virtual TTV_ErrorCode Shutdown()=0
size_t ReceiverTypeId
Definition: ivideoframereceiver.h:28
virtual std::shared_ptr< IVideoFrameReceiver > GetReceiverImplementation(IVideoFrameReceiver::ReceiverTypeId typeId)=0
virtual std::string GetName() const =0