Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), | 115 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), |
| 116 this, | 116 this, |
| 117 qm_callback_.get())), | 117 qm_callback_.get())), |
| 118 send_payload_router_(NULL), | 118 send_payload_router_(NULL), |
| 119 data_cs_(CriticalSectionWrapper::CreateCriticalSection()), | 119 data_cs_(CriticalSectionWrapper::CreateCriticalSection()), |
| 120 stats_proxy_(stats_proxy), | 120 stats_proxy_(stats_proxy), |
| 121 pre_encode_callback_(pre_encode_callback), | 121 pre_encode_callback_(pre_encode_callback), |
| 122 pacer_(pacer), | 122 pacer_(pacer), |
| 123 bitrate_allocator_(bitrate_allocator), | 123 bitrate_allocator_(bitrate_allocator), |
| 124 time_of_last_frame_activity_ms_(0), | 124 time_of_last_frame_activity_ms_(0), |
| 125 simulcast_enabled_(false), | 125 encoder_config_(), |
| 126 min_transmit_bitrate_kbps_(0), | 126 min_transmit_bitrate_kbps_(0), |
| 127 last_observed_bitrate_bps_(0), | 127 last_observed_bitrate_bps_(0), |
| 128 target_delay_ms_(0), | 128 target_delay_ms_(0), |
| 129 network_is_transmitting_(true), | 129 network_is_transmitting_(true), |
| 130 encoder_paused_(false), | 130 encoder_paused_(false), |
| 131 encoder_paused_and_dropped_frame_(false), | 131 encoder_paused_and_dropped_frame_(false), |
| 132 fec_enabled_(false), | |
| 133 nack_enabled_(false), | |
| 134 module_process_thread_(module_process_thread), | 132 module_process_thread_(module_process_thread), |
| 135 has_received_sli_(false), | 133 has_received_sli_(false), |
| 136 picture_id_sli_(0), | 134 picture_id_sli_(0), |
| 137 has_received_rpsi_(false), | 135 has_received_rpsi_(false), |
| 138 picture_id_rpsi_(0), | 136 picture_id_rpsi_(0), |
| 139 video_suspended_(false) { | 137 video_suspended_(false) { |
| 140 bitrate_observer_.reset(new ViEBitrateObserver(this)); | 138 bitrate_observer_.reset(new ViEBitrateObserver(this)); |
| 141 } | 139 } |
| 142 | 140 |
| 143 bool ViEEncoder::Init() { | 141 bool ViEEncoder::Init() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 } | 222 } |
| 225 | 223 |
| 226 int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { | 224 int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { |
| 227 RTC_DCHECK(send_payload_router_ != NULL); | 225 RTC_DCHECK(send_payload_router_ != NULL); |
| 228 // Setting target width and height for VPM. | 226 // Setting target width and height for VPM. |
| 229 if (vpm_->SetTargetResolution(video_codec.width, video_codec.height, | 227 if (vpm_->SetTargetResolution(video_codec.width, video_codec.height, |
| 230 video_codec.maxFramerate) != VPM_OK) { | 228 video_codec.maxFramerate) != VPM_OK) { |
| 231 return -1; | 229 return -1; |
| 232 } | 230 } |
| 233 | 231 |
| 232 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged | |
| 233 // that makes use of the number of simulcast streams configured). | |
| 234 { | 234 { |
| 235 CriticalSectionScoped cs(data_cs_.get()); | 235 CriticalSectionScoped cs(data_cs_.get()); |
| 236 simulcast_enabled_ = video_codec.numberOfSimulcastStreams > 1; | 236 encoder_config_ = video_codec; |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Add a bitrate observer to the allocator and update the start, max and | 239 // Add a bitrate observer to the allocator and update the start, max and |
| 240 // min bitrates of the bitrate controller as needed. | 240 // min bitrates of the bitrate controller as needed. |
| 241 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver( | 241 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver( |
| 242 bitrate_observer_.get(), video_codec.minBitrate * 1000, | 242 bitrate_observer_.get(), video_codec.minBitrate * 1000, |
| 243 video_codec.maxBitrate * 1000); | 243 video_codec.maxBitrate * 1000); |
| 244 | 244 |
| 245 webrtc::VideoCodec modified_video_codec = video_codec; | 245 webrtc::VideoCodec modified_video_codec = video_codec; |
| 246 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000; | 246 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000; |
| 247 | 247 |
| 248 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength(); | 248 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength(); |
| 249 if (vcm_->RegisterSendCodec(&modified_video_codec, number_of_cores_, | 249 if (vcm_->RegisterSendCodec(&modified_video_codec, number_of_cores_, |
| 250 static_cast<uint32_t>(max_data_payload_length)) != | 250 static_cast<uint32_t>(max_data_payload_length)) != |
| 251 VCM_OK) { | 251 VCM_OK) { |
| 252 return -1; | 252 return -1; |
| 253 } | 253 } |
| 254 return 0; | 254 return 0; |
| 255 } | 255 } |
| 256 | 256 |
| 257 int32_t ViEEncoder::GetEncoder(VideoCodec* video_codec) { | |
| 258 *video_codec = vcm_->GetSendCodec(); | |
| 259 return 0; | |
| 260 } | |
| 261 | |
| 262 int32_t ViEEncoder::ScaleInputImage(bool enable) { | 257 int32_t ViEEncoder::ScaleInputImage(bool enable) { |
| 263 VideoFrameResampling resampling_mode = kFastRescaling; | 258 VideoFrameResampling resampling_mode = kFastRescaling; |
| 264 // TODO(mflodman) What? | 259 // TODO(mflodman) What? |
| 265 if (enable) { | 260 if (enable) { |
| 266 // kInterpolation is currently not supported. | 261 // kInterpolation is currently not supported. |
| 267 LOG_F(LS_ERROR) << "Not supported."; | 262 LOG_F(LS_ERROR) << "Not supported."; |
| 268 return -1; | 263 return -1; |
| 269 } | 264 } |
| 270 vpm_->SetInputFrameResampleMode(resampling_mode); | 265 vpm_->SetInputFrameResampleMode(resampling_mode); |
| 271 | 266 |
| 272 return 0; | 267 return 0; |
| 273 } | 268 } |
| 274 | 269 |
| 275 int ViEEncoder::GetPaddingNeededBps() const { | 270 int ViEEncoder::GetPaddingNeededBps() const { |
| 276 int64_t time_of_last_frame_activity_ms; | 271 int64_t time_of_last_frame_activity_ms; |
| 277 int min_transmit_bitrate_bps; | 272 int min_transmit_bitrate_bps; |
| 278 int bitrate_bps; | 273 int bitrate_bps; |
| 274 VideoCodec send_codec; | |
| 279 { | 275 { |
| 280 CriticalSectionScoped cs(data_cs_.get()); | 276 CriticalSectionScoped cs(data_cs_.get()); |
| 281 bool send_padding = simulcast_enabled_ || video_suspended_ || | 277 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 || |
| 282 min_transmit_bitrate_kbps_ > 0; | 278 video_suspended_ || min_transmit_bitrate_kbps_ > 0; |
| 283 if (!send_padding) | 279 if (!send_padding) |
| 284 return 0; | 280 return 0; |
| 285 time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_; | 281 time_of_last_frame_activity_ms = time_of_last_frame_activity_ms_; |
| 286 min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_; | 282 min_transmit_bitrate_bps = 1000 * min_transmit_bitrate_kbps_; |
| 287 bitrate_bps = last_observed_bitrate_bps_; | 283 bitrate_bps = last_observed_bitrate_bps_; |
| 284 send_codec = encoder_config_; | |
| 288 } | 285 } |
| 289 | 286 |
| 290 VideoCodec send_codec; | |
| 291 if (vcm_->SendCodec(&send_codec) != 0) | |
| 292 return 0; | |
| 293 | |
| 294 bool video_is_suspended = vcm_->VideoSuspended(); | 287 bool video_is_suspended = vcm_->VideoSuspended(); |
| 295 | 288 |
| 296 // Find the max amount of padding we can allow ourselves to send at this | 289 // Find the max amount of padding we can allow ourselves to send at this |
| 297 // point, based on which streams are currently active and what our current | 290 // point, based on which streams are currently active and what our current |
| 298 // available bandwidth is. | 291 // available bandwidth is. |
| 299 int pad_up_to_bitrate_bps = 0; | 292 int pad_up_to_bitrate_bps = 0; |
| 300 if (send_codec.numberOfSimulcastStreams == 0) { | 293 if (send_codec.numberOfSimulcastStreams == 0) { |
| 301 pad_up_to_bitrate_bps = send_codec.minBitrate * 1000; | 294 pad_up_to_bitrate_bps = send_codec.minBitrate * 1000; |
| 302 } else { | 295 } else { |
| 303 SimulcastStream* stream_configs = send_codec.simulcastStream; | 296 SimulcastStream* stream_configs = send_codec.simulcastStream; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 encoder_paused_and_dropped_frame_ = false; | 363 encoder_paused_and_dropped_frame_ = false; |
| 371 } | 364 } |
| 372 | 365 |
| 373 void ViEEncoder::DeliverFrame(VideoFrame video_frame) { | 366 void ViEEncoder::DeliverFrame(VideoFrame video_frame) { |
| 374 RTC_DCHECK(send_payload_router_ != NULL); | 367 RTC_DCHECK(send_payload_router_ != NULL); |
| 375 if (!send_payload_router_->active()) { | 368 if (!send_payload_router_->active()) { |
| 376 // We've paused or we have no channels attached, don't waste resources on | 369 // We've paused or we have no channels attached, don't waste resources on |
| 377 // encoding. | 370 // encoding. |
| 378 return; | 371 return; |
| 379 } | 372 } |
| 373 VideoCodecType codec_type; | |
| 380 { | 374 { |
| 381 CriticalSectionScoped cs(data_cs_.get()); | 375 CriticalSectionScoped cs(data_cs_.get()); |
| 382 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); | 376 time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp(); |
| 383 if (EncoderPaused()) { | 377 if (EncoderPaused()) { |
| 384 TraceFrameDropStart(); | 378 TraceFrameDropStart(); |
| 385 return; | 379 return; |
| 386 } | 380 } |
| 387 TraceFrameDropEnd(); | 381 TraceFrameDropEnd(); |
| 382 codec_type = encoder_config_.codecType; | |
| 388 } | 383 } |
| 389 | 384 |
| 390 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), | 385 TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), |
| 391 "Encode"); | 386 "Encode"); |
| 392 VideoFrame* decimated_frame = NULL; | 387 VideoFrame* decimated_frame = NULL; |
| 393 // TODO(wuchengli): support texture frames. | 388 // TODO(wuchengli): support texture frames. |
| 394 if (video_frame.native_handle() == NULL) { | 389 if (video_frame.native_handle() == NULL) { |
| 395 // Pass frame via preprocessor. | 390 // Pass frame via preprocessor. |
| 396 const int ret = vpm_->PreprocessFrame(video_frame, &decimated_frame); | 391 const int ret = vpm_->PreprocessFrame(video_frame, &decimated_frame); |
| 397 if (ret == 1) { | 392 if (ret == 1) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 414 } | 409 } |
| 415 pre_encode_callback_->FrameCallback(decimated_frame); | 410 pre_encode_callback_->FrameCallback(decimated_frame); |
| 416 } | 411 } |
| 417 | 412 |
| 418 // If the frame was not resampled, scaled, or touched by FrameCallback => use | 413 // If the frame was not resampled, scaled, or touched by FrameCallback => use |
| 419 // original. The frame is const from here. | 414 // original. The frame is const from here. |
| 420 const VideoFrame* output_frame = | 415 const VideoFrame* output_frame = |
| 421 (decimated_frame != NULL) ? decimated_frame : &video_frame; | 416 (decimated_frame != NULL) ? decimated_frame : &video_frame; |
| 422 | 417 |
| 423 #ifdef VIDEOCODEC_VP8 | 418 #ifdef VIDEOCODEC_VP8 |
| 424 if (vcm_->SendCodec() == webrtc::kVideoCodecVP8) { | 419 if (codec_type == webrtc::kVideoCodecVP8) { |
| 425 webrtc::CodecSpecificInfo codec_specific_info; | 420 webrtc::CodecSpecificInfo codec_specific_info; |
| 426 codec_specific_info.codecType = webrtc::kVideoCodecVP8; | 421 codec_specific_info.codecType = webrtc::kVideoCodecVP8; |
| 427 { | 422 { |
| 428 CriticalSectionScoped cs(data_cs_.get()); | 423 CriticalSectionScoped cs(data_cs_.get()); |
| 429 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = | 424 codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = |
| 430 has_received_rpsi_; | 425 has_received_rpsi_; |
| 431 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = | 426 codec_specific_info.codecSpecific.VP8.hasReceivedSLI = |
| 432 has_received_sli_; | 427 has_received_sli_; |
| 433 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = | 428 codec_specific_info.codecSpecific.VP8.pictureIdRPSI = |
| 434 picture_id_rpsi_; | 429 picture_id_rpsi_; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 454 CriticalSectionScoped cs(data_cs_.get()); | 449 CriticalSectionScoped cs(data_cs_.get()); |
| 455 return last_observed_bitrate_bps_; | 450 return last_observed_bitrate_bps_; |
| 456 } | 451 } |
| 457 | 452 |
| 458 int ViEEncoder::CodecTargetBitrate(uint32_t* bitrate) const { | 453 int ViEEncoder::CodecTargetBitrate(uint32_t* bitrate) const { |
| 459 if (vcm_->Bitrate(bitrate) != 0) | 454 if (vcm_->Bitrate(bitrate) != 0) |
| 460 return -1; | 455 return -1; |
| 461 return 0; | 456 return 0; |
| 462 } | 457 } |
| 463 | 458 |
| 464 int32_t ViEEncoder::UpdateProtectionMethod(bool nack, bool fec) { | 459 void ViEEncoder::SetProtectionMethod(bool nack, bool fec) { |
| 465 RTC_DCHECK(send_payload_router_ != NULL); | |
| 466 | |
| 467 if (fec_enabled_ == fec && nack_enabled_ == nack) { | |
| 468 // No change needed, we're already in correct state. | |
| 469 return 0; | |
| 470 } | |
| 471 fec_enabled_ = fec; | |
| 472 nack_enabled_ = nack; | |
| 473 | |
| 474 // Set Video Protection for VCM. | 460 // Set Video Protection for VCM. |
| 475 VCMVideoProtection protection_mode; | 461 VCMVideoProtection protection_mode; |
| 476 if (fec_enabled_) { | 462 if (fec) { |
| 477 protection_mode = | 463 protection_mode = |
| 478 nack_enabled_ ? webrtc::kProtectionNackFEC : kProtectionFEC; | 464 nack ? webrtc::kProtectionNackFEC : kProtectionFEC; |
| 479 } else { | 465 } else { |
| 480 protection_mode = nack_enabled_ ? kProtectionNack : kProtectionNone; | 466 protection_mode = nack ? kProtectionNack : kProtectionNone; |
| 481 } | 467 } |
| 482 vcm_->SetVideoProtection(protection_mode, true); | 468 vcm_->SetVideoProtection(protection_mode, true); |
| 483 | |
| 484 if (fec_enabled_ || nack_enabled_) { | |
| 485 // The send codec must be registered to set correct MTU. | |
|
stefan-webrtc
2015/11/10 15:15:26
So now the user of this class needs to make sure i
pbos-webrtc
2015/11/10 15:18:52
Yep, commented.
| |
| 486 webrtc::VideoCodec codec; | |
| 487 if (vcm_->SendCodec(&codec) == 0) { | |
| 488 uint32_t current_bitrate_bps = 0; | |
| 489 if (vcm_->Bitrate(¤t_bitrate_bps) != 0) { | |
| 490 LOG_F(LS_WARNING) << | |
| 491 "Failed to get the current encoder target bitrate."; | |
| 492 } | |
| 493 // Convert to start bitrate in kbps. | |
| 494 codec.startBitrate = (current_bitrate_bps + 500) / 1000; | |
| 495 size_t max_payload_length = send_payload_router_->MaxPayloadLength(); | |
| 496 if (vcm_->RegisterSendCodec(&codec, number_of_cores_, | |
| 497 static_cast<uint32_t>(max_payload_length)) != | |
| 498 0) { | |
| 499 return -1; | |
| 500 } | |
| 501 } | |
| 502 } | |
| 503 return 0; | |
| 504 } | 469 } |
| 505 | 470 |
| 506 void ViEEncoder::SetSenderBufferingMode(int target_delay_ms) { | 471 void ViEEncoder::SetSenderBufferingMode(int target_delay_ms) { |
| 507 { | 472 { |
| 508 CriticalSectionScoped cs(data_cs_.get()); | 473 CriticalSectionScoped cs(data_cs_.get()); |
| 509 target_delay_ms_ = target_delay_ms; | 474 target_delay_ms_ = target_delay_ms; |
| 510 } | 475 } |
| 511 if (target_delay_ms > 0) { | 476 if (target_delay_ms > 0) { |
| 512 // Disable external frame-droppers. | 477 // Disable external frame-droppers. |
| 513 vcm_->EnableFrameDropper(false); | 478 vcm_->EnableFrameDropper(false); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 std::map<unsigned int, int64_t>::iterator time_it = | 577 std::map<unsigned int, int64_t>::iterator time_it = |
| 613 time_last_intra_request_ms_.find(old_ssrc); | 578 time_last_intra_request_ms_.find(old_ssrc); |
| 614 int64_t last_intra_request_ms = 0; | 579 int64_t last_intra_request_ms = 0; |
| 615 if (time_it != time_last_intra_request_ms_.end()) { | 580 if (time_it != time_last_intra_request_ms_.end()) { |
| 616 last_intra_request_ms = time_it->second; | 581 last_intra_request_ms = time_it->second; |
| 617 time_last_intra_request_ms_.erase(time_it); | 582 time_last_intra_request_ms_.erase(time_it); |
| 618 } | 583 } |
| 619 time_last_intra_request_ms_[new_ssrc] = last_intra_request_ms; | 584 time_last_intra_request_ms_[new_ssrc] = last_intra_request_ms; |
| 620 } | 585 } |
| 621 | 586 |
| 622 bool ViEEncoder::SetSsrcs(const std::vector<uint32_t>& ssrcs) { | 587 void ViEEncoder::SetSsrcs(const std::vector<uint32_t>& ssrcs) { |
| 623 VideoCodec codec; | |
| 624 if (vcm_->SendCodec(&codec) != 0) | |
| 625 return false; | |
| 626 | |
| 627 if (codec.numberOfSimulcastStreams > 0 && | |
| 628 ssrcs.size() != codec.numberOfSimulcastStreams) { | |
| 629 return false; | |
| 630 } | |
| 631 | |
| 632 CriticalSectionScoped cs(data_cs_.get()); | 588 CriticalSectionScoped cs(data_cs_.get()); |
| 633 ssrc_streams_.clear(); | 589 ssrc_streams_.clear(); |
| 634 time_last_intra_request_ms_.clear(); | 590 time_last_intra_request_ms_.clear(); |
| 635 int idx = 0; | 591 int idx = 0; |
| 636 for (uint32_t ssrc : ssrcs) { | 592 for (uint32_t ssrc : ssrcs) { |
| 637 ssrc_streams_[ssrc] = idx++; | 593 ssrc_streams_[ssrc] = idx++; |
| 638 } | 594 } |
| 639 return true; | |
| 640 } | 595 } |
| 641 | 596 |
| 642 void ViEEncoder::SetMinTransmitBitrate(int min_transmit_bitrate_kbps) { | 597 void ViEEncoder::SetMinTransmitBitrate(int min_transmit_bitrate_kbps) { |
| 643 assert(min_transmit_bitrate_kbps >= 0); | 598 assert(min_transmit_bitrate_kbps >= 0); |
| 644 CriticalSectionScoped crit(data_cs_.get()); | 599 CriticalSectionScoped crit(data_cs_.get()); |
| 645 min_transmit_bitrate_kbps_ = min_transmit_bitrate_kbps; | 600 min_transmit_bitrate_kbps_ = min_transmit_bitrate_kbps; |
| 646 } | 601 } |
| 647 | 602 |
| 648 // Called from ViEBitrateObserver. | 603 // Called from ViEBitrateObserver. |
| 649 void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps, | 604 void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps, |
| 650 uint8_t fraction_lost, | 605 uint8_t fraction_lost, |
| 651 int64_t round_trip_time_ms) { | 606 int64_t round_trip_time_ms) { |
| 652 LOG(LS_VERBOSE) << "OnNetworkChanged, bitrate" << bitrate_bps | 607 LOG(LS_VERBOSE) << "OnNetworkChanged, bitrate" << bitrate_bps |
| 653 << " packet loss " << static_cast<int>(fraction_lost) | 608 << " packet loss " << static_cast<int>(fraction_lost) |
| 654 << " rtt " << round_trip_time_ms; | 609 << " rtt " << round_trip_time_ms; |
| 655 RTC_DCHECK(send_payload_router_ != NULL); | 610 RTC_DCHECK(send_payload_router_ != NULL); |
| 656 vcm_->SetChannelParameters(bitrate_bps, fraction_lost, round_trip_time_ms); | 611 vcm_->SetChannelParameters(bitrate_bps, fraction_lost, round_trip_time_ms); |
| 657 bool video_is_suspended = vcm_->VideoSuspended(); | 612 bool video_is_suspended = vcm_->VideoSuspended(); |
| 613 bool video_suspension_changed; | |
| 614 VideoCodec send_codec; | |
| 615 uint32_t first_ssrc; | |
| 616 { | |
| 617 CriticalSectionScoped cs(data_cs_.get()); | |
| 618 last_observed_bitrate_bps_ = bitrate_bps; | |
| 619 video_suspension_changed = video_suspended_ != video_is_suspended; | |
| 620 video_suspended_ = video_is_suspended; | |
| 621 send_codec = encoder_config_; | |
| 622 first_ssrc = ssrc_streams_.begin()->first; | |
| 623 } | |
| 658 | 624 |
| 659 VideoCodec send_codec; | |
| 660 if (vcm_->SendCodec(&send_codec) != 0) { | |
| 661 return; | |
| 662 } | |
| 663 SimulcastStream* stream_configs = send_codec.simulcastStream; | 625 SimulcastStream* stream_configs = send_codec.simulcastStream; |
| 664 // Allocate the bandwidth between the streams. | 626 // Allocate the bandwidth between the streams. |
| 665 std::vector<uint32_t> stream_bitrates = AllocateStreamBitrates( | 627 std::vector<uint32_t> stream_bitrates = AllocateStreamBitrates( |
| 666 bitrate_bps, stream_configs, send_codec.numberOfSimulcastStreams); | 628 bitrate_bps, stream_configs, send_codec.numberOfSimulcastStreams); |
| 667 send_payload_router_->SetTargetSendBitrates(stream_bitrates); | 629 send_payload_router_->SetTargetSendBitrates(stream_bitrates); |
| 668 | 630 |
| 669 { | 631 if (!video_suspension_changed) |
| 670 CriticalSectionScoped cs(data_cs_.get()); | 632 return; |
| 671 last_observed_bitrate_bps_ = bitrate_bps; | |
| 672 if (video_suspended_ == video_is_suspended) | |
| 673 return; | |
| 674 video_suspended_ = video_is_suspended; | |
| 675 | |
| 676 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended | |
| 677 << " for ssrc " << ssrc_streams_.begin()->first; | |
| 678 } | |
| 679 // Video suspend-state changed, inform codec observer. | 633 // Video suspend-state changed, inform codec observer. |
| 634 LOG(LS_INFO) << "Video suspend state changed " << video_is_suspended | |
| 635 << " for ssrc " << first_ssrc; | |
| 680 if (stats_proxy_) | 636 if (stats_proxy_) |
| 681 stats_proxy_->OnSuspendChange(video_is_suspended); | 637 stats_proxy_->OnSuspendChange(video_is_suspended); |
| 682 } | 638 } |
| 683 | 639 |
| 684 void ViEEncoder::SuspendBelowMinBitrate() { | 640 void ViEEncoder::SuspendBelowMinBitrate() { |
| 685 vcm_->SuspendBelowMinBitrate(); | 641 vcm_->SuspendBelowMinBitrate(); |
| 686 bitrate_allocator_->EnforceMinBitrate(false); | 642 bitrate_allocator_->EnforceMinBitrate(false); |
| 687 } | 643 } |
| 688 | 644 |
| 689 void ViEEncoder::RegisterPostEncodeImageCallback( | 645 void ViEEncoder::RegisterPostEncodeImageCallback( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 703 const uint32_t width, | 659 const uint32_t width, |
| 704 const uint32_t height) { | 660 const uint32_t height) { |
| 705 return vpm_->SetTargetResolution(width, height, frame_rate); | 661 return vpm_->SetTargetResolution(width, height, frame_rate); |
| 706 } | 662 } |
| 707 | 663 |
| 708 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { | 664 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { |
| 709 vpm_->SetTargetFramerate(frame_rate); | 665 vpm_->SetTargetFramerate(frame_rate); |
| 710 } | 666 } |
| 711 | 667 |
| 712 } // namespace webrtc | 668 } // namespace webrtc |
| OLD | NEW |