Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / video / send_statistics_proxy.h
1 /*
2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #ifndef WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
12 #define WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
13
14 #include <string>
15
16 #include "webrtc/common_types.h"
17 #include "webrtc/video_engine/include/vie_codec.h"
18 #include "webrtc/video_engine/include/vie_capture.h"
19 #include "webrtc/video_send_stream.h"
20 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
21
22 namespace webrtc {
23
24 class CriticalSectionWrapper;
25
26 class SendStatisticsProxy : public RtcpStatisticsCallback,
27                             public StreamDataCountersCallback,
28                             public BitrateStatisticsObserver,
29                             public FrameCountObserver,
30                             public ViEEncoderObserver,
31                             public ViECaptureObserver {
32  public:
33   class StatsProvider {
34    protected:
35     StatsProvider() {}
36     virtual ~StatsProvider() {}
37
38    public:
39     virtual bool GetSendSideDelay(VideoSendStream::Stats* stats) = 0;
40     virtual std::string GetCName() = 0;
41   };
42
43   SendStatisticsProxy(const VideoSendStream::Config& config,
44                       StatsProvider* stats_provider);
45   virtual ~SendStatisticsProxy();
46
47   VideoSendStream::Stats GetStats() const;
48
49  protected:
50   // From RtcpStatisticsCallback.
51   virtual void StatisticsUpdated(const RtcpStatistics& statistics,
52                                  uint32_t ssrc) OVERRIDE;
53   // From StreamDataCountersCallback.
54   virtual void DataCountersUpdated(const StreamDataCounters& counters,
55                                    uint32_t ssrc) OVERRIDE;
56
57   // From BitrateStatisticsObserver.
58   virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) OVERRIDE;
59
60   // From FrameCountObserver.
61   virtual void FrameCountUpdated(FrameType frame_type,
62                                  uint32_t frame_count,
63                                  const unsigned int ssrc) OVERRIDE;
64
65   // From ViEEncoderObserver.
66   virtual void OutgoingRate(const int video_channel,
67                             const unsigned int framerate,
68                             const unsigned int bitrate) OVERRIDE;
69
70   virtual void SuspendChange(int video_channel, bool is_suspended) OVERRIDE {}
71
72   // From ViECaptureObserver.
73   virtual void BrightnessAlarm(const int capture_id,
74                                const Brightness brightness) OVERRIDE {}
75
76   virtual void CapturedFrameRate(const int capture_id,
77                                  const unsigned char frame_rate) OVERRIDE;
78
79   virtual void NoPictureAlarm(const int capture_id,
80                               const CaptureAlarm alarm) OVERRIDE {}
81
82  private:
83   StreamStats* GetStatsEntry(uint32_t ssrc);
84
85   const VideoSendStream::Config config_;
86   scoped_ptr<CriticalSectionWrapper> lock_;
87   VideoSendStream::Stats stats_;
88   StatsProvider* stats_provider_;
89 };
90
91 }  // namespace webrtc
92 #endif  // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_