Twitch SDK (Internal)
streamstats.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 
14 
15 
16 namespace ttv
17 {
18  namespace broadcast
19  {
20  class StreamStats;
21  class StreamStatsListenerProxy;
22  }
23 }
24 
25 
27 {
28 public:
29  enum class StatType
30  {
31  RtmpState,
34  };
35 
36  class IListener
37  {
38  public:
39  virtual void OnStatReceived(StreamStats* source, StatType type, uint64_t data) = 0;
40  };
41 
42 public:
46  void AddListener(const std::shared_ptr<IListener>& listener);
50  void RemoveListener(const std::shared_ptr<IListener>& listener);
54  void Flush();
58  void Add(StatType type, uint64_t data);
59 
60 private:
61  typedef std::pair<StatType, uint64_t> value_t;
64 };
65 
66 
71 {
72 public:
73  typedef std::function<void(StreamStats* source, StreamStats::StatType type, uint64_t data)> OnStatReceivedFunc;
74 
75 public:
76  // StreamStats::Listener implementation
77  virtual void OnStatReceived(StreamStats* source, StreamStats::StatType type, uint64_t data) override
78  {
79  if (mOnStatReceivedFunc != nullptr)
80  {
81  mOnStatReceivedFunc(source, type, data);
82  }
83  }
84 
85 public:
86  OnStatReceivedFunc mOnStatReceivedFunc;
87 };
std::pair< StatType, uint64_t > value_t
Definition: streamstats.h:61
Definition: streamstats.h:36
OnStatReceivedFunc mOnStatReceivedFunc
Definition: streamstats.h:86
void Add(StatType type, uint64_t data)
ConcurrentQueue< value_t > mQueue
Definition: streamstats.h:62
The total number of bytes that have been sent over the socket via RTMP.
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
EventSource< IListener > mListeners
Definition: streamstats.h:63
Definition: eventsource.h:18
void RemoveListener(const std::shared_ptr< IListener > &listener)
The value should be interpretted as RtmpState.
Definition: streamstats.h:26
std::function< void(StreamStats *source, StreamStats::StatType type, uint64_t data)> OnStatReceivedFunc
Definition: streamstats.h:73
The total number of video packets sent.
virtual void OnStatReceived(StreamStats *source, StreamStats::StatType type, uint64_t data) override
Definition: streamstats.h:77
StatType
Definition: streamstats.h:29
Definition: streamstats.h:70
void AddListener(const std::shared_ptr< IListener > &listener)