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

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

Issue 1325023005: Remove Channel::SetRingbackTone() and Channel::PlayRingbackTone(), and the code beneath it (within … (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 3 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
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 // Do not return if fails. SetOutputVolumePan is not available for all 2853 // Do not return if fails. SetOutputVolumePan is not available for all
2854 // pltforms. 2854 // pltforms.
2855 } 2855 }
2856 LOG(LS_INFO) << "SetOutputScaling to left=" << left * scale 2856 LOG(LS_INFO) << "SetOutputScaling to left=" << left * scale
2857 << " right=" << right * scale 2857 << " right=" << right * scale
2858 << " for channel " << ch_id << " and ssrc " << ssrc; 2858 << " for channel " << ch_id << " and ssrc " << ssrc;
2859 } 2859 }
2860 return true; 2860 return true;
2861 } 2861 }
2862 2862
2863 bool WebRtcVoiceMediaChannel::SetRingbackTone(const char *buf, int len) {
2864 ringback_tone_.reset(new WebRtcSoundclipStream(buf, len));
2865 return true;
2866 }
2867
2868 bool WebRtcVoiceMediaChannel::PlayRingbackTone(uint32 ssrc,
2869 bool play, bool loop) {
2870 if (!ringback_tone_) {
2871 return false;
2872 }
2873
2874 // The voe file api is not available in chrome.
2875 if (!engine()->voe()->file()) {
2876 return false;
2877 }
2878
2879 // Determine which VoiceEngine channel to play on.
2880 int channel = (ssrc == 0) ? voe_channel() : GetReceiveChannelNum(ssrc);
2881 if (channel == -1) {
2882 return false;
2883 }
2884
2885 // Make sure the ringtone is cued properly, and play it out.
2886 if (play) {
2887 ringback_tone_->set_loop(loop);
2888 ringback_tone_->Rewind();
2889 if (engine()->voe()->file()->StartPlayingFileLocally(channel,
2890 ringback_tone_.get()) == -1) {
2891 LOG_RTCERR2(StartPlayingFileLocally, channel, ringback_tone_.get());
2892 LOG(LS_ERROR) << "Unable to start ringback tone";
2893 return false;
2894 }
2895 ringback_channels_.insert(channel);
2896 LOG(LS_INFO) << "Started ringback on channel " << channel;
2897 } else {
2898 if (engine()->voe()->file()->IsPlayingFileLocally(channel) == 1 &&
2899 engine()->voe()->file()->StopPlayingFileLocally(channel) == -1) {
2900 LOG_RTCERR1(StopPlayingFileLocally, channel);
2901 return false;
2902 }
2903 LOG(LS_INFO) << "Stopped ringback on channel " << channel;
2904 ringback_channels_.erase(channel);
2905 }
2906
2907 return true;
2908 }
2909
2910 bool WebRtcVoiceMediaChannel::CanInsertDtmf() { 2863 bool WebRtcVoiceMediaChannel::CanInsertDtmf() {
2911 return dtmf_allowed_; 2864 return dtmf_allowed_;
2912 } 2865 }
2913 2866
2914 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event, 2867 bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event,
2915 int duration, int flags) { 2868 int duration, int flags) {
2916 if (!dtmf_allowed_) { 2869 if (!dtmf_allowed_) {
2917 return false; 2870 return false;
2918 } 2871 }
2919 2872
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 2927
2975 // Pick which channel to send this packet to. If this packet doesn't match 2928 // Pick which channel to send this packet to. If this packet doesn't match
2976 // any multiplexed streams, just send it to the default channel. Otherwise, 2929 // any multiplexed streams, just send it to the default channel. Otherwise,
2977 // send it to the specific decoder instance for that stream. 2930 // send it to the specific decoder instance for that stream.
2978 int which_channel = 2931 int which_channel =
2979 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false)); 2932 GetReceiveChannelNum(ParseSsrc(packet->data(), packet->size(), false));
2980 if (which_channel == -1) { 2933 if (which_channel == -1) {
2981 which_channel = voe_channel(); 2934 which_channel = voe_channel();
2982 } 2935 }
2983 2936
2984 // Stop any ringback that might be playing on the channel.
2985 // It's possible the ringback has already stopped, ih which case we'll just
2986 // use the opportunity to remove the channel from ringback_channels_.
2987 if (engine()->voe()->file()) {
2988 const std::set<int>::iterator it = ringback_channels_.find(which_channel);
2989 if (it != ringback_channels_.end()) {
2990 if (engine()->voe()->file()->IsPlayingFileLocally(
2991 which_channel) == 1) {
2992 engine()->voe()->file()->StopPlayingFileLocally(which_channel);
2993 LOG(LS_INFO) << "Stopped ringback on channel " << which_channel
2994 << " due to incoming media";
2995 }
2996 ringback_channels_.erase(which_channel);
2997 }
2998 }
2999
3000 // Pass it off to the decoder. 2937 // Pass it off to the decoder.
3001 engine()->voe()->network()->ReceivedRTPPacket( 2938 engine()->voe()->network()->ReceivedRTPPacket(
3002 which_channel, packet->data(), packet->size(), 2939 which_channel, packet->data(), packet->size(),
3003 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before)); 2940 webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
3004 } 2941 }
3005 2942
3006 void WebRtcVoiceMediaChannel::OnRtcpReceived( 2943 void WebRtcVoiceMediaChannel::OnRtcpReceived(
3007 rtc::Buffer* packet, const rtc::PacketTime& packet_time) { 2944 rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
3008 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 2945 RTC_DCHECK(thread_checker_.CalledOnValidThread());
3009 2946
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
3610 } 3547 }
3611 } 3548 }
3612 } else { 3549 } else {
3613 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 3550 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
3614 return false; 3551 return false;
3615 } 3552 }
3616 } 3553 }
3617 return true; 3554 return true;
3618 } 3555 }
3619 3556
3620 int WebRtcSoundclipStream::Read(void *buf, size_t len) {
3621 size_t res = 0;
3622 mem_.Read(buf, len, &res, NULL);
3623 return static_cast<int>(res);
3624 }
3625
3626 int WebRtcSoundclipStream::Rewind() {
3627 mem_.Rewind();
3628 // Return -1 to keep VoiceEngine from looping.
3629 return (loop_) ? 0 : -1;
3630 }
3631
3632 } // namespace cricket 3557 } // namespace cricket
3633 3558
3634 #endif // HAVE_WEBRTC_VOICE 3559 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.h ('k') | talk/media/webrtc/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698