在Android上播放RTP流刊登在GStreamer [英] Playing an rtp stream on android published with gstreamer

查看:1519
本文介绍了在Android上播放RTP流刊登在GStreamer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个麦克风之间的台式PC和Android智能手机一个RTP连接。

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

我抢使用GStreamer的数据。
因为使用这种麦克风在同一系统中的同时,其他的应用程序的,有一个tcpsink,在其中的数据被公布

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.

这是这个调用来完成:

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

然后我创建第二个数据流,它抓住的TCP连接,并将其转换为一个RTP流通过UDP发布数据

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

这工作,而玩蒙山VLC播放器在localhost

this works while playing whith vlc player on localhost

vlc rtp://129.70.134.128:6000

现在我改变udpsink到Android的手机一部主机。这也做的事情做喊同时与mplayer的应用程序播放。

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.

我试图获得与的Andr​​oid流。 net.rtp 类。

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?

所有可用的体积滑块被接通到最大。我还请我的清单文件互联网和RECORD_AUDIO权限。

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

codeCS也应该是相同的。

the codecs should also be the same.

谢谢您的回答

推荐答案

您应该通过在新语音串流(createInet(127.0.0.1实际IP地址,而不是环回地址127.0.0.1));

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

这篇关于在Android上播放RTP流刊登在GStreamer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