|
Twitch SDK (Internal)
|
#include <framewriter.h>
Classes | |
| struct | TrackedStatsRunningTotals |
Public Types | |
| enum | DelayState { DelayState::Okay, DelayState::Warning, DelayState::Error } |
| using | StreamAbortFunc = std::function< void(FrameWriter *source, TTV_ErrorCode ec)> |
| using | DelayStateChangedCallback = std::function< void(FrameWriter *source, DelayState state)> |
| using | BandwidthStatCallback = std::function< void(FrameWriter *source, const BandwidthStat &stat)> |
Public Member Functions | |
| FrameWriter (bool audioEnabled) | |
| virtual | ~FrameWriter () |
| TTV_ErrorCode | SetFlvMuxer (const std::shared_ptr< FlvMuxer > &flvMuxer) |
| TTV_ErrorCode | SetCustomMuxer (const std::shared_ptr< IMuxer > &muxer) |
| TTV_ErrorCode | Start (const VideoParams &videoParams) |
| TTV_ErrorCode | GetLastError () |
| uint64_t | GetQueueDelayInMilliseconds () const |
| uint32_t | GetQueueDelayInBytes () const |
| uint32_t | GetRecommendedBitRate () const |
| void | SetWarningDelayThresholdMilliseconds (uint64_t warningThreshHold) |
| void | SetErrorDelayThresholdMilliseconds (uint64_t errorThreshold) |
| DelayState | GetDelayState () const |
| void | SetDelayStateChangedCallback (const DelayStateChangedCallback &callback) |
| void | Shutdown () |
| void | SetStreamAbortCallback (StreamAbortFunc func) |
| void | SetBandwidthStatCallback (const BandwidthStatCallback &callback) |
| TTV_ErrorCode | GatherTrackingStats (uint64_t &averageRecommendedKbps, uint64_t &averageEncodedKbps) |
| virtual TTV_ErrorCode | WritePacket (std::unique_ptr< Packet > &&packet) override |
Private Member Functions | |
| void | TransferPacketToOutputQueues (std::unique_ptr< Packet > &&packet) |
| TTV_ErrorCode | SendDataToMuxers () |
| void | UpdateRecommendedBitRate () |
| void | UpdateDelayState () |
Private Attributes | |
| std::mutex | mMutex |
| std::condition_variable | mCondition |
| std::queue< std::unique_ptr< Packet > > | mPacketQueue |
| bool | mWriteFrameThreadProceed |
| Flag to indicate that the write thread should continue processing and will be true until the writer is shutdown. More... | |
| std::shared_ptr< IThread > | mWriteFrameThread |
| The thread that does the writing. More... | |
| std::shared_ptr< FlvMuxer > | mFlvMuxer |
| std::shared_ptr< IMuxer > | mCustomMuxer |
| StreamAbortFunc | mStreamAbortCallback |
| The function to call if the stream goes down. More... | |
| std::queue< std::unique_ptr< Packet > > | mAudioPacketQueue |
| std::queue< std::unique_ptr< Packet > > | mVideoPacketQueue |
| VideoParams | mVideoParams |
| std::atomic< uint64_t > | mLastSentPacketTimestamp |
| std::atomic< uint64_t > | mLastReceivedPacketTimestamp |
| DelayStateChangedCallback | mDelayStateChangedCallback |
| uint64_t | mWarningDelayThreshold |
| uint64_t | mErrorDelayThreshold |
| std::atomic< uint32_t > | mNumQueuedBytes |
| The number of bytes that are in the audio and video packet queues. More... | |
| std::atomic< uint64_t > | mEncodedBitCounter |
| The number of bytes output by the necoder since the last adjustment time. More... | |
| uint64_t | mStreamStartSystemTime |
| The system clock time at the start of the stream. More... | |
| uint64_t | mLastStatTime |
| The last time a bandwidth stat was emitted. More... | |
| TrackedStatsRunningTotals | mRunningTotals |
| std::mutex | mRunningTotalsMutex |
| BandwidthStatCallback | mBandwidthStatCallback |
| Callback that is invoked when a new bandwidth stat is generated. More... | |
| WaitForExpiry | mBitrateUpdateTimer |
| Timer for periodically updating the recommended bit rate. More... | |
| WaitForExpiry | mBitrateIncreaseTimer |
| Timer that enforces the frequency at which we can increase the bit rate. More... | |
| uint32_t | mRecommendedBitRate |
| The last recommended bitrate in bits per second. More... | |
| TTV_ErrorCode | mLastError |
| DelayState | mDelayState |
| bool | mAudioEnabled |
Responsible for gathering data packets from multiple sources and writing them to the FLV stream.
| using ttv::broadcast::FrameWriter::BandwidthStatCallback = std::function<void(FrameWriter* source, const BandwidthStat& stat)> |
| using ttv::broadcast::FrameWriter::DelayStateChangedCallback = std::function<void(FrameWriter* source, DelayState state)> |
| using ttv::broadcast::FrameWriter::StreamAbortFunc = std::function<void(FrameWriter* source, TTV_ErrorCode ec)> |
|
strong |
| ttv::broadcast::FrameWriter::FrameWriter | ( | bool | audioEnabled | ) |
|
virtual |
| TTV_ErrorCode ttv::broadcast::FrameWriter::GatherTrackingStats | ( | uint64_t & | averageRecommendedKbps, |
| uint64_t & | averageEncodedKbps | ||
| ) |
Returns the average recommended kbps and the average encoded kbps since the last time this method was called.
| [out] | averageRecommendedKbps | The average bit rate recommended by the ABS algorithm since the last time this method was called. |
| [out] | averageEncodedKbps | The actual bit rate output by the video encoder since the last time this method was called. |
|
inline |
| TTV_ErrorCode ttv::broadcast::FrameWriter::GetLastError | ( | ) |
|
inline |
Determines how many bytes of data are backed up on the send queue.
| uint64_t ttv::broadcast::FrameWriter::GetQueueDelayInMilliseconds | ( | ) | const |
Determines how many milliseconds of data is backed up on the send queue.
| uint32_t ttv::broadcast::FrameWriter::GetRecommendedBitRate | ( | ) | const |
Determines the bitrate in bits per second that should be used to maintain optimal stream health. This value will change frequently and may drop dramatically if bandwidth conditions worsen.
|
private |
|
inline |
| TTV_ErrorCode ttv::broadcast::FrameWriter::SetCustomMuxer | ( | const std::shared_ptr< IMuxer > & | muxer | ) |
|
inline |
|
inline |
| TTV_ErrorCode ttv::broadcast::FrameWriter::SetFlvMuxer | ( | const std::shared_ptr< FlvMuxer > & | flvMuxer | ) |
|
inline |
|
inline |
| void ttv::broadcast::FrameWriter::Shutdown | ( | ) |
| TTV_ErrorCode ttv::broadcast::FrameWriter::Start | ( | const VideoParams & | videoParams | ) |
|
private |
|
private |
|
private |
|
overridevirtual |
Adds a packet to be written to the network that contains video or audio data.
Implements ttv::broadcast::IFrameWriter.
|
private |
|
private |
|
private |
Callback that is invoked when a new bandwidth stat is generated.
|
private |
Timer that enforces the frequency at which we can increase the bit rate.
|
private |
Timer for periodically updating the recommended bit rate.
|
private |
|
private |
|
private |
|
private |
|
private |
The number of bytes output by the necoder since the last adjustment time.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The last time a bandwidth stat was emitted.
|
private |
|
private |
The number of bytes that are in the audio and video packet queues.
|
private |
|
private |
The last recommended bitrate in bits per second.
|
private |
|
private |
|
private |
The function to call if the stream goes down.
|
private |
The system clock time at the start of the stream.
|
private |
|
private |
|
private |
|
private |
The thread that does the writing.
|
private |
Flag to indicate that the write thread should continue processing and will be true until the writer is shutdown.
1.8.13