I'm working on a project that involves WebRtc for Android and everything is working fine accept for the fact that I don't know how I can play the standard repeating beep sound when you are waiting for that the person you are calling accepts your call.
I have searched a lot for this but accept for a link that was related to IOS which wasn't very helpful, there was nothing useful.
Does anybody know how I can accomplish this?
AFAIK there's is no special "API to play this kind of sound". It's just like playing any other sound. Asking how to find an "outgoing" rings.wav on the internet, is out of scope for stackoverflow.
If you're looking to generate it, you'd need to specify which sound you want, since there is no "standard" one. The sound varies from market to market. Traditionally even, on old POTS networks, the sound was literally sent from the other side, producing different sounds when calling people in other countries.
Also, "ringing" is an app choice, and out of scope for WebRTC. Most WebRTC apps these days tend to pair people up using "rooms" or similar abstractions, rather than the traditional "pick up!" model.
Related
This question might seem to be a repetition of the questions such as following:
How to play an audio file on a voice call in android
Background Audio for a Call in Progress - Possible?
The answers of these questions suggests that it is not possible to play a pre-recorded audio on a voice call in android. I want to know why it is not possible? What is the limitation (hardware/software)? Is it really a limitation or done purposely? Can we alter the source code of android to make it possible?
I think this is a limitation, imposed for security reasons and restricted at the OS level.
Let's analyze the security threat, first of all. If you were able to play custom audio files to the callee, a whole world of cons opens up: you could trick customer supports, you could pretend to be someone else, you could give unauthorized purchase confirmations, and so on. For this reason, neither Android nor iOS allows this functionality.
On Android, you won't be able to do so in a programmatic way, simply because the current APIs won't allow you to do so. It is stated in the official documentation as well, as pointed out here. If you dig into the source code, you can probably enable this feature by accessing the microphone output during a phone call, but that would require running your custom version of Android. A good starting point would be the AudioTrack source, available here.
EDIT: a good example of an audio mod involves enabling the Nexus 5 earpiece as a second loudspeaker (requires root). Can be found here.
After a thorough research, what I have come to know is that there are more than one limitations/hurdles to make it possible. These limitations/hurdles are at three different levels.
First limitation is at API level, because there is no high-level API to play sound files in the conversation audio during a call as mentioned in Android official documentation.
Second limitation is at Radio Interface Layer (RIL). RIL passes on complete control of the call to Radio Daemon (rild) of the Linux library which then further passes the control to the vendor RIL. That means we cannot manipulate voice call in android source code.
Even if we are able to remove these two limitations, we may still not be able to play audio file to an ongoing voice call. Because there is a third limitation. Every vendor has their own library of RIL that communicates with Radio Daemon (rild). This requires that vendor RIL to be open source which is not actually. Hardware vendors do not usually make their device drivers code available.
Detail discussion on this topic is present at this link.
This is software related due to the prioritization of audio routing in Android.
Take a look into the CallManager where you can dig into the method setAudioMode(). After the audio mode was set to MODE_IN_COMMUNICATION the following code is called
audioManager.requestAudioFocusForCall(AudioManager.STREAM_VOICE_CALL,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
From this point on the telephony service has the highest priority and won't let any other audio play in parallel.
Note: You can play back the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call.
See official link
http://developer.android.com/guide/topics/media/mediaplayer.html
By implementing the AudioManager.OnAudioFocusChangeListener you can get the state of the audiomanager. so by this if any music is playing in the background you can get the AudioManager states(playing and pausing is completely in developer hands) similarly......
Some of the native music players in android device where handling this, they restrict the music when call is in TelephonyManager.EXTRA_STATE_OFFHOOK.so this scenario is also completely in developer hand (whether to handle or not) if he is not handling both will play parallel y
I have been searching the internet for an answer, on how to play an audio file through the telephone line (See example if you wonder what I mean). Now I have come to this site to find the answer:
Is it possible to play an audio file located on your telephone, so that the caller can hear it, without turning on your speaker and let it blast it out loud? If so, does anybody know a site to look it up at?
Example:
Peter calls Annie. Annie answers the call, and decides to play her favorite music to Peter, but she doesn't want to turn on her speaker, because her parents are sleeping in the room next to her.
I know that a telecommunications server is able to play music when people are on hold, waiting for an employee or in a queue, but is an Android phone able to do the same?
You can't do this.
All audio calls are routed through the baseband chip at a hardware level. The underlying telephony technology isn't exposed to the OS, much less the Android APIs.
So basically, this is impossible, unless you're willing to settle for playing it over the loudspeaker and hoping it gets picked up clearly.
I have create an app for android that creates and stores a single tone, then plays it back utilizing android audio track class. Here's the issue: on my phone I can only play tones up to a frequency of about 11kHz, and on a virtual phone run from my PC (same exact code) I can get frequencies up to about 14kHz. What could cause this cutoff?
Using a tone generator app from the market, my phone can produce up to 20kHz signals, so I know it is not a hardware issue.
Thanks.
It might help if you provide some of the code for how you're generating the tone.
For audio stuff, you should go here http://music.columbia.edu/mailman/listinfo/andraudio and signup then ask there. There's a great community of Android developers for that list all dedicated to audio development.
Also, self-promotion, I run a forum website (relatively new and needing updates) and I plan to add an Android Audio forum on it once I get enough interested folks. If you're interested, sign up here
I know the rules of StackOverflow and hence apologize beforehand for asking such a subjective question.
I tried the documentation but all it says is this :
RemoteControlClient enables exposing information meant to be consumed
by remote controls capable of displaying metadata, artwork and media
transport control buttons.
A remote control client object is associated with a media button event
receiver. This event receiver must have been previously registered
with registerMediaButtonEventReceiver(ComponentName) before the
RemoteControlClient can be registered through
registerRemoteControlClient(RemoteControlClient).
I don't know about others but for me, this much of documentation was not enough for something which has such a cool name as "RemoteControlClient".
I searched a lot of forums for this but unfortunately, the concept is still not clear to me.
Would indeed be grateful if someone helped me understand it, how it works and most importantly, what all it is capable of.
Thanks in advance and apologies for asking a subjective question.
http://developer.android.com/about/versions/android-4.0.html
The new RemoteControlClient allows media players to enable playback controls from remote control clients such as the device lock screen. Media players can also expose information about the media currently playing for display on the remote control, such as track information and album art.
and a few more paragraphs on the subject.
It also points out:
For a sample implementation, see the Random Music Player, which provides compatibility logic such that it enables the remote control client on Android 4.0 devices while continuing to support devices back to Android 2.1.
I am trying to get a better understanding of android audio framework (froyo onwards in particular).
I've almost got the distinction into streams. The AudioFlinger maps each stream into a "strategy" and then routes a strategy to the proper "device" (BT, Headset, Speaker..)
However I still struggle to understand:
1) How multiple apps play onto the same stream? can they just 'play' or do they have to handle the focus (request, abandon and listen for changes)?
2) When multiple streams are playing...what is the priority of one stream respect to another? surely the in-call stream has top priority but are there any "rules" to understand how things really work.
If anyone with more confidence on this matter has got any doc/resource to study.. it would be great.
Thanks!
Marco
The answer to this question
Concurrent Sound on Android Device
may help you.
Also, here
http://www.droidnova.com/creating-sound-effects-in-android-part-1,570.html
is written how to initialize the SoundManager with the number of concurrent streams you want to play.
If you need to understand the default behavoiur you can see the Cplusplus code at
/hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp
However each vendor can make changes and ship a different flavour