mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
h264 writer - do not inject prive codec data if the Sequence Parameter Set (SPS) and the Picture Parameter Set (PPS) are available in the bitstreamThis should fix playback of stream http://www.djing.com/tv/live.m3u8
This commit is contained in:
@@ -635,7 +635,7 @@ int main(int argc, char *argv[])
|
||||
memset(argvBuff, '\0', sizeof(argvBuff));
|
||||
int commandRetVal = -1;
|
||||
/* inform client that we can handle additional commands */
|
||||
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 36);
|
||||
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 37);
|
||||
if (0 != ParseParams(argc, argv, file, audioFile, &audioTrackIdx, &subtitleTrackIdx))
|
||||
{
|
||||
printf("Usage: exteplayer3 filePath [-u user-agent] [-c cookies] [-h headers] [-p prio] [-a] [-d] [-w] [-l] [-s] [-i] [-t audioTrackId] [-9 subtitleTrackId] [-x separateAudioUri] plabackUri\n");
|
||||
|
@@ -88,6 +88,7 @@ static unsigned int NalLengthBytes = 1;
|
||||
static unsigned char *CodecData = NULL;
|
||||
static unsigned int CodecDataLen = 0;
|
||||
static int avc3 = 0;
|
||||
static int sps_pps_in_stream = 0;
|
||||
|
||||
/* ***************************** */
|
||||
/* Prototypes */
|
||||
@@ -281,6 +282,7 @@ static int reset()
|
||||
{
|
||||
initialHeader = 1;
|
||||
avc3 = 0;
|
||||
sps_pps_in_stream = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -319,21 +321,31 @@ static int writeData(WriterAVCallData_t *call)
|
||||
/* AnnexA */
|
||||
if (!avc3 && ((1 < call->private_size && 0 == call->private_data[0]) ||
|
||||
((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))))
|
||||
(call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x01) ||
|
||||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))))
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint8_t InsertPrivData = !sps_pps_in_stream;
|
||||
uint32_t PacketLength = 0;
|
||||
uint32_t FakeStartCode = (call->Version << 8) | PES_VERSION_FAKE_START_CODE;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
initialHeader = 0;
|
||||
//if (initialHeader) // some rtsp streams can update codec data at runtime
|
||||
while (InsertPrivData && i < 36 && (call->len - i) > 5)
|
||||
{
|
||||
if ((call->data[i] == 0x00 && call->data[i + 1] == 0x00 && call->data[i + 2] == 0x00 && call->data[i + 3] == 0x01 && (call->data[i + 4] == 0x67 || call->data[i + 4] == 0x68)) ||
|
||||
(call->data[i] == 0x00 && call->data[i + 1] == 0x00 && call->data[i + 2] == 0x00 && (call->data[i + 3] == 0x67 || call->data[i + 3] == 0x68)))
|
||||
{
|
||||
InsertPrivData = 0;
|
||||
sps_pps_in_stream = 1;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if (InsertPrivData && call->private_size > 0 /*&& initialHeader*/) // some rtsp streams can update codec data at runtime
|
||||
{
|
||||
initialHeader = 0;
|
||||
iov[ic].iov_base = call->private_data;
|
||||
iov[ic++].iov_len = call->private_size;
|
||||
PacketLength += call->private_size;
|
||||
}
|
||||
iov[ic].iov_base = "";
|
||||
iov[ic++].iov_len = 1;
|
||||
iov[ic].iov_base = call->data;
|
||||
iov[ic++].iov_len = call->len;
|
||||
PacketLength += call->len;
|
||||
@@ -348,7 +360,7 @@ static int writeData(WriterAVCallData_t *call)
|
||||
uint32_t PacketLength = 0;
|
||||
ic = 0;
|
||||
iov[ic++].iov_base = PesHeader;
|
||||
if (initialHeader)
|
||||
//if (initialHeader)
|
||||
{
|
||||
if (CodecData)
|
||||
{
|
||||
|
Reference in New Issue
Block a user