user2747064
user2747064

Reputation: 1

Playing an rtp stream on android published with gstreamer

I'm trying to get a rtp connection between a microphone on a desktop pc and an android smartphone.

I grab the data using gstreamer. Because of other applications using this microphone at the same time in the same system, there is an tcpsink, in which the data is published.

this is done with this call:

gst-launch-0.10 -v alsasrc ! 'audio/x-raw-int, depth=16, width=16, \ 
             endianness=1234, channels=1, rate=16000' ! \ 
             tcpserversink host=localhost port=20000

then I create a second stream, which grabs the tcp connection and convert it to an rtp stream to publish the data over udp

gst-launch-0.10 tcpclientsrc host=localhost protocol=0 port=20000 ! \
             audio/x-raw-int,depth=16, width=16,endianness=1234, channels=1,\
             rate=16000 ! lamemp3enc target=1 bitrate=64 cbr=true ! mad ! \
             audioconvert ! audioresample ! mulawenc ! rtppcmupay pt=96 ! \
             udpsink host=129.70.134.128 port=6000

this works while playing whith vlc player on localhost

vlc rtp://129.70.134.128:6000

now I change the host in udpsink to the android's phone one. This also does what it shout do while playing with the mplayer app.

After this, the last step should be to play the sound with my own app.

I'm trying to get the stream with the android.net.rtp class.

AudioManager audioManager = (AudioManager);
mContext.getSystemService(mContext.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
AudioStream inRtpStream = new AudioStream(createInet("127.0.0.1"));

inRtpStream.associate(createInet(url), 6000);
inRtpStream.setMode(RtpStream.MODE_RECEIVE_ONLY);  
inRtpStream.setCodec(AudioCodec.PCMU);
inRtpStream.setDtmfType(96);
// Initialize an AudioGroup and attach an AudioStream
AudioGroup main_grp = new AudioGroup();
main_grp.setMode(AudioGroup.MODE_NORMAL);
inRtpStream.join(main_grp);

but there is silence. the logging output makes me think, that there is some kind of data, the application is trying to play.

DEBUG   AudioGroup  stream[57] is configured as PCMU 8kHz 20ms mode 2
DEBUG   AudioGroup  stream[64] is configured as RAW 8kHz 32ms mode 0
DEBUG   AudioGroup  stream[64] joins group[63]
DEBUG   AudioGroup  group[63] switches from mode 0 to 2
DEBUG   AudioGroup  stream[57] joins group[63]
DEBUG   AudioGroup  reported frame count: output 1149, input 384
DEBUG   AudioGroup  adjusted frame count: output 1149, input 512
DEBUG   AudioGroup  latency: output 302, input 64

am I missing something like starting the stream, or switching the speaker on?

all available volume sliders are turned to the maximum. I also requested the INTERNET and RECORD_AUDIO permissions in my manifest file.

the codecs should also be the same.

thanks for your answers

Upvotes: 0

Views: 3260

Answers (3)

Herold
Herold

Reputation: 1

Try to turn the speaker on: audioManager.setSpeakerphoneOn(true);

Upvotes: 0

onizukaek
onizukaek

Reputation: 1233

When creating the audioStream the port number is randomly generated. You get yours by calling the AudioStream getLocalPort() function, then you have to send your IP + port to the other device through a signalling protocol like sip or simply by TCP or UDP. The other device has to send you the same as well. Once you get this datas from the other device, you can then use the associate function on your side with the remote IP and the remote port. Note that getting the other device's IP is not necessary, you can hardcode that, but you can't do anything concerning the port because (once again) it's randomly generated.

Cheers

Upvotes: 1

BallisticNylon
BallisticNylon

Reputation: 11

You should pass in actual IP address AND NOT LOOP BACK ADDRESS 127.0.0.1 in "new AudioStream(createInet("127.0.0.1"));"

Upvotes: 1

Related Questions