|
|
|
@ -12,20 +12,26 @@ public final class VideoStreamer {
|
|
|
|
|
private static final long PACKET_FLAG_KEY_FRAME = 1L << 62;
|
|
|
|
|
|
|
|
|
|
private final FileDescriptor fd;
|
|
|
|
|
private final VideoCodec codec;
|
|
|
|
|
private final boolean sendCodecId;
|
|
|
|
|
private final boolean sendFrameMeta;
|
|
|
|
|
|
|
|
|
|
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
|
|
|
|
|
|
|
|
|
public VideoStreamer(FileDescriptor fd, boolean sendFrameMeta) {
|
|
|
|
|
public VideoStreamer(FileDescriptor fd, VideoCodec codec, boolean sendCodecId, boolean sendFrameMeta) {
|
|
|
|
|
this.fd = fd;
|
|
|
|
|
this.codec = codec;
|
|
|
|
|
this.sendCodecId = sendCodecId;
|
|
|
|
|
this.sendFrameMeta = sendFrameMeta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writeHeader(int codecId) throws IOException {
|
|
|
|
|
ByteBuffer buffer = ByteBuffer.allocate(4);
|
|
|
|
|
buffer.putInt(codecId);
|
|
|
|
|
buffer.flip();
|
|
|
|
|
IO.writeFully(fd, buffer);
|
|
|
|
|
public void writeHeader() throws IOException {
|
|
|
|
|
if (sendCodecId) {
|
|
|
|
|
ByteBuffer buffer = ByteBuffer.allocate(4);
|
|
|
|
|
buffer.putInt(codec.getId());
|
|
|
|
|
buffer.flip();
|
|
|
|
|
IO.writeFully(fd, buffer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writePacket(ByteBuffer codecBuffer, MediaCodec.BufferInfo bufferInfo) throws IOException {
|
|
|
|
|