How to send video data streams collected by Android cameras to the target server in real time through Socket

Source: Internet
Author: User

It can be divided into two parts:

1. Obtain the video stream collected by the camera

2. send to the server

Protected MediaRecorder mMediaRecorder; private LocalServerSocket mLss = null; private LocalSocket mReceiver, mSender = null; mLss = new LocalServerSocket ("myVideoStream"); mReceiver = new LocalSocket (); // connect to mLss, that is, the receiver actively initiates a connection to the mReceiver. connect (new LocalSocketAddress ("myVideoStream"); mReceiver. setReceiveBufferSize (100*1024); mSender = mLss. accept (); mSender. setSendBufferSize (100*1024); mMediaRecorder. start (); // mReceiver has established a connection with mSender, so you can think that the video streams collected by camera will continue // sent to mReceiver through mReceiver. getInputStream () can get the mSocketHelper Video Stream Input by mSerder. setInputStream (mReceiver. getInputStream (); // mSocketHelper is your own Socket encapsulation. Based on the different encoding formats of mMediaRecorder, mSocketHelper can be sent in different ways. start ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.