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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 bool WebRtcVoiceMediaChannel::SetSendParameters( | 1447 bool WebRtcVoiceMediaChannel::SetSendParameters( |
1461 const AudioSendParameters& params) { | 1448 const AudioSendParameters& params) { |
1462 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1449 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1463 // TODO(pthatcher): Refactor this to be more clean now that we have | 1450 // TODO(pthatcher): Refactor this to be more clean now that we have |
1464 // all the information at once. | 1451 // all the information at once. |
1465 | 1452 |
1466 if (!SetSendCodecs(params.codecs)) { | 1453 if (!SetSendCodecs(params.codecs)) { |
1467 return false; | 1454 return false; |
1468 } | 1455 } |
1469 | 1456 |
1470 std::vector<webrtc::RtpExtension> send_rtp_extensions = | 1457 if (!ValidateRtpExtensions(params.extensions)) { |
1471 FindAudioRtpHeaderExtensions(params.extensions); | 1458 return false; |
1472 if (send_rtp_extensions_ != send_rtp_extensions) { | 1459 } |
1473 send_rtp_extensions_.swap(send_rtp_extensions); | 1460 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1461 FilterRtpExtensions(params.extensions, |
| 1462 webrtc::RtpExtension::IsSupportedForAudio, true); |
| 1463 if (send_rtp_extensions_ != filtered_extensions) { |
| 1464 send_rtp_extensions_.swap(filtered_extensions); |
1474 for (auto& it : send_streams_) { | 1465 for (auto& it : send_streams_) { |
1475 it.second->RecreateAudioSendStream(send_rtp_extensions_); | 1466 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
1476 } | 1467 } |
1477 } | 1468 } |
1478 | 1469 |
1479 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { | 1470 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { |
1480 return false; | 1471 return false; |
1481 } | 1472 } |
1482 return SetOptions(params.options); | 1473 return SetOptions(params.options); |
1483 } | 1474 } |
1484 | 1475 |
1485 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1476 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
1486 const AudioRecvParameters& params) { | 1477 const AudioRecvParameters& params) { |
1487 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1478 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1488 // TODO(pthatcher): Refactor this to be more clean now that we have | 1479 // TODO(pthatcher): Refactor this to be more clean now that we have |
1489 // all the information at once. | 1480 // all the information at once. |
1490 | 1481 |
1491 if (!SetRecvCodecs(params.codecs)) { | 1482 if (!SetRecvCodecs(params.codecs)) { |
1492 return false; | 1483 return false; |
1493 } | 1484 } |
1494 | 1485 |
1495 std::vector<webrtc::RtpExtension> recv_rtp_extensions = | 1486 if (!ValidateRtpExtensions(params.extensions)) { |
1496 FindAudioRtpHeaderExtensions(params.extensions); | 1487 return false; |
1497 if (recv_rtp_extensions_ != recv_rtp_extensions) { | 1488 } |
1498 recv_rtp_extensions_.swap(recv_rtp_extensions); | 1489 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1490 FilterRtpExtensions(params.extensions, |
| 1491 webrtc::RtpExtension::IsSupportedForAudio, false); |
| 1492 if (recv_rtp_extensions_ != filtered_extensions) { |
| 1493 recv_rtp_extensions_.swap(filtered_extensions); |
1499 for (auto& it : recv_streams_) { | 1494 for (auto& it : recv_streams_) { |
1500 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); | 1495 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); |
1501 } | 1496 } |
1502 } | 1497 } |
1503 | 1498 |
1504 return true; | 1499 return true; |
1505 } | 1500 } |
1506 | 1501 |
1507 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { | 1502 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { |
1508 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1503 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 } | 2657 } |
2663 } else { | 2658 } else { |
2664 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2659 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2665 engine()->voe()->base()->StopPlayout(channel); | 2660 engine()->voe()->base()->StopPlayout(channel); |
2666 } | 2661 } |
2667 return true; | 2662 return true; |
2668 } | 2663 } |
2669 } // namespace cricket | 2664 } // namespace cricket |
2670 | 2665 |
2671 #endif // HAVE_WEBRTC_VOICE | 2666 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |