MediaRecorder issue on Android Lollipop
I filed a bug report on AOSP.
https://code.google.com/p/android/issues/detail?id=80715
"The current SELinux policies don't allow for mediaserver to handle app generated abstract unix domain sockets.
Instead, I'd recommend you create a pipe-pair ( http://developer.android.com/reference/android/os/ParcelFileDescriptor.html#createPipe() ) which is allowed by the Android 5.0 policy.
"
I don't know why they did this or how we were supposed to know.
I'm using a very old/modified (can't tell) version of libstreaming where mediastream is still extended from mediarecorder, but looking at the current version, in MediaStream you'll probably want to change createSockets to something including the following:
ParcelFileDescriptor[] parcelFileDescriptors =ParcelFileDescriptor.createPipe();
parcelRead = new ParcelFileDescriptor(parcelFileDescriptors[0]);
parcelWrite = new ParcelFileDescriptor(parcelFileDescriptors[1]);
then in your video/audio stream
setOutputFile(parcelWrite.getFileDescriptor());
and in that same file
change
// The packetizer encapsulates the bit stream in an RTP stream and send it over the network
mPacketizer.setInputStream(mReceiver.getInputStream());
mPacketizer.start();
to
InputStream is = null;
try{ is = new ParcelFileDescriptor.AutoCloseInputStream(parcelRead);
}
catch (Exception e){}
mPacketizer.setInputStream(is);
As andreasperelli pointed out in the comment, make sure to close the ParcelFileDescriptors in closeSockets(), or depending on your implementation and version, before closeSockets() and before you call MediaRecorder.stop().
Problems recording + playback (MediaRecorder + MediaPlayer)
use this code:
mp = new MediaPlayer();
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
FileInputStream fis = new FileInputStream(yourFilename);
mp.setDataSource(fis.getFD);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
mp.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.start();
Related Topics
How to Make Part of The Text Bold in Android at Runtime
Android - Set a Progressbar to Be a Vertical Bar Instead of Horizontal
How to Set Android Tablayout in The Bottom of The Screen
Uninstall App Silently with System Privileges
Android - How to Set Background Color of All Screens
Android Gcm Sender_Id, How to Get It
How to Avoid Restarting Activity When Orientation Changes on Android
When Does Application's Oncreate() Method Get Called
Difference Between Getstring() and Getresources.Getstring()
Getting Gradle Error "Could Not Reserve Enough Space for Object Heap" Constantly in Intellij Idea
Disable Webview Touch Events in Android
Detecting The Scrolling Direction in The Adapter (Up/Down)
Is Main Thread The Same as UI Thread
Android: Why Does Long Click Also Trigger a Normal Click
Commitallowingstateloss() in Fragment Activities