• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_VIDEO_RECEIVE_STREAM_H_
12 #define WEBRTC_VIDEO_VIDEO_RECEIVE_STREAM_H_
13 
14 #include <vector>
15 
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/call.h"
18 #include "webrtc/call/transport_adapter.h"
19 #include "webrtc/common_video/include/incoming_video_stream.h"
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
21 #include "webrtc/modules/video_render/video_render_defines.h"
22 #include "webrtc/system_wrappers/include/clock.h"
23 #include "webrtc/video/encoded_frame_callback_adapter.h"
24 #include "webrtc/video/receive_statistics_proxy.h"
25 #include "webrtc/video/vie_channel.h"
26 #include "webrtc/video/vie_encoder.h"
27 #include "webrtc/video_encoder.h"
28 #include "webrtc/video_receive_stream.h"
29 
30 namespace webrtc {
31 
32 class CallStats;
33 class CongestionController;
34 class VoiceEngine;
35 
36 namespace internal {
37 
38 class VideoReceiveStream : public webrtc::VideoReceiveStream,
39                            public I420FrameCallback,
40                            public VideoRenderCallback,
41                            public EncodedImageCallback {
42  public:
43   VideoReceiveStream(int num_cpu_cores,
44                      CongestionController* congestion_controller,
45                      const VideoReceiveStream::Config& config,
46                      webrtc::VoiceEngine* voice_engine,
47                      ProcessThread* process_thread,
48                      CallStats* call_stats);
49   ~VideoReceiveStream() override;
50 
51   // webrtc::ReceiveStream implementation.
52   void Start() override;
53   void Stop() override;
54   void SignalNetworkState(NetworkState state) override;
55   bool DeliverRtcp(const uint8_t* packet, size_t length) override;
56   bool DeliverRtp(const uint8_t* packet,
57                   size_t length,
58                   const PacketTime& packet_time) override;
59 
60   // webrtc::VideoReceiveStream implementation.
61   webrtc::VideoReceiveStream::Stats GetStats() const override;
62 
63   // Overrides I420FrameCallback.
64   void FrameCallback(VideoFrame* video_frame) override;
65 
66   // Overrides VideoRenderCallback.
67   int RenderFrame(const uint32_t /*stream_id*/,
68                   const VideoFrame& video_frame) override;
69 
70   // Overrides EncodedImageCallback.
71   int32_t Encoded(const EncodedImage& encoded_image,
72                   const CodecSpecificInfo* codec_specific_info,
73                   const RTPFragmentationHeader* fragmentation) override;
74 
config()75   const Config& config() const { return config_; }
76 
77   void SetSyncChannel(VoiceEngine* voice_engine, int audio_channel_id);
78 
79  private:
80   TransportAdapter transport_adapter_;
81   EncodedFrameCallbackAdapter encoded_frame_proxy_;
82   const VideoReceiveStream::Config config_;
83   Clock* const clock_;
84 
85   CongestionController* const congestion_controller_;
86   CallStats* const call_stats_;
87 
88   rtc::scoped_ptr<IncomingVideoStream> incoming_video_stream_;
89   rtc::scoped_ptr<ReceiveStatisticsProxy> stats_proxy_;
90   rtc::scoped_ptr<ViEChannel> vie_channel_;
91 };
92 }  // namespace internal
93 }  // namespace webrtc
94 
95 #endif  // WEBRTC_VIDEO_VIDEO_RECEIVE_STREAM_H_
96