Если вы просто хотите отправить каждый кадр в виде необработанного набора данных, вы можете использовать сокеты.
Этот код, приведенный ниже, устарел, но при последней проверке работал нормально - он отправляет видео целиком, но вы можете используйте то же самое, чтобы отправить любой файл, который вы хотите:
//Send the video file to helper over a Socket connection so he helper can compress the video file
Socket helperSocket = null;
try {
Log.d("VideoChunkDistributeTask doInBackground","connecting to: " + helperIPAddress + ":" + helperPort);
helperSocket = new Socket(helperIPAddress, helperPort);
BufferedOutputStream helperSocketBOS = new BufferedOutputStream(helperSocket.getOutputStream());
byte[] buffer = new byte[4096];
//Write the video chunk to the output stream
//Open the file
File videoChunkFile = new File(videoChunkFileName);
BufferedInputStream chunkFileIS = new BufferedInputStream(new FileInputStream(videoChunkFile));
//First send a long with the file length - wrap the BufferedOutputStream in a DataOuputStream to
//allow us send a long directly
DataOutputStream helperSocketDOS = new DataOutputStream(
new BufferedOutputStream(helperSocket.getOutputStream()));
long chunkLength = videoChunkFile.length();
helperSocketDOS.writeLong(chunkLength);
Log.d("VideoChunkDistributeTask doInBackground","chunkLength: " + chunkLength);
//Now loop through the video chunk file sending it to the helper via the socket - note this will simply
//do nothing if the file is empty
int readCount = 0;
int totalReadCount = 0;
while(totalReadCount < chunkLength) {
//write the buffer to the output stream of the socket
readCount = chunkFileIS.read(buffer);
helperSocketDOS.write(buffer, 0, readCount);
totalReadCount += readCount;
}
Log.d("VideoChunkDistributeTask doInBackground","file sent");
chunkFileIS.close();
helperSocketDOS.flush();
} catch (UnknownHostException e) {
Log.d("VideoChunkDistributeTask doInBackground","unknown host");
e.printStackTrace();
return null;
} catch (IOException e) {
Log.d("VideoChunkDistributeTask doInBackground","IO exceptiont");
e.printStackTrace();
return null;
}
Полный исходный код находится по адресу: https://github.com/mickod/ColabAndroid/tree/master/src/com/amodtech/colabandroid
Вы также можете найти больше Доступны библиотеки сокетов даты, которые могут быть лучше для вас, но общие принципы должны быть похожими.
Если вы хотите транслировать ваше видео, чтобы другое приложение могло воспроизводить его как обычное видео, которое оно передает из web, тогда вы захотите настроить веб-сервер на «отправляющем» устройстве. В этот момент может быть проще отправить его на сервер и оттуда отправить поток.