分两块:

1.取得摄像头採集的视频流

2.发送到server端

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();

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