Twitch SDK (Internal)
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
ttv::broadcast Namespace Reference

Namespaces

 flv
 

Classes

class  AacAudioFrame
 
class  AacReceiver
 
class  AMF0Encoder
 
class  AMF0Nop
 
class  AMF0NumberDecoder
 
class  AMF0Printer
 
class  AMF0PropertyDecoder
 
class  AMF0StringDecoder
 
class  AppleAacEncoder
 
class  AppleAudioCapture
 
class  AppleVideoEncoder
 
struct  ArchivingState
 
class  AudioCaptureBase
 
class  AudioFrame
 
class  AudioMixerProxy
 
struct  AudioParams
 
class  AudioStreamer
 
class  BandwidthReport
 
struct  BandwidthStat
 
class  BaseFrameAllocator
 
class  BroadcastAPI
 
class  ChannelInfoTask
 
struct  ChunkHeader
 
struct  D3DAllocatorParams
 
class  D3DFrameAllocator
 
class  FlvMuxer
 
class  FrameWriter
 
struct  GameInfo
 
struct  GameInfoList
 
class  GameStreamsTask
 
class  IAacAudioFrameReceiver
 
class  IAMF0
 
class  IAudioCapture
 
class  IAudioEncoder
 
class  IAudioFrameReceiver
 
class  IAudioMixer
 
class  IBandwidthStatListener
 
class  IBroadcastAPIListener
 
class  ICVPixelBufferVideoFrameReceiver
 
class  ID3dDeviceManager9VideoFrameReceiver
 
class  IFrameWriter
 
class  IIngestTester
 
class  IIngestTesterListener
 
class  IMuxer
 
class  IngestListTask
 
struct  IngestSampleData
 
struct  IngestServer
 
class  IngestTester
 
class  IngestTesterListenerProxy
 
class  IntelVideoEncoder
 
class  IPcmAudioFrameReceiver
 
class  IPreEncodedAudioFrameReceiver
 
class  IPreEncodedVideoFrameReceiver
 
class  IRawVideoFrameReceiver
 
class  IVideoCapture
 
class  IVideoEncoder
 
class  IVideoFrameQueue
 
class  IVideoFrameReceiver
 
class  LameAudioEncoder
 
class  MatchGameNamesTask
 
class  MetaDataTask
 
struct  mfxAllocatorParams
 
class  MFXBufferAllocator
 
class  MFXFrameAllocator
 
struct  MuxerParameters
 
struct  Packet
 
class  PassThroughAudioCapture
 
class  PassThroughAudioEncoder
 
class  PassThroughVideoCapture
 
class  PassThroughVideoEncoder
 
class  PauseFrameGenerator
 
class  PcmAudioFrame
 
class  PcmAudioMixer
 
class  PcmAudioReceiver
 
class  RecordingStatusTask
 
class  RtmpConnectState
 
struct  RtmpContext
 
class  RtmpCreateStreamState
 
class  RtmpErrorState
 
class  RtmpHandshakeState
 
class  RtmpIdleState
 
class  RtmpInitializeState
 
class  RtmpMessageDetails
 
class  RtmpPublishState
 
class  RtmpSendVideoState
 
class  RtmpShutdownState
 
class  RtmpState
 
class  RtmpStream
 
class  RunCommercialTask
 
class  SetStreamInfoTask
 
class  Streamer
 
struct  StreamerContext
 
class  StreamerListenerProxy
 
class  StreamStats
 
class  StreamStatsListenerProxy
 
struct  SysMemAllocatorParams
 
class  SysMemBufferAllocator
 
class  SysMemFrameAllocator
 
class  TwitchAPI
 
class  VideoFrame
 
class  VideoFrameQueue
 
struct  VideoParams
 
class  VideoStreamer
 
class  WaveFileWriter
 
class  WinAudioCapture
 

Typedefs

typedef uint32_t AudioLayerId
 
typedef uint8_t RtmpMessageheader[16]
 
typedef std::array< uint8_t, 0x10000 > rtmpinputbuffer_t
 

Enumerations

enum  PixelFormat { PixelFormat::TTV_PF_BGRA = 0x00010203, PixelFormat::TTV_PF_ABGR = 0x01020300, PixelFormat::TTV_PF_RGBA = 0x02010003, PixelFormat::TTV_PF_ARGB = 0x03020100 }
 
enum  YUVFormat { YUVFormat::TTV_YUV_NONE = -1, YUVFormat::TTV_YUV_I420, YUVFormat::TTV_YUV_YV12, YUVFormat::TTV_YUV_NV12 }
 
