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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 uint32_t* sent_nack_rate_bps, | 70 uint32_t* sent_nack_rate_bps, |
| 71 uint32_t* sent_fec_rate_bps) override { | 71 uint32_t* sent_fec_rate_bps) override { |
| 72 return owner_->ProtectionRequest(delta_fec_params, key_fec_params, | 72 return owner_->ProtectionRequest(delta_fec_params, key_fec_params, |
| 73 sent_video_rate_bps, sent_nack_rate_bps, | 73 sent_video_rate_bps, sent_nack_rate_bps, |
| 74 sent_fec_rate_bps); | 74 sent_fec_rate_bps); |
| 75 } | 75 } |
| 76 private: | 76 private: |
| 77 ViEChannel* owner_; | 77 ViEChannel* owner_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 ViEChannel::ViEChannel(int32_t channel_id, | 80 ViEChannel::ViEChannel(uint32_t number_of_cores, |
| 81 int32_t engine_id, | |
| 82 uint32_t number_of_cores, | |
| 83 Transport* transport, | 81 Transport* transport, |
| 84 ProcessThread* module_process_thread, | 82 ProcessThread* module_process_thread, |
| 85 RtcpIntraFrameObserver* intra_frame_observer, | 83 RtcpIntraFrameObserver* intra_frame_observer, |
| 86 RtcpBandwidthObserver* bandwidth_observer, | 84 RtcpBandwidthObserver* bandwidth_observer, |
| 87 TransportFeedbackObserver* transport_feedback_observer, | 85 TransportFeedbackObserver* transport_feedback_observer, |
| 88 RemoteBitrateEstimator* remote_bitrate_estimator, | 86 RemoteBitrateEstimator* remote_bitrate_estimator, |
| 89 RtcpRttStats* rtt_stats, | 87 RtcpRttStats* rtt_stats, |
| 90 PacedSender* paced_sender, | 88 PacedSender* paced_sender, |
| 91 PacketRouter* packet_router, | 89 PacketRouter* packet_router, |
| 92 size_t max_rtp_streams, | 90 size_t max_rtp_streams, |
| 93 bool sender) | 91 bool sender) |
| 94 : channel_id_(channel_id), | 92 : number_of_cores_(number_of_cores), |
| 95 engine_id_(engine_id), | |
| 96 number_of_cores_(number_of_cores), | |
| 97 sender_(sender), | 93 sender_(sender), |
| 98 module_process_thread_(module_process_thread), | 94 module_process_thread_(module_process_thread), |
| 99 crit_(CriticalSectionWrapper::CreateCriticalSection()), | 95 crit_(CriticalSectionWrapper::CreateCriticalSection()), |
| 100 send_payload_router_(new PayloadRouter()), | 96 send_payload_router_(new PayloadRouter()), |
| 101 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), | 97 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), |
| 102 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), | 98 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), |
| 103 nullptr, | 99 nullptr, |
| 104 nullptr)), | 100 nullptr)), |
| 105 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this), | 101 vie_receiver_(vcm_, remote_bitrate_estimator, this), |
| 106 vie_sync_(vcm_), | 102 vie_sync_(vcm_), |
| 107 stats_observer_(new ChannelStatsObserver(this)), | 103 stats_observer_(new ChannelStatsObserver(this)), |
| 108 receive_stats_callback_(nullptr), | 104 receive_stats_callback_(nullptr), |
| 109 incoming_video_stream_(nullptr), | 105 incoming_video_stream_(nullptr), |
| 110 intra_frame_observer_(intra_frame_observer), | 106 intra_frame_observer_(intra_frame_observer), |
| 111 rtt_stats_(rtt_stats), | 107 rtt_stats_(rtt_stats), |
| 112 paced_sender_(paced_sender), | 108 paced_sender_(paced_sender), |
| 113 packet_router_(packet_router), | 109 packet_router_(packet_router), |
| 114 bandwidth_observer_(bandwidth_observer), | 110 bandwidth_observer_(bandwidth_observer), |
| 115 transport_feedback_observer_(transport_feedback_observer), | 111 transport_feedback_observer_(transport_feedback_observer), |
| 116 nack_history_size_sender_(kSendSidePacketHistorySize), | 112 nack_history_size_sender_(kSendSidePacketHistorySize), |
| 117 max_nack_reordering_threshold_(kMaxPacketAgeToNack), | 113 max_nack_reordering_threshold_(kMaxPacketAgeToNack), |
| 118 pre_render_callback_(NULL), | 114 pre_render_callback_(NULL), |
| 119 report_block_stats_sender_(new ReportBlockStats()), | 115 report_block_stats_sender_(new ReportBlockStats()), |
| 120 time_of_first_rtt_ms_(-1), | 116 time_of_first_rtt_ms_(-1), |
| 121 rtt_sum_ms_(0), | 117 rtt_sum_ms_(0), |
| 122 num_rtts_(0), | 118 num_rtts_(0), |
| 123 rtp_rtcp_modules_( | 119 rtp_rtcp_modules_( |
| 124 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), | 120 CreateRtpRtcpModules(!sender, |
| 125 !sender, | |
| 126 vie_receiver_.GetReceiveStatistics(), | 121 vie_receiver_.GetReceiveStatistics(), |
| 127 transport, | 122 transport, |
| 128 sender ? intra_frame_observer_ : nullptr, | 123 sender ? intra_frame_observer_ : nullptr, |
| 129 sender ? bandwidth_observer_.get() : nullptr, | 124 sender ? bandwidth_observer_.get() : nullptr, |
| 130 transport_feedback_observer_, | 125 transport_feedback_observer_, |
| 131 rtt_stats_, | 126 rtt_stats_, |
| 132 &rtcp_packet_type_counter_observer_, | 127 &rtcp_packet_type_counter_observer_, |
| 133 remote_bitrate_estimator, | 128 remote_bitrate_estimator, |
| 134 paced_sender_, | 129 paced_sender_, |
| 135 packet_router_, | 130 packet_router_, |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 return stats_observer_.get(); | 1011 return stats_observer_.get(); |
| 1017 } | 1012 } |
| 1018 | 1013 |
| 1019 // Do not acquire the lock of |vcm_| in this function. Decode callback won't | 1014 // Do not acquire the lock of |vcm_| in this function. Decode callback won't |
| 1020 // necessarily be called from the decoding thread. The decoding thread may have | 1015 // necessarily be called from the decoding thread. The decoding thread may have |
| 1021 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring | 1016 // held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring |
| 1022 // the same lock in the path of decode callback can deadlock. | 1017 // the same lock in the path of decode callback can deadlock. |
| 1023 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT | 1018 int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT |
| 1024 CriticalSectionScoped cs(crit_.get()); | 1019 CriticalSectionScoped cs(crit_.get()); |
| 1025 | 1020 |
| 1026 | |
| 1027 if (pre_render_callback_ != NULL) | 1021 if (pre_render_callback_ != NULL) |
| 1028 pre_render_callback_->FrameCallback(&video_frame); | 1022 pre_render_callback_->FrameCallback(&video_frame); |
| 1029 | 1023 |
| 1030 incoming_video_stream_->RenderFrame(channel_id_, video_frame); | 1024 // TODO(pbos): Remove stream id argument. |
| 1025 incoming_video_stream_->RenderFrame(0, video_frame); | |
|
mflodman
2015/09/17 05:36:54
Why did you leave this one? Given the CL descripti
| |
| 1031 return 0; | 1026 return 0; |
| 1032 } | 1027 } |
| 1033 | 1028 |
| 1034 int32_t ViEChannel::ReceivedDecodedReferenceFrame( | 1029 int32_t ViEChannel::ReceivedDecodedReferenceFrame( |
| 1035 const uint64_t picture_id) { | 1030 const uint64_t picture_id) { |
| 1036 return rtp_rtcp_modules_[0]->SendRTCPReferencePictureSelection(picture_id); | 1031 return rtp_rtcp_modules_[0]->SendRTCPReferencePictureSelection(picture_id); |
| 1037 } | 1032 } |
| 1038 | 1033 |
| 1039 void ViEChannel::OnIncomingPayloadType(int payload_type) { | 1034 void ViEChannel::OnIncomingPayloadType(int payload_type) { |
| 1040 CriticalSectionScoped cs(crit_.get()); | 1035 CriticalSectionScoped cs(crit_.get()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 rtp_rtcp->BitrateSent(¬_used, &module_video_rate, &module_fec_rate, | 1122 rtp_rtcp->BitrateSent(¬_used, &module_video_rate, &module_fec_rate, |
| 1128 &module_nack_rate); | 1123 &module_nack_rate); |
| 1129 *video_rate_bps += module_video_rate; | 1124 *video_rate_bps += module_video_rate; |
| 1130 *nack_rate_bps += module_nack_rate; | 1125 *nack_rate_bps += module_nack_rate; |
| 1131 *fec_rate_bps += module_fec_rate; | 1126 *fec_rate_bps += module_fec_rate; |
| 1132 } | 1127 } |
| 1133 return 0; | 1128 return 0; |
| 1134 } | 1129 } |
| 1135 | 1130 |
| 1136 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules( | 1131 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules( |
| 1137 int32_t id, | |
| 1138 bool receiver_only, | 1132 bool receiver_only, |
| 1139 ReceiveStatistics* receive_statistics, | 1133 ReceiveStatistics* receive_statistics, |
| 1140 Transport* outgoing_transport, | 1134 Transport* outgoing_transport, |
| 1141 RtcpIntraFrameObserver* intra_frame_callback, | 1135 RtcpIntraFrameObserver* intra_frame_callback, |
| 1142 RtcpBandwidthObserver* bandwidth_callback, | 1136 RtcpBandwidthObserver* bandwidth_callback, |
| 1143 TransportFeedbackObserver* transport_feedback_callback, | 1137 TransportFeedbackObserver* transport_feedback_callback, |
| 1144 RtcpRttStats* rtt_stats, | 1138 RtcpRttStats* rtt_stats, |
| 1145 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, | 1139 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, |
| 1146 RemoteBitrateEstimator* remote_bitrate_estimator, | 1140 RemoteBitrateEstimator* remote_bitrate_estimator, |
| 1147 PacedSender* paced_sender, | 1141 PacedSender* paced_sender, |
| 1148 PacketRouter* packet_router, | 1142 PacketRouter* packet_router, |
| 1149 BitrateStatisticsObserver* send_bitrate_observer, | 1143 BitrateStatisticsObserver* send_bitrate_observer, |
| 1150 FrameCountObserver* send_frame_count_observer, | 1144 FrameCountObserver* send_frame_count_observer, |
| 1151 SendSideDelayObserver* send_side_delay_observer, | 1145 SendSideDelayObserver* send_side_delay_observer, |
| 1152 size_t num_modules) { | 1146 size_t num_modules) { |
| 1153 DCHECK_GT(num_modules, 0u); | 1147 DCHECK_GT(num_modules, 0u); |
| 1154 RtpRtcp::Configuration configuration; | 1148 RtpRtcp::Configuration configuration; |
| 1155 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; | 1149 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; |
| 1156 configuration.id = id; | |
| 1157 configuration.audio = false; | 1150 configuration.audio = false; |
| 1158 configuration.receiver_only = receiver_only; | 1151 configuration.receiver_only = receiver_only; |
| 1159 configuration.receive_statistics = receive_statistics; | 1152 configuration.receive_statistics = receive_statistics; |
| 1160 configuration.outgoing_transport = outgoing_transport; | 1153 configuration.outgoing_transport = outgoing_transport; |
| 1161 configuration.intra_frame_callback = intra_frame_callback; | 1154 configuration.intra_frame_callback = intra_frame_callback; |
| 1162 configuration.rtt_stats = rtt_stats; | 1155 configuration.rtt_stats = rtt_stats; |
| 1163 configuration.rtcp_packet_type_counter_observer = | 1156 configuration.rtcp_packet_type_counter_observer = |
| 1164 rtcp_packet_type_counter_observer; | 1157 rtcp_packet_type_counter_observer; |
| 1165 configuration.paced_sender = paced_sender; | 1158 configuration.paced_sender = paced_sender; |
| 1166 configuration.packet_router = packet_router; | 1159 configuration.packet_router = packet_router; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1224 } | 1217 } |
| 1225 | 1218 |
| 1226 void ViEChannel::RegisterPreDecodeImageCallback( | 1219 void ViEChannel::RegisterPreDecodeImageCallback( |
| 1227 EncodedImageCallback* pre_decode_callback) { | 1220 EncodedImageCallback* pre_decode_callback) { |
| 1228 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); | 1221 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); |
| 1229 } | 1222 } |
| 1230 | 1223 |
| 1231 // TODO(pbos): Remove OnInitializeDecoder which is called from the RTP module, | 1224 // TODO(pbos): Remove OnInitializeDecoder which is called from the RTP module, |
| 1232 // any decoder resetting should be handled internally within the VCM. | 1225 // any decoder resetting should be handled internally within the VCM. |
| 1233 int32_t ViEChannel::OnInitializeDecoder( | 1226 int32_t ViEChannel::OnInitializeDecoder( |
| 1234 const int32_t id, | |
| 1235 const int8_t payload_type, | 1227 const int8_t payload_type, |
| 1236 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 1228 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 1237 const int frequency, | 1229 const int frequency, |
| 1238 const uint8_t channels, | 1230 const uint8_t channels, |
| 1239 const uint32_t rate) { | 1231 const uint32_t rate) { |
| 1240 LOG(LS_INFO) << "OnInitializeDecoder " << static_cast<int>(payload_type) | 1232 LOG(LS_INFO) << "OnInitializeDecoder " << static_cast<int>(payload_type) |
| 1241 << " " << payload_name; | 1233 << " " << payload_name; |
| 1242 vcm_->ResetDecoder(); | 1234 vcm_->ResetDecoder(); |
| 1243 | 1235 |
| 1244 return 0; | 1236 return 0; |
| 1245 } | 1237 } |
| 1246 | 1238 |
| 1247 void ViEChannel::OnIncomingSSRCChanged(const int32_t id, const uint32_t ssrc) { | 1239 void ViEChannel::OnIncomingSSRCChanged(const uint32_t ssrc) { |
| 1248 DCHECK_EQ(channel_id_, ChannelId(id)); | |
| 1249 rtp_rtcp_modules_[0]->SetRemoteSSRC(ssrc); | 1240 rtp_rtcp_modules_[0]->SetRemoteSSRC(ssrc); |
| 1250 } | 1241 } |
| 1251 | 1242 |
| 1252 void ViEChannel::OnIncomingCSRCChanged(const int32_t id, | 1243 void ViEChannel::OnIncomingCSRCChanged(const uint32_t CSRC, const bool added) {} |
| 1253 const uint32_t CSRC, | |
| 1254 const bool added) { | |
| 1255 DCHECK_EQ(channel_id_, ChannelId(id)); | |
| 1256 CriticalSectionScoped cs(crit_.get()); | |
| 1257 } | |
| 1258 | 1244 |
| 1259 void ViEChannel::RegisterSendFrameCountObserver( | 1245 void ViEChannel::RegisterSendFrameCountObserver( |
| 1260 FrameCountObserver* observer) { | 1246 FrameCountObserver* observer) { |
| 1261 send_frame_count_observer_.Set(observer); | 1247 send_frame_count_observer_.Set(observer); |
| 1262 } | 1248 } |
| 1263 | 1249 |
| 1264 void ViEChannel::RegisterReceiveStatisticsProxy( | 1250 void ViEChannel::RegisterReceiveStatisticsProxy( |
| 1265 ReceiveStatisticsProxy* receive_statistics_proxy) { | 1251 ReceiveStatisticsProxy* receive_statistics_proxy) { |
| 1266 CriticalSectionScoped cs(crit_.get()); | 1252 CriticalSectionScoped cs(crit_.get()); |
| 1267 receive_stats_callback_ = receive_statistics_proxy; | 1253 receive_stats_callback_ = receive_statistics_proxy; |
| 1268 } | 1254 } |
| 1269 | 1255 |
| 1270 void ViEChannel::SetIncomingVideoStream( | 1256 void ViEChannel::SetIncomingVideoStream( |
| 1271 IncomingVideoStream* incoming_video_stream) { | 1257 IncomingVideoStream* incoming_video_stream) { |
| 1272 CriticalSectionScoped cs(crit_.get()); | 1258 CriticalSectionScoped cs(crit_.get()); |
| 1273 incoming_video_stream_ = incoming_video_stream; | 1259 incoming_video_stream_ = incoming_video_stream; |
| 1274 } | 1260 } |
| 1275 } // namespace webrtc | 1261 } // namespace webrtc |
| OLD | NEW |