Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine.h

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

Powered by Google App Engine
This is Rietveld 408576698