| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2013 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 | 
| 11 #include "webrtc/video/video_receive_stream.h" | 11 #include "webrtc/video/video_receive_stream.h" | 
| 12 | 12 | 
| 13 #include <stdlib.h> | 13 #include <stdlib.h> | 
| 14 | 14 | 
| 15 #include <set> | 15 #include <set> | 
| 16 #include <string> | 16 #include <string> | 
| 17 #include <utility> | 17 #include <utility> | 
| 18 | 18 | 
| 19 #include "webrtc/api/optional.h" | 19 #include "webrtc/api/optional.h" | 
| 20 #include "webrtc/call/rtp_stream_receiver_controller_interface.h" | 20 #include "webrtc/call/rtp_stream_receiver_controller_interface.h" | 
| 21 #include "webrtc/call/rtx_receive_stream.h" |  | 
| 22 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" | 
| 23 #include "webrtc/common_video/h264/profile_level_id.h" | 22 #include "webrtc/common_video/h264/profile_level_id.h" | 
| 24 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 23 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 
| 25 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 
| 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 
| 27 #include "webrtc/modules/utility/include/process_thread.h" | 26 #include "webrtc/modules/utility/include/process_thread.h" | 
| 28 #include "webrtc/modules/video_coding/frame_object.h" | 27 #include "webrtc/modules/video_coding/frame_object.h" | 
| 29 #include "webrtc/modules/video_coding/include/video_coding.h" | 28 #include "webrtc/modules/video_coding/include/video_coding.h" | 
| 30 #include "webrtc/modules/video_coding/jitter_estimator.h" | 29 #include "webrtc/modules/video_coding/jitter_estimator.h" | 
| 31 #include "webrtc/modules/video_coding/timing.h" | 30 #include "webrtc/modules/video_coding/timing.h" | 
| 32 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 31 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | 
| 33 #include "webrtc/rtc_base/checks.h" | 32 #include "webrtc/rtc_base/checks.h" | 
| 34 #include "webrtc/rtc_base/location.h" | 33 #include "webrtc/rtc_base/location.h" | 
| 35 #include "webrtc/rtc_base/logging.h" | 34 #include "webrtc/rtc_base/logging.h" | 
| 36 #include "webrtc/rtc_base/ptr_util.h" |  | 
| 37 #include "webrtc/rtc_base/trace_event.h" | 35 #include "webrtc/rtc_base/trace_event.h" | 
| 38 #include "webrtc/system_wrappers/include/clock.h" | 36 #include "webrtc/system_wrappers/include/clock.h" | 
| 39 #include "webrtc/system_wrappers/include/field_trial.h" | 37 #include "webrtc/system_wrappers/include/field_trial.h" | 
| 40 #include "webrtc/video/call_stats.h" | 38 #include "webrtc/video/call_stats.h" | 
| 41 #include "webrtc/video/receive_statistics_proxy.h" | 39 #include "webrtc/video/receive_statistics_proxy.h" | 
| 42 | 40 | 
| 43 namespace webrtc { | 41 namespace webrtc { | 
| 44 | 42 | 
| 45 namespace { | 43 namespace { | 
| 46 VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) { | 44 VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) { | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 83     : transport_adapter_(config.rtcp_send_transport), | 81     : transport_adapter_(config.rtcp_send_transport), | 
| 84       config_(std::move(config)), | 82       config_(std::move(config)), | 
| 85       num_cpu_cores_(num_cpu_cores), | 83       num_cpu_cores_(num_cpu_cores), | 
| 86       process_thread_(process_thread), | 84       process_thread_(process_thread), | 
| 87       clock_(Clock::GetRealTimeClock()), | 85       clock_(Clock::GetRealTimeClock()), | 
| 88       decode_thread_(&DecodeThreadFunction, | 86       decode_thread_(&DecodeThreadFunction, | 
| 89                      this, | 87                      this, | 
| 90                      "DecodingThread", | 88                      "DecodingThread", | 
| 91                      rtc::kHighestPriority), | 89                      rtc::kHighestPriority), | 
| 92       call_stats_(call_stats), | 90       call_stats_(call_stats), | 
| 93       rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), |  | 
| 94       timing_(new VCMTiming(clock_)), | 91       timing_(new VCMTiming(clock_)), | 
| 95       video_receiver_(clock_, nullptr, this, timing_.get(), this, this), | 92       video_receiver_(clock_, nullptr, this, timing_.get(), this, this), | 
| 96       stats_proxy_(&config_, clock_), | 93       stats_proxy_(&config_, clock_), | 
| 97       rtp_video_stream_receiver_(&transport_adapter_, | 94       rtp_video_stream_receiver_(&transport_adapter_, | 
| 98                                  call_stats_->rtcp_rtt_stats(), | 95                                  call_stats_->rtcp_rtt_stats(), | 
| 99                                  packet_router, | 96                                  packet_router, | 
| 100                                  &config_, | 97                                  &config_, | 
| 101                                  rtp_receive_statistics_.get(), |  | 
| 102                                  &stats_proxy_, | 98                                  &stats_proxy_, | 
| 103                                  process_thread_, | 99                                  process_thread_, | 
| 104                                  this,  // NackSender | 100                                  this,  // NackSender | 
| 105                                  this,  // KeyFrameRequestSender | 101                                  this,  // KeyFrameRequestSender | 
| 106                                  this,  // OnCompleteFrameCallback | 102                                  this,  // OnCompleteFrameCallback | 
| 107                                  timing_.get()), | 103                                  timing_.get()), | 
| 108       rtp_stream_sync_(this) { | 104       rtp_stream_sync_(this) { | 
| 109   LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 105   LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 
| 110 | 106 | 
| 111   RTC_DCHECK(process_thread_); | 107   RTC_DCHECK(process_thread_); | 
| 112   RTC_DCHECK(call_stats_); | 108   RTC_DCHECK(call_stats_); | 
| 113 | 109 | 
| 114   module_process_sequence_checker_.Detach(); | 110   module_process_sequence_checker_.Detach(); | 
| 115 | 111 | 
| 116   RTC_DCHECK(!config_.decoders.empty()); | 112   RTC_DCHECK(!config_.decoders.empty()); | 
| 117   std::set<int> decoder_payload_types; | 113   std::set<int> decoder_payload_types; | 
| 118   for (const Decoder& decoder : config_.decoders) { | 114   for (const Decoder& decoder : config_.decoders) { | 
| 119     RTC_CHECK(decoder.decoder); | 115     RTC_CHECK(decoder.decoder); | 
| 120     RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 116     RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 
| 121               decoder_payload_types.end()) | 117               decoder_payload_types.end()) | 
| 122         << "Duplicate payload type (" << decoder.payload_type | 118         << "Duplicate payload type (" << decoder.payload_type | 
| 123         << ") for different decoders."; | 119         << ") for different decoders."; | 
| 124     decoder_payload_types.insert(decoder.payload_type); | 120     decoder_payload_types.insert(decoder.payload_type); | 
| 125   } | 121   } | 
| 126 | 122 | 
| 127   video_receiver_.SetRenderDelay(config_.render_delay_ms); | 123   video_receiver_.SetRenderDelay(config.render_delay_ms); | 
| 128 | 124 | 
| 129   jitter_estimator_.reset(new VCMJitterEstimator(clock_)); | 125   jitter_estimator_.reset(new VCMJitterEstimator(clock_)); | 
| 130   frame_buffer_.reset(new video_coding::FrameBuffer( | 126   frame_buffer_.reset(new video_coding::FrameBuffer( | 
| 131       clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); | 127       clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); | 
| 132 | 128 | 
| 133   process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); | 129   process_thread_->RegisterModule(&rtp_stream_sync_, RTC_FROM_HERE); | 
| 134 | 130 | 
| 135   // Register with RtpStreamReceiverController. | 131   // Register with RtpStreamReceiverController. | 
| 136   media_receiver_ = receiver_controller->CreateReceiver( | 132   media_receiver_ = receiver_controller->CreateReceiver( | 
| 137       config_.rtp.remote_ssrc, &rtp_video_stream_receiver_); | 133       config_.rtp.remote_ssrc, &rtp_video_stream_receiver_); | 
| 138   if (config_.rtp.rtx_ssrc) { | 134   if (config.rtp.rtx_ssrc) { | 
| 139     rtx_receive_stream_ = rtc::MakeUnique<RtxReceiveStream>( |  | 
| 140         &rtp_video_stream_receiver_, config.rtp.rtx_associated_payload_types, |  | 
| 141         config_.rtp.remote_ssrc, rtp_receive_statistics_.get()); |  | 
| 142     rtx_receiver_ = receiver_controller->CreateReceiver( | 135     rtx_receiver_ = receiver_controller->CreateReceiver( | 
| 143         config_.rtp.rtx_ssrc, rtx_receive_stream_.get()); | 136         config_.rtp.rtx_ssrc, &rtp_video_stream_receiver_); | 
| 144   } | 137   } | 
| 145 } | 138 } | 
| 146 | 139 | 
| 147 VideoReceiveStream::~VideoReceiveStream() { | 140 VideoReceiveStream::~VideoReceiveStream() { | 
| 148   RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_); | 141   RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_); | 
| 149   LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 142   LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 
| 150   Stop(); | 143   Stop(); | 
| 151 | 144 | 
| 152   process_thread_->DeRegisterModule(&rtp_stream_sync_); | 145   process_thread_->DeRegisterModule(&rtp_stream_sync_); | 
| 153 } | 146 } | 
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 444     if (stream_is_active && !receiving_keyframe) { | 437     if (stream_is_active && !receiving_keyframe) { | 
| 445       LOG(LS_WARNING) << "No decodable frame in " << wait_ms | 438       LOG(LS_WARNING) << "No decodable frame in " << wait_ms | 
| 446                       << " ms, requesting keyframe."; | 439                       << " ms, requesting keyframe."; | 
| 447       RequestKeyFrame(); | 440       RequestKeyFrame(); | 
| 448     } | 441     } | 
| 449   } | 442   } | 
| 450   return true; | 443   return true; | 
| 451 } | 444 } | 
| 452 }  // namespace internal | 445 }  // namespace internal | 
| 453 }  // namespace webrtc | 446 }  // namespace webrtc | 
| OLD | NEW | 
|---|