Streaming audio and video from Android to PC / Internet.

I recently started using the Android SDK, and the overall goal of this project is to create an application very similar to Ustream or Qik (yes, I don’t know what is best for a beginner). I need streaming audio and video on the Internet. There will be a video server, most likely using Wowza, processing video encoding in the proper format.

From what I have found so far, I need to use android MediaRecorder with a camera as a source and direct the output to the server. It makes sense to me, but I don’t know exactly how to do it. Can someone give me a push in the right direction? I looked at the example in "http://ipcamera-for-android.googlecode.com/svn/trunk", but it looks a lot more complicated than necessary for what I need to do, and I couldn’t get it working in eclipse, to test it anyway.

+5
source share
2 answers

Doing this is not easy, but possible.

API MediaRecorder , , mp4 ( ). ipcamera-for-android, , . , API MediaRecorder "" , fps, sps/pps ( h264) .. , . API ( ), , , .

ipcamera-for-android , , , , , , , , .

mp4 ( , ) . , .

:

, , , ... , .

, , , : MediaRecorder

+8

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).

0

All Articles