enum  EncodingCpuUsage { EncodingCpuUsage::Default, EncodingCpuUsage::Low, EncodingCpuUsage::Medium, EncodingCpuUsage::High }
 
enum  ConnectionType { ConnectionType::Wifi, ConnectionType::Ethernet, ConnectionType::Cellular, ConnectionType::Unknown }
 
enum  AudioFormat { AudioFormat::None, AudioFormat::PCM, AudioFormat::MP3, AudioFormat::AAC }
 
enum  AudioSampleFormat { AudioSampleFormat::TTV_ASF_PCM_S16 }
 
enum  AudioSampleRate { AudioSampleRate::Hz11250 = 11250, AudioSampleRate::Hz22500 = 22500, AudioSampleRate::Hz44100 = 44100 }
 
enum  StreamStartFlags { StreamStartFlags::None = 0, StreamStartFlags::BandwidthTest = 1 << 0 }
 
enum  BroadcastState {
  BroadcastState::Initialized, BroadcastState::ReadyToBroadcast, BroadcastState::StartingBroadcast, BroadcastState::Broadcasting,
  BroadcastState::StoppingBroadcast
}
 
enum  { RTMP_DEFAULT_CHUNK_SIZE = 128 }
 
enum  Chunktype : uint8_t { RTMP_CHUNKTYPE_LARGE = 0, RTMP_CHUNKTYPE_MEDIUM, RTMP_CHUNKTYPE_SMALL, RTMP_CHUNKTYPE_NONE }
 
enum  Channel : uint8_t {
  RTMP_CHANNEL_INVALID = 0, RTMP_CHANNEL_NETWORK = 2, RTMP_CHANNEL_SYSTEM, RTMP_CHANNEL_SOURCE,
  RTMP_CHANNEL_NETSTREAM, RTMP_CHANNEL_VIDEO = 8, RTMP_CHANNEL_AUDIO
}
 
enum  PacketType : uint8_t {
  RTMP_PKT_INVALID = 0x00, RTMP_PKT_CHUNK_SIZE = 0x01, RTMP_PKT_ABORT_MSG = 0x02, RTMP_PKT_BYTES_READ = 0x03,
  RTMP_PKT_CONTROL = 0x04, RTMP_PKT_WINACKSIZE = 0x05, RTMP_PKT_PEER_BW = 0x06, RTMP_PKT_EDGE_ORIGIN = 0x07,
  RTMP_PKT_AUDIO = 0x08, RTMP_PKT_VIDEO = 0x09, RTMP_PKT_AMF3_DATA = 0x0F, RTMP_PKT_AMF3_SO = 0x10,
  RTMP_PKT_AMF3 = 0x11, RTMP_PKT_AMF0_DATA = 0x12, RTMP_PKT_AMF0_SO = 0x13, RTMP_PKT_AMF0 = 0x14,
  RTMP_PKT_AGGREGATE = 0x16
}
 
enum  CtlType : uint8_t {
  RTMP_CTL_STREAM_BEGIN = 0, RTMP_CTL_STREAM_EOF, RTMP_CTL_STREAM_DRY, RTMP_CTL_SET_BUFFER_LENGTH,
  RTMP_CTL_STREAM_RECORDED, RTMP_CTL_PING = 6, RTMP_CTL_PONG
}
 
enum  eTypeHandle { DXVA2_PROCESSOR = 0x00, DXVA2_DECODER = 0x01 }
 

Functions

const char * BroadcastErrorToString (TTV_ErrorCode ec)
 
void GetBroadcastErrorCodeValues (std::vector< EnumValue > &result)
 
const uint8_t * DecodeAMF (const uint8_t *data, std::shared_ptr< IAMF0 > output)
 
template<class Inserter >
void InsertBigEndian32 (Inserter it, uint32_t val)
 
template<class Inserter >
void InsertBigEndian (Inserter it, uint32_t val)
 
template<class Inserter >
void InsertBigEndian (Inserter it, uint16_t val)
 
uint32_t BigToLittle (uint32_t source)
 
uint32_t BigToLittle (flv::uint24_t source)
 
size_t GetChunkSize (char firstByteOfChunk)
 
ChunkHeader PopulateChunkHeader (const uint8_t *buffer)
 
bool IsValidOSVersion ()
 
const char * GetOSName ()
 
void RGBtoYUV (const uint8_t *rgbBuffer, uint32_t bgraMask, uint width, uint height, uint8_t *YBuffer, uint8_t *UVBuffer, YUVFormat yuvFormat, bool verticalFlip=false)
 
void RGBtoYUV_SSE (const uint8_t *rgbBuffer, uint32_t bgraMask, uint width, uint height, uint8_t *YBuffer, uint8_t *UVBuffer, YUVFormat yuvFormat, bool verticalFlip)
 

Variables

const uint32_t kAudioEncodeRate = 44100
 The sample rate of the audio to be sent on the stream. More...
 
const uint32_t kInputAudioBitsPerSample = 16
 Bits per input audio sample per channel (PCM) More...
 
const uint32_t kMp3Bitrate = 128
 
const uint32_t kMinBitRate = 300
 The minimum bit rate supported by the Twitch backend. More...
 
const uint32_t kMaxBitRate = 6000
 The absolute maximum bit rate supported by the Twitch backend. More...
 
const uint32_t kDefaultInitialBitRate = 1500
 The default starting bit rate of a broadcast. More...
 
const uint32_t kDefaultFramesPerSecond = 30
 The default frames per second of the broadcast. More...
 
const uint32_t kMinFramesPerSecond = 10
 The minimum frames per second supported by the Twitch backend. More...
 
const uint32_t kMaxFramesPerSecond = 60
 The maximum frames per second supported by the Twitch backend. More...
 
const uint32_t kMaxFrameWidth = 1920
 The maximum width supported by the Twitch backend. Must be a multiple of 16. More...
 
const uint32_t kMaxFrameHeight = 1200
 The maximum height supported by the Twitch backend. Must be a multiple of 16. More...
 
const float kRecommendedBitsPerPixel = 0.1f
 

Class Documentation

◆ ttv::broadcast::BandwidthStat

struct ttv::broadcast::BandwidthStat
Class Members
double backBufferSeconds How many seconds of data is buffered to be sent.
double congestionLevel What fraction of our time is spent blocking on the network socket, from 0.0-1.0.
uint64_t encoderOutputBitsPerSecond The rate at which the vide encoder is actually producing data.
uint64_t measuredBitsPerSecond The actual measured speed we are sending data over the socket in bits per second.
uint64_t recommendedBitsPerSecond The bit rate the ABS algorithm has recommended to the encoder in bits per second.
double recordedTime The time of the measurement in number of seconds since the start of broadcast.

◆ ttv::broadcast::ChunkHeader

struct ttv::broadcast::ChunkHeader
Class Members
uint32_t messageStreamId
PacketType messageType
uint32_t packetLength
uint8_t streamId
uint32_t timestamp
Chunktype type

◆ ttv::broadcast::GameInfoList

struct ttv::broadcast::GameInfoList

A list of game info structs.

Class Members
vector< GameInfo > games

◆ ttv::broadcast::MuxerParameters

struct ttv::broadcast::MuxerParameters

The values required to initialize an video + optional audio stream.

Class Members
string appVersion The version of the app using the muxer.
bool audioEnabled Whether or not to capture and encode audio.
AudioFormat audioFormat The audio encoding format.
uint32_t audioSampleRate The number of audio samples per second.
uint32_t audioSampleSize The number of bits in a sample.
bool audioStereo Whether or not to encode stereo audio.
uint32_t frameRate The number of frames per second.
uint32_t videoHeight The height of the video frame.
vector< uint8_t > videoPps Picture parameter set.
vector< uint8_t > videoSps Sequence parameter set.
uint32_t videoWidth The width of the video frame.

Typedef Documentation

◆ AudioLayerId

typedef uint32_t ttv::broadcast::AudioLayerId

◆ rtmpinputbuffer_t

typedef std::array<uint8_t, 0x10000> ttv::broadcast::rtmpinputbuffer_t

◆ RtmpMessageheader

typedef uint8_t ttv::broadcast::RtmpMessageheader[16]

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RTMP_DEFAULT_CHUNK_SIZE 

◆ AudioFormat

The data format of audio samples.

Enumerator
None 

No audio.

PCM 

Pulse-code modulation.

MP3 

MPEG-2 Audio Layer III.

AAC 

Advanced Audio Coding.

◆ AudioSampleFormat

Supported input audio sample formats

Enumerator
TTV_ASF_PCM_S16 

PCM signed 16-bit.

◆ AudioSampleRate

The supported sample rates in samples per second.

Enumerator
Hz11250 
Hz22500 
Hz44100 

