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