I want to stream audio (opus codec) with ffmpeg directly to android device.
On PC i start stream:
./ffmpeg -re -stream_loop -1 -i akgld-c8mxm.opus -acodec libopus -ac 1 -ab 96k -vn -f rtp rtp://192.168.0.100:6000
Where 192.168.0.100 - local wifi address of my phone.
On Android device i tried to play stream:
public void tryPlayStream() {
String ip = Utils.wifiIpAddress(this);
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_ECHO_SUPPRESSION);
InetAddress inetAddress;
try {
inetAddress = InetAddress.getByName(ip);
audioStream = new AudioStream(inetAddress);
audioStream.setCodec(AudioCodec.PCMA);
audioStream.setMode(RtpStream.MODE_RECEIVE_ONLY);
InetAddress inetAddressRemote = InetAddress.getByName(ip);
audioStream.associate(inetAddressRemote, 6000);
audioStream.join(audioGroup);
} catch (Exception e) {
e.printStackTrace();
}
}
In logcat i see next lines:
E/AudioRecord: AudioFlinger could not create record track, status: -1
E/AudioGroup: cannot initialize audio device
What im doing wrong? Thanks for any help