lukeweber / webrtc-jingle-client

Webrtc audio + jingle protocol brought to IOS and Android.
https://groups.google.com/forum/?fromgroups#!forum/webrtc-jingle
BSD 3-Clause "New" or "Revised" License
336 stars 136 forks source link

WebRtcVoiceMediaChannel::SetRingbackTone (or how to play ringing sound?) #97

Closed seankovacs closed 11 years ago

seankovacs commented 11 years ago

Has anyone implemented this? Can't figure out how to implement. I added this method to call.cc in the libjingle library:

void Call::PlayRingbackTone(Session* session, const std::string& file) { VoiceChannel* voice_channel = GetVoiceChannel(session); if (voice_channel) { voice_channel->SetRingbackTone(file.c_str(), strlen(file.c_str())); voice_channel->PlayRingbackTone(0, true, true); } }

And I'm sending it a valid path for a WAV file, and I am getting this on the debug output:

Changing voice state, recv=0 send=0 ------- OnSignalCallStateChange Call_id -1766528965 Playing ringback tone, loop=1 Started ringback on channel 0

But I hear nothing when placing a call. I have it call the method Call::PlayRingbackTone once the call is created. I'll keep fiddling with it, but I'm just surprised nobody has implemented this (can't find any examples on the internet).

I'm assuming this plays a ringing sound or whatever WAV file I provided.

lukeweber commented 11 years ago

I just played a file in java. This had a few properties that I liked. 1) Connecting sound in my app isn't related to whether or not I've hit call or am even yet logged into an xmpp server. 2) I don't deal with ringback tones in terms of a single call, but instead do connecting, once I see an endpoint for the contact I try to session-initiate. Once I see session-initiate-ack from that user, I start the ringing sound. 3) When a contact answers(session-accept) I stop ringback sounds. 4) On a terminate either after a call, or during process, i play a call ended tone.

Anyways good luck on the ringback stuff, let me know what you come up with. Maybe someone here finds it useful for their app.

lukeweber commented 11 years ago

Ah, as well you can you ToneGenerator(http://developer.android.com/reference/android/media/ToneGenerator.html) possibly for some tones, but I haven't played around with this too much.

seankovacs commented 11 years ago

I've actually just went the route you took as well. It works, quick and easy.