OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 } | 2230 } |
2231 if (duration < kMinTelephoneEventDuration || | 2231 if (duration < kMinTelephoneEventDuration || |
2232 duration > kMaxTelephoneEventDuration) { | 2232 duration > kMaxTelephoneEventDuration) { |
2233 LOG(LS_WARNING) << "DTMF event duration " << duration << " out of range."; | 2233 LOG(LS_WARNING) << "DTMF event duration " << duration << " out of range."; |
2234 return false; | 2234 return false; |
2235 } | 2235 } |
2236 return it->second->SendTelephoneEvent(*dtmf_payload_type_, event, duration); | 2236 return it->second->SendTelephoneEvent(*dtmf_payload_type_, event, duration); |
2237 } | 2237 } |
2238 | 2238 |
2239 void WebRtcVoiceMediaChannel::OnPacketReceived( | 2239 void WebRtcVoiceMediaChannel::OnPacketReceived( |
2240 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2240 rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { |
2241 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2241 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2242 | 2242 |
2243 uint32_t ssrc = 0; | 2243 uint32_t ssrc = 0; |
2244 if (!GetRtpSsrc(packet->data(), packet->size(), &ssrc)) { | 2244 if (!GetRtpSsrc(packet->cdata(), packet->size(), &ssrc)) { |
2245 return; | 2245 return; |
2246 } | 2246 } |
2247 | 2247 |
2248 // If we don't have a default channel, and the SSRC is unknown, create a | 2248 // If we don't have a default channel, and the SSRC is unknown, create a |
2249 // default channel. | 2249 // default channel. |
2250 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { | 2250 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { |
2251 StreamParams sp; | 2251 StreamParams sp; |
2252 sp.ssrcs.push_back(ssrc); | 2252 sp.ssrcs.push_back(ssrc); |
2253 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; | 2253 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; |
2254 if (!AddRecvStream(sp)) { | 2254 if (!AddRecvStream(sp)) { |
2255 LOG(LS_WARNING) << "Could not create default receive stream."; | 2255 LOG(LS_WARNING) << "Could not create default receive stream."; |
2256 return; | 2256 return; |
2257 } | 2257 } |
2258 default_recv_ssrc_ = ssrc; | 2258 default_recv_ssrc_ = ssrc; |
2259 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); | 2259 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); |
2260 if (default_sink_) { | 2260 if (default_sink_) { |
2261 std::unique_ptr<webrtc::AudioSinkInterface> proxy_sink( | 2261 std::unique_ptr<webrtc::AudioSinkInterface> proxy_sink( |
2262 new ProxySink(default_sink_.get())); | 2262 new ProxySink(default_sink_.get())); |
2263 SetRawAudioSink(default_recv_ssrc_, std::move(proxy_sink)); | 2263 SetRawAudioSink(default_recv_ssrc_, std::move(proxy_sink)); |
2264 } | 2264 } |
2265 } | 2265 } |
2266 | 2266 |
2267 // Forward packet to Call. If the SSRC is unknown we'll return after this. | 2267 // Forward packet to Call. If the SSRC is unknown we'll return after this. |
2268 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2268 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2269 packet_time.not_before); | 2269 packet_time.not_before); |
2270 webrtc::PacketReceiver::DeliveryStatus delivery_result = | 2270 webrtc::PacketReceiver::DeliveryStatus delivery_result = |
2271 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 2271 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2272 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | 2272 packet->cdata(), packet->size(), webrtc_packet_time); |
2273 webrtc_packet_time); | |
2274 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { | 2273 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { |
2275 // If the SSRC is unknown here, route it to the default channel, if we have | 2274 // If the SSRC is unknown here, route it to the default channel, if we have |
2276 // one. See: https://bugs.chromium.org/p/webrtc/issues/detail?id=5208 | 2275 // one. See: https://bugs.chromium.org/p/webrtc/issues/detail?id=5208 |
2277 if (default_recv_ssrc_ == -1) { | 2276 if (default_recv_ssrc_ == -1) { |
2278 return; | 2277 return; |
2279 } else { | 2278 } else { |
2280 ssrc = default_recv_ssrc_; | 2279 ssrc = default_recv_ssrc_; |
2281 } | 2280 } |
2282 } | 2281 } |
2283 | 2282 |
2284 // Find the channel to send this packet to. It must exist since webrtc::Call | 2283 // Find the channel to send this packet to. It must exist since webrtc::Call |
2285 // was able to demux the packet. | 2284 // was able to demux the packet. |
2286 int channel = GetReceiveChannelId(ssrc); | 2285 int channel = GetReceiveChannelId(ssrc); |
2287 RTC_DCHECK(channel != -1); | 2286 RTC_DCHECK(channel != -1); |
2288 | 2287 |
2289 // Pass it off to the decoder. | 2288 // Pass it off to the decoder. |
2290 engine()->voe()->network()->ReceivedRTPPacket( | 2289 engine()->voe()->network()->ReceivedRTPPacket( |
2291 channel, packet->data(), packet->size(), webrtc_packet_time); | 2290 channel, packet->cdata(), packet->size(), webrtc_packet_time); |
2292 } | 2291 } |
2293 | 2292 |
2294 void WebRtcVoiceMediaChannel::OnRtcpReceived( | 2293 void WebRtcVoiceMediaChannel::OnRtcpReceived( |
2295 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { | 2294 rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { |
2296 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2295 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2297 | 2296 |
2298 // Forward packet to Call as well. | 2297 // Forward packet to Call as well. |
2299 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2298 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2300 packet_time.not_before); | 2299 packet_time.not_before); |
2301 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 2300 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2302 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | 2301 packet->cdata(), packet->size(), webrtc_packet_time); |
2303 webrtc_packet_time); | |
2304 | 2302 |
2305 // Sending channels need all RTCP packets with feedback information. | 2303 // Sending channels need all RTCP packets with feedback information. |
2306 // Even sender reports can contain attached report blocks. | 2304 // Even sender reports can contain attached report blocks. |
2307 // Receiving channels need sender reports in order to create | 2305 // Receiving channels need sender reports in order to create |
2308 // correct receiver reports. | 2306 // correct receiver reports. |
2309 int type = 0; | 2307 int type = 0; |
2310 if (!GetRtcpType(packet->data(), packet->size(), &type)) { | 2308 if (!GetRtcpType(packet->cdata(), packet->size(), &type)) { |
2311 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; | 2309 LOG(LS_WARNING) << "Failed to parse type from received RTCP packet"; |
2312 return; | 2310 return; |
2313 } | 2311 } |
2314 | 2312 |
2315 // If it is a sender report, find the receive channel that is listening. | 2313 // If it is a sender report, find the receive channel that is listening. |
2316 if (type == kRtcpTypeSR) { | 2314 if (type == kRtcpTypeSR) { |
2317 uint32_t ssrc = 0; | 2315 uint32_t ssrc = 0; |
2318 if (!GetRtcpSsrc(packet->data(), packet->size(), &ssrc)) { | 2316 if (!GetRtcpSsrc(packet->cdata(), packet->size(), &ssrc)) { |
2319 return; | 2317 return; |
2320 } | 2318 } |
2321 int recv_channel_id = GetReceiveChannelId(ssrc); | 2319 int recv_channel_id = GetReceiveChannelId(ssrc); |
2322 if (recv_channel_id != -1) { | 2320 if (recv_channel_id != -1) { |
2323 engine()->voe()->network()->ReceivedRTCPPacket( | 2321 engine()->voe()->network()->ReceivedRTCPPacket( |
2324 recv_channel_id, packet->data(), packet->size()); | 2322 recv_channel_id, packet->cdata(), packet->size()); |
2325 } | 2323 } |
2326 } | 2324 } |
2327 | 2325 |
2328 // SR may continue RR and any RR entry may correspond to any one of the send | 2326 // SR may continue RR and any RR entry may correspond to any one of the send |
2329 // channels. So all RTCP packets must be forwarded all send channels. VoE | 2327 // channels. So all RTCP packets must be forwarded all send channels. VoE |
2330 // will filter out RR internally. | 2328 // will filter out RR internally. |
2331 for (const auto& ch : send_streams_) { | 2329 for (const auto& ch : send_streams_) { |
2332 engine()->voe()->network()->ReceivedRTCPPacket( | 2330 engine()->voe()->network()->ReceivedRTCPPacket( |
2333 ch.second->channel(), packet->data(), packet->size()); | 2331 ch.second->channel(), packet->cdata(), packet->size()); |
2334 } | 2332 } |
2335 } | 2333 } |
2336 | 2334 |
2337 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { | 2335 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { |
2338 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2336 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2339 int channel = GetSendChannelId(ssrc); | 2337 int channel = GetSendChannelId(ssrc); |
2340 if (channel == -1) { | 2338 if (channel == -1) { |
2341 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; | 2339 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; |
2342 return false; | 2340 return false; |
2343 } | 2341 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 } | 2540 } |
2543 } else { | 2541 } else { |
2544 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2542 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2545 engine()->voe()->base()->StopPlayout(channel); | 2543 engine()->voe()->base()->StopPlayout(channel); |
2546 } | 2544 } |
2547 return true; | 2545 return true; |
2548 } | 2546 } |
2549 } // namespace cricket | 2547 } // namespace cricket |
2550 | 2548 |
2551 #endif // HAVE_WEBRTC_VOICE | 2549 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |