Add buffering for Linux DVB outputs

Signed-off-by: max_10 <max_10@gmx.de>
This commit is contained in:
samsamsam
2018-03-31 11:39:41 +02:00
committed by Thilo Graf
parent b0e666e1cb
commit 2878ec69bc
25 changed files with 563 additions and 320 deletions

View File

@@ -195,7 +195,7 @@ static int _writeData(WriterAVCallData_t *call, int type)
iov[0].iov_len = HeaderLength;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
return writev_with_retry(call->fd, iov, 2);
return call->WriteV(call->fd, iov, 2);
}
static int writeDataADTS(WriterAVCallData_t *call)
@@ -253,7 +253,7 @@ static int writeDataADTS(WriterAVCallData_t *call)
iov[0].iov_len = headerSize + AAC_HEADER_LENGTH;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
return writev_with_retry(call->fd, iov, 2);
return call->WriteV(call->fd, iov, 2);
}
static int writeDataLATM(WriterAVCallData_t *call)
@@ -309,7 +309,7 @@ static int writeDataLATM(WriterAVCallData_t *call)
iov[1].iov_len = 3;
iov[2].iov_base = pLATMCtx->buffer;
iov[2].iov_len = pLATMCtx->len;
return writev_with_retry(call->fd, iov, 3);
return call->WriteV(call->fd, iov, 3);
}
/* ***************************** */

View File

@@ -126,7 +126,7 @@ static int writeData(WriterAVCallData_t *call)
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
ac3_printf(40, "PES HEADER LEN %d\n", iov[0].iov_len);
return writev_with_retry(call->fd, iov, 2);
return call->WriteV(call->fd, iov, 2);
}
/* ***************************** */

View File

@@ -145,7 +145,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = headerSize;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
int len = writev_with_retry(call->fd, iov, 2);
int len = call->WriteV(call->fd, iov, 2);
amr_printf(10, "amr_Write-< len=%d\n", len);
return len;
}

View File

@@ -169,7 +169,7 @@ static int writeData(WriterAVCallData_t *call)
iov[ic++].iov_len = headerSize;
iov[ic].iov_base = call->data;
iov[ic++].iov_len = call->len;
int len = writev_with_retry(call->fd, iov, ic);
int len = call->WriteV(call->fd, iov, ic);
divx_printf(10, "xvid_Write < len=%d\n", len);
return len;
}

View File

@@ -150,7 +150,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = InsertPesHeader(PesHeader, Size, MPEG_AUDIO_PES_START_CODE, call->Pts, 0);
iov[1].iov_base = Data;
iov[1].iov_len = Size;
int32_t len = writev_with_retry(call->fd, iov, 2);
int32_t len = call->WriteV(call->fd, iov, 2);
dts_printf(10, "< len %d\n", len);
return len;
}

View File

@@ -125,7 +125,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = HeaderLength;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
len = writev_with_retry(call->fd, iov, 2);
len = call->WriteV(call->fd, iov, 2);
h263_printf(10, "< len %d\n", len);
return len;
}

View File

