我读到(我想甚至是在堆积流上读到的),你可以向媒体规则提供TCP-连接文件手。然后你可以听这个连接,读取数据,将其包装成一个RTSP/RTP-Stream。
如果我碰巧找到原始的邮箱, 我会在这里引用它。
<强度 > EDIT: 强度 >
有关文件描述器的部分来自:http://www.mattakis.com/blog/kisg/20090708/brownscast-viciod-with-andkid-android-to-to-the-file-system
举例来说, 我引用博客上的例子:
String hostname = "your.host.name";
int port = 1234;
Socket socket = new Socket(InetAddress.getByName(hostname), port);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
MediaRecorder recorder = new MediaRecorder(); // Additional MediaRecorder setup (output format ... etc.) omitted
recorder.setOutputFile(pfd.getFileDescriptor());
recorder.prepare();
recorder.start();
然而,它只会将视频文件数据传送到线上。 您可以保存它, 然后放回去。 但如前所述, 它不是一个流, 还没有 。
UPDATE: You do not even have to use a TCP Socket for the first step. I just tripped over "LocalSocket"(1), that also gets you a FileHandle to feed the MediaRecorder. Those Local sockets are "AF_LOCAL/UNIX domain stream socket"s. See http://developer.android.com/reference/android/net/LocalSocket.html
我从今天起还没有尝试过所有上述方法,但很快会尝试。因此,也许我可以在不远的将来给予更多的帮助:)
(1) 出于安全原因, < 强度 > 本地Socket < /强度 > 无法在新型Android版本上使用!见2015-11-25年最新消息。
UPDATE 2: Just saw in the Android Sources the "OUTPUT_FORMAT_RTP_AVP". But it is hidden :( So I guess it will be available in future API versions of Android. https://github.com/android/platform_frameworks_base/blob/master/media/java/android/media/MediaRecorder.java Line 219:
public static final int OUTPUT_FORMAT_RTP_AVP = 7;
我没有试图通过提供硬码 7
... 来欺骗隐藏... 如果有人这样做, 请在这里留下注释! em>
<强度 > 更新2015-11-25 强 >
I just ran into libstreaming: https://github.com/fyhertz/libstreaming I did not look into it too deeply, but it seems there is a lot to be learned about streaming from Android from this project (if not only using it). I read there that the LocalSocket solution is invalid for newer Android versions :( But they present an alternative: ParcelFileDescriptor.