blob: a313c13ef913e9eebd4d1dca8ab41858c8d653f8 [file] [log] [blame]
sprang@webrtc.orgccd42842014-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.orgb10363f2014-03-13 13:31:21 +000021#include "webrtc/system_wrappers/interface/thread_annotations.h"
sprang@webrtc.orgccd42842014-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.org09315702014-02-07 12:06:29 +000034 class StatsProvider {
35 protected:
36 StatsProvider() {}
37 virtual ~StatsProvider() {}
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000038
sprang@webrtc.org09315702014-02-07 12:06:29 +000039 public:
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000040 virtual bool GetSendSideDelay(VideoSendStream::Stats* stats) = 0;
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000041 };
42
43 SendStatisticsProxy(const VideoSendStream::Config& config,
sprang@webrtc.org09315702014-02-07 12:06:29 +000044 StatsProvider* stats_provider);
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000045 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
henrik.lundin@webrtc.orgb10363f2014-03-13 13:31:21 +000070 virtual void SuspendChange(int video_channel, bool is_suspended) OVERRIDE;
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000071
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:
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000083 StreamStats* GetStatsEntry(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(crit_);
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000084
85 const VideoSendStream::Config config_;
henrik.lundin@webrtc.orgb10363f2014-03-13 13:31:21 +000086 StatsProvider* const stats_provider_;
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +000087 scoped_ptr<CriticalSectionWrapper> crit_;
88 VideoSendStream::Stats stats_ GUARDED_BY(crit_);
sprang@webrtc.orgccd42842014-01-07 09:54:34 +000089};
90
91} // namespace webrtc
92#endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_