@@ -55,6 +55,7 @@
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define H264_SILENT
//#define H264_DEBUG
#ifdef H264_DEBUG
@@ -348,7 +349,7 @@ static int writeData(WriterAVCallData_t *call)
iov[ic++].iov_len = call->len;
PacketLength += call->len;
iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode);
return writev_with_retry(call->fd, iov, ic);
return call->WriteV(call->fd, iov, ic);
}
else if (!call->private_data || call->private_size < 7 || 1 != call->private_data[0])
{
@@ -418,7 +419,7 @@ static int writeData(WriterAVCallData_t *call)
while ((pos + NalLengthBytes) < call->len);
h264_printf(10, "<<<< PacketLength [%d]\n", PacketLength);
iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
len = writev_with_retry(call->fd, iov, ic);
len = call->WriteV(call->fd, iov, ic);
PacketLength += iov[0].iov_len;
if (PacketLength != len)
{

View File

@@ -55,6 +55,7 @@
/* ***************************** */
/* Makros/Constants */
/* ***************************** */
#define H264_SILENT
//#define H265_DEBUG
#ifdef H265_DEBUG
@@ -220,7 +221,7 @@ static int writeData(WriterAVCallData_t *call)
iov[ic++].iov_len = call->len;
PacketLength += call->len;
iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, FakeStartCode);
return writev_with_retry(call->fd, iov, ic);
return call->WriteV(call->fd, iov, ic);
}
uint32_t PacketLength = 0;
ic = 0;
@@ -275,7 +276,7 @@ static int writeData(WriterAVCallData_t *call)
while ((pos + NalLengthBytes) < call->len);
h264_printf(10, "<<<< PacketLength [%d]\n", PacketLength);
iov[0].iov_len = InsertPesHeader(PesHeader, -1, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
len = writev_with_retry(call->fd, iov, ic);
len = call->WriteV(call->fd, iov, ic);
PacketLength += iov[0].iov_len;
if (PacketLength != len)
{

View File

@@ -238,7 +238,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = pes_header_size;
iov[1].iov_base = frame;
iov[1].iov_len = i_frame_size;
i_ret_size += writev_with_retry(call->fd, iov, 2);
i_ret_size += call->WriteV(call->fd, iov, 2);
}
memcpy(p_buffer, call->data + i_bytes_consumed, i_leftover_samples * i_channels * 2);
i_buffer_used = i_leftover_samples;

View File

@@ -123,7 +123,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = headerSize;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
int len = writev_with_retry(call->fd, iov, 2);
int len = call->WriteV(call->fd, iov, 2);
mp3_printf(10, "mp3_Write-< len=%d\n", len);
return len;
}

View File

@@ -125,7 +125,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, 0xe0, call->Pts, 0);
iov[1].iov_base = call->data + Position;
iov[1].iov_len = PacketLength;
ssize_t l = writev_with_retry(call->fd, iov, 2);
ssize_t l = call->WriteV(call->fd, iov, 2);
if (l < 0)
{
len = l;

View File

@@ -137,7 +137,7 @@ static int writeData(WriterAVCallData_t *call)
}
iov[ic].iov_base = call->data;
iov[ic++].iov_len = call->len;
int len = writev_with_retry(call->fd, iov, ic);
int len = call->WriteV(call->fd, iov, ic);
mpeg4_printf(10, "xvid_Write < len=%d\n", len);
return len;
}

View File

@@ -265,10 +265,10 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = headerSize;
iov[1].iov_base = fixed_buffer;
iov[1].iov_len = fixed_buffersize;
writev_with_retry(call->fd, iov, 2);
call->WriteV(call->fd, iov, 2);
fixed_buffertimestamp += fixed_bufferduration;
int g_fd_dump = open("/hdd/lpcm/ffmpeg.pes", O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
writev_with_retry(g_fd_dump, iov, 2);
call->WriteV(g_fd_dump, iov, 2);
close(g_fd_dump);
}
return size;

View File

@@ -175,7 +175,7 @@ static int writeData(WriterAVCallData_t *call)
free(videocodecdata.data);
videocodecdata.data = NULL;
}
return writev_with_retry(call->fd, iov, ic);
return call->WriteV(call->fd, iov, ic);
}
/* ***************************** */

View File

@@ -138,7 +138,7 @@ static int writeData(WriterAVCallData_t *call, int is_vp6)
iov[0].iov_len = pes_header_len;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
return writev_with_retry(call->fd, iov, 2);
return call->WriteV(call->fd, iov, 2);
}
static int writeDataVP6(WriterAVCallData_t *call)

View File

@@ -158,7 +158,7 @@ static int writeData(WriterAVCallData_t *call)
iov[0].iov_len = headerSize;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
return writev_with_retry(call->fd, iov, 2);
return call->WriteV(call->fd, iov, 2);
}
/* ***************************** */

View File

@@ -181,7 +181,7 @@ static int writeData(WriterAVCallData_t *call)
free(videocodecdata.data);
videocodecdata.data = NULL;
}
return writev_with_retry(call->fd, iov, ic);
return call->WriteV(call->fd, iov, ic);
}
/* ***************************** */