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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #include <algorithm> | 36 #include <algorithm> |
37 #include <cstdio> | 37 #include <cstdio> |
38 #include <string> | 38 #include <string> |
39 #include <vector> | 39 #include <vector> |
40 | 40 |
41 #include "talk/media/base/audioframe.h" | 41 #include "talk/media/base/audioframe.h" |
42 #include "talk/media/base/audiorenderer.h" | 42 #include "talk/media/base/audiorenderer.h" |
43 #include "talk/media/base/constants.h" | 43 #include "talk/media/base/constants.h" |
44 #include "talk/media/base/streamparams.h" | 44 #include "talk/media/base/streamparams.h" |
| 45 #include "talk/media/webrtc/webrtcmediaengine.h" |
45 #include "talk/media/webrtc/webrtcvoe.h" | 46 #include "talk/media/webrtc/webrtcvoe.h" |
46 #include "webrtc/base/arraysize.h" | 47 #include "webrtc/base/arraysize.h" |
47 #include "webrtc/base/base64.h" | 48 #include "webrtc/base/base64.h" |
48 #include "webrtc/base/byteorder.h" | 49 #include "webrtc/base/byteorder.h" |
49 #include "webrtc/base/common.h" | 50 #include "webrtc/base/common.h" |
50 #include "webrtc/base/helpers.h" | 51 #include "webrtc/base/helpers.h" |
51 #include "webrtc/base/logging.h" | 52 #include "webrtc/base/logging.h" |
52 #include "webrtc/base/stringencode.h" | 53 #include "webrtc/base/stringencode.h" |
53 #include "webrtc/base/stringutils.h" | 54 #include "webrtc/base/stringutils.h" |
54 #include "webrtc/call/rtc_event_log.h" | 55 #include "webrtc/call/rtc_event_log.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 options.aec_dump = rtc::Optional<bool>(false); | 290 options.aec_dump = rtc::Optional<bool>(false); |
290 return options; | 291 return options; |
291 } | 292 } |
292 | 293 |
293 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { | 294 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { |
294 webrtc::AudioState::Config config; | 295 webrtc::AudioState::Config config; |
295 config.voice_engine = voe_wrapper->engine(); | 296 config.voice_engine = voe_wrapper->engine(); |
296 return config; | 297 return config; |
297 } | 298 } |
298 | 299 |
299 std::vector<webrtc::RtpExtension> FindAudioRtpHeaderExtensions( | |
300 const std::vector<RtpHeaderExtension>& extensions) { | |
301 std::vector<webrtc::RtpExtension> result; | |
302 for (const auto& extension : extensions) { | |
303 if (extension.uri == kRtpAbsoluteSenderTimeHeaderExtension || | |
304 extension.uri == kRtpAudioLevelHeaderExtension) { | |
305 result.push_back({extension.uri, extension.id}); | |
306 } else { | |
307 LOG(LS_WARNING) << "Unsupported RTP extension: " << extension.ToString(); | |
308 } | |
309 } | |
310 return result; | |
311 } | |
312 | |
313 class WebRtcVoiceCodecs final { | 300 class WebRtcVoiceCodecs final { |
314 public: | 301 public: |
315 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec | 302 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec |
316 // list and add a test which verifies VoE supports the listed codecs. | 303 // list and add a test which verifies VoE supports the listed codecs. |
317 static std::vector<AudioCodec> SupportedCodecs() { | 304 static std::vector<AudioCodec> SupportedCodecs() { |
318 LOG(LS_INFO) << "WebRtc VoiceEngine codecs:"; | 305 LOG(LS_INFO) << "WebRtc VoiceEngine codecs:"; |
319 std::vector<AudioCodec> result; | 306 std::vector<AudioCodec> result; |
320 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { | 307 for (webrtc::CodecInst voe_codec : webrtc::acm2::RentACodec::Database()) { |
321 // Change the sample rate of G722 to 8000 to match SDP. | 308 // Change the sample rate of G722 to 8000 to match SDP. |
322 MaybeFixupG722(&voe_codec, 8000); | 309 MaybeFixupG722(&voe_codec, 8000); |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 } | 1430 } |
1444 while (!recv_streams_.empty()) { | 1431 while (!recv_streams_.empty()) { |
1445 RemoveRecvStream(recv_streams_.begin()->first); | 1432 RemoveRecvStream(recv_streams_.begin()->first); |
1446 } | 1433 } |
1447 engine()->UnregisterChannel(this); | 1434 engine()->UnregisterChannel(this); |
1448 } | 1435 } |
1449 | 1436 |
1450 bool WebRtcVoiceMediaChannel::SetSendParameters( | 1437 bool WebRtcVoiceMediaChannel::SetSendParameters( |
1451 const AudioSendParameters& params) { | 1438 const AudioSendParameters& params) { |
1452 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1439 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1440 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " |
| 1441 << params.ToString(); |
1453 // TODO(pthatcher): Refactor this to be more clean now that we have | 1442 // TODO(pthatcher): Refactor this to be more clean now that we have |
1454 // all the information at once. | 1443 // all the information at once. |
1455 | 1444 |
1456 if (!SetSendCodecs(params.codecs)) { | 1445 if (!SetSendCodecs(params.codecs)) { |
1457 return false; | 1446 return false; |
1458 } | 1447 } |
1459 | 1448 |
1460 std::vector<webrtc::RtpExtension> send_rtp_extensions = | 1449 if (!ValidateRtpExtensions(params.extensions)) { |
1461 FindAudioRtpHeaderExtensions(params.extensions); | 1450 return false; |
1462 if (send_rtp_extensions_ != send_rtp_extensions) { | 1451 } |
1463 send_rtp_extensions_.swap(send_rtp_extensions); | 1452 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1453 FilterRtpExtensions(params.extensions, |
| 1454 webrtc::RtpExtension::IsSupportedForAudio, true); |
| 1455 if (send_rtp_extensions_ != filtered_extensions) { |
| 1456 send_rtp_extensions_.swap(filtered_extensions); |
1464 for (auto& it : send_streams_) { | 1457 for (auto& it : send_streams_) { |
1465 it.second->RecreateAudioSendStream(send_rtp_extensions_); | 1458 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
1466 } | 1459 } |
1467 } | 1460 } |
1468 | 1461 |
1469 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { | 1462 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { |
1470 return false; | 1463 return false; |
1471 } | 1464 } |
1472 return SetOptions(params.options); | 1465 return SetOptions(params.options); |
1473 } | 1466 } |
1474 | 1467 |
1475 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1468 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
1476 const AudioRecvParameters& params) { | 1469 const AudioRecvParameters& params) { |
1477 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1470 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1471 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " |
| 1472 << params.ToString(); |
1478 // TODO(pthatcher): Refactor this to be more clean now that we have | 1473 // TODO(pthatcher): Refactor this to be more clean now that we have |
1479 // all the information at once. | 1474 // all the information at once. |
1480 | 1475 |
1481 if (!SetRecvCodecs(params.codecs)) { | 1476 if (!SetRecvCodecs(params.codecs)) { |
1482 return false; | 1477 return false; |
1483 } | 1478 } |
1484 | 1479 |
1485 std::vector<webrtc::RtpExtension> recv_rtp_extensions = | 1480 if (!ValidateRtpExtensions(params.extensions)) { |
1486 FindAudioRtpHeaderExtensions(params.extensions); | 1481 return false; |
1487 if (recv_rtp_extensions_ != recv_rtp_extensions) { | 1482 } |
1488 recv_rtp_extensions_.swap(recv_rtp_extensions); | 1483 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1484 FilterRtpExtensions(params.extensions, |
| 1485 webrtc::RtpExtension::IsSupportedForAudio, false); |
| 1486 if (recv_rtp_extensions_ != filtered_extensions) { |
| 1487 recv_rtp_extensions_.swap(filtered_extensions); |
1489 for (auto& it : recv_streams_) { | 1488 for (auto& it : recv_streams_) { |
1490 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); | 1489 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); |
1491 } | 1490 } |
1492 } | 1491 } |
1493 | 1492 |
1494 return true; | 1493 return true; |
1495 } | 1494 } |
1496 | 1495 |
1497 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { | 1496 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { |
1498 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1497 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2652 } | 2651 } |
2653 } else { | 2652 } else { |
2654 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2653 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2655 engine()->voe()->base()->StopPlayout(channel); | 2654 engine()->voe()->base()->StopPlayout(channel); |
2656 } | 2655 } |
2657 return true; | 2656 return true; |
2658 } | 2657 } |
2659 } // namespace cricket | 2658 } // namespace cricket |
2660 | 2659 |
2661 #endif // HAVE_WEBRTC_VOICE | 2660 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |