Twitch SDK (Internal)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ttv::broadcast::FlvMuxer Class Reference

#include <flvmuxer.h>

Inheritance diagram for ttv::broadcast::FlvMuxer:
ttv::broadcast::IMuxer

Public Member Functions

 FlvMuxer (std::shared_ptr< StreamStats > streamStats)
 
virtual ~FlvMuxer ()
 
void Update ()
 
TTV_ErrorCode GetError ()
 
TTV_ErrorCode GetAverageSendBitRate (uint64_t measurementWindowMilliseconds, uint64_t &bitsPerSecond) const
 
TTV_ErrorCode GetCongestionLevel (uint64_t measurementWindowMilliseconds, double &congestionLevel) const
 
virtual TTV_ErrorCode Start (const MuxerParameters &params) override
 
virtual TTV_ErrorCode WriteVideoPacket (const Packet &packet) override
 
virtual TTV_ErrorCode WriteAudioPacket (const Packet &packet) override
 
virtual TTV_ErrorCode WriteVideoSpsPps (const std::vector< uint8_t > &sps, const std::vector< uint8_t > &pps) override
 
virtual TTV_ErrorCode Stop () override
 
void SetRtmpUrl (const std::string &url)
 
void SetFlvPath (const std::wstring &path)
 

Private Member Functions

TTV_ErrorCode WriteMetaPacket (const std::shared_ptr< AMF0Encoder > &encoder)
 
TTV_ErrorCode WriteAudioHeader (uint8_t audioFlags, AudioFormat encodingFormat)
 
TTV_ErrorCode BeginChunk (flv::TagTypes type, uint32_t timestamp, size_t length)
 
TTV_ErrorCode EndChunk (size_t length)
 
size_t WriteToOutput (const uint8_t *data, size_t length, bool rtmpData=true)
 
template<class _T >
size_t WriteToOutput (_T *data, bool rtmpData=true)
 
size_t WriteToOutput (const std::vector< uint8_t > &data, bool rtmpData=true)
 

Private Attributes

FILE * mOutputFile
 
std::unique_ptr< RtmpStreammRtmpStream
 
std::shared_ptr< StreamStatsmStreamStats
 
std::vector< uint8_t > mAudioFlags
 
std::vector< uint8_t > mVideoFlags
 
MuxerParameters mInitParams
 
std::string mRtmpUrl
 
std::wstring mFlvPath
 
uint64_t mTotalVideoPacketsSent
 

Constructor & Destructor Documentation

◆ FlvMuxer()

ttv::broadcast::FlvMuxer::FlvMuxer ( std::shared_ptr< StreamStats streamStats)

◆ ~FlvMuxer()

virtual ttv::broadcast::FlvMuxer::~FlvMuxer ( )
virtual

Member Function Documentation

◆ BeginChunk()

TTV_ErrorCode ttv::broadcast::FlvMuxer::BeginChunk ( flv::TagTypes  type,
uint32_t  timestamp,
size_t  length 
)
private

◆ EndChunk()

TTV_ErrorCode ttv::broadcast::FlvMuxer::EndChunk ( size_t  length)
private

◆ GetAverageSendBitRate()

TTV_ErrorCode ttv::broadcast::FlvMuxer::GetAverageSendBitRate ( uint64_t  measurementWindowMilliseconds,
uint64_t &  bitsPerSecond 
) const

Computes the average sending bit rate in bits per second over a sliding window.

◆ GetCongestionLevel()

TTV_ErrorCode ttv::broadcast::FlvMuxer::GetCongestionLevel ( uint64_t  measurementWindowMilliseconds,
double &  congestionLevel 
) const

Returns the fraction of time spent blocking on the socket over a sliding window.

◆ GetError()

TTV_ErrorCode ttv::broadcast::FlvMuxer::GetError ( )

Retrieves the fatal error if the stream has become invalid.

◆ SetFlvPath()

void ttv::broadcast::FlvMuxer::SetFlvPath ( const std::wstring &  path)
inline

◆ SetRtmpUrl()

void ttv::broadcast::FlvMuxer::SetRtmpUrl ( const std::string &  url)
inline

◆ Start()

virtual TTV_ErrorCode ttv::broadcast::FlvMuxer::Start ( const MuxerParameters parameters)
overridevirtual

Specifies that the encoding has begun.

