OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1237 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1238 RTC_DCHECK(stream_); | 1238 RTC_DCHECK(stream_); |
1239 return stream_->GetStats(); | 1239 return stream_->GetStats(); |
1240 } | 1240 } |
1241 | 1241 |
1242 int channel() const { | 1242 int channel() const { |
1243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1244 return config_.voe_channel_id; | 1244 return config_.voe_channel_id; |
1245 } | 1245 } |
1246 | 1246 |
1247 void SetRawAudioSink( | 1247 void SetRawAudioSink(rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
1248 const rtc::scoped_refptr<webrtc::AudioSinkInterface>& sink) { | |
1249 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1248 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1250 stream_->SetSink(sink); | 1249 stream_->SetSink(std::move(sink)); |
1251 } | 1250 } |
1252 | 1251 |
1253 private: | 1252 private: |
1254 void RecreateAudioReceiveStream(bool use_combined_bwe, | 1253 void RecreateAudioReceiveStream(bool use_combined_bwe, |
1255 const std::vector<webrtc::RtpExtension>& extensions) { | 1254 const std::vector<webrtc::RtpExtension>& extensions) { |
1256 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1255 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1257 if (stream_) { | 1256 if (stream_) { |
1258 call_->DestroyAudioReceiveStream(stream_); | 1257 call_->DestroyAudioReceiveStream(stream_); |
1259 stream_ = nullptr; | 1258 stream_ = nullptr; |
1260 } | 1259 } |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { | 2179 if (default_recv_ssrc_ == -1 && GetReceiveChannelId(ssrc) == -1) { |
2181 StreamParams sp; | 2180 StreamParams sp; |
2182 sp.ssrcs.push_back(ssrc); | 2181 sp.ssrcs.push_back(ssrc); |
2183 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; | 2182 LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << "."; |
2184 if (!AddRecvStream(sp)) { | 2183 if (!AddRecvStream(sp)) { |
2185 LOG(LS_WARNING) << "Could not create default receive stream."; | 2184 LOG(LS_WARNING) << "Could not create default receive stream."; |
2186 return; | 2185 return; |
2187 } | 2186 } |
2188 default_recv_ssrc_ = ssrc; | 2187 default_recv_ssrc_ = ssrc; |
2189 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); | 2188 SetOutputVolume(default_recv_ssrc_, default_recv_volume_); |
2190 SetRawAudioSink(default_recv_ssrc_, default_sink_); | |
2191 } | 2189 } |
2192 | 2190 |
2193 // Forward packet to Call. If the SSRC is unknown we'll return after this. | 2191 // Forward packet to Call. If the SSRC is unknown we'll return after this. |
2194 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, | 2192 const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp, |
2195 packet_time.not_before); | 2193 packet_time.not_before); |
2196 webrtc::PacketReceiver::DeliveryStatus delivery_result = | 2194 webrtc::PacketReceiver::DeliveryStatus delivery_result = |
2197 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, | 2195 call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, |
2198 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), | 2196 reinterpret_cast<const uint8_t*>(packet->data()), packet->size(), |
2199 webrtc_packet_time); | 2197 webrtc_packet_time); |
2200 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { | 2198 if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 rinfo.decoding_plc_cng = stats.decoding_plc_cng; | 2405 rinfo.decoding_plc_cng = stats.decoding_plc_cng; |
2408 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; | 2406 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; |
2409 info->receivers.push_back(rinfo); | 2407 info->receivers.push_back(rinfo); |
2410 } | 2408 } |
2411 | 2409 |
2412 return true; | 2410 return true; |
2413 } | 2411 } |
2414 | 2412 |
2415 void WebRtcVoiceMediaChannel::SetRawAudioSink( | 2413 void WebRtcVoiceMediaChannel::SetRawAudioSink( |
2416 uint32_t ssrc, | 2414 uint32_t ssrc, |
2417 const rtc::scoped_refptr<webrtc::AudioSinkInterface>& sink) { | 2415 rtc::scoped_ptr<webrtc::AudioSinkInterface> sink) { |
2418 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2416 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2419 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; | 2417 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::SetRawAudioSink"; |
2420 if (ssrc == 0) { | |
2421 default_sink_ = sink; | |
2422 if (default_recv_ssrc_ == -1) { | |
2423 return; | |
2424 } | |
2425 ssrc = static_cast<uint32_t>(default_recv_ssrc_); | |
2426 } | |
2427 const auto it = recv_streams_.find(ssrc); | 2418 const auto it = recv_streams_.find(ssrc); |
2428 if (it == recv_streams_.end()) { | 2419 if (it == recv_streams_.end()) { |
2429 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; | 2420 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; |
2430 return; | 2421 return; |
2431 } | 2422 } |
2432 it->second->SetRawAudioSink(sink); | 2423 it->second->SetRawAudioSink(std::move(sink)); |
2433 } | 2424 } |
2434 | 2425 |
2435 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 2426 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
2436 unsigned int ulevel = 0; | 2427 unsigned int ulevel = 0; |
2437 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 2428 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
2438 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 2429 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
2439 } | 2430 } |
2440 | 2431 |
2441 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { | 2432 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { |
2442 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2433 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 } | 2500 } |
2510 } else { | 2501 } else { |
2511 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2502 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2512 engine()->voe()->base()->StopPlayout(channel); | 2503 engine()->voe()->base()->StopPlayout(channel); |
2513 } | 2504 } |
2514 return true; | 2505 return true; |
2515 } | 2506 } |
2516 } // namespace cricket | 2507 } // namespace cricket |
2517 | 2508 |
2518 #endif // HAVE_WEBRTC_VOICE | 2509 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |