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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(uint32_t number_of_cores, | 80 ViEChannel::ViEChannel(uint32_t number_of_cores, |
81 Transport* transport, | 81 Transport* transport, |
82 ProcessThread* module_process_thread, | 82 ProcessThread* module_process_thread, |
| 83 PayloadRouter* send_payload_router, |
| 84 VideoCodingModule* vcm, |
83 RtcpIntraFrameObserver* intra_frame_observer, | 85 RtcpIntraFrameObserver* intra_frame_observer, |
84 RtcpBandwidthObserver* bandwidth_observer, | 86 RtcpBandwidthObserver* bandwidth_observer, |
85 TransportFeedbackObserver* transport_feedback_observer, | 87 TransportFeedbackObserver* transport_feedback_observer, |
86 RemoteBitrateEstimator* remote_bitrate_estimator, | 88 RemoteBitrateEstimator* remote_bitrate_estimator, |
87 RtcpRttStats* rtt_stats, | 89 RtcpRttStats* rtt_stats, |
88 PacedSender* paced_sender, | 90 PacedSender* paced_sender, |
89 PacketRouter* packet_router, | 91 PacketRouter* packet_router, |
90 size_t max_rtp_streams, | 92 size_t max_rtp_streams, |
91 bool sender) | 93 bool sender) |
92 : number_of_cores_(number_of_cores), | 94 : number_of_cores_(number_of_cores), |
93 sender_(sender), | 95 sender_(sender), |
94 module_process_thread_(module_process_thread), | 96 module_process_thread_(module_process_thread), |
95 send_payload_router_(new PayloadRouter()), | 97 send_payload_router_(send_payload_router), |
96 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), | 98 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), |
97 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), | 99 vcm_(vcm), |
98 nullptr, | |
99 nullptr)), | |
100 vie_receiver_(vcm_, remote_bitrate_estimator, this), | 100 vie_receiver_(vcm_, remote_bitrate_estimator, this), |
101 vie_sync_(vcm_), | 101 vie_sync_(vcm_), |
102 stats_observer_(new ChannelStatsObserver(this)), | 102 stats_observer_(new ChannelStatsObserver(this)), |
103 receive_stats_callback_(nullptr), | 103 receive_stats_callback_(nullptr), |
104 incoming_video_stream_(nullptr), | 104 incoming_video_stream_(nullptr), |
105 intra_frame_observer_(intra_frame_observer), | 105 intra_frame_observer_(intra_frame_observer), |
106 rtt_stats_(rtt_stats), | 106 rtt_stats_(rtt_stats), |
107 paced_sender_(paced_sender), | 107 paced_sender_(paced_sender), |
108 packet_router_(packet_router), | 108 packet_router_(packet_router), |
109 bandwidth_observer_(bandwidth_observer), | 109 bandwidth_observer_(bandwidth_observer), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 RTC_DCHECK(!send_payload_router_->active()); | 157 RTC_DCHECK(!send_payload_router_->active()); |
158 } | 158 } |
159 if (vcm_->RegisterReceiveCallback(this) != 0) { | 159 if (vcm_->RegisterReceiveCallback(this) != 0) { |
160 return -1; | 160 return -1; |
161 } | 161 } |
162 vcm_->RegisterFrameTypeCallback(this); | 162 vcm_->RegisterFrameTypeCallback(this); |
163 vcm_->RegisterReceiveStatisticsCallback(this); | 163 vcm_->RegisterReceiveStatisticsCallback(this); |
164 vcm_->RegisterDecoderTimingCallback(this); | 164 vcm_->RegisterDecoderTimingCallback(this); |
165 vcm_->SetRenderDelay(kDefaultRenderDelayMs); | 165 vcm_->SetRenderDelay(kDefaultRenderDelayMs); |
166 | 166 |
167 module_process_thread_->RegisterModule(vcm_); | |
168 module_process_thread_->RegisterModule(&vie_sync_); | 167 module_process_thread_->RegisterModule(&vie_sync_); |
169 | 168 |
170 return 0; | 169 return 0; |
171 } | 170 } |
172 | 171 |
173 ViEChannel::~ViEChannel() { | 172 ViEChannel::~ViEChannel() { |
174 UpdateHistograms(); | 173 UpdateHistograms(); |
175 // Make sure we don't get more callbacks from the RTP module. | 174 // Make sure we don't get more callbacks from the RTP module. |
176 module_process_thread_->DeRegisterModule( | 175 module_process_thread_->DeRegisterModule( |
177 vie_receiver_.GetReceiveStatistics()); | 176 vie_receiver_.GetReceiveStatistics()); |
178 module_process_thread_->DeRegisterModule(vcm_); | |
179 module_process_thread_->DeRegisterModule(&vie_sync_); | 177 module_process_thread_->DeRegisterModule(&vie_sync_); |
180 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); | 178 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); |
181 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | 179 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) |
182 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 180 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
183 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 181 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
184 module_process_thread_->DeRegisterModule(rtp_rtcp); | 182 module_process_thread_->DeRegisterModule(rtp_rtcp); |
185 delete rtp_rtcp; | 183 delete rtp_rtcp; |
186 } | 184 } |
187 if (!sender_) | 185 if (!sender_) |
188 StopDecodeThread(); | 186 StopDecodeThread(); |
189 // Release modules. | |
190 VideoCodingModule::Destroy(vcm_); | |
191 } | 187 } |
192 | 188 |
193 void ViEChannel::UpdateHistograms() { | 189 void ViEChannel::UpdateHistograms() { |
194 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 190 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
195 | 191 |
196 { | 192 { |
197 rtc::CritScope lock(&crit_); | 193 rtc::CritScope lock(&crit_); |
198 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; | 194 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; |
199 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && | 195 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && |
200 elapsed_sec > metrics::kMinRunTimeInSeconds) { | 196 elapsed_sec > metrics::kMinRunTimeInSeconds) { |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 931 int32_t ViEChannel::SetMTU(uint16_t mtu) { |
936 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 932 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
937 rtp_rtcp->SetMaxTransferUnit(mtu); | 933 rtp_rtcp->SetMaxTransferUnit(mtu); |
938 return 0; | 934 return 0; |
939 } | 935 } |
940 | 936 |
941 RtpRtcp* ViEChannel::rtp_rtcp() { | 937 RtpRtcp* ViEChannel::rtp_rtcp() { |
942 return rtp_rtcp_modules_[0]; | 938 return rtp_rtcp_modules_[0]; |
943 } | 939 } |
944 | 940 |
945 rtc::scoped_refptr<PayloadRouter> ViEChannel::send_payload_router() { | |
946 return send_payload_router_; | |
947 } | |
948 | |
949 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { | 941 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { |
950 return vcm_protection_callback_.get(); | 942 return vcm_protection_callback_.get(); |
951 } | 943 } |
952 | 944 |
953 CallStatsObserver* ViEChannel::GetStatsObserver() { | 945 CallStatsObserver* ViEChannel::GetStatsObserver() { |
954 return stats_observer_.get(); | 946 return stats_observer_.get(); |
955 } | 947 } |
956 | 948 |
957 // Do not acquire the lock of |vcm_| in this function. Decode callback won't | 949 // Do not acquire the lock of |vcm_| in this function. Decode callback won't |
958 // necessarily be called from the decoding thread. The decoding thread may have | 950 // necessarily be called from the decoding thread. The decoding thread may have |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 rtc::CritScope lock(&crit_); | 1189 rtc::CritScope lock(&crit_); |
1198 receive_stats_callback_ = receive_statistics_proxy; | 1190 receive_stats_callback_ = receive_statistics_proxy; |
1199 } | 1191 } |
1200 | 1192 |
1201 void ViEChannel::SetIncomingVideoStream( | 1193 void ViEChannel::SetIncomingVideoStream( |
1202 IncomingVideoStream* incoming_video_stream) { | 1194 IncomingVideoStream* incoming_video_stream) { |
1203 rtc::CritScope lock(&crit_); | 1195 rtc::CritScope lock(&crit_); |
1204 incoming_video_stream_ = incoming_video_stream; | 1196 incoming_video_stream_ = incoming_video_stream; |
1205 } | 1197 } |
1206 } // namespace webrtc | 1198 } // namespace webrtc |
OLD | NEW |