Parameters
parametersThe parameters of the encoding.
Returns
  • TTV_EC_SUCCESS if the start is successful.
  • Any other error code otherwise. This will prevent the encoding stream from continuing if this is the only muxer.

Implements ttv::broadcast::IMuxer.

◆ Stop()

virtual TTV_ErrorCode ttv::broadcast::FlvMuxer::Stop ( )
overridevirtual

Specifies that the encoding has stopped.

Returns
TTV_EC_SUCCESS if the stop is successful. Any errors returned from this will be ignored.

Implements ttv::broadcast::IMuxer.

◆ Update()

void ttv::broadcast::FlvMuxer::Update ( )

◆ WriteAudioHeader()

TTV_ErrorCode ttv::broadcast::FlvMuxer::WriteAudioHeader ( uint8_t  audioFlags,
AudioFormat  encodingFormat 
)
private

◆ WriteAudioPacket()

virtual TTV_ErrorCode ttv::broadcast::FlvMuxer::WriteAudioPacket ( const Packet packet)
overridevirtual

Writes an audio packet to the stream.

Parameters
packetThe audio data.
Returns
  • TTV_EC_SUCCESS if the writing is successful.
  • Any other error code otherwise. This will stop the encoding stream if this is the only muxer.

Implements ttv::broadcast::IMuxer.

◆ WriteMetaPacket()

TTV_ErrorCode ttv::broadcast::FlvMuxer::WriteMetaPacket ( const std::shared_ptr< AMF0Encoder > &  encoder)
private

◆ WriteToOutput() [1/3]

size_t ttv::broadcast::FlvMuxer::WriteToOutput ( const uint8_t *  data,
size_t  length,
bool  rtmpData = true 
)
private

◆ WriteToOutput() [2/3]

template<class _T >
size_t ttv::broadcast::FlvMuxer::WriteToOutput ( _T *  data,
bool  rtmpData = true 
)
inlineprivate

◆ WriteToOutput() [3/3]

size_t ttv::broadcast::FlvMuxer::WriteToOutput ( const std::vector< uint8_t > &  data,
bool  rtmpData = true 
)
inlineprivate

◆ WriteVideoPacket()

virtual TTV_ErrorCode ttv::broadcast::FlvMuxer::WriteVideoPacket ( const Packet packet)
overridevirtual

Writes a video packet to the stream.

Parameters
packetThe video data.
Returns
  • TTV_EC_SUCCESS if the writing is successful.
  • Any other error code otherwise. This will stop the encoding stream if this is the only muxer.

Implements ttv::broadcast::IMuxer.

◆ WriteVideoSpsPps()

virtual TTV_ErrorCode ttv::broadcast::FlvMuxer::WriteVideoSpsPps ( const std::vector< uint8_t > &  sps,
const std::vector< uint8_t > &  pps 
)
overridevirtual

Writes the video SPS and PPS to the stream. This needs to be done before an IDR frame that it applies to.

Parameters
spsThe video SPS data.
ppsThe video PPS data.
Returns
  • TTV_EC_SUCCESS if the writing is successful.
  • Any other error code otherwise. This will stop the encoding stream if this is the only muxer.

Implements ttv::broadcast::IMuxer.

Member Data Documentation

◆ mAudioFlags

std::vector<uint8_t> ttv::broadcast::FlvMuxer::mAudioFlags
private

◆ mFlvPath

std::wstring ttv::broadcast::FlvMuxer::mFlvPath
private

◆ mInitParams

MuxerParameters ttv::broadcast::FlvMuxer::mInitParams
private

◆ mOutputFile

FILE* ttv::broadcast::FlvMuxer::mOutputFile
private

◆ mRtmpStream

std::unique_ptr<RtmpStream> ttv::broadcast::FlvMuxer::mRtmpStream
private

◆ mRtmpUrl

std::string ttv::broadcast::FlvMuxer::mRtmpUrl
private

◆ mStreamStats

std::shared_ptr<StreamStats> ttv::broadcast::FlvMuxer::mStreamStats
private

◆ mTotalVideoPacketsSent

uint64_t ttv::broadcast::FlvMuxer::mTotalVideoPacketsSent
private

◆ mVideoFlags

std::vector<uint8_t> ttv::broadcast::FlvMuxer::mVideoFlags
private

The documentation for this class was generated from the following file: