| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  403                                              size_t max_data_payload_length) { |  403                                              size_t max_data_payload_length) { | 
|  404   RTC_DCHECK_RUN_ON(&encoder_queue_); |  404   RTC_DCHECK_RUN_ON(&encoder_queue_); | 
|  405   RTC_DCHECK(sink_); |  405   RTC_DCHECK(sink_); | 
|  406   LOG(LS_INFO) << "ConfigureEncoder requested."; |  406   LOG(LS_INFO) << "ConfigureEncoder requested."; | 
|  407  |  407  | 
|  408   max_data_payload_length_ = max_data_payload_length; |  408   max_data_payload_length_ = max_data_payload_length; | 
|  409   encoder_config_ = std::move(config); |  409   encoder_config_ = std::move(config); | 
|  410   pending_encoder_reconfiguration_ = true; |  410   pending_encoder_reconfiguration_ = true; | 
|  411  |  411  | 
|  412   // Reconfigure the encoder now if the encoder has an internal source or |  412   // Reconfigure the encoder now if the encoder has an internal source or | 
|  413   // if the frame resolution is known. Otherwise, the reconfiguration is |  413   // if this is the first time the encoder is configured. | 
|  414   // deferred until the next frame to minimize the number of reconfigurations. |  414   // Otherwise, the reconfiguration is deferred until the next frame to minimize | 
|  415   // The codec configuration depends on incoming video frame size. |  415   // the number of reconfigurations. The codec configuration depends on incoming | 
|  416   if (last_frame_info_) { |  416   // video frame size. | 
|  417     ReconfigureEncoder(); |  417   if (!last_frame_info_ || settings_.internal_source) { | 
|  418   } else if (settings_.internal_source) { |  418     if (!last_frame_info_) { | 
|  419     last_frame_info_ = rtc::Optional<VideoFrameInfo>( |  419       last_frame_info_ = rtc::Optional<VideoFrameInfo>( | 
|  420         VideoFrameInfo(1, 1, kVideoRotation_0, true)); |  420           VideoFrameInfo(176, 144, kVideoRotation_0, false)); | 
 |  421     } | 
|  421     ReconfigureEncoder(); |  422     ReconfigureEncoder(); | 
|  422   } |  423   } | 
|  423 } |  424 } | 
|  424  |  425  | 
|  425 void ViEEncoder::ReconfigureEncoder() { |  426 void ViEEncoder::ReconfigureEncoder() { | 
|  426   RTC_DCHECK_RUN_ON(&encoder_queue_); |  427   RTC_DCHECK_RUN_ON(&encoder_queue_); | 
|  427   RTC_DCHECK(pending_encoder_reconfiguration_); |  428   RTC_DCHECK(pending_encoder_reconfiguration_); | 
|  428   std::vector<VideoStream> streams = |  429   std::vector<VideoStream> streams = | 
|  429       encoder_config_.video_stream_factory->CreateEncoderStreams( |  430       encoder_config_.video_stream_factory->CreateEncoderStreams( | 
|  430           last_frame_info_->width, last_frame_info_->height, encoder_config_); |  431           last_frame_info_->width, last_frame_info_->height, encoder_config_); | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  534   } |  535   } | 
|  535   encoder_paused_and_dropped_frame_ = false; |  536   encoder_paused_and_dropped_frame_ = false; | 
|  536 } |  537 } | 
|  537  |  538  | 
|  538 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame, |  539 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame, | 
|  539                                   int64_t time_when_posted_in_ms) { |  540                                   int64_t time_when_posted_in_ms) { | 
|  540   RTC_DCHECK_RUN_ON(&encoder_queue_); |  541   RTC_DCHECK_RUN_ON(&encoder_queue_); | 
|  541   if (pre_encode_callback_) |  542   if (pre_encode_callback_) | 
|  542     pre_encode_callback_->OnFrame(video_frame); |  543     pre_encode_callback_->OnFrame(video_frame); | 
|  543  |  544  | 
|  544   if (!last_frame_info_ || video_frame.width() != last_frame_info_->width || |  545   if (video_frame.width() != last_frame_info_->width || | 
|  545       video_frame.height() != last_frame_info_->height || |  546       video_frame.height() != last_frame_info_->height || | 
|  546       video_frame.rotation() != last_frame_info_->rotation || |  547       video_frame.rotation() != last_frame_info_->rotation || | 
|  547       video_frame.is_texture() != last_frame_info_->is_texture) { |  548       video_frame.is_texture() != last_frame_info_->is_texture) { | 
|  548     pending_encoder_reconfiguration_ = true; |  549     pending_encoder_reconfiguration_ = true; | 
|  549     last_frame_info_ = rtc::Optional<VideoFrameInfo>( |  550     last_frame_info_ = rtc::Optional<VideoFrameInfo>( | 
|  550         VideoFrameInfo(video_frame.width(), video_frame.height(), |  551         VideoFrameInfo(video_frame.width(), video_frame.height(), | 
|  551                        video_frame.rotation(), video_frame.is_texture())); |  552                        video_frame.rotation(), video_frame.is_texture())); | 
|  552     LOG(LS_INFO) << "Video frame parameters changed: dimensions=" |  553     LOG(LS_INFO) << "Video frame parameters changed: dimensions=" | 
|  553                  << last_frame_info_->width << "x" << last_frame_info_->height |  554                  << last_frame_info_->width << "x" << last_frame_info_->height | 
|  554                  << ", rotation=" << last_frame_info_->rotation |  555                  << ", rotation=" << last_frame_info_->rotation | 
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  704     load_observer_->OnLoadUpdate(LoadObserver::kOveruse); |  705     load_observer_->OnLoadUpdate(LoadObserver::kOveruse); | 
|  705 } |  706 } | 
|  706  |  707  | 
|  707 void ViEEncoder::NormalUsage() { |  708 void ViEEncoder::NormalUsage() { | 
|  708   RTC_DCHECK_RUN_ON(&encoder_queue_); |  709   RTC_DCHECK_RUN_ON(&encoder_queue_); | 
|  709   if (load_observer_) |  710   if (load_observer_) | 
|  710     load_observer_->OnLoadUpdate(LoadObserver::kUnderuse); |  711     load_observer_->OnLoadUpdate(LoadObserver::kUnderuse); | 
|  711 } |  712 } | 
|  712  |  713  | 
|  713 }  // namespace webrtc |  714 }  // namespace webrtc | 
| OLD | NEW |