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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 ss << "{decoders: ["; | 40 ss << "{decoders: ["; |
41 for (size_t i = 0; i < decoders.size(); ++i) { | 41 for (size_t i = 0; i < decoders.size(); ++i) { |
42 ss << decoders[i].ToString(); | 42 ss << decoders[i].ToString(); |
43 if (i != decoders.size() - 1) | 43 if (i != decoders.size() - 1) |
44 ss << ", "; | 44 ss << ", "; |
45 } | 45 } |
46 ss << ']'; | 46 ss << ']'; |
47 ss << ", rtp: " << rtp.ToString(); | 47 ss << ", rtp: " << rtp.ToString(); |
48 ss << ", renderer: " << (renderer != nullptr ? "(renderer)" : "nullptr"); | 48 ss << ", renderer: " << (renderer != nullptr ? "(renderer)" : "nullptr"); |
49 ss << ", render_delay_ms: " << render_delay_ms; | 49 ss << ", render_delay_ms: " << render_delay_ms; |
50 ss << ", audio_channel_id: " << audio_channel_id; | 50 if (!sync_group.empty()) |
| 51 ss << ", sync_group: " << sync_group; |
51 ss << ", pre_decode_callback: " | 52 ss << ", pre_decode_callback: " |
52 << (pre_decode_callback != nullptr ? "(EncodedFrameObserver)" : "nullptr"); | 53 << (pre_decode_callback != nullptr ? "(EncodedFrameObserver)" : "nullptr"); |
53 ss << ", pre_render_callback: " | 54 ss << ", pre_render_callback: " |
54 << (pre_render_callback != nullptr ? "(I420FrameCallback)" : "nullptr"); | 55 << (pre_render_callback != nullptr ? "(I420FrameCallback)" : "nullptr"); |
55 ss << ", target_delay_ms: " << target_delay_ms; | 56 ss << ", target_delay_ms: " << target_delay_ms; |
56 ss << '}'; | 57 ss << '}'; |
57 | 58 |
58 return ss.str(); | 59 return ss.str(); |
59 } | 60 } |
60 | 61 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 ChannelGroup* channel_group, | 129 ChannelGroup* channel_group, |
129 int channel_id, | 130 int channel_id, |
130 const VideoReceiveStream::Config& config, | 131 const VideoReceiveStream::Config& config, |
131 newapi::Transport* transport, | 132 newapi::Transport* transport, |
132 webrtc::VoiceEngine* voice_engine) | 133 webrtc::VoiceEngine* voice_engine) |
133 : transport_adapter_(transport), | 134 : transport_adapter_(transport), |
134 encoded_frame_proxy_(config.pre_decode_callback), | 135 encoded_frame_proxy_(config.pre_decode_callback), |
135 config_(config), | 136 config_(config), |
136 clock_(Clock::GetRealTimeClock()), | 137 clock_(Clock::GetRealTimeClock()), |
137 channel_group_(channel_group), | 138 channel_group_(channel_group), |
138 channel_id_(channel_id), | 139 channel_id_(channel_id) { |
139 voe_sync_interface_(nullptr) { | |
140 CHECK(channel_group_->CreateReceiveChannel(channel_id_, 0, base_channel_id, | 140 CHECK(channel_group_->CreateReceiveChannel(channel_id_, 0, base_channel_id, |
141 &transport_adapter_, num_cpu_cores, | 141 &transport_adapter_, num_cpu_cores, |
142 true)); | 142 true)); |
143 | 143 |
144 vie_channel_ = channel_group_->GetChannel(channel_id_); | 144 vie_channel_ = channel_group_->GetChannel(channel_id_); |
145 | 145 |
146 // TODO(pbos): This is not fine grained enough... | 146 // TODO(pbos): This is not fine grained enough... |
147 vie_channel_->SetNACKStatus(config_.rtp.nack.rtp_history_ms > 0); | 147 vie_channel_->SetNACKStatus(config_.rtp.nack.rtp_history_ms > 0); |
148 vie_channel_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); | 148 vie_channel_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); |
149 SetRtcpMode(config_.rtp.rtcp_mode); | 149 SetRtcpMode(config_.rtp.rtcp_mode); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 234 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
235 | 235 |
236 CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); | 236 CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); |
237 } | 237 } |
238 | 238 |
239 incoming_video_stream_.reset(new IncomingVideoStream(0)); | 239 incoming_video_stream_.reset(new IncomingVideoStream(0)); |
240 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); | 240 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); |
241 incoming_video_stream_->SetExternalCallback(this); | 241 incoming_video_stream_->SetExternalCallback(this); |
242 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); | 242 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); |
243 | 243 |
244 if (voice_engine && config_.audio_channel_id != -1) { | |
245 voe_sync_interface_ = VoEVideoSync::GetInterface(voice_engine); | |
246 vie_channel_->SetVoiceChannel(config.audio_channel_id, voe_sync_interface_); | |
247 } | |
248 | |
249 if (config.pre_decode_callback) | 244 if (config.pre_decode_callback) |
250 vie_channel_->RegisterPreDecodeImageCallback(&encoded_frame_proxy_); | 245 vie_channel_->RegisterPreDecodeImageCallback(&encoded_frame_proxy_); |
251 vie_channel_->RegisterPreRenderCallback(this); | 246 vie_channel_->RegisterPreRenderCallback(this); |
252 } | 247 } |
253 | 248 |
254 VideoReceiveStream::~VideoReceiveStream() { | 249 VideoReceiveStream::~VideoReceiveStream() { |
255 incoming_video_stream_->Stop(); | 250 incoming_video_stream_->Stop(); |
256 vie_channel_->RegisterPreRenderCallback(nullptr); | 251 vie_channel_->RegisterPreRenderCallback(nullptr); |
257 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 252 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
258 | 253 |
259 for (size_t i = 0; i < config_.decoders.size(); ++i) | 254 for (size_t i = 0; i < config_.decoders.size(); ++i) |
260 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); | 255 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); |
261 | 256 |
262 if (voe_sync_interface_ != nullptr) { | |
263 vie_channel_->SetVoiceChannel(-1, nullptr); | |
264 voe_sync_interface_->Release(); | |
265 } | |
266 vie_channel_->RegisterCodecObserver(nullptr); | 257 vie_channel_->RegisterCodecObserver(nullptr); |
267 vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(nullptr); | 258 vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(nullptr); |
268 vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback(nullptr); | 259 vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback(nullptr); |
269 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); | 260 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); |
270 channel_group_->DeleteChannel(channel_id_); | 261 channel_group_->DeleteChannel(channel_id_); |
271 } | 262 } |
272 | 263 |
273 void VideoReceiveStream::Start() { | 264 void VideoReceiveStream::Start() { |
274 transport_adapter_.Enable(); | 265 transport_adapter_.Enable(); |
275 incoming_video_stream_->Start(); | 266 incoming_video_stream_->Start(); |
276 vie_channel_->StartReceive(); | 267 vie_channel_->StartReceive(); |
277 } | 268 } |
278 | 269 |
279 void VideoReceiveStream::Stop() { | 270 void VideoReceiveStream::Stop() { |
280 incoming_video_stream_->Stop(); | 271 incoming_video_stream_->Stop(); |
281 vie_channel_->StopReceive(); | 272 vie_channel_->StopReceive(); |
282 transport_adapter_.Disable(); | 273 transport_adapter_.Disable(); |
283 } | 274 } |
284 | 275 |
| 276 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, |
| 277 int audio_channel_id) { |
| 278 if (voice_engine != nullptr && audio_channel_id != -1) { |
| 279 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); |
| 280 vie_channel_->SetVoiceChannel(audio_channel_id, voe_sync_interface); |
| 281 voe_sync_interface->Release(); |
| 282 } else { |
| 283 vie_channel_->SetVoiceChannel(-1, nullptr); |
| 284 } |
| 285 } |
| 286 |
285 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { | 287 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { |
286 return stats_proxy_->GetStats(); | 288 return stats_proxy_->GetStats(); |
287 } | 289 } |
288 | 290 |
289 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 291 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
290 return vie_channel_->ReceivedRTCPPacket(packet, length) == 0; | 292 return vie_channel_->ReceivedRTCPPacket(packet, length) == 0; |
291 } | 293 } |
292 | 294 |
293 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, size_t length) { | 295 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, size_t length) { |
294 return vie_channel_->ReceivedRTPPacket(packet, length, PacketTime()) == 0; | 296 return vie_channel_->ReceivedRTPPacket(packet, length, PacketTime()) == 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 case newapi::kRtcpCompound: | 334 case newapi::kRtcpCompound: |
333 vie_channel_->SetRTCPMode(kRtcpCompound); | 335 vie_channel_->SetRTCPMode(kRtcpCompound); |
334 break; | 336 break; |
335 case newapi::kRtcpReducedSize: | 337 case newapi::kRtcpReducedSize: |
336 vie_channel_->SetRTCPMode(kRtcpNonCompound); | 338 vie_channel_->SetRTCPMode(kRtcpNonCompound); |
337 break; | 339 break; |
338 } | 340 } |
339 } | 341 } |
340 } // namespace internal | 342 } // namespace internal |
341 } // namespace webrtc | 343 } // namespace webrtc |
OLD | NEW |