我是新来的Android和套接字编程。我想创建一个从设备摄像头实时传输视频到电脑Android应用程序。什么首先我要做的就是获得previewCallback参数的原始视频数据,并将其转换为RTP包。我只是用JLibRTP做到这一点。关于到包我想转让,也有一些相关的类:RtpPkt,RtpSession和RtpSocket。
I'm new to Android and socket programming. I want to create an android application that transfer video live from device camera to PC. What first i do is to get a raw video data from PreviewCallback arguments and convert it to an RTP Packet. I was just using JLibRTP to do this. Regarding to transfer the packet i think, there are some related class: RtpPkt, RtpSession, and RtpSocket.
下面是我一眼code:
Here is my glance code:
DatagramSocket rtpSocket = new DatagramSocket();
DatagramSocket rtcpSocket = new new DatagramSocket();
RtpSession rtpSession = new RtpSession(rtpSocket, rtcpSocket);
public void surfaceCreated(SurfaceHolder holder) {
try {
camera = Camera.open();
camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] _data, Camera _camera) {
int height = 240;
try {
rtps.sendData(_data);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_SHORT).show();
}
}
});
camera.setPreviewDisplay(holder);
camera.startPreview();
} catch (IOException e) {
Log.d("CAMERA", e.getMessage());
}
}
我还是想知道我必须把地址和端口信息。我知道code以上仍然需要纠正任何主。感谢提前..
I'm still wondering where i have to put address and port information. I know the code above still need correction from you any master. Thanks for advance..
我不知道这个库包含一些对数据包流式传输到PC, 但如果没有,你有问题,由于Android只支持RTP流,因为3.1版本(API等级12)。如果你的水平是较低的,你必须写自己的RTP服务器,这是能够从设备中的数据包传输到电脑上。
I don't know if this library includes something to stream the packets to the pc, but if not, you've a problem, because android only supports RTP streaming since version 3.1 (API level 12). if your level is lower, you have to write your own "rtp-server" which is able to stream the packets from your device to the pc.
有关详细信息,请查看sipdroid项目。他们创造了自己的RTP服务器:http://$c$c.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/sipua/ui/VideoCamera.java
for more information check out the sipdroid project. they have created their own "rtp-server": http://code.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/sipua/ui/VideoCamera.java
更新:
另一种可能性是使用从ffserver的FFmpeg的库,但因此,你必须编译库机器人。这里是一个小教程如何做到这一点,以及如何与图书馆合作:如何建立FFmpeg的Android版
another possibility is to use the ffserver from the ffmpeg libraries, but therefore you have to compile the libraries for android. here is a small tutorial how to do this and how to work with the libraries: How to Build FFmpeg for Android
UPDATE2:
href="http://$c$c.google.com/p/spydroid-ipcamera/" rel="nofollow"> spydroid应用的
上一篇:AudioSource.VOICE_CALL不工作在Android 4.0的,但是在Android 2.3的工作工作、但是在、VOICE_CALL、AudioSource
下一篇:Android的SDK工具版本12有问题,使用ProGuard =>错误转换的Dalvik格式失败,错误1错误、版本、格式、工具