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

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

Issue 2951033003: [EXPERIMENTAL] Generic stereo codec with index header sending single frames
Patch Set: Rebase and add external codec support. Created 3 years, 2 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 | « media/base/mediaconstants.cc ('k') | 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 virtual ~WebRtcVideoEngine(); 114 virtual ~WebRtcVideoEngine();
115 115
116 WebRtcVideoChannel* CreateChannel(webrtc::Call* call, 116 WebRtcVideoChannel* CreateChannel(webrtc::Call* call,
117 const MediaConfig& config, 117 const MediaConfig& config,
118 const VideoOptions& options); 118 const VideoOptions& options);
119 119
120 std::vector<VideoCodec> codecs() const; 120 std::vector<VideoCodec> codecs() const;
121 RtpCapabilities GetCapabilities() const; 121 RtpCapabilities GetCapabilities() const;
122 122
123 private: 123 private:
124 const std::unique_ptr<DecoderFactoryAdapter> decoder_factory_; 124 std::unique_ptr<DecoderFactoryAdapter> decoder_factory_;
125 const std::unique_ptr<EncoderFactoryAdapter> encoder_factory_; 125 std::unique_ptr<EncoderFactoryAdapter> encoder_factory_;
126 }; 126 };
127 127
128 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport { 128 class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
129 public: 129 public:
130 WebRtcVideoChannel(webrtc::Call* call, 130 WebRtcVideoChannel(webrtc::Call* call,
131 const MediaConfig& config, 131 const MediaConfig& config,
132 const VideoOptions& options, 132 const VideoOptions& options,
133 const EncoderFactoryAdapter* encoder_factory, 133 EncoderFactoryAdapter* encoder_factory,
134 const DecoderFactoryAdapter* decoder_factory); 134 DecoderFactoryAdapter* decoder_factory);
135 ~WebRtcVideoChannel() override; 135 ~WebRtcVideoChannel() override;
136 136
137 // VideoMediaChannel implementation 137 // VideoMediaChannel implementation
138 rtc::DiffServCodePoint PreferredDscp() const override; 138 rtc::DiffServCodePoint PreferredDscp() const override;
139 139
140 bool SetSendParameters(const VideoSendParameters& params) override; 140 bool SetSendParameters(const VideoSendParameters& params) override;
141 bool SetRecvParameters(const VideoRecvParameters& params) override; 141 bool SetRecvParameters(const VideoRecvParameters& params) override;
142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override; 142 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
143 bool SetRtpSendParameters(uint32_t ssrc, 143 bool SetRtpSendParameters(uint32_t ssrc,
144 const webrtc::RtpParameters& parameters) override; 144 const webrtc::RtpParameters& parameters) override;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // of |other|. 198 // of |other|.
199 bool operator==(const VideoCodecSettings& other) const; 199 bool operator==(const VideoCodecSettings& other) const;
200 bool operator!=(const VideoCodecSettings& other) const; 200 bool operator!=(const VideoCodecSettings& other) const;
201 201
202 // Checks if all members of |a|, except |flexfec_payload_type|, are equal 202 // Checks if all members of |a|, except |flexfec_payload_type|, are equal
203 // to the corresponding members of |b|. 203 // to the corresponding members of |b|.
204 static bool EqualsDisregardingFlexfec(const VideoCodecSettings& a, 204 static bool EqualsDisregardingFlexfec(const VideoCodecSettings& a,
205 const VideoCodecSettings& b); 205 const VideoCodecSettings& b);
206 206
207 VideoCodec codec; 207 VideoCodec codec;
208 rtc::Optional<VideoCodec> stereo_codec;
208 webrtc::UlpfecConfig ulpfec; 209 webrtc::UlpfecConfig ulpfec;
209 int flexfec_payload_type; 210 int flexfec_payload_type;
210 int rtx_payload_type; 211 int rtx_payload_type;
211 }; 212 };
212 213
213 struct ChangedSendParameters { 214 struct ChangedSendParameters {
214 // These optionals are unset if not changed. 215 // These optionals are unset if not changed.
215 rtc::Optional<VideoCodecSettings> codec; 216 rtc::Optional<VideoCodecSettings> codec;
216 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions; 217 rtc::Optional<std::vector<webrtc::RtpExtension>> rtp_header_extensions;
217 rtc::Optional<int> max_bandwidth_bps; 218 rtc::Optional<int> max_bandwidth_bps;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 // Wrapper for the sender part. 254 // Wrapper for the sender part.
254 class WebRtcVideoSendStream 255 class WebRtcVideoSendStream
255 : public rtc::VideoSourceInterface<webrtc::VideoFrame> { 256 : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
256 public: 257 public:
257 WebRtcVideoSendStream( 258 WebRtcVideoSendStream(
258 webrtc::Call* call, 259 webrtc::Call* call,
259 const StreamParams& sp, 260 const StreamParams& sp,
260 webrtc::VideoSendStream::Config config, 261 webrtc::VideoSendStream::Config config,
261 const VideoOptions& options, 262 const VideoOptions& options,
262 const EncoderFactoryAdapter* encoder_factory, 263 EncoderFactoryAdapter* encoder_factory,
263 bool enable_cpu_overuse_detection, 264 bool enable_cpu_overuse_detection,
264 int max_bitrate_bps, 265 int max_bitrate_bps,
265 const rtc::Optional<VideoCodecSettings>& codec_settings, 266 const rtc::Optional<VideoCodecSettings>& codec_settings,
266 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, 267 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
267 const VideoSendParameters& send_params); 268 const VideoSendParameters& send_params);
268 virtual ~WebRtcVideoSendStream(); 269 virtual ~WebRtcVideoSendStream();
269 270
270 void SetSendParameters(const ChangedSendParameters& send_params); 271 void SetSendParameters(const ChangedSendParameters& send_params);
271 bool SetRtpParameters(const webrtc::RtpParameters& parameters); 272 bool SetRtpParameters(const webrtc::RtpParameters& parameters);
272 webrtc::RtpParameters GetRtpParameters() const; 273 webrtc::RtpParameters GetRtpParameters() const;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 331
331 rtc::ThreadChecker thread_checker_; 332 rtc::ThreadChecker thread_checker_;
332 rtc::AsyncInvoker invoker_; 333 rtc::AsyncInvoker invoker_;
333 rtc::Thread* worker_thread_; 334 rtc::Thread* worker_thread_;
334 const std::vector<uint32_t> ssrcs_ RTC_ACCESS_ON(&thread_checker_); 335 const std::vector<uint32_t> ssrcs_ RTC_ACCESS_ON(&thread_checker_);
335 const std::vector<SsrcGroup> ssrc_groups_ RTC_ACCESS_ON(&thread_checker_); 336 const std::vector<SsrcGroup> ssrc_groups_ RTC_ACCESS_ON(&thread_checker_);
336 webrtc::Call* const call_; 337 webrtc::Call* const call_;
337 const bool enable_cpu_overuse_detection_; 338 const bool enable_cpu_overuse_detection_;
338 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_ 339 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_
339 RTC_ACCESS_ON(&thread_checker_); 340 RTC_ACCESS_ON(&thread_checker_);
340 const EncoderFactoryAdapter* const encoder_factory_ 341 EncoderFactoryAdapter* encoder_factory_ RTC_ACCESS_ON(&thread_checker_);
341 RTC_ACCESS_ON(&thread_checker_);
342 342
343 webrtc::VideoSendStream* stream_ RTC_ACCESS_ON(&thread_checker_); 343 webrtc::VideoSendStream* stream_ RTC_ACCESS_ON(&thread_checker_);
344 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ 344 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_
345 RTC_ACCESS_ON(&thread_checker_); 345 RTC_ACCESS_ON(&thread_checker_);
346 // Contains settings that are the same for all streams in the MediaChannel, 346 // Contains settings that are the same for all streams in the MediaChannel,
347 // such as codecs, header extensions, and the global bitrate limit for the 347 // such as codecs, header extensions, and the global bitrate limit for the
348 // entire channel. 348 // entire channel.
349 VideoSendStreamParameters parameters_ RTC_ACCESS_ON(&thread_checker_); 349 VideoSendStreamParameters parameters_ RTC_ACCESS_ON(&thread_checker_);
350 // Contains settings that are unique for each stream, such as max_bitrate. 350 // Contains settings that are unique for each stream, such as max_bitrate.
351 // Does *not* contain codecs, however. 351 // Does *not* contain codecs, however.
(...skipping 10 matching lines...) Expand all
362 362
363 // 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
364 // reconstruct the underlying VideoReceiveStream. 364 // reconstruct the underlying VideoReceiveStream.
365 class WebRtcVideoReceiveStream 365 class WebRtcVideoReceiveStream
366 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { 366 : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
367 public: 367 public:
368 WebRtcVideoReceiveStream( 368 WebRtcVideoReceiveStream(
369 webrtc::Call* call, 369 webrtc::Call* call,
370 const StreamParams& sp, 370 const StreamParams& sp,
371 webrtc::VideoReceiveStream::Config config, 371 webrtc::VideoReceiveStream::Config config,
372 const DecoderFactoryAdapter* decoder_factory, 372 DecoderFactoryAdapter* decoder_factory,
373 bool default_stream, 373 bool default_stream,
374 const std::vector<VideoCodecSettings>& recv_codecs, 374 const std::vector<VideoCodecSettings>& recv_codecs,
375 const webrtc::FlexfecReceiveStream::Config& flexfec_config); 375 const webrtc::FlexfecReceiveStream::Config& flexfec_config);
376 ~WebRtcVideoReceiveStream(); 376 ~WebRtcVideoReceiveStream();
377 377
378 const std::vector<uint32_t>& GetSsrcs() const; 378 const std::vector<uint32_t>& GetSsrcs() const;
379 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const; 379 rtc::Optional<uint32_t> GetFirstPrimarySsrc() const;
380 380
381 void SetLocalSsrc(uint32_t local_ssrc); 381 void SetLocalSsrc(uint32_t local_ssrc);
382 // TODO(deadbeef): Move these feedback parameters into the recv parameters. 382 // TODO(deadbeef): Move these feedback parameters into the recv parameters.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 423
424 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are 424 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are
425 // destroyed by calling call_->DestroyVideoReceiveStream and 425 // destroyed by calling call_->DestroyVideoReceiveStream and
426 // call_->DestroyFlexfecReceiveStream, respectively. 426 // call_->DestroyFlexfecReceiveStream, respectively.
427 webrtc::VideoReceiveStream* stream_; 427 webrtc::VideoReceiveStream* stream_;
428 const bool default_stream_; 428 const bool default_stream_;
429 webrtc::VideoReceiveStream::Config config_; 429 webrtc::VideoReceiveStream::Config config_;
430 webrtc::FlexfecReceiveStream::Config flexfec_config_; 430 webrtc::FlexfecReceiveStream::Config flexfec_config_;
431 webrtc::FlexfecReceiveStream* flexfec_stream_; 431 webrtc::FlexfecReceiveStream* flexfec_stream_;
432 432
433 const DecoderFactoryAdapter* decoder_factory_; 433 DecoderFactoryAdapter* decoder_factory_;
434 DecoderMap allocated_decoders_; 434 DecoderMap allocated_decoders_;
435 435
436 rtc::CriticalSection sink_lock_; 436 rtc::CriticalSection sink_lock_;
437 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ 437 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_
438 RTC_GUARDED_BY(sink_lock_); 438 RTC_GUARDED_BY(sink_lock_);
439 // Expands remote RTP timestamps to int64_t to be able to estimate how long 439 // Expands remote RTP timestamps to int64_t to be able to estimate how long
440 // the stream has been running. 440 // the stream has been running.
441 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ 441 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_
442 RTC_GUARDED_BY(sink_lock_); 442 RTC_GUARDED_BY(sink_lock_);
443 int64_t first_frame_timestamp_ RTC_GUARDED_BY(sink_lock_); 443 int64_t first_frame_timestamp_ RTC_GUARDED_BY(sink_lock_);
444 // Start NTP time is estimated as current remote NTP time (estimated from 444 // Start NTP time is estimated as current remote NTP time (estimated from
445 // RTCP) minus the elapsed time, as soon as remote NTP time is available. 445 // RTCP) minus the elapsed time, as soon as remote NTP time is available.
446 int64_t estimated_remote_start_ntp_time_ms_ RTC_GUARDED_BY(sink_lock_); 446 int64_t estimated_remote_start_ntp_time_ms_ RTC_GUARDED_BY(sink_lock_);
447 }; 447 };
448 448
449 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine); 449 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine);
450 450
451 bool SendRtp(const uint8_t* data, 451 bool SendRtp(const uint8_t* data,
452 size_t len, 452 size_t len,
453 const webrtc::PacketOptions& options) override; 453 const webrtc::PacketOptions& options) override;
454 bool SendRtcp(const uint8_t* data, size_t len) override; 454 bool SendRtcp(const uint8_t* data, size_t len) override;
455 455
456 static std::vector<VideoCodecSettings> MapCodecs( 456 static std::vector<VideoCodecSettings> MapCodecs(
457 const std::vector<VideoCodec>& codecs); 457 const std::vector<VideoCodec>& codecs);
458 // Select what video codec will be used for sending, i.e. what codec is used 458 // Select what video codec will be used for sending, i.e. what codec is used
459 // for local encoding, based on supported remote codecs. The first remote 459 // for local encoding, based on supported remote codecs. The first remote
460 // codec that is supported locally will be selected. 460 // codec that is supported locally will be selected.
461 rtc::Optional<VideoCodecSettings> SelectSendVideoCodec( 461 rtc::Optional<VideoCodecSettings> SelectSendVideoCodec(
462 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const; 462 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const;
463 rtc::Optional<WebRtcVideoChannel::VideoCodecSettings>
464 SelectStereoAssociatedVideoCodec(
465 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const;
463 466
464 static bool NonFlexfecReceiveCodecsHaveChanged( 467 static bool NonFlexfecReceiveCodecsHaveChanged(
465 std::vector<VideoCodecSettings> before, 468 std::vector<VideoCodecSettings> before,
466 std::vector<VideoCodecSettings> after); 469 std::vector<VideoCodecSettings> after);
467 470
468 void FillSenderStats(VideoMediaInfo* info, bool log_stats); 471 void FillSenderStats(VideoMediaInfo* info, bool log_stats);
469 void FillReceiverStats(VideoMediaInfo* info, bool log_stats); 472 void FillReceiverStats(VideoMediaInfo* info, bool log_stats);
470 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, 473 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats,
471 VideoMediaInfo* info); 474 VideoMediaInfo* info);
472 void FillSendAndReceiveCodecStats(VideoMediaInfo* video_media_info); 475 void FillSendAndReceiveCodecStats(VideoMediaInfo* video_media_info);
(...skipping 14 matching lines...) Expand all
487 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_ 490 std::map<uint32_t, WebRtcVideoSendStream*> send_streams_
488 RTC_GUARDED_BY(stream_crit_); 491 RTC_GUARDED_BY(stream_crit_);
489 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_ 492 std::map<uint32_t, WebRtcVideoReceiveStream*> receive_streams_
490 RTC_GUARDED_BY(stream_crit_); 493 RTC_GUARDED_BY(stream_crit_);
491 std::set<uint32_t> send_ssrcs_ RTC_GUARDED_BY(stream_crit_); 494 std::set<uint32_t> send_ssrcs_ RTC_GUARDED_BY(stream_crit_);
492 std::set<uint32_t> receive_ssrcs_ RTC_GUARDED_BY(stream_crit_); 495 std::set<uint32_t> receive_ssrcs_ RTC_GUARDED_BY(stream_crit_);
493 496
494 rtc::Optional<VideoCodecSettings> send_codec_; 497 rtc::Optional<VideoCodecSettings> send_codec_;
495 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_; 498 rtc::Optional<std::vector<webrtc::RtpExtension>> send_rtp_extensions_;
496 499
497 const EncoderFactoryAdapter* const encoder_factory_; 500 EncoderFactoryAdapter* encoder_factory_;
498 const DecoderFactoryAdapter* const decoder_factory_; 501 DecoderFactoryAdapter* decoder_factory_;
499 std::vector<VideoCodecSettings> recv_codecs_; 502 std::vector<VideoCodecSettings> recv_codecs_;
500 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; 503 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
501 // See reason for keeping track of the FlexFEC payload type separately in 504 // See reason for keeping track of the FlexFEC payload type separately in
502 // comment in WebRtcVideoChannel::ChangedRecvParameters. 505 // comment in WebRtcVideoChannel::ChangedRecvParameters.
503 int recv_flexfec_payload_type_; 506 int recv_flexfec_payload_type_;
504 webrtc::Call::Config::BitrateConfig bitrate_config_; 507 webrtc::Call::Config::BitrateConfig bitrate_config_;
505 // TODO(deadbeef): Don't duplicate information between 508 // TODO(deadbeef): Don't duplicate information between
506 // send_params/recv_params, rtp_extensions, options, etc. 509 // send_params/recv_params, rtp_extensions, options, etc.
507 VideoSendParameters send_params_; 510 VideoSendParameters send_params_;
508 VideoOptions default_send_options_; 511 VideoOptions default_send_options_;
(...skipping 19 matching lines...) Expand all
528 const std::string codec_name_; 531 const std::string codec_name_;
529 const int max_qp_; 532 const int max_qp_;
530 const int max_framerate_; 533 const int max_framerate_;
531 const bool is_screencast_; 534 const bool is_screencast_;
532 const bool conference_mode_; 535 const bool conference_mode_;
533 }; 536 };
534 537
535 } // namespace cricket 538 } // namespace cricket
536 539
537 #endif // MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ 540 #endif // MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_
OLDNEW
« no previous file with comments | « media/base/mediaconstants.cc ('k') | media/engine/webrtcvideoengine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698