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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) | 235 void DeleteReceiveStream(WebRtcVideoReceiveStream* stream) |
236 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); | 236 EXCLUSIVE_LOCKS_REQUIRED(stream_crit_); |
237 | 237 |
238 static std::string CodecSettingsVectorToString( | 238 static std::string CodecSettingsVectorToString( |
239 const std::vector<VideoCodecSettings>& codecs); | 239 const std::vector<VideoCodecSettings>& codecs); |
240 | 240 |
241 // Wrapper for the sender part, this is where the source is connected and | 241 // Wrapper for the sender part, this is where the source is connected and |
242 // frames are then converted from cricket frames to webrtc frames. | 242 // frames are then converted from cricket frames to webrtc frames. |
243 class WebRtcVideoSendStream | 243 class WebRtcVideoSendStream |
244 : public rtc::VideoSinkInterface<cricket::VideoFrame>, | 244 : public rtc::VideoSinkInterface<cricket::VideoFrame>, |
245 public rtc::VideoSourceInterface<webrtc::VideoFrame>, | 245 public rtc::VideoSourceInterface<webrtc::VideoFrame> { |
246 public webrtc::LoadObserver { | |
247 public: | 246 public: |
248 WebRtcVideoSendStream( | 247 WebRtcVideoSendStream( |
249 webrtc::Call* call, | 248 webrtc::Call* call, |
250 const StreamParams& sp, | 249 const StreamParams& sp, |
251 webrtc::VideoSendStream::Config config, | 250 webrtc::VideoSendStream::Config config, |
252 const VideoOptions& options, | 251 const VideoOptions& options, |
253 WebRtcVideoEncoderFactory* external_encoder_factory, | 252 WebRtcVideoEncoderFactory* external_encoder_factory, |
254 bool enable_cpu_overuse_detection, | 253 bool enable_cpu_overuse_detection, |
255 int max_bitrate_bps, | 254 int max_bitrate_bps, |
256 const rtc::Optional<VideoCodecSettings>& codec_settings, | 255 const rtc::Optional<VideoCodecSettings>& codec_settings, |
(...skipping 12 matching lines...) Expand all Loading... |
269 // TODO(perkj, nisse): Refactor WebRtcVideoSendStream to directly connect | 268 // TODO(perkj, nisse): Refactor WebRtcVideoSendStream to directly connect |
270 // the camera input |source_| | 269 // the camera input |source_| |
271 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink, | 270 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink, |
272 const rtc::VideoSinkWants& wants) override; | 271 const rtc::VideoSinkWants& wants) override; |
273 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override; | 272 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override; |
274 | 273 |
275 void OnFrame(const cricket::VideoFrame& frame) override; | 274 void OnFrame(const cricket::VideoFrame& frame) override; |
276 bool SetVideoSend(bool mute, | 275 bool SetVideoSend(bool mute, |
277 const VideoOptions* options, | 276 const VideoOptions* options, |
278 rtc::VideoSourceInterface<cricket::VideoFrame>* source); | 277 rtc::VideoSourceInterface<cricket::VideoFrame>* source); |
279 void DisconnectSource(); | |
280 | 278 |
281 void SetSend(bool send); | 279 void SetSend(bool send); |
282 | 280 |
283 // Implements webrtc::LoadObserver. | |
284 void OnLoadUpdate(Load load) override; | |
285 | |
286 const std::vector<uint32_t>& GetSsrcs() const; | 281 const std::vector<uint32_t>& GetSsrcs() const; |
287 VideoSenderInfo GetVideoSenderInfo(bool log_stats); | 282 VideoSenderInfo GetVideoSenderInfo(bool log_stats); |
288 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 283 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
289 | 284 |
290 private: | 285 private: |
291 // Parameters needed to reconstruct the underlying stream. | 286 // Parameters needed to reconstruct the underlying stream. |
292 // webrtc::VideoSendStream doesn't support setting a lot of options on the | 287 // webrtc::VideoSendStream doesn't support setting a lot of options on the |
293 // fly, so when those need to be changed we tear down and reconstruct with | 288 // fly, so when those need to be changed we tear down and reconstruct with |
294 // similar parameters depending on which options changed etc. | 289 // similar parameters depending on which options changed etc. |
295 struct VideoSendStreamParameters { | 290 struct VideoSendStreamParameters { |
(...skipping 16 matching lines...) Expand all Loading... |
312 struct AllocatedEncoder { | 307 struct AllocatedEncoder { |
313 AllocatedEncoder(webrtc::VideoEncoder* encoder, | 308 AllocatedEncoder(webrtc::VideoEncoder* encoder, |
314 webrtc::VideoCodecType type, | 309 webrtc::VideoCodecType type, |
315 bool external); | 310 bool external); |
316 webrtc::VideoEncoder* encoder; | 311 webrtc::VideoEncoder* encoder; |
317 webrtc::VideoEncoder* external_encoder; | 312 webrtc::VideoEncoder* external_encoder; |
318 webrtc::VideoCodecType type; | 313 webrtc::VideoCodecType type; |
319 bool external; | 314 bool external; |
320 }; | 315 }; |
321 | 316 |
322 // TODO(perkj): VideoFrameInfo is currently used for CPU adaptation since | 317 // TODO(perkj): VideoFrameInfo is currently used for sending a black frame |
323 // we currently do not express CPU overuse using SinkWants in lower | 318 // when the video source is removed. Consider moving that logic to |
324 // layers. This will be fixed in an upcoming cl. | 319 // VieEncoder or remove it. |
325 struct VideoFrameInfo { | 320 struct VideoFrameInfo { |
326 VideoFrameInfo() | 321 VideoFrameInfo() |
327 : width(0), | 322 : width(0), |
328 height(0), | 323 height(0), |
329 rotation(webrtc::kVideoRotation_0), | 324 rotation(webrtc::kVideoRotation_0), |
330 is_texture(false) {} | 325 is_texture(false) {} |
331 int width; | 326 int width; |
332 int height; | 327 int height; |
333 webrtc::VideoRotation rotation; | 328 webrtc::VideoRotation rotation; |
334 bool is_texture; | 329 bool is_texture; |
(...skipping 15 matching lines...) Expand all Loading... |
350 void UpdateSendState(); | 345 void UpdateSendState(); |
351 | 346 |
352 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_); | 347 void UpdateHistograms() const EXCLUSIVE_LOCKS_REQUIRED(lock_); |
353 | 348 |
354 rtc::ThreadChecker thread_checker_; | 349 rtc::ThreadChecker thread_checker_; |
355 rtc::AsyncInvoker invoker_; | 350 rtc::AsyncInvoker invoker_; |
356 rtc::Thread* worker_thread_; | 351 rtc::Thread* worker_thread_; |
357 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); | 352 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); |
358 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); | 353 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); |
359 webrtc::Call* const call_; | 354 webrtc::Call* const call_; |
360 rtc::VideoSinkWants sink_wants_ ACCESS_ON(&thread_checker_); | 355 const bool enable_cpu_overuse_detection_; |
361 // Counter used for deciding if the video resolution is currently | |
362 // restricted by CPU usage. It is reset if |source_| is changed. | |
363 int cpu_restricted_counter_; | |
364 // Total number of times resolution as been requested to be changed due to | |
365 // CPU adaptation. | |
366 int number_of_cpu_adapt_changes_ ACCESS_ON(&thread_checker_); | |
367 // Total number of frames sent to |stream_|. | |
368 int frame_count_ GUARDED_BY(lock_); | |
369 // Total number of cpu restricted frames sent to |stream_|. | |
370 int cpu_restricted_frame_count_ GUARDED_BY(lock_); | |
371 rtc::VideoSourceInterface<cricket::VideoFrame>* source_ | 356 rtc::VideoSourceInterface<cricket::VideoFrame>* source_ |
372 ACCESS_ON(&thread_checker_); | 357 ACCESS_ON(&thread_checker_); |
373 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 358 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
374 ACCESS_ON(&thread_checker_); | 359 ACCESS_ON(&thread_checker_); |
375 | 360 |
376 rtc::CriticalSection lock_; | 361 rtc::CriticalSection lock_; |
377 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); | 362 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); |
378 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ | 363 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ |
379 GUARDED_BY(lock_); | 364 GUARDED_BY(lock_); |
380 // Contains settings that are the same for all streams in the MediaChannel, | 365 // Contains settings that are the same for all streams in the MediaChannel, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 VideoSendParameters send_params_; | 523 VideoSendParameters send_params_; |
539 VideoOptions default_send_options_; | 524 VideoOptions default_send_options_; |
540 VideoRecvParameters recv_params_; | 525 VideoRecvParameters recv_params_; |
541 bool red_disabled_by_remote_side_; | 526 bool red_disabled_by_remote_side_; |
542 int64_t last_stats_log_ms_; | 527 int64_t last_stats_log_ms_; |
543 }; | 528 }; |
544 | 529 |
545 } // namespace cricket | 530 } // namespace cricket |
546 | 531 |
547 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 532 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
OLD | NEW |