Home | History | Annotate | Download | only in video
      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 #include "webrtc/system_wrappers/interface/thread_annotations.h"
     22 
     23 namespace webrtc {
     24 
     25 class CriticalSectionWrapper;
     26 
     27 class SendStatisticsProxy : public RtcpStatisticsCallback,
     28                             public StreamDataCountersCallback,
     29                             public BitrateStatisticsObserver,
     30                             public FrameCountObserver,
     31                             public ViEEncoderObserver,
     32                             public ViECaptureObserver {
     33  public:
     34   class StatsProvider {
     35    protected:
     36     StatsProvider() {}
     37     virtual ~StatsProvider() {}
     38 
     39    public:
     40     virtual bool GetSendSideDelay(VideoSendStream::Stats* stats) = 0;
     41     virtual std::string GetCName() = 0;
     42   };
     43 
     44   SendStatisticsProxy(const VideoSendStream::Config& config,
     45                       StatsProvider* stats_provider);
     46   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 
     71   virtual void SuspendChange(int video_channel, bool is_suspended) OVERRIDE;
     72 
     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:
     84   StreamStats* GetStatsEntry(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(crit_);
     85 
     86   const VideoSendStream::Config config_;
     87   StatsProvider* const stats_provider_;
     88   scoped_ptr<CriticalSectionWrapper> crit_;
     89   VideoSendStream::Stats stats_ GUARDED_BY(crit_);
     90 };
     91 
     92 }  // namespace webrtc
     93 #endif  // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
     94