OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 std::vector<VideoCodec> video_codecs_; | 123 std::vector<VideoCodec> video_codecs_; |
124 | 124 |
125 bool initialized_; | 125 bool initialized_; |
126 | 126 |
127 WebRtcVideoDecoderFactory* external_decoder_factory_; | 127 WebRtcVideoDecoderFactory* external_decoder_factory_; |
128 WebRtcVideoEncoderFactory* external_encoder_factory_; | 128 WebRtcVideoEncoderFactory* external_encoder_factory_; |
129 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; | 129 rtc::scoped_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_; |
130 }; | 130 }; |
131 | 131 |
132 class WebRtcVideoChannel2 : public VideoMediaChannel, | 132 class WebRtcVideoChannel2 : public VideoMediaChannel, public webrtc::Transport { |
133 public webrtc::Transport, | |
134 public webrtc::LoadObserver { | |
135 public: | 133 public: |
136 WebRtcVideoChannel2(webrtc::Call* call, | 134 WebRtcVideoChannel2(webrtc::Call* call, |
137 const MediaConfig& config, | 135 const MediaConfig& config, |
138 const VideoOptions& options, | 136 const VideoOptions& options, |
139 const std::vector<VideoCodec>& recv_codecs, | 137 const std::vector<VideoCodec>& recv_codecs, |
140 WebRtcVideoEncoderFactory* external_encoder_factory, | 138 WebRtcVideoEncoderFactory* external_encoder_factory, |
141 WebRtcVideoDecoderFactory* external_decoder_factory); | 139 WebRtcVideoDecoderFactory* external_decoder_factory); |
142 ~WebRtcVideoChannel2() override; | 140 ~WebRtcVideoChannel2() override; |
143 | 141 |
144 // VideoMediaChannel implementation | 142 // VideoMediaChannel implementation |
(...skipping 16 matching lines...) Expand all Loading... |
161 bool GetStats(VideoMediaInfo* info) override; | 159 bool GetStats(VideoMediaInfo* info) override; |
162 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; | 160 bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; |
163 | 161 |
164 void OnPacketReceived(rtc::Buffer* packet, | 162 void OnPacketReceived(rtc::Buffer* packet, |
165 const rtc::PacketTime& packet_time) override; | 163 const rtc::PacketTime& packet_time) override; |
166 void OnRtcpReceived(rtc::Buffer* packet, | 164 void OnRtcpReceived(rtc::Buffer* packet, |
167 const rtc::PacketTime& packet_time) override; | 165 const rtc::PacketTime& packet_time) override; |
168 void OnReadyToSend(bool ready) override; | 166 void OnReadyToSend(bool ready) override; |
169 void SetInterface(NetworkInterface* iface) override; | 167 void SetInterface(NetworkInterface* iface) override; |
170 | 168 |
171 void OnLoadUpdate(Load load) override; | |
172 | |
173 // Implemented for VideoMediaChannelTest. | 169 // Implemented for VideoMediaChannelTest. |
174 bool sending() const { return sending_; } | 170 bool sending() const { return sending_; } |
175 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } | 171 uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } |
176 | 172 |
177 private: | 173 private: |
178 class WebRtcVideoReceiveStream; | 174 class WebRtcVideoReceiveStream; |
179 struct VideoCodecSettings { | 175 struct VideoCodecSettings { |
180 VideoCodecSettings(); | 176 VideoCodecSettings(); |
181 | 177 |
182 bool operator==(const VideoCodecSettings& other) const; | 178 bool operator==(const VideoCodecSettings& other) const; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 218 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
223 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 219 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
224 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 220 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
225 | 221 |
226 static std::string CodecSettingsVectorToString( | 222 static std::string CodecSettingsVectorToString( |
227 const std::vector<VideoCodecSettings>& codecs); | 223 const std::vector<VideoCodecSettings>& codecs); |
228 | 224 |
229 // Wrapper for the sender part, this is where the capturer is connected and | 225 // Wrapper for the sender part, this is where the capturer is connected and |
230 // frames are then converted from cricket frames to webrtc frames. | 226 // frames are then converted from cricket frames to webrtc frames. |
231 class WebRtcVideoSendStream | 227 class WebRtcVideoSendStream |
232 : public rtc::VideoSinkInterface<cricket::VideoFrame> { | 228 : public rtc::VideoSinkInterface<cricket::VideoFrame>, |
| 229 public webrtc::LoadObserver { |
233 public: | 230 public: |
234 WebRtcVideoSendStream( | 231 WebRtcVideoSendStream( |
235 webrtc::Call* call, | 232 webrtc::Call* call, |
236 const StreamParams& sp, | 233 const StreamParams& sp, |
237 const webrtc::VideoSendStream::Config& config, | 234 const webrtc::VideoSendStream::Config& config, |
238 WebRtcVideoEncoderFactory* external_encoder_factory, | 235 WebRtcVideoEncoderFactory* external_encoder_factory, |
239 const VideoOptions& options, | 236 const VideoOptions& options, |
| 237 bool enable_cpu_overuse_detection, |
240 int max_bitrate_bps, | 238 int max_bitrate_bps, |
241 const rtc::Optional<VideoCodecSettings>& codec_settings, | 239 const rtc::Optional<VideoCodecSettings>& codec_settings, |
242 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 240 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
243 const VideoSendParameters& send_params); | 241 const VideoSendParameters& send_params); |
244 virtual ~WebRtcVideoSendStream(); | 242 virtual ~WebRtcVideoSendStream(); |
245 | 243 |
246 void SetOptions(const VideoOptions& options); | 244 void SetOptions(const VideoOptions& options); |
247 // TODO(pbos): Move logic from SetOptions into this method. | 245 // TODO(pbos): Move logic from SetOptions into this method. |
248 void SetSendParameters(const ChangedSendParameters& send_params); | 246 void SetSendParameters(const ChangedSendParameters& send_params); |
249 | 247 |
250 void OnFrame(const cricket::VideoFrame& frame) override; | 248 void OnFrame(const cricket::VideoFrame& frame) override; |
251 bool SetCapturer(VideoCapturer* capturer); | 249 bool SetCapturer(VideoCapturer* capturer); |
252 void MuteStream(bool mute); | 250 void MuteStream(bool mute); |
253 bool DisconnectCapturer(); | 251 bool DisconnectCapturer(); |
254 | 252 |
255 void Start(); | 253 void Start(); |
256 void Stop(); | 254 void Stop(); |
257 | 255 |
| 256 // Implements webrtc::LoadObserver. |
| 257 void OnLoadUpdate(Load load) override; |
| 258 |
258 const std::vector<uint32_t>& GetSsrcs() const; | 259 const std::vector<uint32_t>& GetSsrcs() const; |
259 VideoSenderInfo GetVideoSenderInfo(); | 260 VideoSenderInfo GetVideoSenderInfo(); |
260 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 261 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
261 | 262 |
262 private: | 263 private: |
263 // Parameters needed to reconstruct the underlying stream. | 264 // Parameters needed to reconstruct the underlying stream. |
264 // webrtc::VideoSendStream doesn't support setting a lot of options on the | 265 // webrtc::VideoSendStream doesn't support setting a lot of options on the |
265 // fly, so when those need to be changed we tear down and reconstruct with | 266 // fly, so when those need to be changed we tear down and reconstruct with |
266 // similar parameters depending on which options changed etc. | 267 // similar parameters depending on which options changed etc. |
267 struct VideoSendStreamParameters { | 268 struct VideoSendStreamParameters { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 void SetCodecAndOptions(const VideoCodecSettings& codec, | 334 void SetCodecAndOptions(const VideoCodecSettings& codec, |
334 const VideoOptions& options) | 335 const VideoOptions& options) |
335 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 336 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
336 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 337 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
337 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | 338 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( |
338 const Dimensions& dimensions, | 339 const Dimensions& dimensions, |
339 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); | 340 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); |
340 void SetDimensions(int width, int height, bool is_screencast) | 341 void SetDimensions(int width, int height, bool is_screencast) |
341 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 342 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
342 | 343 |
| 344 rtc::ThreadChecker thread_checker_; |
343 const std::vector<uint32_t> ssrcs_; | 345 const std::vector<uint32_t> ssrcs_; |
344 const std::vector<SsrcGroup> ssrc_groups_; | 346 const std::vector<SsrcGroup> ssrc_groups_; |
345 webrtc::Call* const call_; | 347 webrtc::Call* const call_; |
346 rtc::VideoSinkWants sink_wants_; | 348 rtc::VideoSinkWants sink_wants_; |
| 349 class LoadObserverProxy; |
| 350 rtc::scoped_ptr<LoadObserverProxy> load_proxy_; |
| 351 size_t cpu_downgrade_count_ = 0; |
347 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 352 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
348 GUARDED_BY(lock_); | 353 GUARDED_BY(lock_); |
349 | 354 |
350 rtc::CriticalSection lock_; | 355 rtc::CriticalSection lock_; |
351 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 356 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
352 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 357 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
353 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 358 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
354 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 359 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
355 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 360 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
356 Dimensions last_dimensions_ GUARDED_BY(lock_); | 361 Dimensions last_dimensions_ GUARDED_BY(lock_); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 VideoOptions options_; | 522 VideoOptions options_; |
518 // TODO(deadbeef): Don't duplicate information between | 523 // TODO(deadbeef): Don't duplicate information between |
519 // send_params/recv_params, rtp_extensions, options, etc. | 524 // send_params/recv_params, rtp_extensions, options, etc. |
520 VideoSendParameters send_params_; | 525 VideoSendParameters send_params_; |
521 VideoRecvParameters recv_params_; | 526 VideoRecvParameters recv_params_; |
522 }; | 527 }; |
523 | 528 |
524 } // namespace cricket | 529 } // namespace cricket |
525 | 530 |
526 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 531 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
OLD | NEW |