android rtp音频传输,java – 如何接收RTP音频流Android?

我正在使用

Java将rtp音频从麦克风传输到我的

Android手机应用程序,但我没有听到任何声音.设置AudioGroup和AudioStream时没有错误,所以我假设一切正常.这是应用程序端的代码:

AudioStream audioStream;

AudioGroup audioGroup;

AudioCodec codec = AudioCodec.PCMU;

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();

StrictMode.setThreadPolicy(policy);

AudioManager audio = (AudioManager)getSystemService(AUDIO_SERVICE);

audio.setMode(AudioManager.MODE_IN_COMMUNICATION);

audioGroup = new AudioGroup();

audioGroup.setMode(AudioGroup.MODE_NORMAL);

InetAddress inetAddress;

try {

inetAddress = InetAddress.getByName("163.11.62.208");

audioStream = new AudioStream(inetAddress);

audioStream.setMode(RtpStream.MODE_RECEIVE_ONLY);

audioStream.setCodec(codec);

InetAddress inetAddressRemote = InetAddress.getByName("163.11.169.206");

audioStream.associate(inetAddressRemote, 5004);

audioStream.join(audioGroup);

}

我使用的ffmpeg流测试(适用于vlc Android播放器)是

ffmpeg -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -vcodec pcm_u8 -f rtp rtp://163.11.62.208:5004

再次..这适用于VLC安卓播放器,但不适用于我的应用程序.没有错误..只是没有音频.

好吧,我刚刚在LogCat中注意到我收到的消息告诉我它正在运行.这是一些日志.

stream[59] is configured as RAW 8kHz 32ms mode 0

D/AudioGroup﹕ stream[59] joins group[56]

group[56] switches from mode 0 to 1

stream[54] joins group[56]

getOutputSamplingRate() reading from output desc

V/AudioSystem﹕ getSamplingRate() streamType 0, output 2, sampling rate 48000

V/AudioSystem﹕ getFrameCount() streamType 0, output 2, frameCount 960

V/AudioSystem﹕ getLatency() streamType 0, output 2, latency 160

V/AudioTrack﹕ getMinFrameCount=1280: afFrameCount=960, minBufCount=8, afSampleRate=48000, afLatency=160

D/AudioGroup﹕ reported frame count: output 1280, input 320

D/AudioGroup﹕ adjusted frame count: output 1280, input 512

V/AudioTrack﹕ sampleRate 8000, channelMask 0x1, format 1

V/AudioTrack﹕ streamType 0

V/AudioTrack﹕ set() streamType 0, sampleRate 8000, format 1, frameCount 1280, flags 0000

V/AudioSystem﹕ getLatency() streamType 0, output 2, latency 160

V/AudioSystem﹕ getFrameCount() streamType 0, output 2, frameCount 960

V/AudioSystem﹕ getOutputSamplingRate() reading from output desc

V/AudioSystem﹕ getSamplingRate() streamType 0, output 2, sampling rate 48000

V/AudioTrack﹕ createTrack_l() output 2 afLatency 160

V/AudioTrack﹕ afFrameCount=960, minBufCount=8, afSampleRate=48000, afLatency=160

V/AudioTrack﹕ minFrameCount: 1280, afFrameCount=960, minBufCount=8, sampleRate=8000, afSampleRate=48000, afLatency=160

V/AudioRecord﹕ sampleRate 8000, channelMask 0x10, format 1

V/AudioRecord﹕ inputSource 7

V/AudioRecord﹕ set(): sampleRate 8000, channelMask 0x10, frameCount 512

D/AudioRecord﹕ set(): voiceActivationState 0

D/AudioRecord﹕ Keep input Source type.

V/AudioRecord﹕ AudioRecord::set() minFrameCount = 320

V/AudioRecord﹕ set(): mSessionId 1827

V/AudioSystem﹕ ioConfigChanged() event 3, ioHandle 1828

但是:我也注意到在运行我的应用程序时根本没有系统音量.当我改变系统音量时,通常会发出一个指示器噪音,以显示它是多么响亮/安静,但我什么都没听到.我不知道为什么会这样.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值