◆ BroadcastState

Enumerator
Initialized 

Initialize has been called.

ReadyToBroadcast 

Idle and ready to broadcast.

StartingBroadcast 

Processing a request to start broadcasting.

Broadcasting 

Currently broadcasting.

StoppingBroadcast 

Processing a request to stop broadcasting.

◆ Channel

enum ttv::broadcast::Channel : uint8_t

Common Chunk-stream-ids. Not set in stone- they are just the usual convention...

enum names and values taken from imbibe, so kept the naming to make debugging easier

Enumerator
RTMP_CHANNEL_INVALID 
RTMP_CHANNEL_NETWORK 
RTMP_CHANNEL_SYSTEM 
RTMP_CHANNEL_SOURCE 
RTMP_CHANNEL_NETSTREAM 
RTMP_CHANNEL_VIDEO 
RTMP_CHANNEL_AUDIO 

◆ Chunktype

enum ttv::broadcast::Chunktype : uint8_t

Chunk header-type, indicated in first byte of chunk basic header

enum names and values taken from imbibe, so kept the naming to make debugging easier

Enumerator
RTMP_CHUNKTYPE_LARGE 
RTMP_CHUNKTYPE_MEDIUM 
RTMP_CHUNKTYPE_SMALL 
RTMP_CHUNKTYPE_NONE 

◆ ConnectionType

Enumerator
Wifi 
Ethernet 
Cellular 
Unknown 

◆ CtlType

enum ttv::broadcast::CtlType : uint8_t

When packet type is RTMP_PKT_CONTROL- these are the possible payloads

enum names and values taken from imbibe, so kept the naming to make debugging easier

Enumerator
RTMP_CTL_STREAM_BEGIN 

Data: stream-id (4B)

RTMP_CTL_STREAM_EOF 

Data: stream-id (4B)

RTMP_CTL_STREAM_DRY 

Data: stream-id (4B)

RTMP_CTL_SET_BUFFER_LENGTH 

Data: stream-id, buffer-length in milliseconds (*** 8B ***)

RTMP_CTL_STREAM_RECORDED 

Server telling client it's not live, Data: stream-id (4B)

RTMP_CTL_PING 

Data: timestamp (4B)

RTMP_CTL_PONG 

Responds with the ping's timestamp, so RTT can be calculated (4B)

◆ EncodingCpuUsage

Set CPU usage level for video encoding. This may not have any effect on some platforms and encoders.

Enumerator
Default 
Low 
Medium 
High 

◆ eTypeHandle

Enumerator
DXVA2_PROCESSOR 
DXVA2_DECODER 

◆ PacketType

Packet types, indicated in the chunk header

enum names and values taken from imbibe, so kept the naming to make debugging easier

Enumerator
RTMP_PKT_INVALID 

Not a real value according to the standard.

RTMP_PKT_CHUNK_SIZE 
RTMP_PKT_ABORT_MSG 
RTMP_PKT_BYTES_READ 
RTMP_PKT_CONTROL 

See RTMP_CTL_* below for possible values.

RTMP_PKT_WINACKSIZE 
RTMP_PKT_PEER_BW 
RTMP_PKT_EDGE_ORIGIN 

No payloads actually documented...

RTMP_PKT_AUDIO 
RTMP_PKT_VIDEO 
RTMP_PKT_AMF3_DATA 

amf3 metadata body

RTMP_PKT_AMF3_SO 

