Twitch SDK (Internal)
broadcasttypes.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 #include <vector>
14 
15 namespace ttv
16 {
17  namespace broadcast
18  {
19  const uint32_t kMinBitRate = 300;
20  const uint32_t kMaxBitRate = 6000;
21  const uint32_t kDefaultInitialBitRate = 1500;
22  const uint32_t kDefaultFramesPerSecond = 30;
23  const uint32_t kMinFramesPerSecond = 10;
24  const uint32_t kMaxFramesPerSecond = 60;
25  const uint32_t kMaxFrameWidth = 1920;
26  const uint32_t kMaxFrameHeight = 1200;
27  const float kRecommendedBitsPerPixel = 0.1f;
28 
32  struct IngestServer
33  {
34  IngestServer();
35  IngestServer(const IngestServer& other);
36  void operator=(const IngestServer& other);
37 
38  std::string serverName;
39  std::string serverUrl;
40  uint32_t priority;
41  uint32_t serverId;
42  };
43 
47  enum class PixelFormat
48  {
49  TTV_PF_BGRA = 0x00010203,
50  TTV_PF_ABGR = 0x01020300,
51  TTV_PF_RGBA = 0x02010003,
52  TTV_PF_ARGB = 0x03020100
53  };
54 
58  enum class YUVFormat
59  {
60  TTV_YUV_NONE = -1,
61  TTV_YUV_I420,
62  TTV_YUV_YV12,
64  };
65 
69  enum class EncodingCpuUsage
70  {
71  Default,
72  Low,
73  Medium,
74  High
75  };
76 
80  struct VideoParams
81  {
82  VideoParams();
83 
88  uint32_t outputWidth;
93  uint32_t outputHeight;
102  uint32_t initialKbps;
106  uint32_t minimumKbps;
110  uint32_t maximumKbps;
119 
134  static TTV_ErrorCode ConfigureForBandwidth(uint32_t expectedKbps, uint32_t framesPerSecond, float bitsPerPixel, float aspectRatio, VideoParams& result);
150  static TTV_ErrorCode ConfigureForResolution(uint32_t width, uint32_t height, uint32_t framesPerSecond, float bitsPerPixel, VideoParams& result);
151  };
152 
153 
154  enum class ConnectionType
155  {
156  Wifi,
157  Ethernet,
158  Cellular,
159  Unknown
160  };
161 
162 
166  enum class AudioFormat
167  {
168  None,
169  PCM,
170  MP3,
171  AAC,
172  };
173 
177  enum class AudioSampleFormat
178  {
180  };
181 
185  enum class AudioSampleRate
186  {
187  Hz11250 = 11250,
188  Hz22500 = 22500,
189  Hz44100 = 44100
190  };
191 
192  typedef uint32_t AudioLayerId;
193 
198  {
199  ArchivingState();
200 
201  std::string cureUrl;
203  };
204 
208  struct GameInfo
209  {
210  GameInfo();
211 
212  std::string name;
213  uint32_t popularity;
214  uint32_t gameId;
215  };
216 
221  {
222  std::vector<GameInfo> games;
223  };
224 
225  enum class StreamStartFlags
226  {
227  None = 0,
228  BandwidthTest = 1 << 0
229  };
230 
231  enum class BroadcastState
232  {
233  Initialized,
236  Broadcasting,
238  };
239 
241  {
246  double recordedTime;
248  };
249 
254  {
255  std::string appVersion;
256 
257  uint32_t videoWidth;
258  uint32_t videoHeight;
259  uint32_t frameRate;
260  std::vector<uint8_t> videoSps;
261  std::vector<uint8_t> videoPps;
262 
264  uint32_t audioSampleRate;
265  uint32_t audioSampleSize;
267  bool audioStereo;
268  };
269  }
270 }
const uint32_t kMinFramesPerSecond
The minimum frames per second supported by the Twitch backend.
Definition: broadcasttypes.h:23
uint32_t videoWidth
The width of the video frame.
Definition: broadcasttypes.h:257
std::vector< uint8_t > videoPps
Picture parameter set.
Definition: broadcasttypes.h:261
std::string serverUrl
The URL of the Twitch server.
Definition: broadcasttypes.h:39
Definition: broadcasttypes.h:240
const uint32_t kMinBitRate
The minimum bit rate supported by the Twitch backend.
Definition: broadcasttypes.h:19
uint64_t recommendedBitsPerSecond
The bit rate the ABS algorithm has recommended to the encoder in bits per second. ...
Definition: broadcasttypes.h:242
std::string appVersion
The version of the app using the muxer.
Definition: broadcasttypes.h:255
8 bit Y plane followed by 8 bit 2x2 subsampled V and U planes (12 bits/pixel)
const float kRecommendedBitsPerPixel
Definition: broadcasttypes.h:27
uint32_t outputWidth
Definition: broadcasttypes.h:88
bool audioEnabled
Whether or not to capture and encode audio.
Definition: broadcasttypes.h:266
uint32_t gameId
The game&#39;s unique id.
Definition: broadcasttypes.h:214
uint64_t encoderOutputBitsPerSecond
The rate at which the vide encoder is actually producing data.
Definition: broadcasttypes.h:244
bool audioStereo
Whether or not to encode stereo audio.
Definition: broadcasttypes.h:267
std::vector< GameInfo > games
Definition: broadcasttypes.h:222
double congestionLevel
What fraction of our time is spent blocking on the network socket, from 0.0-1.0.
Definition: broadcasttypes.h:247
double backBufferSeconds
How many seconds of data is buffered to be sent.
Definition: broadcasttypes.h:245
uint32_t AudioLayerId
Definition: broadcasttypes.h:192
uint32_t targetFramesPerSecond
Definition: broadcasttypes.h:97
StreamStartFlags
Definition: broadcasttypes.h:225
MPEG-2 Audio Layer III.
EncodingCpuUsage
Definition: broadcasttypes.h:69
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
uint32_t audioSampleSize
The number of bits in a sample.
Definition: broadcasttypes.h:265
const uint32_t kMaxFrameHeight
The maximum height supported by the Twitch backend. Must be a multiple of 16.
Definition: broadcasttypes.h:26
uint32_t frameRate
The number of frames per second.
Definition: broadcasttypes.h:259
uint32_t initialKbps
Definition: broadcasttypes.h:102
AudioFormat audioFormat
The audio encoding format.
Definition: broadcasttypes.h:263
uint32_t audioSampleRate
The number of audio samples per second.
Definition: broadcasttypes.h:264
Definition: broadcasttypes.h:197
const uint32_t kMaxBitRate
The absolute maximum bit rate supported by the Twitch backend.
Definition: broadcasttypes.h:20
bool recordingEnabled
Recording is enabled/disabled for the channel.
Definition: broadcasttypes.h:202
ConnectionType
Definition: broadcasttypes.h:154
Definition: broadcasttypes.h:80
Definition: broadcasttypes.h:32
PixelFormat
Definition: broadcasttypes.h:47
bool automaticBitRateAdjustmentEnabled
Definition: broadcasttypes.h:118
std::string serverName
The name of the server suitable for displaying in UI.
Definition: broadcasttypes.h:38
uint32_t serverId
The unique server ID which should not change.
Definition: broadcasttypes.h:41
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
std::vector< uint8_t > videoSps
Sequence parameter set.
Definition: broadcasttypes.h:260
uint32_t popularity
A popularity rating for the game.
Definition: broadcasttypes.h:213
YUVFormat
Definition: broadcasttypes.h:58
AudioSampleFormat
Definition: broadcasttypes.h:177
double recordedTime
The time of the measurement in number of seconds since the start of broadcast.
Definition: broadcasttypes.h:246
8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling (12 bits/pixel) ...
Processing a request to stop broadcasting.
Advanced Audio Coding.
const uint32_t kMaxFrameWidth
The maximum width supported by the Twitch backend. Must be a multiple of 16.
Definition: broadcasttypes.h:25
const uint32_t kDefaultInitialBitRate
The default starting bit rate of a broadcast.
Definition: broadcasttypes.h:21
uint32_t outputHeight
Definition: broadcasttypes.h:93
uint32_t videoHeight
The height of the video frame.
Definition: broadcasttypes.h:258
uint64_t measuredBitsPerSecond
The actual measured speed we are sending data over the socket in bits per second. ...
Definition: broadcasttypes.h:243
void operator=(const IngestServer &other)
const uint32_t kMaxFramesPerSecond
The maximum frames per second supported by the Twitch backend.
Definition: broadcasttypes.h:24
BroadcastState
Definition: broadcasttypes.h:231
Processing a request to start broadcasting.
Definition: broadcasttypes.h:208
Definition: broadcasttypes.h:253
std::string cureUrl
The URL for where the user can go to enable video recording for the channel.
Definition: broadcasttypes.h:201
Pulse-code modulation.
AudioFormat
Definition: broadcasttypes.h:166
const uint32_t kDefaultFramesPerSecond
The default frames per second of the broadcast.
Definition: broadcasttypes.h:22
std::string name
The display name of the game.
Definition: broadcasttypes.h:212
AudioSampleRate
Definition: broadcasttypes.h:185
Definition: broadcasttypes.h:220
uint32_t minimumKbps
Definition: broadcasttypes.h:106
8 bit Y plane followed by 8 bit 2x2 subsampled U and V planes (12 bits/pixel)
EncodingCpuUsage encodingCpuUsage
Definition: broadcasttypes.h:114
uint32_t priority
The priority of the server, the lower the better option for the client.
Definition: broadcasttypes.h:40
uint32_t maximumKbps
Definition: broadcasttypes.h:110