Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 new webrtc::ExperimentalNs(experimental_ns)); 857 new webrtc::ExperimentalNs(experimental_ns));
858 } 858 }
859 859
860 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine 860 // We check audioproc for the benefit of tests, since FakeWebRtcVoiceEngine
861 // returns NULL on audio_processing(). 861 // returns NULL on audio_processing().
862 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing(); 862 webrtc::AudioProcessing* audioproc = voe_wrapper_->base()->audio_processing();
863 if (audioproc) { 863 if (audioproc) {
864 audioproc->SetExtraOptions(config); 864 audioproc->SetExtraOptions(config);
865 } 865 }
866 866
867 uint32 recording_sample_rate; 867 uint32_t recording_sample_rate;
868 if (options.recording_sample_rate.Get(&recording_sample_rate)) { 868 if (options.recording_sample_rate.Get(&recording_sample_rate)) {
869 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; 869 LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate;
870 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { 870 if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) {
871 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate); 871 LOG_RTCERR1(SetRecordingSampleRate, recording_sample_rate);
872 } 872 }
873 } 873 }
874 874
875 uint32 playout_sample_rate; 875 uint32_t playout_sample_rate;
876 if (options.playout_sample_rate.Get(&playout_sample_rate)) { 876 if (options.playout_sample_rate.Get(&playout_sample_rate)) {
877 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; 877 LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate;
878 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { 878 if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) {
879 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate); 879 LOG_RTCERR1(SetPlayoutSampleRate, playout_sample_rate);
880 } 880 }
881 } 881 }
882 882
883 return true; 883 return true;
884 } 884 }
885 885
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 std::string msg(trace + 71, length - 72); 1291 std::string msg(trace + 71, length - 72);
1292 if (!ShouldIgnoreTrace(msg)) { 1292 if (!ShouldIgnoreTrace(msg)) {
1293 LOG_V(sev) << "webrtc: " << msg; 1293 LOG_V(sev) << "webrtc: " << msg;
1294 } 1294 }
1295 } 1295 }
1296 } 1296 }
1297 1297
1298 void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) { 1298 void WebRtcVoiceEngine::CallbackOnError(int channel_num, int err_code) {
1299 rtc::CritScope lock(&channels_cs_); 1299 rtc::CritScope lock(&channels_cs_);
1300 WebRtcVoiceMediaChannel* channel = NULL; 1300 WebRtcVoiceMediaChannel* channel = NULL;
1301 uint32 ssrc = 0; 1301 uint32_t ssrc = 0;
1302 LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel " 1302 LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel "
1303 << channel_num << "."; 1303 << channel_num << ".";
1304 if (FindChannelAndSsrc(channel_num, &channel, &ssrc)) { 1304 if (FindChannelAndSsrc(channel_num, &channel, &ssrc)) {
1305 RTC_DCHECK(channel != NULL); 1305 RTC_DCHECK(channel != NULL);
1306 channel->OnError(ssrc, err_code); 1306 channel->OnError(ssrc, err_code);
1307 } else { 1307 } else {
1308 LOG(LS_ERROR) << "VoiceEngine channel " << channel_num 1308 LOG(LS_ERROR) << "VoiceEngine channel " << channel_num
1309 << " could not be found in channel list when error reported."; 1309 << " could not be found in channel list when error reported.";
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 bool WebRtcVoiceEngine::FindChannelAndSsrc( 1313 bool WebRtcVoiceEngine::FindChannelAndSsrc(int channel_num,
1314 int channel_num, WebRtcVoiceMediaChannel** channel, uint32* ssrc) const { 1314 WebRtcVoiceMediaChannel** channel,
1315 uint32_t* ssrc) const {
1315 RTC_DCHECK(channel != NULL && ssrc != NULL); 1316 RTC_DCHECK(channel != NULL && ssrc != NULL);
1316 1317
1317 *channel = NULL; 1318 *channel = NULL;
1318 *ssrc = 0; 1319 *ssrc = 0;
1319 // Find corresponding channel and ssrc 1320 // Find corresponding channel and ssrc
1320 for (WebRtcVoiceMediaChannel* ch : channels_) { 1321 for (WebRtcVoiceMediaChannel* ch : channels_) {
1321 RTC_DCHECK(ch != NULL); 1322 RTC_DCHECK(ch != NULL);
1322 if (ch->FindSsrc(channel_num, ssrc)) { 1323 if (ch->FindSsrc(channel_num, ssrc)) {
1323 *channel = ch; 1324 *channel = ch;
1324 return true; 1325 return true;
1325 } 1326 }
1326 } 1327 }
1327 1328
1328 return false; 1329 return false;
1329 } 1330 }
1330 1331
1331 // This method will search through the WebRtcVoiceMediaChannels and 1332 // This method will search through the WebRtcVoiceMediaChannels and
1332 // obtain the voice engine's channel number. 1333 // obtain the voice engine's channel number.
1333 bool WebRtcVoiceEngine::FindChannelNumFromSsrc( 1334 bool WebRtcVoiceEngine::FindChannelNumFromSsrc(
1334 uint32 ssrc, MediaProcessorDirection direction, int* channel_num) { 1335 uint32_t ssrc,
1336 MediaProcessorDirection direction,
1337 int* channel_num) {
1335 RTC_DCHECK(channel_num != NULL); 1338 RTC_DCHECK(channel_num != NULL);
1336 RTC_DCHECK(direction == MPD_RX || direction == MPD_TX); 1339 RTC_DCHECK(direction == MPD_RX || direction == MPD_TX);
1337 1340
1338 *channel_num = -1; 1341 *channel_num = -1;
1339 // Find corresponding channel for ssrc. 1342 // Find corresponding channel for ssrc.
1340 for (const WebRtcVoiceMediaChannel* ch : channels_) { 1343 for (const WebRtcVoiceMediaChannel* ch : channels_) {
1341 RTC_DCHECK(ch != NULL); 1344 RTC_DCHECK(ch != NULL);
1342 if (direction & MPD_RX) { 1345 if (direction & MPD_RX) {
1343 *channel_num = ch->GetReceiveChannelNum(ssrc); 1346 *channel_num = ch->GetReceiveChannelNum(ssrc);
1344 } 1347 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 if (voe_wrapper_->processing()->StartDebugRecording(aec_dump_file_stream) != 1417 if (voe_wrapper_->processing()->StartDebugRecording(aec_dump_file_stream) !=
1415 webrtc::AudioProcessing::kNoError) { 1418 webrtc::AudioProcessing::kNoError) {
1416 LOG_RTCERR0(StartDebugRecording); 1419 LOG_RTCERR0(StartDebugRecording);
1417 fclose(aec_dump_file_stream); 1420 fclose(aec_dump_file_stream);
1418 return false; 1421 return false;
1419 } 1422 }
1420 is_dumping_aec_ = true; 1423 is_dumping_aec_ = true;
1421 return true; 1424 return true;
1422 } 1425 }
1423 1426
1424 bool WebRtcVoiceEngine::RegisterProcessor( 1427 bool WebRtcVoiceEngine::RegisterProcessor(uint32_t ssrc,
1425 uint32 ssrc, 1428 VoiceProcessor* voice_processor,
1426 VoiceProcessor* voice_processor, 1429 MediaProcessorDirection direction) {
1427 MediaProcessorDirection direction) {
1428 bool register_with_webrtc = false; 1430 bool register_with_webrtc = false;
1429 int channel_id = -1; 1431 int channel_id = -1;
1430 bool success = false; 1432 bool success = false;
1431 uint32* processor_ssrc = NULL; 1433 uint32_t* processor_ssrc = NULL;
1432 bool found_channel = FindChannelNumFromSsrc(ssrc, direction, &channel_id); 1434 bool found_channel = FindChannelNumFromSsrc(ssrc, direction, &channel_id);
1433 if (voice_processor == NULL || !found_channel) { 1435 if (voice_processor == NULL || !found_channel) {
1434 LOG(LS_WARNING) << "Media Processing Registration Failed. ssrc: " << ssrc 1436 LOG(LS_WARNING) << "Media Processing Registration Failed. ssrc: " << ssrc
1435 << " foundChannel: " << found_channel; 1437 << " foundChannel: " << found_channel;
1436 return false; 1438 return false;
1437 } 1439 }
1438 1440
1439 webrtc::ProcessingTypes processing_type; 1441 webrtc::ProcessingTypes processing_type;
1440 { 1442 {
1441 rtc::CritScope cs(&signal_media_critical_); 1443 rtc::CritScope cs(&signal_media_critical_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 } else { 1479 } else {
1478 // If we don't have to register with the engine, we just needed to 1480 // If we don't have to register with the engine, we just needed to
1479 // connect a new processor, set success to true; 1481 // connect a new processor, set success to true;
1480 success = true; 1482 success = true;
1481 } 1483 }
1482 return success; 1484 return success;
1483 } 1485 }
1484 1486
1485 bool WebRtcVoiceEngine::UnregisterProcessorChannel( 1487 bool WebRtcVoiceEngine::UnregisterProcessorChannel(
1486 MediaProcessorDirection channel_direction, 1488 MediaProcessorDirection channel_direction,
1487 uint32 ssrc, 1489 uint32_t ssrc,
1488 VoiceProcessor* voice_processor, 1490 VoiceProcessor* voice_processor,
1489 MediaProcessorDirection processor_direction) { 1491 MediaProcessorDirection processor_direction) {
1490 bool success = true; 1492 bool success = true;
1491 FrameSignal* signal; 1493 FrameSignal* signal;
1492 webrtc::ProcessingTypes processing_type; 1494 webrtc::ProcessingTypes processing_type;
1493 uint32* processor_ssrc = NULL; 1495 uint32_t* processor_ssrc = NULL;
1494 if (channel_direction == MPD_RX) { 1496 if (channel_direction == MPD_RX) {
1495 signal = &SignalRxMediaFrame; 1497 signal = &SignalRxMediaFrame;
1496 processing_type = webrtc::kPlaybackAllChannelsMixed; 1498 processing_type = webrtc::kPlaybackAllChannelsMixed;
1497 processor_ssrc = &rx_processor_ssrc_; 1499 processor_ssrc = &rx_processor_ssrc_;
1498 } else { 1500 } else {
1499 signal = &SignalTxMediaFrame; 1501 signal = &SignalTxMediaFrame;
1500 processing_type = webrtc::kRecordingPerChannel; 1502 processing_type = webrtc::kRecordingPerChannel;
1501 processor_ssrc = &tx_processor_ssrc_; 1503 processor_ssrc = &tx_processor_ssrc_;
1502 } 1504 }
1503 1505
(...skipping 21 matching lines...) Expand all
1525 } else { 1527 } else {
1526 LOG_RTCERR2(DeRegisterExternalMediaProcessing, 1528 LOG_RTCERR2(DeRegisterExternalMediaProcessing,
1527 deregister_id, 1529 deregister_id,
1528 processing_type); 1530 processing_type);
1529 success = false; 1531 success = false;
1530 } 1532 }
1531 } 1533 }
1532 return success; 1534 return success;
1533 } 1535 }
1534 1536
1535 bool WebRtcVoiceEngine::UnregisterProcessor( 1537 bool WebRtcVoiceEngine::UnregisterProcessor(uint32_t ssrc,
1536 uint32 ssrc, 1538 VoiceProcessor* voice_processor,
1537 VoiceProcessor* voice_processor, 1539 MediaProcessorDirection direction) {
1538 MediaProcessorDirection direction) {
1539 bool success = true; 1540 bool success = true;
1540 if (voice_processor == NULL) { 1541 if (voice_processor == NULL) {
1541 LOG(LS_WARNING) << "Media Processing Deregistration Failed. ssrc: " 1542 LOG(LS_WARNING) << "Media Processing Deregistration Failed. ssrc: "
1542 << ssrc; 1543 << ssrc;
1543 return false; 1544 return false;
1544 } 1545 }
1545 if (!UnregisterProcessorChannel(MPD_RX, ssrc, voice_processor, direction)) { 1546 if (!UnregisterProcessorChannel(MPD_RX, ssrc, voice_processor, direction)) {
1546 success = false; 1547 success = false;
1547 } 1548 }
1548 if (!UnregisterProcessorChannel(MPD_TX, ssrc, voice_processor, direction)) { 1549 if (!UnregisterProcessorChannel(MPD_TX, ssrc, voice_processor, direction)) {
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 RTC_DCHECK(send == SEND_NOTHING); 2369 RTC_DCHECK(send == SEND_NOTHING);
2369 if (engine()->voe()->base()->StopSend(channel) == -1) { 2370 if (engine()->voe()->base()->StopSend(channel) == -1) {
2370 LOG_RTCERR1(StopSend, channel); 2371 LOG_RTCERR1(StopSend, channel);
2371 return false; 2372 return false;
2372 } 2373 }
2373 } 2374 }
2374 2375
2375 return true; 2376 return true;
2376 } 2377 }
2377 2378
2378 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32 ssrc, bool mute, 2379 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
2380 bool mute,
2379 const AudioOptions* options, 2381 const AudioOptions* options,
2380 AudioRenderer* renderer) { 2382 AudioRenderer* renderer) {
2381 // TODO(solenberg): The state change should be fully rolled back if any one of 2383 // TODO(solenberg): The state change should be fully rolled back if any one of
2382 // these calls fail. 2384 // these calls fail.
2383 if (!SetLocalRenderer(ssrc, renderer)) { 2385 if (!SetLocalRenderer(ssrc, renderer)) {
2384 return false; 2386 return false;
2385 } 2387 }
2386 if (!MuteStream(ssrc, mute)) { 2388 if (!MuteStream(ssrc, mute)) {
2387 return false; 2389 return false;
2388 } 2390 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2490 return false; 2492 return false;
2491 } 2493 }
2492 2494
2493 // Set the current codecs to be used for the new channel. 2495 // Set the current codecs to be used for the new channel.
2494 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_)) 2496 if (!send_codecs_.empty() && !SetSendCodecs(channel, send_codecs_))
2495 return false; 2497 return false;
2496 2498
2497 return ChangeSend(channel, desired_send_); 2499 return ChangeSend(channel, desired_send_);
2498 } 2500 }
2499 2501
2500 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32 ssrc) { 2502 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
2501 ChannelMap::iterator it = send_channels_.find(ssrc); 2503 ChannelMap::iterator it = send_channels_.find(ssrc);
2502 if (it == send_channels_.end()) { 2504 if (it == send_channels_.end()) {
2503 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc 2505 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
2504 << " which doesn't exist."; 2506 << " which doesn't exist.";
2505 return false; 2507 return false;
2506 } 2508 }
2507 2509
2508 int channel = it->second->channel(); 2510 int channel = it->second->channel();
2509 ChangeSend(channel, SEND_NOTHING); 2511 ChangeSend(channel, SEND_NOTHING);
2510 2512
(...skipping 19 matching lines...) Expand all
2530 2532
2531 return true; 2533 return true;
2532 } 2534 }
2533 2535
2534 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { 2536 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
2535 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 2537 RTC_DCHECK(thread_checker_.CalledOnValidThread());
2536 rtc::CritScope lock(&receive_channels_cs_); 2538 rtc::CritScope lock(&receive_channels_cs_);
2537 2539
2538 if (!VERIFY(sp.ssrcs.size() == 1)) 2540 if (!VERIFY(sp.ssrcs.size() == 1))
2539 return false; 2541 return false;
2540 uint32 ssrc = sp.first_ssrc(); 2542 uint32_t ssrc = sp.first_ssrc();
2541 2543
2542 if (ssrc == 0) { 2544 if (ssrc == 0) {
2543 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; 2545 LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported.";
2544 return false; 2546 return false;
2545 } 2547 }
2546 2548
2547 if (receive_channels_.find(ssrc) != receive_channels_.end()) { 2549 if (receive_channels_.find(ssrc) != receive_channels_.end()) {
2548 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc; 2550 LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc;
2549 return false; 2551 return false;
2550 } 2552 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 SetNack(channel, nack_enabled_); 2656 SetNack(channel, nack_enabled_);
2655 2657
2656 // Set RTP header extension for the new channel. 2658 // Set RTP header extension for the new channel.
2657 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) { 2659 if (!SetChannelRecvRtpHeaderExtensions(channel, receive_extensions_)) {
2658 return false; 2660 return false;
2659 } 2661 }
2660 2662
2661 return SetPlayout(channel, playout_); 2663 return SetPlayout(channel, playout_);
2662 } 2664 }
2663 2665
2664 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { 2666 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
2665 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 2667 RTC_DCHECK(thread_checker_.CalledOnValidThread());
2666 rtc::CritScope lock(&receive_channels_cs_); 2668 rtc::CritScope lock(&receive_channels_cs_);
2667 ChannelMap::iterator it = receive_channels_.find(ssrc); 2669 ChannelMap::iterator it = receive_channels_.find(ssrc);
2668 if (it == receive_channels_.end()) { 2670 if (it == receive_channels_.end()) {
2669 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc 2671 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
2670 << " which doesn't exist."; 2672 << " which doesn't exist.";
2671 return false; 2673 return false;
2672 } 2674 }
2673 2675
2674 RemoveAudioReceiveStream(ssrc); 2676 RemoveAudioReceiveStream(ssrc);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 enable_default_channel_playout = true; 2714 enable_default_channel_playout = true;
2713 } 2715 }
2714 if (enable_default_channel_playout && playout_) { 2716 if (enable_default_channel_playout && playout_) {
2715 LOG(LS_INFO) << "Enabling playback on the default voice channel"; 2717 LOG(LS_INFO) << "Enabling playback on the default voice channel";
2716 SetPlayout(voe_channel(), true); 2718 SetPlayout(voe_channel(), true);
2717 } 2719 }
2718 2720
2719 return true; 2721 return true;
2720 } 2722 }
2721 2723
2722 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32 ssrc, 2724 bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32_t ssrc,
2723 AudioRenderer* renderer) { 2725 AudioRenderer* renderer) {
2724 ChannelMap::iterator it = receive_channels_.find(ssrc); 2726 ChannelMap::iterator it = receive_channels_.find(ssrc);
2725 if (it == receive_channels_.end()) { 2727 if (it == receive_channels_.end()) {
2726 if (renderer) { 2728 if (renderer) {
2727 // Return an error if trying to set a valid renderer with an invalid ssrc. 2729 // Return an error if trying to set a valid renderer with an invalid ssrc.
2728 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc; 2730 LOG(LS_ERROR) << "SetRemoteRenderer failed with ssrc "<< ssrc;
2729 return false; 2731 return false;
2730 } 2732 }
2731 2733
2732 // The channel likely has gone away, do nothing. 2734 // The channel likely has gone away, do nothing.
2733 return true; 2735 return true;
2734 } 2736 }
2735 2737
2736 if (renderer) 2738 if (renderer)
2737 it->second->Start(renderer); 2739 it->second->Start(renderer);
2738 else 2740 else
2739 it->second->Stop(); 2741 it->second->Stop();
2740 2742
2741 return true; 2743 return true;
2742 } 2744 }
2743 2745
2744 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32 ssrc, 2746 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc,
2745 AudioRenderer* renderer) { 2747 AudioRenderer* renderer) {
2746 ChannelMap::iterator it = send_channels_.find(ssrc); 2748 ChannelMap::iterator it = send_channels_.find(ssrc);
2747 if (it == send_channels_.end()) { 2749 if (it == send_channels_.end()) {
2748 if (renderer) { 2750 if (renderer) {
2749 // Return an error if trying to set a valid renderer with an invalid ssrc. 2751 // Return an error if trying to set a valid renderer with an invalid ssrc.
2750 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; 2752 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc;
2751 return false; 2753 return false;
2752 } 2754 }
2753 2755
2754 // The channel likely has gone away, do nothing. 2756 // The channel likely has gone away, do nothing.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 if (engine()->voe()->processing()->SetTypingDetectionParameters( 2807 if (engine()->voe()->processing()->SetTypingDetectionParameters(
2806 time_window, cost_per_typing, 2808 time_window, cost_per_typing,
2807 reporting_threshold, penalty_decay, type_event_delay) == -1) { 2809 reporting_threshold, penalty_decay, type_event_delay) == -1) {
2808 // In case of error, log the info and continue 2810 // In case of error, log the info and continue
2809 LOG_RTCERR5(SetTypingDetectionParameters, time_window, 2811 LOG_RTCERR5(SetTypingDetectionParameters, time_window,
2810 cost_per_typing, reporting_threshold, penalty_decay, 2812 cost_per_typing, reporting_threshold, penalty_decay,
2811 type_event_delay); 2813 type_event_delay);
2812 } 2814 }
2813 } 2815 }
2814 2816
2815 bool WebRtcVoiceMediaChannel::SetOutputScaling( 2817 bool WebRtcVoiceMediaChannel::SetOutputScaling(uint32_t ssrc,
2816 uint32 ssrc, double left, double right) { 2818 double left,
2819 double right) {
2817 rtc::CritScope lock(&receive_channels_cs_); 2820 rtc::CritScope lock(&receive_channels_cs_);
2818 // Collect the channels to scale the output volume. 2821 // Collect the channels to scale the output volume.
2819 std::vector<int> channels; 2822 std::vector<int> channels;
2820 if (0 == ssrc) { // Collect all channels, including the default one. 2823 if (0 == ssrc) { // Collect all channels, including the default one.
2821 // Default channel is not in receive_channels_ if it is not being used for 2824 // Default channel is not in receive_channels_ if it is not being used for
2822 // playout. 2825 // playout.
2823 if (default_receive_ssrc_ == 0) 2826 if (default_receive_ssrc_ == 0)
2824 channels.push_back(voe_channel()); 2827 channels.push_back(voe_channel());
2825 for (const auto& ch : receive_channels_) { 2828 for (const auto& ch : receive_channels_) {
2826 channels.push_back(ch.second->channel()); 2829 channels.push_back(ch.second->channel());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 << " for channel " << ch_id << " and ssrc " << ssrc; 2861 << " for channel " << ch_id << " and ssrc " << ssrc;
2859 } 2862 }
2860 return true; 2863 return true;
2861 } 2864 }
2862 2865
2863 bool WebRtcVoiceMediaChannel::SetRingbackTone(const char *buf, int len) { 2866 bool WebRtcVoiceMediaChannel::SetRingbackTone(const char *buf, int len) {
2864 ringback_tone_.reset(new WebRtcSoundclipStream(buf, len)); 2867 ringback_tone_.reset(new WebRtcSoundclipStream(buf, len));
2865 return true; 2868 return true;
2866 } 2869 }
2867 2870
2868 bool WebRtcVoiceMediaChannel::PlayRingbackTone(uint32 ssrc, 2871 bool WebRtcVoiceMediaChannel::PlayRingbackTone(uint32_t ssrc,
2869 bool play, bool loop) { 2872 bool play,
2873 bool loop) {
2870 if (!ringback_tone_) { 2874 if (!ringback_tone_) {
2871 return false; 2875 return false;
2872 } 2876 }
2873 2877
2874 // The voe file api is not available in chrome. 2878 // The voe file api is not available in chrome.
2875 if (!engine()->voe()->file()) { 2879 if (!engine()->voe()->file()) {
2876 return false; 2880 return false;
2877 } 2881 }
2878 2882
2879 // Determine which VoiceEngine channel to play on. 2883 // Determine which VoiceEngine channel to play on.
(...skipping 24 matching lines...) Expand all
2904 ringback_channels_.erase(channel); 2908 ringback_channels_.erase(channel);
2905 } 2909 }
2906 2910
2907 return true; 2911 return true;
2908 } 2912 }
2909 2913
2910 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { 2914 bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
2911 return dtmf_allowed_; 2915 return dtmf_allowed_;
2912 } 2916 }
2913 2917
2914 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event, 2918 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc,
2915 int duration, int flags) { 2919 int event,
2920 int duration,
2921 int flags) {
2916 if (!dtmf_allowed_) { 2922 if (!dtmf_allowed_) {
2917 return false; 2923 return false;
2918 } 2924 }
2919 2925
2920 // Send the event. 2926 // Send the event.
2921 if (flags & cricket::DF_SEND) { 2927 if (flags & cricket::DF_SEND) {
2922 int channel = -1; 2928 int channel = -1;
2923 if (ssrc == 0) { 2929 if (ssrc == 0) {
2924 bool default_channel_is_inuse = false; 2930 bool default_channel_is_inuse = false;
2925 for (const auto& ch : send_channels_) { 2931 for (const auto& ch : send_channels_) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 // Make sure not sending the same packet to default channel more than once. 3051 // Make sure not sending the same packet to default channel more than once.
3046 if (IsDefaultChannel(ch.second->channel()) && 3052 if (IsDefaultChannel(ch.second->channel()) &&
3047 has_sent_to_default_channel) 3053 has_sent_to_default_channel)
3048 continue; 3054 continue;
3049 3055
3050 engine()->voe()->network()->ReceivedRTCPPacket( 3056 engine()->voe()->network()->ReceivedRTCPPacket(
3051 ch.second->channel(), packet->data(), packet->size()); 3057 ch.second->channel(), packet->data(), packet->size());
3052 } 3058 }
3053 } 3059 }
3054 3060
3055 bool WebRtcVoiceMediaChannel::MuteStream(uint32 ssrc, bool muted) { 3061 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) {
3056 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc); 3062 int channel = (ssrc == 0) ? voe_channel() : GetSendChannelNum(ssrc);
3057 if (channel == -1) { 3063 if (channel == -1) {
3058 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; 3064 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use.";
3059 return false; 3065 return false;
3060 } 3066 }
3061 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { 3067 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) {
3062 LOG_RTCERR2(SetInputMute, channel, muted); 3068 LOG_RTCERR2(SetInputMute, channel, muted);
3063 return false; 3069 return false;
3064 } 3070 }
3065 // We set the AGC to mute state only when all the channels are muted. 3071 // We set the AGC to mute state only when all the channels are muted.
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 rinfo.audio_level = (engine()->voe()->volume()-> 3323 rinfo.audio_level = (engine()->voe()->volume()->
3318 GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1; 3324 GetSpeechOutputLevelFullRange(ch_id, level) != -1) ? level : -1;
3319 info->receivers.push_back(rinfo); 3325 info->receivers.push_back(rinfo);
3320 } 3326 }
3321 } 3327 }
3322 3328
3323 return true; 3329 return true;
3324 } 3330 }
3325 3331
3326 void WebRtcVoiceMediaChannel::GetLastMediaError( 3332 void WebRtcVoiceMediaChannel::GetLastMediaError(
3327 uint32* ssrc, VoiceMediaChannel::Error* error) { 3333 uint32_t* ssrc,
3334 VoiceMediaChannel::Error* error) {
3328 RTC_DCHECK(ssrc != NULL); 3335 RTC_DCHECK(ssrc != NULL);
3329 RTC_DCHECK(error != NULL); 3336 RTC_DCHECK(error != NULL);
3330 FindSsrc(voe_channel(), ssrc); 3337 FindSsrc(voe_channel(), ssrc);
3331 *error = WebRtcErrorToChannelError(GetLastEngineError()); 3338 *error = WebRtcErrorToChannelError(GetLastEngineError());
3332 } 3339 }
3333 3340
3334 bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32* ssrc) { 3341 bool WebRtcVoiceMediaChannel::FindSsrc(int channel_num, uint32_t* ssrc) {
3335 rtc::CritScope lock(&receive_channels_cs_); 3342 rtc::CritScope lock(&receive_channels_cs_);
3336 RTC_DCHECK(ssrc != NULL); 3343 RTC_DCHECK(ssrc != NULL);
3337 if (channel_num == -1 && send_ != SEND_NOTHING) { 3344 if (channel_num == -1 && send_ != SEND_NOTHING) {
3338 // Sometimes the VoiceEngine core will throw error with channel_num = -1. 3345 // Sometimes the VoiceEngine core will throw error with channel_num = -1.
3339 // This means the error is not limited to a specific channel. Signal the 3346 // This means the error is not limited to a specific channel. Signal the
3340 // message using ssrc=0. If the current channel is sending, use this 3347 // message using ssrc=0. If the current channel is sending, use this
3341 // channel for sending the message. 3348 // channel for sending the message.
3342 *ssrc = 0; 3349 *ssrc = 0;
3343 return true; 3350 return true;
3344 } else { 3351 } else {
3345 // Check whether this is a sending channel. 3352 // Check whether this is a sending channel.
3346 for (const auto& ch : send_channels_) { 3353 for (const auto& ch : send_channels_) {
3347 if (ch.second->channel() == channel_num) { 3354 if (ch.second->channel() == channel_num) {
3348 // This is a sending channel. 3355 // This is a sending channel.
3349 uint32 local_ssrc = 0; 3356 uint32_t local_ssrc = 0;
3350 if (engine()->voe()->rtp()->GetLocalSSRC( 3357 if (engine()->voe()->rtp()->GetLocalSSRC(
3351 channel_num, local_ssrc) != -1) { 3358 channel_num, local_ssrc) != -1) {
3352 *ssrc = local_ssrc; 3359 *ssrc = local_ssrc;
3353 } 3360 }
3354 return true; 3361 return true;
3355 } 3362 }
3356 } 3363 }
3357 3364
3358 // Check whether this is a receiving channel. 3365 // Check whether this is a receiving channel.
3359 for (const auto& ch : receive_channels_) { 3366 for (const auto& ch : receive_channels_) {
3360 if (ch.second->channel() == channel_num) { 3367 if (ch.second->channel() == channel_num) {
3361 *ssrc = ch.first; 3368 *ssrc = ch.first;
3362 return true; 3369 return true;
3363 } 3370 }
3364 } 3371 }
3365 } 3372 }
3366 return false; 3373 return false;
3367 } 3374 }
3368 3375
3369 void WebRtcVoiceMediaChannel::OnError(uint32 ssrc, int error) { 3376 void WebRtcVoiceMediaChannel::OnError(uint32_t ssrc, int error) {
3370 if (error == VE_TYPING_NOISE_WARNING) { 3377 if (error == VE_TYPING_NOISE_WARNING) {
3371 typing_noise_detected_ = true; 3378 typing_noise_detected_ = true;
3372 } else if (error == VE_TYPING_NOISE_OFF_WARNING) { 3379 } else if (error == VE_TYPING_NOISE_OFF_WARNING) {
3373 typing_noise_detected_ = false; 3380 typing_noise_detected_ = false;
3374 } 3381 }
3375 SignalMediaError(ssrc, WebRtcErrorToChannelError(error)); 3382 SignalMediaError(ssrc, WebRtcErrorToChannelError(error));
3376 } 3383 }
3377 3384
3378 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { 3385 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
3379 unsigned int ulevel; 3386 unsigned int ulevel;
3380 int ret = 3387 int ret =
3381 engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); 3388 engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel);
3382 return (ret == 0) ? static_cast<int>(ulevel) : -1; 3389 return (ret == 0) ? static_cast<int>(ulevel) : -1;
3383 } 3390 }
3384 3391
3385 int WebRtcVoiceMediaChannel::GetReceiveChannelNum(uint32 ssrc) const { 3392 int WebRtcVoiceMediaChannel::GetReceiveChannelNum(uint32_t ssrc) const {
3386 ChannelMap::const_iterator it = receive_channels_.find(ssrc); 3393 ChannelMap::const_iterator it = receive_channels_.find(ssrc);
3387 if (it != receive_channels_.end()) 3394 if (it != receive_channels_.end())
3388 return it->second->channel(); 3395 return it->second->channel();
3389 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; 3396 return (ssrc == default_receive_ssrc_) ? voe_channel() : -1;
3390 } 3397 }
3391 3398
3392 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32 ssrc) const { 3399 int WebRtcVoiceMediaChannel::GetSendChannelNum(uint32_t ssrc) const {
3393 ChannelMap::const_iterator it = send_channels_.find(ssrc); 3400 ChannelMap::const_iterator it = send_channels_.find(ssrc);
3394 if (it != send_channels_.end()) 3401 if (it != send_channels_.end())
3395 return it->second->channel(); 3402 return it->second->channel();
3396 3403
3397 return -1; 3404 return -1;
3398 } 3405 }
3399 3406
3400 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec, 3407 bool WebRtcVoiceMediaChannel::GetRedSendCodec(const AudioCodec& red_codec,
3401 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) { 3408 const std::vector<AudioCodec>& all_codecs, webrtc::CodecInst* send_codec) {
3402 // Get the RED encodings from the parameter with no name. This may 3409 // Get the RED encodings from the parameter with no name. This may
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 LOG_RTCERR1(StartPlayout, channel); 3483 LOG_RTCERR1(StartPlayout, channel);
3477 return false; 3484 return false;
3478 } 3485 }
3479 } else { 3486 } else {
3480 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 3487 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
3481 engine()->voe()->base()->StopPlayout(channel); 3488 engine()->voe()->base()->StopPlayout(channel);
3482 } 3489 }
3483 return true; 3490 return true;
3484 } 3491 }
3485 3492
3486 uint32 WebRtcVoiceMediaChannel::ParseSsrc(const void* data, size_t len, 3493 uint32_t WebRtcVoiceMediaChannel::ParseSsrc(const void* data,
3487 bool rtcp) { 3494 size_t len,
3495 bool rtcp) {
3488 size_t ssrc_pos = (!rtcp) ? 8 : 4; 3496 size_t ssrc_pos = (!rtcp) ? 8 : 4;
3489 uint32 ssrc = 0; 3497 uint32_t ssrc = 0;
3490 if (len >= (ssrc_pos + sizeof(ssrc))) { 3498 if (len >= (ssrc_pos + sizeof(ssrc))) {
3491 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos); 3499 ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos);
3492 } 3500 }
3493 return ssrc; 3501 return ssrc;
3494 } 3502 }
3495 3503
3496 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. 3504 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum.
3497 VoiceMediaChannel::Error 3505 VoiceMediaChannel::Error
3498 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { 3506 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) {
3499 switch (err_code) { 3507 switch (err_code) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3546 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { 3554 void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() {
3547 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 3555 RTC_DCHECK(thread_checker_.CalledOnValidThread());
3548 for (const auto& it : receive_channels_) { 3556 for (const auto& it : receive_channels_) {
3549 RemoveAudioReceiveStream(it.first); 3557 RemoveAudioReceiveStream(it.first);
3550 } 3558 }
3551 for (const auto& it : receive_channels_) { 3559 for (const auto& it : receive_channels_) {
3552 AddAudioReceiveStream(it.first); 3560 AddAudioReceiveStream(it.first);
3553 } 3561 }
3554 } 3562 }
3555 3563
3556 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { 3564 void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) {
3557 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 3565 RTC_DCHECK(thread_checker_.CalledOnValidThread());
3558 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; 3566 WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc];
3559 RTC_DCHECK(channel != nullptr); 3567 RTC_DCHECK(channel != nullptr);
3560 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end()); 3568 RTC_DCHECK(receive_streams_.find(ssrc) == receive_streams_.end());
3561 webrtc::AudioReceiveStream::Config config; 3569 webrtc::AudioReceiveStream::Config config;
3562 config.rtp.remote_ssrc = ssrc; 3570 config.rtp.remote_ssrc = ssrc;
3563 // Only add RTP extensions if we support combined A/V BWE. 3571 // Only add RTP extensions if we support combined A/V BWE.
3564 config.rtp.extensions = recv_rtp_extensions_; 3572 config.rtp.extensions = recv_rtp_extensions_;
3565 config.combined_audio_video_bwe = 3573 config.combined_audio_video_bwe =
3566 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false); 3574 options_.combined_audio_video_bwe.GetWithDefaultIfUnset(false);
3567 config.voe_channel_id = channel->channel(); 3575 config.voe_channel_id = channel->channel();
3568 config.sync_group = receive_stream_params_[ssrc].sync_label; 3576 config.sync_group = receive_stream_params_[ssrc].sync_label;
3569 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config); 3577 webrtc::AudioReceiveStream* s = call_->CreateAudioReceiveStream(config);
3570 receive_streams_.insert(std::make_pair(ssrc, s)); 3578 receive_streams_.insert(std::make_pair(ssrc, s));
3571 } 3579 }
3572 3580
3573 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { 3581 void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) {
3574 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 3582 RTC_DCHECK(thread_checker_.CalledOnValidThread());
3575 auto stream_it = receive_streams_.find(ssrc); 3583 auto stream_it = receive_streams_.find(ssrc);
3576 if (stream_it != receive_streams_.end()) { 3584 if (stream_it != receive_streams_.end()) {
3577 call_->DestroyAudioReceiveStream(stream_it->second); 3585 call_->DestroyAudioReceiveStream(stream_it->second);
3578 receive_streams_.erase(stream_it); 3586 receive_streams_.erase(stream_it);
3579 } 3587 }
3580 } 3588 }
3581 3589
3582 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal( 3590 bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal(
3583 const std::vector<AudioCodec>& new_codecs) { 3591 const std::vector<AudioCodec>& new_codecs) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3625 3633
3626 int WebRtcSoundclipStream::Rewind() { 3634 int WebRtcSoundclipStream::Rewind() {
3627 mem_.Rewind(); 3635 mem_.Rewind();
3628 // Return -1 to keep VoiceEngine from looping. 3636 // Return -1 to keep VoiceEngine from looping.
3629 return (loop_) ? 0 : -1; 3637 return (loop_) ? 0 : -1;
3630 } 3638 }
3631 3639
3632 } // namespace cricket 3640 } // namespace cricket
3633 3641
3634 #endif // HAVE_WEBRTC_VOICE 3642 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698