且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android棒棒糖MediaRecorder问题

更新时间:2021-12-28 21:45:48

我提交的AOSP的bug报告。 https://$c$c.google.com/p/android/issues/detail?id=80715

I filed a bug report on AOSP. https://code.google.com/p/android/issues/detail?id=80715

目前的SELinux策略不允许的媒体服务器来处理生成的应用程序抽象的UNIX域套接字。

"The current SELinux policies don't allow for mediaserver to handle app generated abstract unix domain sockets.

相反,我建议你创建一个管道对(http://developer.android.com/reference/android/os/ParcelFileDescriptor.html#createPipe() ),其允许由所述机器人5.0政策。 我不知道他们为什么这样做,否则我们是如何应该知道。

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.

我使用的是很旧的/修改(不能告诉)版本​​libstreaming哪里MediaStream可仍然受到mediarecorder延长,但看目前的版本,在MediaStream可你可能会想createSockets更改为包括以下内容:

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();

            InputStream is = null;
            try{ is = new ParcelFileDescriptor.AutoCloseInputStream(parcelRead);
            }
            catch (Exception e){}
            mPacketizer.setInputStream(is);

这工作,但由于某些原因,视频很janky。如果我解决这个问题,我会编辑这个答案。 编辑:jankiness走了,当我重新启动设备。正如andreasperelli指出的评论,请务必关闭closeSockets的ParcelFileDescriptors(),或者根据您的实现和版本,closeSockets()之前,你调用MediaRecorder.stop()。在

This works, but for some reason the video is very janky. I'll edit this answer if I fix that. the jankiness went away when I restarted the device. 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().