amf3 shared object command (don't support)

RTMP_PKT_AMF3 

cmd-name, trans-id, amf3 body

RTMP_PKT_AMF0_DATA 

amf0 metadata body

RTMP_PKT_AMF0_SO 

amf0 shared object command (don't support)

RTMP_PKT_AMF0 

cmd-name, trans-id, amf0 body

RTMP_PKT_AGGREGATE 

needs to be chopped up

◆ PixelFormat

Supported input frame pixel formats.

Enumerator
TTV_PF_BGRA 
TTV_PF_ABGR 
TTV_PF_RGBA 
TTV_PF_ARGB 

◆ StreamStartFlags

Enumerator
None 
BandwidthTest 

◆ YUVFormat

Supported YUV convertion types.

Enumerator
TTV_YUV_NONE 
TTV_YUV_I420 

8 bit Y plane followed by 8 bit 2x2 subsampled U and V planes (12 bits/pixel)

TTV_YUV_YV12 

8 bit Y plane followed by 8 bit 2x2 subsampled V and U planes (12 bits/pixel)

TTV_YUV_NV12 

8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling (12 bits/pixel)

Function Documentation

◆ BigToLittle() [1/2]

uint32_t ttv::broadcast::BigToLittle ( uint32_t  source)
inline

◆ BigToLittle() [2/2]

uint32_t ttv::broadcast::BigToLittle ( flv::uint24_t  source)
inline

◆ BroadcastErrorToString()

const char* ttv::broadcast::BroadcastErrorToString ( TTV_ErrorCode  ec)

The error code string lookup for broadcast. This is not normally used directly by clients. Use ttv::ErrorToString() instead.

◆ DecodeAMF()

const uint8_t* ttv::broadcast::DecodeAMF ( const uint8_t *  data,
std::shared_ptr< IAMF0 output 
)

◆ GetBroadcastErrorCodeValues()

void ttv::broadcast::GetBroadcastErrorCodeValues ( std::vector< EnumValue > &  result)

◆ GetChunkSize()

size_t ttv::broadcast::GetChunkSize ( char  firstByteOfChunk)
inline

◆ GetOSName()

const char* ttv::broadcast::GetOSName ( )

◆ InsertBigEndian() [1/2]

template<class Inserter >
void ttv::broadcast::InsertBigEndian ( Inserter  it,
uint32_t  val 
)
inline

◆ InsertBigEndian() [2/2]

template<class Inserter >
void ttv::broadcast::InsertBigEndian ( Inserter  it,
uint16_t  val 
)
inline

◆ InsertBigEndian32()

template<class Inserter >
void ttv::broadcast::InsertBigEndian32 ( Inserter  it,
uint32_t  val 
)
inline

◆ IsValidOSVersion()

bool ttv::broadcast::IsValidOSVersion ( )

◆ PopulateChunkHeader()

ChunkHeader ttv::broadcast::PopulateChunkHeader ( const uint8_t *  buffer)
inline

◆ RGBtoYUV()

void ttv::broadcast::RGBtoYUV ( const uint8_t *  rgbBuffer,
uint32_t  bgraMask,
uint  width,
uint  height,
uint8_t *  YBuffer,
uint8_t *  UVBuffer,
YUVFormat  yuvFormat,
bool  verticalFlip = false 
)

◆ RGBtoYUV_SSE()

void ttv::broadcast::RGBtoYUV_SSE ( const uint8_t *  rgbBuffer,
uint32_t  bgraMask,
uint  width,
uint  height,
uint8_t *  YBuffer,
uint8_t *  UVBuffer,
YUVFormat  yuvFormat,
bool  verticalFlip 
)

Variable Documentation

◆ kAudioEncodeRate

const uint32_t ttv::broadcast::kAudioEncodeRate = 44100

The sample rate of the audio to be sent on the stream.

◆ kDefaultFramesPerSecond

const uint32_t ttv::broadcast::kDefaultFramesPerSecond = 30

The default frames per second of the broadcast.

◆ kDefaultInitialBitRate

const uint32_t ttv::broadcast::kDefaultInitialBitRate = 1500

The default starting bit rate of a broadcast.

◆ kInputAudioBitsPerSample

const uint32_t ttv::broadcast::kInputAudioBitsPerSample = 16

Bits per input audio sample per channel (PCM)

◆ kMaxBitRate

const uint32_t ttv::broadcast::kMaxBitRate = 6000

The absolute maximum bit rate supported by the Twitch backend.

◆ kMaxFrameHeight

const uint32_t ttv::broadcast::kMaxFrameHeight = 1200

The maximum height supported by the Twitch backend. Must be a multiple of 16.

◆ kMaxFramesPerSecond

const uint32_t ttv::broadcast::kMaxFramesPerSecond = 60

The maximum frames per second supported by the Twitch backend.

◆ kMaxFrameWidth

const uint32_t ttv::broadcast::kMaxFrameWidth = 1920

The maximum width supported by the Twitch backend. Must be a multiple of 16.

◆ kMinBitRate

const uint32_t ttv::broadcast::kMinBitRate = 300

The minimum bit rate supported by the Twitch backend.

◆ kMinFramesPerSecond

const uint32_t ttv::broadcast::kMinFramesPerSecond = 10

The minimum frames per second supported by the Twitch backend.

◆ kMp3Bitrate

const uint32_t ttv::broadcast::kMp3Bitrate = 128

◆ kRecommendedBitsPerPixel

const float ttv::broadcast::kRecommendedBitsPerPixel = 0.1f