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 29 matching lines...) Expand all Loading... |
40 class VideoEncoder; | 40 class VideoEncoder; |
41 struct MediaConfig; | 41 struct MediaConfig; |
42 } | 42 } |
43 | 43 |
44 namespace rtc { | 44 namespace rtc { |
45 class Thread; | 45 class Thread; |
46 } // namespace rtc | 46 } // namespace rtc |
47 | 47 |
48 namespace cricket { | 48 namespace cricket { |
49 | 49 |
50 class DecoderFactoryAdapter; | |
51 class EncoderFactoryAdapter; | 50 class EncoderFactoryAdapter; |
52 class VideoCapturer; | 51 class VideoCapturer; |
53 class VideoProcessor; | 52 class VideoProcessor; |
54 class VideoRenderer; | 53 class VideoRenderer; |
55 class VoiceMediaChannel; | 54 class VoiceMediaChannel; |
56 class WebRtcDecoderObserver; | 55 class WebRtcDecoderObserver; |
57 class WebRtcEncoderObserver; | 56 class WebRtcEncoderObserver; |
58 class WebRtcLocalStreamInfo; | 57 class WebRtcLocalStreamInfo; |
59 class WebRtcRenderAdapter; | 58 class WebRtcRenderAdapter; |
60 class WebRtcVideoChannel; | 59 class WebRtcVideoChannel; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); | 114 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory); |
116 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does | 115 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does |
117 // not take the ownership of |encoder_factory|. The caller needs to make sure | 116 // not take the ownership of |encoder_factory|. The caller needs to make sure |
118 // that |encoder_factory| outlives the video engine. | 117 // that |encoder_factory| outlives the video engine. |
119 virtual void SetExternalEncoderFactory( | 118 virtual void SetExternalEncoderFactory( |
120 WebRtcVideoEncoderFactory* encoder_factory); | 119 WebRtcVideoEncoderFactory* encoder_factory); |
121 | 120 |
122 private: | 121 private: |
123 bool initialized_; | 122 bool initialized_; |
124 | 123 |
125 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; | 124 WebRtcVideoDecoderFactory* external_decoder_factory_; |
126 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_; | 125 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_; |
127 }; | 126 }; |
128 | 127 |
129 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { | 128 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { |
130 public: | 129 public: |
131 WebRtcVideoChannel(webrtc::Call* call, | 130 WebRtcVideoChannel(webrtc::Call* call, |
132 const MediaConfig& config, | 131 const MediaConfig& config, |
133 const VideoOptions& options, | 132 const VideoOptions& options, |
134 const EncoderFactoryAdapter& encoder_factory, | 133 const EncoderFactoryAdapter& encoder_factory, |
135 const DecoderFactoryAdapter& decoder_factory); | 134 WebRtcVideoDecoderFactory* external_decoder_factory); |
136 ~WebRtcVideoChannel() override; | 135 ~WebRtcVideoChannel() override; |
137 | 136 |
138 // VideoMediaChannel implementation | 137 // VideoMediaChannel implementation |
139 rtc::DiffServCodePoint PreferredDscp() const override; | 138 rtc::DiffServCodePoint PreferredDscp() const override; |
140 | 139 |
141 bool SetSendParameters(const VideoSendParameters& params) override; | 140 bool SetSendParameters(const VideoSendParameters& params) override; |
142 bool SetRecvParameters(const VideoRecvParameters& params) override; | 141 bool SetRecvParameters(const VideoRecvParameters& params) override; |
143 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; | 142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; |
144 bool SetRtpSendParameters(uint32_t ssrc, | 143 bool SetRtpSendParameters(uint32_t ssrc, |
145 const webrtc::RtpParameters& parameters) override; | 144 const webrtc::RtpParameters& parameters) override; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 362 |
364 // Wrapper for the receiver part, contains configs etc. that are needed to | 363 // Wrapper for the receiver part, contains configs etc. that are needed to |
365 // reconstruct the underlying VideoReceiveStream. | 364 // reconstruct the underlying VideoReceiveStream. |
366 class WebRtcVideoReceiveStream | 365 class WebRtcVideoReceiveStream |
367 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { | 366 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
368 public: | 367 public: |
369 WebRtcVideoReceiveStream( | 368 WebRtcVideoReceiveStream( |
370 webrtc::Call* call, | 369 webrtc::Call* call, |
371 const StreamParams& sp, | 370 const StreamParams& sp, |
372 webrtc::VideoReceiveStream::Config config, | 371 webrtc::VideoReceiveStream::Config config, |
373 const DecoderFactoryAdapter& decoder_factory, | 372 WebRtcVideoDecoderFactory* external_decoder_factory, |
374 bool default_stream, | 373 bool default_stream, |
375 const std::vector<VideoCodecSettings>& recv_codecs, | 374 const std::vector<VideoCodecSettings>& recv_codecs, |
376 const webrtc::FlexfecReceiveStream::Config& flexfec_config); | 375 const webrtc::FlexfecReceiveStream::Config& flexfec_config); |
377 ~WebRtcVideoReceiveStream(); | 376 ~WebRtcVideoReceiveStream(); |
378 | 377 |
379 const std::vector<uint32_t>& GetSsrcs() const; | 378 const std::vector<uint32_t>& GetSsrcs() const; |
380 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const; | 379 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const; |
381 | 380 |
382 void SetLocalSsrc(uint32_t local_ssrc); | 381 void SetLocalSsrc(uint32_t local_ssrc); |
383 // TODO(deadbeef): Move these feedback parameters into the recv parameters. | 382 // TODO(deadbeef): Move these feedback parameters into the recv parameters. |
384 void SetFeedbackParameters(bool nack_enabled, | 383 void SetFeedbackParameters(bool nack_enabled, |
385 bool remb_enabled, | 384 bool remb_enabled, |
386 bool transport_cc_enabled, | 385 bool transport_cc_enabled, |
387 webrtc::RtcpMode rtcp_mode); | 386 webrtc::RtcpMode rtcp_mode); |
388 void SetRecvParameters(const ChangedRecvParameters& recv_params); | 387 void SetRecvParameters(const ChangedRecvParameters& recv_params); |
389 | 388 |
390 void OnFrame(const webrtc::VideoFrame& frame) override; | 389 void OnFrame(const webrtc::VideoFrame& frame) override; |
391 bool IsDefaultStream() const; | 390 bool IsDefaultStream() const; |
392 | 391 |
393 void SetSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); | 392 void SetSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink); |
394 | 393 |
395 VideoReceiverInfo GetVideoReceiverInfo(bool log_stats); | 394 VideoReceiverInfo GetVideoReceiverInfo(bool log_stats); |
396 | 395 |
397 private: | 396 private: |
| 397 struct AllocatedDecoder { |
| 398 AllocatedDecoder(webrtc::VideoDecoder* decoder, |
| 399 webrtc::VideoCodecType type, |
| 400 bool external); |
| 401 webrtc::VideoDecoder* decoder; |
| 402 // Decoder wrapped into a fallback decoder to permit software fallback. |
| 403 webrtc::VideoDecoder* external_decoder; |
| 404 webrtc::VideoCodecType type; |
| 405 bool external; |
| 406 }; |
| 407 |
398 void RecreateWebRtcVideoStream(); | 408 void RecreateWebRtcVideoStream(); |
399 void MaybeRecreateWebRtcFlexfecStream(); | 409 void MaybeRecreateWebRtcFlexfecStream(); |
400 | 410 |
401 void MaybeAssociateFlexfecWithVideo(); | 411 void MaybeAssociateFlexfecWithVideo(); |
402 void MaybeDissociateFlexfecFromVideo(); | 412 void MaybeDissociateFlexfecFromVideo(); |
403 | 413 |
404 void ConfigureCodecs( | 414 void ConfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs, |
405 const std::vector<VideoCodecSettings>& recv_codecs, | 415 std::vector<AllocatedDecoder>* old_codecs); |
406 std::map<webrtc::VideoCodecType, std::unique_ptr<webrtc::VideoDecoder>>* | |
407 old_codecs); | |
408 void ConfigureFlexfecCodec(int flexfec_payload_type); | 416 void ConfigureFlexfecCodec(int flexfec_payload_type); |
| 417 AllocatedDecoder CreateOrReuseVideoDecoder( |
| 418 std::vector<AllocatedDecoder>* old_decoder, |
| 419 const VideoCodec& codec); |
| 420 void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders); |
409 | 421 |
410 std::string GetCodecNameFromPayloadType(int payload_type); | 422 std::string GetCodecNameFromPayloadType(int payload_type); |
411 | 423 |
412 webrtc::Call* const call_; | 424 webrtc::Call* const call_; |
413 StreamParams stream_params_; | 425 StreamParams stream_params_; |
414 | 426 |
415 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are | 427 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are |
416 // destroyed by calling call_->DestroyVideoReceiveStream and | 428 // destroyed by calling call_->DestroyVideoReceiveStream and |
417 // call_->DestroyFlexfecReceiveStream, respectively. | 429 // call_->DestroyFlexfecReceiveStream, respectively. |
418 webrtc::VideoReceiveStream* stream_; | 430 webrtc::VideoReceiveStream* stream_; |
419 const bool default_stream_; | 431 const bool default_stream_; |
420 webrtc::VideoReceiveStream::Config config_; | 432 webrtc::VideoReceiveStream::Config config_; |
421 webrtc::FlexfecReceiveStream::Config flexfec_config_; | 433 webrtc::FlexfecReceiveStream::Config flexfec_config_; |
422 webrtc::FlexfecReceiveStream* flexfec_stream_; | 434 webrtc::FlexfecReceiveStream* flexfec_stream_; |
423 | 435 |
424 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; | 436 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
425 std::map<webrtc::VideoCodecType, std::unique_ptr<webrtc::VideoDecoder>> | 437 std::vector<AllocatedDecoder> allocated_decoders_; |
426 allocated_decoders_; | |
427 | 438 |
428 rtc::CriticalSection sink_lock_; | 439 rtc::CriticalSection sink_lock_; |
429 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ GUARDED_BY(sink_lock_); | 440 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ GUARDED_BY(sink_lock_); |
430 // Expands remote RTP timestamps to int64_t to be able to estimate how long | 441 // Expands remote RTP timestamps to int64_t to be able to estimate how long |
431 // the stream has been running. | 442 // the stream has been running. |
432 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ | 443 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ |
433 GUARDED_BY(sink_lock_); | 444 GUARDED_BY(sink_lock_); |
434 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); | 445 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); |
435 // Start NTP time is estimated as current remote NTP time (estimated from | 446 // Start NTP time is estimated as current remote NTP time (estimated from |
436 // RTCP) minus the elapsed time, as soon as remote NTP time is available. | 447 // RTCP) minus the elapsed time, as soon as remote NTP time is available. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 GUARDED_BY(stream_crit_); | 490 GUARDED_BY(stream_crit_); |
480 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ | 491 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ |
481 GUARDED_BY(stream_crit_); | 492 GUARDED_BY(stream_crit_); |
482 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_); | 493 std::set<uint32_t> send_ssrcs_ GUARDED_BY(stream_crit_); |
483 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); | 494 std::set<uint32_t> receive_ssrcs_ GUARDED_BY(stream_crit_); |
484 | 495 |
485 rtc::Optional<VideoCodecSettings> send_codec_; | 496 rtc::Optional<VideoCodecSettings> send_codec_; |
486 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; | 497 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; |
487 | 498 |
488 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_; | 499 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_; |
489 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; | 500 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
490 std::vector<VideoCodecSettings> recv_codecs_; | 501 std::vector<VideoCodecSettings> recv_codecs_; |
491 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 502 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
492 // See reason for keeping track of the FlexFEC payload type separately in | 503 // See reason for keeping track of the FlexFEC payload type separately in |
493 // comment in WebRtcVideoChannel::ChangedRecvParameters. | 504 // comment in WebRtcVideoChannel::ChangedRecvParameters. |
494 int recv_flexfec_payload_type_; | 505 int recv_flexfec_payload_type_; |
495 webrtc::Call::Config::BitrateConfig bitrate_config_; | 506 webrtc::Call::Config::BitrateConfig bitrate_config_; |
496 // TODO(deadbeef): Don't duplicate information between | 507 // TODO(deadbeef): Don't duplicate information between |
497 // send_params/recv_params, rtp_extensions, options, etc. | 508 // send_params/recv_params, rtp_extensions, options, etc. |
498 VideoSendParameters send_params_; | 509 VideoSendParameters send_params_; |
499 VideoOptions default_send_options_; | 510 VideoOptions default_send_options_; |
(...skipping 19 matching lines...) Expand all Loading... |
519 const std::string codec_name_; | 530 const std::string codec_name_; |
520 const int max_qp_; | 531 const int max_qp_; |
521 const int max_framerate_; | 532 const int max_framerate_; |
522 const bool is_screencast_; | 533 const bool is_screencast_; |
523 const bool conference_mode_; | 534 const bool conference_mode_; |
524 }; | 535 }; |
525 | 536 |
526 } // namespace cricket | 537 } // namespace cricket |
527 | 538 |
528 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ | 539 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ |
OLD | NEW |