分两块:
1.取得摄像头采集的视频流
2.发送到服务器端
protected MediaRecorder mMediaRecorder; private LocalServerSocket mLss = null; private LocalSocket mReceiver, mSender = null; mLss = new LocalServerSocket("myVideoStream"); mReceiver = new LocalSocket(); //连接mLss,即接受方主动发起连接 mReceiver.connect( new LocalSocketAddress("myVideoStream")); mReceiver.setReceiveBufferSize(100*1024); mSender = mLss.accept(); mSender.setSendBufferSize(100*1024); mMediaRecorder.start(); //mReceiver已经和mSender建立连接,也就可以认为,camera采集的视频流会持续 //发给mReceiver,通过mReceiver.getInputStream()就可以获取到mSerder输入的视频流 mSocketHelper.setInputStream(mReceiver.getInputStream()); //mSocketHelper是你自己对Socket的封装,根据mMediaRecorder的不同的编码格式,实现不同的发送方式 mSocketHelper.start();
Android摄像头采集的视频数据流如何通过Socket实时发送到目标服务端,布布扣,bubuko.com
时间: 2024-10-29 19:12:27