SipDroid不正是你需要的。
它涉及到一種破解需要文件描述符的MediaRecorder
類的限制。它將MediaRecorder視頻流的結果保存到本地套接字(用作一種管道),然後重新讀取(在同一個應用程序中,但另一個線程),從另一端的此套接字創建RTP數據包從收到的數據中取出,最後將RTP數據包廣播到網絡(您可以在此處使用廣播或單播模式)。
基本上它歸結爲以下的(簡化的代碼):
// Create a MediaRecorder
MediaRecorder mr = new MediaRecorder();
// (Initialize mr as usual)
// Create a LocalServerSocket
LocalServerSocket lss = new LocalServerSocket("foobar");
// Connect both end of this socket
LocalSocket sender = lss.accept();
LocalSocket receiver = new LocalSocket();
receiver.connect(new LocalSocketAddress("foobar"));
// Set the output of the MediaRecorder to the sender socket file descriptor
mr.setOutputFile(sender.getFileDescriptor());
// Start the video recording:
mr.start();
// Launch a background thread that will loop,
// reading from the receiver socket,
// and creating a RTP packet out of read data.
RtpSocket rtpSocket = new RtpSocket();
InputStream in = receiver.getInputStream();
while(true) {
fis.read(buffer, ...);
// Here some data manipulation on the received buffer ...
RtpPacket rtp = new RtpPacket(buffer, ...);
rtpSocket.send(rtpPacket);
}
的RtpPacket
和RtpSocket
類(相當簡單的),並且其操作所述視頻流內容的確切的代碼的執行可以在找到SipDroid項目(尤其是VideoCamera.java
)。
我有類似的問題,我試過使用WebRTC,但沒有在智能電視工作(我的問題是Android和智能電視之間的傳輸),智能電視沒有鍍鉻:( – vrbsm