Twitch SDK (Internal)
rtmpstream.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 
11 
12 namespace ttv
13 {
14  namespace broadcast
15  {
16  class RtmpStream;
17  class RtmpState;
18  class StreamStats;
19  class RtmpMessageDetails;
20  }
21 }
22 
24 {
25 public:
26  RtmpStream(std::shared_ptr<StreamStats> streamStats);
28 
29  void Start(const std::string& url);
30  void Update();
31  void Stop();
32 
33  TTV_ErrorCode BeginFLVChunk(flv::TagTypes type, uint32_t timestamp, size_t length);
34  TTV_ErrorCode AddFLVData(const uint8_t* data, size_t length);
43  TTV_ErrorCode GetAverageSendBitRate(uint64_t measurementWindowMilliseconds, uint64_t& bitsPerSecond) const { return mContext.mSocket.GetAverageSendBitRate(measurementWindowMilliseconds, bitsPerSecond); }
47  TTV_ErrorCode GetCongestionLevel(uint64_t measurementWindowMilliseconds, double& congestionLevel) const { return mContext.mSocket.GetCongestionLevel(measurementWindowMilliseconds, congestionLevel); }
48 
49 private:
50  bool ChangeState();
51 
53  std::array< std::unique_ptr<RtmpState>, static_cast<uint32_t>(RtmpContext::State::Count) > mStates;
54 
56 };
TTV_ErrorCode AddFLVData(const uint8_t *data, size_t length)
RtmpContext mContext
Definition: rtmpstream.h:52
TTV_ErrorCode BeginFLVChunk(flv::TagTypes type, uint32_t timestamp, size_t length)
TTV_ErrorCode EndFLVChunk()
TTV_ErrorCode GetError()
Definition: rtmpcontext.h:31
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
TTV_ErrorCode GetAverageSendBitRate(uint64_t measurementWindowMilliseconds, uint64_t &bitsPerSecond) const
Definition: rtmpstream.h:43
Definition: rtmpstream.h:23
BufferedSocket mSocket
Definition: rtmpcontext.h:71
TagTypes
Definition: flvformat.h:22
TTV_ErrorCode GetAverageSendBitRate(uint64_t measurementWindow, uint64_t &bitsPerSecond) const
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
RtmpMessageDetails mChunkDetails
Definition: rtmpstream.h:55
TTV_ErrorCode GetCongestionLevel(uint64_t measurementWindow, double &congestionLevel) const
TTV_ErrorCode GetCongestionLevel(uint64_t measurementWindowMilliseconds, double &congestionLevel) const
Definition: rtmpstream.h:47
RtmpStream(std::shared_ptr< StreamStats > streamStats)
void Start(const std::string &url)
~RtmpStream()
Definition: rtmpstream.h:27
std::array< std::unique_ptr< RtmpState >, static_cast< uint32_t >RtmpContext::State::Count) > mStates
Definition: rtmpstream.h:53