| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 bool external; | 322 bool external; |
| 322 }; | 323 }; |
| 323 | 324 |
| 324 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> | 325 rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings> |
| 325 ConfigureVideoEncoderSettings(const VideoCodec& codec); | 326 ConfigureVideoEncoderSettings(const VideoCodec& codec); |
| 326 // If force_encoder_allocation is true, a new AllocatedEncoder is always | 327 // If force_encoder_allocation is true, a new AllocatedEncoder is always |
| 327 // created. If false, the allocated encoder may be reused, if the type | 328 // created. If false, the allocated encoder may be reused, if the type |
| 328 // matches. | 329 // matches. |
| 329 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec, | 330 AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec, |
| 330 bool force_encoder_allocation); | 331 bool force_encoder_allocation); |
| 332 AllocatedEncoder CreateStereoVideoEncoder(const VideoCodec& codec); |
| 331 void DestroyVideoEncoder(AllocatedEncoder* encoder); | 333 void DestroyVideoEncoder(AllocatedEncoder* encoder); |
| 332 void SetCodec(const VideoCodecSettings& codec, | 334 void SetCodec(const VideoCodecSettings& codec, |
| 333 bool force_encoder_allocation); | 335 bool force_encoder_allocation); |
| 334 void RecreateWebRtcStream(); | 336 void RecreateWebRtcStream(); |
| 335 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | 337 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( |
| 336 const VideoCodec& codec) const; | 338 const VideoCodec& codec) const; |
| 337 void ReconfigureEncoder(); | 339 void ReconfigureEncoder(); |
| 338 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); | 340 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); |
| 339 | 341 |
| 340 // Calls Start or Stop according to whether or not |sending_| is true, | 342 // Calls Start or Stop according to whether or not |sending_| is true, |
| 341 // and whether or not the encoding in |rtp_parameters_| is active. | 343 // and whether or not the encoding in |rtp_parameters_| is active. |
| 342 void UpdateSendState(); | 344 void UpdateSendState(); |
| 343 | 345 |
| 344 webrtc::VideoSendStream::DegradationPreference GetDegradationPreference() | 346 webrtc::VideoSendStream::DegradationPreference GetDegradationPreference() |
| 345 const EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_); | 347 const EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_); |
| 346 | 348 |
| 347 rtc::ThreadChecker thread_checker_; | 349 rtc::ThreadChecker thread_checker_; |
| 348 rtc::AsyncInvoker invoker_; | 350 rtc::AsyncInvoker invoker_; |
| 349 rtc::Thread* worker_thread_; | 351 rtc::Thread* worker_thread_; |
| 350 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); | 352 const std::vector<uint32_t> ssrcs_ ACCESS_ON(&thread_checker_); |
| 351 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); | 353 const std::vector<SsrcGroup> ssrc_groups_ ACCESS_ON(&thread_checker_); |
| 352 webrtc::Call* const call_; | 354 webrtc::Call* const call_; |
| 353 const bool enable_cpu_overuse_detection_; | 355 const bool enable_cpu_overuse_detection_; |
| 354 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_ | 356 rtc::VideoSourceInterface<webrtc::VideoFrame>* source_ |
| 355 ACCESS_ON(&thread_checker_); | 357 ACCESS_ON(&thread_checker_); |
| 356 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 358 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 357 ACCESS_ON(&thread_checker_); | 359 ACCESS_ON(&thread_checker_); |
| 358 const std::unique_ptr<WebRtcVideoEncoderFactory> internal_encoder_factory_ | 360 const std::unique_ptr<WebRtcVideoEncoderFactory> internal_encoder_factory_ |
| 359 ACCESS_ON(&thread_checker_); | 361 ACCESS_ON(&thread_checker_); |
| 362 std::unique_ptr<WebRtcVideoEncoderFactory> stereo_encoder_factory_ |
| 363 ACCESS_ON(&thread_checker_); |
| 360 | 364 |
| 361 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); | 365 webrtc::VideoSendStream* stream_ ACCESS_ON(&thread_checker_); |
| 362 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ | 366 rtc::VideoSinkInterface<webrtc::VideoFrame>* encoder_sink_ |
| 363 ACCESS_ON(&thread_checker_); | 367 ACCESS_ON(&thread_checker_); |
| 364 // Contains settings that are the same for all streams in the MediaChannel, | 368 // Contains settings that are the same for all streams in the MediaChannel, |
| 365 // such as codecs, header extensions, and the global bitrate limit for the | 369 // such as codecs, header extensions, and the global bitrate limit for the |
| 366 // entire channel. | 370 // entire channel. |
| 367 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_); | 371 VideoSendStreamParameters parameters_ ACCESS_ON(&thread_checker_); |
| 368 // Contains settings that are unique for each stream, such as max_bitrate. | 372 // Contains settings that are unique for each stream, such as max_bitrate. |
| 369 // Does *not* contain codecs, however. | 373 // Does *not* contain codecs, however. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 427 |
| 424 void RecreateWebRtcVideoStream(); | 428 void RecreateWebRtcVideoStream(); |
| 425 void MaybeRecreateWebRtcFlexfecStream(); | 429 void MaybeRecreateWebRtcFlexfecStream(); |
| 426 | 430 |
| 427 void ConfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs, | 431 void ConfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs, |
| 428 std::vector<AllocatedDecoder>* old_codecs); | 432 std::vector<AllocatedDecoder>* old_codecs); |
| 429 void ConfigureFlexfecCodec(int flexfec_payload_type); | 433 void ConfigureFlexfecCodec(int flexfec_payload_type); |
| 430 AllocatedDecoder CreateOrReuseVideoDecoder( | 434 AllocatedDecoder CreateOrReuseVideoDecoder( |
| 431 std::vector<AllocatedDecoder>* old_decoder, | 435 std::vector<AllocatedDecoder>* old_decoder, |
| 432 const VideoCodec& codec); | 436 const VideoCodec& codec); |
| 437 AllocatedDecoder CreateStereoVideoDecoder(const VideoCodec& codec); |
| 433 void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders); | 438 void ClearDecoders(std::vector<AllocatedDecoder>* allocated_decoders); |
| 434 | 439 |
| 435 std::string GetCodecNameFromPayloadType(int payload_type); | 440 std::string GetCodecNameFromPayloadType(int payload_type); |
| 436 | 441 |
| 437 webrtc::Call* const call_; | 442 webrtc::Call* const call_; |
| 438 StreamParams stream_params_; | 443 StreamParams stream_params_; |
| 439 | 444 |
| 440 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are | 445 // Both |stream_| and |flexfec_stream_| are managed by |this|. They are |
| 441 // destroyed by calling call_->DestroyVideoReceiveStream and | 446 // destroyed by calling call_->DestroyVideoReceiveStream and |
| 442 // call_->DestroyFlexfecReceiveStream, respectively. | 447 // call_->DestroyFlexfecReceiveStream, respectively. |
| 443 webrtc::VideoReceiveStream* stream_; | 448 webrtc::VideoReceiveStream* stream_; |
| 444 const bool default_stream_; | 449 const bool default_stream_; |
| 445 webrtc::VideoReceiveStream::Config config_; | 450 webrtc::VideoReceiveStream::Config config_; |
| 446 webrtc::FlexfecReceiveStream::Config flexfec_config_; | 451 webrtc::FlexfecReceiveStream::Config flexfec_config_; |
| 447 webrtc::FlexfecReceiveStream* flexfec_stream_; | 452 webrtc::FlexfecReceiveStream* flexfec_stream_; |
| 448 | 453 |
| 449 WebRtcVideoDecoderFactory* const external_decoder_factory_; | 454 WebRtcVideoDecoderFactory* const external_decoder_factory_; |
| 455 const std::unique_ptr<WebRtcVideoDecoderFactory> internal_decoder_factory_; |
| 456 std::unique_ptr<WebRtcVideoDecoderFactory> stereo_decoder_factory_; |
| 450 std::vector<AllocatedDecoder> allocated_decoders_; | 457 std::vector<AllocatedDecoder> allocated_decoders_; |
| 451 | 458 |
| 452 rtc::CriticalSection sink_lock_; | 459 rtc::CriticalSection sink_lock_; |
| 453 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ GUARDED_BY(sink_lock_); | 460 rtc::VideoSinkInterface<webrtc::VideoFrame>* sink_ GUARDED_BY(sink_lock_); |
| 454 // Expands remote RTP timestamps to int64_t to be able to estimate how long | 461 // Expands remote RTP timestamps to int64_t to be able to estimate how long |
| 455 // the stream has been running. | 462 // the stream has been running. |
| 456 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ | 463 rtc::TimestampWrapAroundHandler timestamp_wraparound_handler_ |
| 457 GUARDED_BY(sink_lock_); | 464 GUARDED_BY(sink_lock_); |
| 458 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); | 465 int64_t first_frame_timestamp_ GUARDED_BY(sink_lock_); |
| 459 // Start NTP time is estimated as current remote NTP time (estimated from | 466 // Start NTP time is estimated as current remote NTP time (estimated from |
| 460 // RTCP) minus the elapsed time, as soon as remote NTP time is available. | 467 // RTCP) minus the elapsed time, as soon as remote NTP time is available. |
| 461 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); | 468 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); |
| 462 }; | 469 }; |
| 463 | 470 |
| 464 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine); | 471 void Construct(webrtc::Call* call, WebRtcVideoEngine* engine); |
| 465 | 472 |
| 466 bool SendRtp(const uint8_t* data, | 473 bool SendRtp(const uint8_t* data, |
| 467 size_t len, | 474 size_t len, |
| 468 const webrtc::PacketOptions& options) override; | 475 const webrtc::PacketOptions& options) override; |
| 469 bool SendRtcp(const uint8_t* data, size_t len) override; | 476 bool SendRtcp(const uint8_t* data, size_t len) override; |
| 470 | 477 |
| 471 static std::vector<VideoCodecSettings> MapCodecs( | 478 static std::vector<VideoCodecSettings> MapCodecs( |
| 472 const std::vector<VideoCodec>& codecs); | 479 const std::vector<VideoCodec>& codecs); |
| 473 // Select what video codec will be used for sending, i.e. what codec is used | 480 // Select what video codec will be used for sending, i.e. what codec is used |
| 474 // for local encoding, based on supported remote codecs. The first remote | 481 // for local encoding, based on supported remote codecs. The first remote |
| 475 // codec that is supported locally will be selected. | 482 // codec that is supported locally will be selected. |
| 476 rtc::Optional<VideoCodecSettings> SelectSendVideoCodec( | 483 rtc::Optional<VideoCodecSettings> SelectSendVideoCodec( |
| 477 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const; | 484 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const; |
| 485 rtc::Optional<WebRtcVideoChannel::VideoCodecSettings> |
| 486 SelectStereoAssociatedVideoCodec( |
| 487 const std::vector<VideoCodecSettings>& remote_mapped_codecs) const; |
| 478 | 488 |
| 479 static bool NonFlexfecReceiveCodecsHaveChanged( | 489 static bool NonFlexfecReceiveCodecsHaveChanged( |
| 480 std::vector<VideoCodecSettings> before, | 490 std::vector<VideoCodecSettings> before, |
| 481 std::vector<VideoCodecSettings> after); | 491 std::vector<VideoCodecSettings> after); |
| 482 | 492 |
| 483 void FillSenderStats(VideoMediaInfo* info, bool log_stats); | 493 void FillSenderStats(VideoMediaInfo* info, bool log_stats); |
| 484 void FillReceiverStats(VideoMediaInfo* info, bool log_stats); | 494 void FillReceiverStats(VideoMediaInfo* info, bool log_stats); |
| 485 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, | 495 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, |
| 486 VideoMediaInfo* info); | 496 VideoMediaInfo* info); |
| 487 void FillSendAndReceiveCodecStats(VideoMediaInfo* video_media_info); | 497 void FillSendAndReceiveCodecStats(VideoMediaInfo* video_media_info); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 const std::string codec_name_; | 553 const std::string codec_name_; |
| 544 const int max_qp_; | 554 const int max_qp_; |
| 545 const int max_framerate_; | 555 const int max_framerate_; |
| 546 const bool is_screencast_; | 556 const bool is_screencast_; |
| 547 const bool conference_mode_; | 557 const bool conference_mode_; |
| 548 }; | 558 }; |
| 549 | 559 |
| 550 } // namespace cricket | 560 } // namespace cricket |
| 551 | 561 |
| 552 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ | 562 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE_H_ |
| OLD | NEW |