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

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

Issue 3008043002: Simplify passing video codec factories in media engine (Closed)
Patch Set: 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
« no previous file with comments | « webrtc/media/engine/webrtcmediaengine.cc ('k') | webrtc/media/engine/webrtcvideoengine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 virtual ~DefaultUnsignalledSsrcHandler() = default; 91 virtual ~DefaultUnsignalledSsrcHandler() = default;
92 92
93 private: 93 private:
94 rtc::VideoSinkInterface<webrtc::VideoFrame>* default_sink_; 94 rtc::VideoSinkInterface<webrtc::VideoFrame>* default_sink_;
95 }; 95 };
96 96
97 // WebRtcVideoEngine is used for the new native WebRTC Video API (webrtc:1667). 97 // WebRtcVideoEngine is used for the new native WebRTC Video API (webrtc:1667).
98 class WebRtcVideoEngine { 98 class WebRtcVideoEngine {
99 public: 99 public:
100 WebRtcVideoEngine(); 100 // Video engine does not take ownership of the video codec factories and the
101 // caller needs to make sure they outlive the video engine. Internal SW video
102 // codecs will be added on top of the external codecs.
103 WebRtcVideoEngine(WebRtcVideoEncoderFactory* external_video_encoder_factory,
104 WebRtcVideoDecoderFactory* external_video_decoder_factory);
101 virtual ~WebRtcVideoEngine(); 105 virtual ~WebRtcVideoEngine();
102 106
103 // Basic video engine implementation.
104 void Init();
105
106 WebRtcVideoChannel* CreateChannel(webrtc::Call* call, 107 WebRtcVideoChannel* CreateChannel(webrtc::Call* call,
107 const MediaConfig& config, 108 const MediaConfig& config,
108 const VideoOptions& options); 109 const VideoOptions& options);
109 110
110 std::vector<VideoCodec> codecs() const; 111 std::vector<VideoCodec> codecs() const;
111 RtpCapabilities GetCapabilities() const; 112 RtpCapabilities GetCapabilities() const;
112 113
113 // Set a WebRtcVideoDecoderFactory for external decoding. Video engine does
114 // not take the ownership of |decoder_factory|. The caller needs to make sure
115 // that |decoder_factory| outlives the video engine.
116 void SetExternalDecoderFactory(WebRtcVideoDecoderFactory* decoder_factory);
117 // Set a WebRtcVideoEncoderFactory for external encoding. Video engine does
118 // not take the ownership of |encoder_factory|. The caller needs to make sure
119 // that |encoder_factory| outlives the video engine.
120 virtual void SetExternalEncoderFactory(
121 WebRtcVideoEncoderFactory* encoder_factory);
122
123 private: 114 private:
124 bool initialized_; 115 const std::unique_ptr<DecoderFactoryAdapter> decoder_factory_;
125 116 const std::unique_ptr<EncoderFactoryAdapter> encoder_factory_;
126 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_;
127 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_;
128 }; 117 };
129 118
130 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { 119 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
131 public: 120 public:
132 WebRtcVideoChannel(webrtc::Call* call, 121 WebRtcVideoChannel(webrtc::Call* call,
133 const MediaConfig& config, 122 const MediaConfig& config,
134 const VideoOptions& options, 123 const VideoOptions& options,
135 const EncoderFactoryAdapter& encoder_factory, 124 const EncoderFactoryAdapter* encoder_factory,
136 const DecoderFactoryAdapter& decoder_factory); 125 const DecoderFactoryAdapter* decoder_factory);
137 ~WebRtcVideoChannel() override; 126 ~WebRtcVideoChannel() override;
138 127
139 // VideoMediaChannel implementation 128 // VideoMediaChannel implementation
140 rtc::DiffServCodePoint PreferredDscp() const override; 129 rtc::DiffServCodePoint PreferredDscp() const override;
141 130
142 bool SetSendParameters(const VideoSendParameters& params) override; 131 bool SetSendParameters(const VideoSendParameters& params) override;
143 bool SetRecvParameters(const VideoRecvParameters& params) override; 132 bool SetRecvParameters(const VideoRecvParameters& params) override;
144 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; 133 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
145 bool SetRtpSendParameters(uint32_t ssrc, 134 bool SetRtpSendParameters(uint32_t ssrc,
146 const webrtc::RtpParameters& parameters) override; 135 const webrtc::RtpParameters& parameters) override;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 243
255 // Wrapper for the sender part. 244 // Wrapper for the sender part.
256 class WebRtcVideoSendStream 245 class WebRtcVideoSendStream
257 : public rtc::VideoSourceInterface<webrtc::VideoFrame> { 246 : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
258 public: 247 public:
259 WebRtcVideoSendStream( 248 WebRtcVideoSendStream(
260 webrtc::Call* call, 249 webrtc::Call* call,
261 const StreamParams& sp, 250 const StreamParams& sp,
262 webrtc::VideoSendStream::Config config, 251 webrtc::VideoSendStream::Config config,
263 const VideoOptions& options, 252 const VideoOptions& options,
264 const EncoderFactoryAdapter& encoder_factory, 253 const EncoderFactoryAdapter* encoder_factory,
265 bool enable_cpu_overuse_detection, 254 bool enable_cpu_overuse_detection,
266 int max_bitrate_bps, 255 int max_bitrate_bps,
267 const rtc::Optional<VideoCodecSettings>& codec_settings, 256 const rtc::Optional<VideoCodecSettings>& codec_settings,
268 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, 257 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
269 const VideoSendParameters& send_params); 258 const VideoSendParameters& send_params);
270 virtual ~WebRtcVideoSendStream(); 259 virtual ~WebRtcVideoSendStream();
271 260
272 void SetSendParameters(const ChangedSendParameters& send_params); 261 void SetSendParameters(const ChangedSendParameters& send_params);
273 bool SetRtpParameters(const webrtc::RtpParameters& parameters); 262 bool SetRtpParameters(const webrtc::RtpParameters& parameters);
274 webrtc::RtpParameters GetRtpParameters() const; 263 webrtc::RtpParameters GetRtpParameters() const;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const RTC_EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_); 320 const RTC_EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_);
332 321
333 rtc::ThreadChecker thread_checker_; 322 rtc::ThreadChecker thread_checker_;
334 rtc::AsyncInvoker invoker_; 323 rtc::AsyncInvoker invoker_;
335 rtc::Thread* worker_thread_; 324 rtc::Thread* worker_thread_;
336 const std::vector<uint32_t> ssrcs_ RTC_ACCESS_ON(&thread_checker_); 325 const std::vector<uint32_t> ssrcs_ RTC_ACCESS_ON(&thread_checker_);
337 const std::vector<SsrcGroup> ssrc_groups_ RTC_ACCESS_ON(&thread_checker_); 326 const std::vector<SsrcGroup> ssrc_groups_ RTC_ACCESS_ON(&thread_checker_);
338 webrtc::Call* const call_; 327 webrtc::Call* const call_;
339 const bool enable_cpu_overuse_detection_; 328 const bool enable_cpu_overuse_detection_;
340 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_ 329 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_
341 RTC_ACCESS_ON(&thread_checker_); 330 ACCESS_ON(&thread_checker_);
342 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_ 331 const EncoderFactoryAdapter* const encoder_factory_
343 RTC_ACCESS_ON(&thread_checker_); 332 ACCESS_ON(&thread_checker_);
344 333
345 webrtc::VideoSendStream* stream_ RTC_ACCESS_ON(&thread_checker_); 334 webrtc::VideoSendStream* stream_ RTC_ACCESS_ON(&thread_checker_);
346 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 335 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
347 RTC_ACCESS_ON(&thread_checker_); 336 RTC_ACCESS_ON(&thread_checker_);
348 // Contains settings that are the same for all streams in the MediaChannel, 337 // Contains settings that are the same for all streams in the MediaChannel,
349 // such as codecs, header extensions, and the global bitrate limit for the 338 // such as codecs, header extensions, and the global bitrate limit for the
350 // entire channel. 339 // entire channel.
351 VideoSendStreamParameters parameters_ RTC_ACCESS_ON(&thread_checker_); 340 VideoSendStreamParameters parameters_ RTC_ACCESS_ON(&thread_checker_);
352 // Contains settings that are unique for each stream, such as max_bitrate. 341 // Contains settings that are unique for each stream, such as max_bitrate.
353 // Does *not* contain codecs, however. 342 // Does *not* contain codecs, however.
(...skipping 10 matching lines...) Expand all
364 353
365 // Wrapper for the receiver part, contains configs etc. that are needed to 354 // Wrapper for the receiver part, contains configs etc. that are needed to
366 // reconstruct the underlying VideoReceiveStream. 355 // reconstruct the underlying VideoReceiveStream.
367 class WebRtcVideoReceiveStream 356 class WebRtcVideoReceiveStream
368 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { 357 : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
369 public: 358 public:
370 WebRtcVideoReceiveStream( 359 WebRtcVideoReceiveStream(
371 webrtc::Call* call, 360 webrtc::Call* call,
372 const StreamParams& sp, 361 const StreamParams& sp,
373 webrtc::VideoReceiveStream::Config config, 362 webrtc::VideoReceiveStream::Config config,
374 const DecoderFactoryAdapter& decoder_factory, 363 const DecoderFactoryAdapter* decoder_factory,
375 bool default_stream, 364 bool default_stream,
376 const std::vector<VideoCodecSettings>& recv_codecs, 365 const std::vector<VideoCodecSettings>& recv_codecs,
377 const webrtc::FlexfecReceiveStream::Config& flexfec_config); 366 const webrtc::FlexfecReceiveStream::Config& flexfec_config);
378 ~WebRtcVideoReceiveStream(); 367 ~WebRtcVideoReceiveStream();
379 368
380 const std::vector<uint32_t>& GetSsrcs() const; 369 const std::vector<uint32_t>& GetSsrcs() const;
381 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const; 370 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const;
382 371
383 void SetLocalSsrc(uint32_t local_ssrc); 372 void SetLocalSsrc(uint32_t local_ssrc);
384 // TODO(deadbeef): Move these feedback parameters into the recv parameters. 373 // TODO(deadbeef): Move these feedback parameters into the recv parameters.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 414
426 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are 415 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are
427 // destroyed by calling call_->DestroyVideoReceiveStream and 416 // destroyed by calling call_->DestroyVideoReceiveStream and
428 // call_->DestroyFlexfecReceiveStream, respectively. 417 // call_->DestroyFlexfecReceiveStream, respectively.
429 webrtc::VideoReceiveStream* stream_; 418 webrtc::VideoReceiveStream* stream_;
430 const bool default_stream_; 419 const bool default_stream_;
431 webrtc::VideoReceiveStream::Config config_; 420 webrtc::VideoReceiveStream::Config config_;
432 webrtc::FlexfecReceiveStream::Config flexfec_config_; 421 webrtc::FlexfecReceiveStream::Config flexfec_config_;
433 webrtc::FlexfecReceiveStream* flexfec_stream_; 422 webrtc::FlexfecReceiveStream* flexfec_stream_;
434 423
435 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; 424 const DecoderFactoryAdapter* decoder_factory_;
436 DecoderMap allocated_decoders_; 425 DecoderMap allocated_decoders_;
437 426
438 rtc::CriticalSection sink_lock_; 427 rtc::CriticalSection sink_lock_;
439 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ 428 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_
440 RTC_GUARDED_BY(sink_lock_); 429 RTC_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 RTC_GUARDED_BY(sink_lock_); 433 RTC_GUARDED_BY(sink_lock_);
445 int64_t first_frame_timestamp_ RTC_GUARDED_BY(sink_lock_); 434 int64_t first_frame_timestamp_ RTC_GUARDED_BY(sink_lock_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_ 478 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_
490 RTC_GUARDED_BY(stream_crit_); 479 RTC_GUARDED_BY(stream_crit_);
491 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ 480 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_
492 RTC_GUARDED_BY(stream_crit_); 481 RTC_GUARDED_BY(stream_crit_);
493 std::set<uint32_t> send_ssrcs_ RTC_GUARDED_BY(stream_crit_); 482 std::set<uint32_t> send_ssrcs_ RTC_GUARDED_BY(stream_crit_);
494 std::set<uint32_t> receive_ssrcs_ RTC_GUARDED_BY(stream_crit_); 483 std::set<uint32_t> receive_ssrcs_ RTC_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 const EncoderFactoryAdapter* const encoder_factory_;
500 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; 489 const DecoderFactoryAdapter* const 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/webrtcmediaengine.cc ('k') | webrtc/media/engine/webrtcvideoengine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698