| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 50                              const uint32_t height); | 50                              const uint32_t height); | 
| 51 | 51 | 
| 52  private: | 52  private: | 
| 53   VideoProcessing* vp_; | 53   VideoProcessing* vp_; | 
| 54 }; | 54 }; | 
| 55 | 55 | 
| 56 ViEEncoder::ViEEncoder(uint32_t number_of_cores, | 56 ViEEncoder::ViEEncoder(uint32_t number_of_cores, | 
| 57                        const std::vector<uint32_t>& ssrcs, | 57                        const std::vector<uint32_t>& ssrcs, | 
| 58                        ProcessThread* module_process_thread, | 58                        ProcessThread* module_process_thread, | 
| 59                        SendStatisticsProxy* stats_proxy, | 59                        SendStatisticsProxy* stats_proxy, | 
| 60                        OveruseFrameDetector* overuse_detector) | 60                        rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 
|  | 61                        OveruseFrameDetector* overuse_detector, | 
|  | 62                        PacedSender* pacer) | 
| 61     : number_of_cores_(number_of_cores), | 63     : number_of_cores_(number_of_cores), | 
| 62       ssrcs_(ssrcs), | 64       ssrcs_(ssrcs), | 
| 63       vp_(VideoProcessing::Create()), | 65       vp_(VideoProcessing::Create()), | 
| 64       qm_callback_(new QMVideoSettingsCallback(vp_.get())), | 66       qm_callback_(new QMVideoSettingsCallback(vp_.get())), | 
| 65       video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()), | 67       video_sender_(Clock::GetRealTimeClock(), this, this, qm_callback_.get()), | 
| 66       stats_proxy_(stats_proxy), | 68       stats_proxy_(stats_proxy), | 
|  | 69       pre_encode_callback_(pre_encode_callback), | 
| 67       overuse_detector_(overuse_detector), | 70       overuse_detector_(overuse_detector), | 
|  | 71       pacer_(pacer), | 
| 68       time_of_last_frame_activity_ms_(0), | 72       time_of_last_frame_activity_ms_(0), | 
| 69       encoder_config_(), | 73       encoder_config_(), | 
| 70       min_transmit_bitrate_bps_(0), | 74       min_transmit_bitrate_bps_(0), | 
| 71       last_observed_bitrate_bps_(0), | 75       last_observed_bitrate_bps_(0), | 
| 72       network_is_transmitting_(true), | 76       network_is_transmitting_(true), | 
| 73       encoder_paused_(true), | 77       encoder_paused_(true), | 
| 74       encoder_paused_and_dropped_frame_(false), | 78       encoder_paused_and_dropped_frame_(false), | 
| 75       time_last_intra_request_ms_(ssrcs.size(), -1), | 79       time_last_intra_request_ms_(ssrcs.size(), -1), | 
| 76       module_process_thread_(module_process_thread), | 80       module_process_thread_(module_process_thread), | 
| 77       has_received_sli_(false), | 81       has_received_sli_(false), | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 243 | 247 | 
| 244   return pad_up_to_bitrate_bps; | 248   return pad_up_to_bitrate_bps; | 
| 245 } | 249 } | 
| 246 | 250 | 
| 247 bool ViEEncoder::EncoderPaused() const { | 251 bool ViEEncoder::EncoderPaused() const { | 
| 248   // Pause video if paused by caller or as long as the network is down or the | 252   // Pause video if paused by caller or as long as the network is down or the | 
| 249   // pacer queue has grown too large in buffered mode. | 253   // pacer queue has grown too large in buffered mode. | 
| 250   if (encoder_paused_) { | 254   if (encoder_paused_) { | 
| 251     return true; | 255     return true; | 
| 252   } | 256   } | 
| 253   if (video_suspended_ || last_observed_bitrate_bps_ == 0) { | 257   if (pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs) { | 
|  | 258     // Too much data in pacer queue, drop frame. | 
| 254     return true; | 259     return true; | 
| 255   } | 260   } | 
| 256   return !network_is_transmitting_; | 261   return !network_is_transmitting_; | 
| 257 } | 262 } | 
| 258 | 263 | 
| 259 void ViEEncoder::TraceFrameDropStart() { | 264 void ViEEncoder::TraceFrameDropStart() { | 
| 260   // Start trace event only on the first frame after encoder is paused. | 265   // Start trace event only on the first frame after encoder is paused. | 
| 261   if (!encoder_paused_and_dropped_frame_) { | 266   if (!encoder_paused_and_dropped_frame_) { | 
| 262     TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); | 267     TRACE_EVENT_ASYNC_BEGIN0("webrtc", "EncoderPaused", this); | 
| 263   } | 268   } | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 292   // TODO(wuchengli): support texture frames. | 297   // TODO(wuchengli): support texture frames. | 
| 293   if (!video_frame.video_frame_buffer()->native_handle()) { | 298   if (!video_frame.video_frame_buffer()->native_handle()) { | 
| 294     // Pass frame via preprocessor. | 299     // Pass frame via preprocessor. | 
| 295     frame_to_send = vp_->PreprocessFrame(video_frame); | 300     frame_to_send = vp_->PreprocessFrame(video_frame); | 
| 296     if (!frame_to_send) { | 301     if (!frame_to_send) { | 
| 297       // Drop this frame, or there was an error processing it. | 302       // Drop this frame, or there was an error processing it. | 
| 298       return; | 303       return; | 
| 299     } | 304     } | 
| 300   } | 305   } | 
| 301 | 306 | 
|  | 307   if (pre_encode_callback_) { | 
|  | 308     pre_encode_callback_->OnFrame(*frame_to_send); | 
|  | 309   } | 
|  | 310 | 
| 302   if (codec_type == webrtc::kVideoCodecVP8) { | 311   if (codec_type == webrtc::kVideoCodecVP8) { | 
| 303     webrtc::CodecSpecificInfo codec_specific_info; | 312     webrtc::CodecSpecificInfo codec_specific_info; | 
| 304     codec_specific_info.codecType = webrtc::kVideoCodecVP8; | 313     codec_specific_info.codecType = webrtc::kVideoCodecVP8; | 
| 305     { | 314     { | 
| 306       rtc::CritScope lock(&data_cs_); | 315       rtc::CritScope lock(&data_cs_); | 
| 307       codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = | 316       codec_specific_info.codecSpecific.VP8.hasReceivedRPSI = | 
| 308           has_received_rpsi_; | 317           has_received_rpsi_; | 
| 309       codec_specific_info.codecSpecific.VP8.hasReceivedSLI = | 318       codec_specific_info.codecSpecific.VP8.hasReceivedSLI = | 
| 310           has_received_sli_; | 319           has_received_sli_; | 
| 311       codec_specific_info.codecSpecific.VP8.pictureIdRPSI = | 320       codec_specific_info.codecSpecific.VP8.pictureIdRPSI = | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 433     } | 442     } | 
| 434     video_sender_.IntraFrameRequest(static_cast<int>(i)); | 443     video_sender_.IntraFrameRequest(static_cast<int>(i)); | 
| 435     return; | 444     return; | 
| 436   } | 445   } | 
| 437   RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs."; | 446   RTC_NOTREACHED() << "Should not receive keyframe requests on unknown SSRCs."; | 
| 438 } | 447 } | 
| 439 | 448 | 
| 440 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, | 449 void ViEEncoder::OnBitrateUpdated(uint32_t bitrate_bps, | 
| 441                                   uint8_t fraction_lost, | 450                                   uint8_t fraction_lost, | 
| 442                                   int64_t round_trip_time_ms) { | 451                                   int64_t round_trip_time_ms) { | 
| 443   LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate " << bitrate_bps | 452   LOG(LS_VERBOSE) << "OnBitrateUpdated, bitrate" << bitrate_bps | 
| 444                   << " packet loss " << static_cast<int>(fraction_lost) | 453                   << " packet loss " << static_cast<int>(fraction_lost) | 
| 445                   << " rtt " << round_trip_time_ms; | 454                   << " rtt " << round_trip_time_ms; | 
| 446   video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, | 455   video_sender_.SetChannelParameters(bitrate_bps, fraction_lost, | 
| 447                                      round_trip_time_ms); | 456                                      round_trip_time_ms); | 
| 448   bool video_is_suspended = video_sender_.VideoSuspended(); | 457   bool video_is_suspended = video_sender_.VideoSuspended(); | 
| 449   bool video_suspension_changed; | 458   bool video_suspension_changed; | 
| 450   { | 459   { | 
| 451     rtc::CritScope lock(&data_cs_); | 460     rtc::CritScope lock(&data_cs_); | 
| 452     last_observed_bitrate_bps_ = bitrate_bps; | 461     last_observed_bitrate_bps_ = bitrate_bps; | 
| 453     video_suspension_changed = video_suspended_ != video_is_suspended; | 462     video_suspension_changed = video_suspended_ != video_is_suspended; | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 471 } | 480 } | 
| 472 | 481 | 
| 473 int32_t QMVideoSettingsCallback::SetVideoQMSettings( | 482 int32_t QMVideoSettingsCallback::SetVideoQMSettings( | 
| 474     const uint32_t frame_rate, | 483     const uint32_t frame_rate, | 
| 475     const uint32_t width, | 484     const uint32_t width, | 
| 476     const uint32_t height) { | 485     const uint32_t height) { | 
| 477   return vp_->SetTargetResolution(width, height, frame_rate); | 486   return vp_->SetTargetResolution(width, height, frame_rate); | 
| 478 } | 487 } | 
| 479 | 488 | 
| 480 }  // namespace webrtc | 489 }  // namespace webrtc | 
| OLD | NEW | 
|---|