blob: 2f45ff7f9b514038ee39149029205407de1d05f7 [file] [log] [blame]
sprang@webrtc.org49812e62014-01-07 09:54:34 +00001/*
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"
henrik.lundin@webrtc.org9376c692014-03-13 13:31:21 +000021#include "webrtc/system_wrappers/interface/thread_annotations.h"
sprang@webrtc.org49812e62014-01-07 09:54:34 +000022
23namespace webrtc {
24
25class CriticalSectionWrapper;
26
27class SendStatisticsProxy : public RtcpStatisticsCallback,
28 public StreamDataCountersCallback,
29 public BitrateStatisticsObserver,
30 public FrameCountObserver,
31 public ViEEncoderObserver,
32 public ViECaptureObserver {
33 public:
sprang@webrtc.orgc8ab7212014-02-07 12:06:29 +000034 class StatsProvider {
35 protected:
36 StatsProvider() {}
37 virtual ~StatsProvider() {}
sprang@webrtc.org49812e62014-01-07 09:54:34 +000038
sprang@webrtc.orgc8ab7212014-02-07 12:06:29 +000039 public:
sprang@webrtc.org49812e62014-01-07 09:54:34 +000040 virtual bool GetSendSideDelay(VideoSendStream::Stats* stats) = 0;
41 virtual std::string GetCName() = 0;
42 };
43
44 SendStatisticsProxy(const VideoSendStream::Config& config,
sprang@webrtc.orgc8ab7212014-02-07 12:06:29 +000045 StatsProvider* stats_provider);
sprang@webrtc.org49812e62014-01-07 09:54:34 +000046 virtual ~SendStatisticsProxy();
47
48 VideoSendStream::Stats GetStats() const;
49
50 protected:
51 // From RtcpStatisticsCallback.
52 virtual void StatisticsUpdated(const RtcpStatistics& statistics,
53 uint32_t ssrc) OVERRIDE;
54 // From StreamDataCountersCallback.
55 virtual void DataCountersUpdated(const StreamDataCounters& counters,
56 uint32_t ssrc) OVERRIDE;
57
58 // From BitrateStatisticsObserver.
59 virtual void Notify(const BitrateStatistics& stats, uint32_t ssrc) OVERRIDE;
60
61 // From FrameCountObserver.
62 virtual void FrameCountUpdated(FrameType frame_type,
63 uint32_t frame_count,
64 const unsigned int ssrc) OVERRIDE;
65
66 // From ViEEncoderObserver.
67 virtual void OutgoingRate(const int video_channel,
68 const unsigned int framerate,
69 const unsigned int bitrate) OVERRIDE;
70
henrik.lundin@webrtc.org9376c692014-03-13 13:31:21 +000071 virtual void SuspendChange(int video_channel, bool is_suspended) OVERRIDE;
sprang@webrtc.org49812e62014-01-07 09:54:34 +000072
73 // From ViECaptureObserver.
74 virtual void BrightnessAlarm(const int capture_id,
75 const Brightness brightness) OVERRIDE {}
76
77 virtual void CapturedFrameRate(const int capture_id,
78 const unsigned char frame_rate) OVERRIDE;
79
80 virtual void NoPictureAlarm(const int capture_id,
81 const CaptureAlarm alarm) OVERRIDE {}
82
83 private:
henrik.lundin@webrtc.org9376c692014-03-13 13:31:21 +000084 StreamStats* GetStatsEntry(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(lock_);
sprang@webrtc.org49812e62014-01-07 09:54:34 +000085
86 const VideoSendStream::Config config_;
87 scoped_ptr<CriticalSectionWrapper> lock_;
henrik.lundin@webrtc.org9376c692014-03-13 13:31:21 +000088 VideoSendStream::Stats stats_ GUARDED_BY(lock_);
89 StatsProvider* const stats_provider_;
sprang@webrtc.org49812e62014-01-07 09:54:34 +000090};
91
92} // namespace webrtc
93#endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_