| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 int max_bitrate_bps, | 241 int max_bitrate_bps, |
| 242 const rtc::Optional<VideoCodecSettings>& codec_settings, | 242 const rtc::Optional<VideoCodecSettings>& codec_settings, |
| 243 const std::vector<webrtc::RtpExtension>& rtp_extensions, | 243 const std::vector<webrtc::RtpExtension>& rtp_extensions, |
| 244 const VideoSendParameters& send_params); | 244 const VideoSendParameters& send_params); |
| 245 virtual ~WebRtcVideoSendStream(); | 245 virtual ~WebRtcVideoSendStream(); |
| 246 | 246 |
| 247 void SetOptions(const VideoOptions& options); | 247 void SetOptions(const VideoOptions& options); |
| 248 // TODO(pbos): Move logic from SetOptions into this method. | 248 // TODO(pbos): Move logic from SetOptions into this method. |
| 249 void SetSendParameters(const ChangedSendParameters& send_params); | 249 void SetSendParameters(const ChangedSendParameters& send_params); |
| 250 bool SetRtpParameters(const webrtc::RtpParameters& parameters); | 250 bool SetRtpParameters(const webrtc::RtpParameters& parameters); |
| 251 webrtc::RtpParameters GetRtpParameters() const; |
| 251 | 252 |
| 252 void OnFrame(const cricket::VideoFrame& frame) override; | 253 void OnFrame(const cricket::VideoFrame& frame) override; |
| 253 bool SetCapturer(VideoCapturer* capturer); | 254 bool SetCapturer(VideoCapturer* capturer); |
| 254 void MuteStream(bool mute); | 255 void MuteStream(bool mute); |
| 255 bool DisconnectCapturer(); | 256 bool DisconnectCapturer(); |
| 256 | 257 |
| 257 void Start(); | 258 void SetSend(bool send); |
| 258 void Stop(); | |
| 259 | |
| 260 webrtc::RtpParameters rtp_parameters() const { return rtp_parameters_; } | |
| 261 | 259 |
| 262 // Implements webrtc::LoadObserver. | 260 // Implements webrtc::LoadObserver. |
| 263 void OnLoadUpdate(Load load) override; | 261 void OnLoadUpdate(Load load) override; |
| 264 | 262 |
| 265 const std::vector<uint32_t>& GetSsrcs() const; | 263 const std::vector<uint32_t>& GetSsrcs() const; |
| 266 VideoSenderInfo GetVideoSenderInfo(); | 264 VideoSenderInfo GetVideoSenderInfo(); |
| 267 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); | 265 void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); |
| 268 | 266 |
| 269 private: | 267 private: |
| 270 // Parameters needed to reconstruct the underlying stream. | 268 // Parameters needed to reconstruct the underlying stream. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 void SetCodec(const VideoCodecSettings& codec) | 336 void SetCodec(const VideoCodecSettings& codec) |
| 339 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 337 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 340 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); | 338 void RecreateWebRtcStream() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 341 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( | 339 webrtc::VideoEncoderConfig CreateVideoEncoderConfig( |
| 342 const Dimensions& dimensions, | 340 const Dimensions& dimensions, |
| 343 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); | 341 const VideoCodec& codec) const EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 344 void SetDimensions(int width, int height) | 342 void SetDimensions(int width, int height) |
| 345 EXCLUSIVE_LOCKS_REQUIRED(lock_); | 343 EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 346 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); | 344 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); |
| 347 | 345 |
| 346 // Calls Start or Stop according to whether or not |sending_| is true, |
| 347 // and whether or not the encoding in |rtp_parameters_| is active. |
| 348 void UpdateSendState() EXCLUSIVE_LOCKS_REQUIRED(lock_); |
| 349 |
| 348 rtc::ThreadChecker thread_checker_; | 350 rtc::ThreadChecker thread_checker_; |
| 349 rtc::AsyncInvoker invoker_; | 351 rtc::AsyncInvoker invoker_; |
| 350 rtc::Thread* worker_thread_; | 352 rtc::Thread* worker_thread_; |
| 351 const std::vector<uint32_t> ssrcs_; | 353 const std::vector<uint32_t> ssrcs_; |
| 352 const std::vector<SsrcGroup> ssrc_groups_; | 354 const std::vector<SsrcGroup> ssrc_groups_; |
| 353 webrtc::Call* const call_; | 355 webrtc::Call* const call_; |
| 354 rtc::VideoSinkWants sink_wants_; | 356 rtc::VideoSinkWants sink_wants_; |
| 355 // Counter used for deciding if the video resolution is currently | 357 // Counter used for deciding if the video resolution is currently |
| 356 // restricted by CPU usage. It is reset if |capturer_| is changed. | 358 // restricted by CPU usage. It is reset if |capturer_| is changed. |
| 357 int cpu_restricted_counter_; | 359 int cpu_restricted_counter_; |
| 358 // Total number of times resolution as been requested to be changed due to | 360 // Total number of times resolution as been requested to be changed due to |
| 359 // CPU adaptation. | 361 // CPU adaptation. |
| 360 int number_of_cpu_adapt_changes_; | 362 int number_of_cpu_adapt_changes_; |
| 361 VideoCapturer* capturer_; | 363 VideoCapturer* capturer_; |
| 362 WebRtcVideoEncoderFactory* const external_encoder_factory_ | 364 WebRtcVideoEncoderFactory* const external_encoder_factory_ |
| 363 GUARDED_BY(lock_); | 365 GUARDED_BY(lock_); |
| 364 | 366 |
| 365 rtc::CriticalSection lock_; | 367 rtc::CriticalSection lock_; |
| 366 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); | 368 webrtc::VideoSendStream* stream_ GUARDED_BY(lock_); |
| 367 // Contains settings that are the same for all streams in the MediaChannel, | 369 // Contains settings that are the same for all streams in the MediaChannel, |
| 368 // such as codecs, header extensions, and the global bitrate limit for the | 370 // such as codecs, header extensions, and the global bitrate limit for the |
| 369 // entire channel. | 371 // entire channel. |
| 370 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); | 372 VideoSendStreamParameters parameters_ GUARDED_BY(lock_); |
| 371 // Contains settings that are unique for each stream, such as max_bitrate. | 373 // Contains settings that are unique for each stream, such as max_bitrate. |
| 372 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. | 374 // TODO(skvlad): Move ssrcs_ and ssrc_groups_ into rtp_parameters_. |
| 373 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only | 375 // TODO(skvlad): Combine parameters_ and rtp_parameters_ once we have only |
| 374 // one stream per MediaChannel. | 376 // one stream per MediaChannel. |
| 375 webrtc::RtpParameters rtp_parameters_; | 377 webrtc::RtpParameters rtp_parameters_ GUARDED_BY(lock_); |
| 376 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); | 378 bool pending_encoder_reconfiguration_ GUARDED_BY(lock_); |
| 377 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); | 379 VideoEncoderSettings encoder_settings_ GUARDED_BY(lock_); |
| 378 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); | 380 AllocatedEncoder allocated_encoder_ GUARDED_BY(lock_); |
| 379 Dimensions last_dimensions_ GUARDED_BY(lock_); | 381 Dimensions last_dimensions_ GUARDED_BY(lock_); |
| 380 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = | 382 webrtc::VideoRotation last_rotation_ GUARDED_BY(lock_) = |
| 381 webrtc::kVideoRotation_0; | 383 webrtc::kVideoRotation_0; |
| 382 | 384 |
| 383 bool sending_ GUARDED_BY(lock_); | 385 bool sending_ GUARDED_BY(lock_); |
| 384 bool muted_ GUARDED_BY(lock_); | 386 bool muted_ GUARDED_BY(lock_); |
| 385 | 387 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); | 477 int64_t estimated_remote_start_ntp_time_ms_ GUARDED_BY(sink_lock_); |
| 476 }; | 478 }; |
| 477 | 479 |
| 478 void Construct(webrtc::Call* call, WebRtcVideoEngine2* engine); | 480 void Construct(webrtc::Call* call, WebRtcVideoEngine2* engine); |
| 479 | 481 |
| 480 bool SendRtp(const uint8_t* data, | 482 bool SendRtp(const uint8_t* data, |
| 481 size_t len, | 483 size_t len, |
| 482 const webrtc::PacketOptions& options) override; | 484 const webrtc::PacketOptions& options) override; |
| 483 bool SendRtcp(const uint8_t* data, size_t len) override; | 485 bool SendRtcp(const uint8_t* data, size_t len) override; |
| 484 | 486 |
| 485 void StartAllSendStreams(); | |
| 486 void StopAllSendStreams(); | |
| 487 | |
| 488 static std::vector<VideoCodecSettings> MapCodecs( | 487 static std::vector<VideoCodecSettings> MapCodecs( |
| 489 const std::vector<VideoCodec>& codecs); | 488 const std::vector<VideoCodec>& codecs); |
| 490 std::vector<VideoCodecSettings> FilterSupportedCodecs( | 489 std::vector<VideoCodecSettings> FilterSupportedCodecs( |
| 491 const std::vector<VideoCodecSettings>& mapped_codecs) const; | 490 const std::vector<VideoCodecSettings>& mapped_codecs) const; |
| 492 static bool ReceiveCodecsHaveChanged(std::vector<VideoCodecSettings> before, | 491 static bool ReceiveCodecsHaveChanged(std::vector<VideoCodecSettings> before, |
| 493 std::vector<VideoCodecSettings> after); | 492 std::vector<VideoCodecSettings> after); |
| 494 | 493 |
| 495 void FillSenderStats(VideoMediaInfo* info); | 494 void FillSenderStats(VideoMediaInfo* info); |
| 496 void FillReceiverStats(VideoMediaInfo* info); | 495 void FillReceiverStats(VideoMediaInfo* info); |
| 497 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, | 496 void FillBandwidthEstimationStats(const webrtc::Call::Stats& stats, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // TODO(deadbeef): Don't duplicate information between | 529 // TODO(deadbeef): Don't duplicate information between |
| 531 // send_params/recv_params, rtp_extensions, options, etc. | 530 // send_params/recv_params, rtp_extensions, options, etc. |
| 532 VideoSendParameters send_params_; | 531 VideoSendParameters send_params_; |
| 533 VideoOptions default_send_options_; | 532 VideoOptions default_send_options_; |
| 534 VideoRecvParameters recv_params_; | 533 VideoRecvParameters recv_params_; |
| 535 }; | 534 }; |
| 536 | 535 |
| 537 } // namespace cricket | 536 } // namespace cricket |
| 538 | 537 |
| 539 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ | 538 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENGINE2_H_ |
| OLD | NEW |