h264: don't mess with packet length

Origin commit data
------------------
Branch: master
Commit: 0c4711b209
Author: martii <m4rtii@gmx.de>
Date: 2013-07-19 (Fri, 19 Jul 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2013-07-19 10:30:04 +02:00
parent 9d22af41c5
commit 1c7bd2dead
2 changed files with 42 additions and 50 deletions

View File

@@ -147,8 +147,8 @@ static int writeData(void* _call)
return 0; return 0;
} }
// This seems to make playback unreliable. Disabled for now. --martii
if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) || if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
// This seems to make playback unreliable. Disabled for now. --martii
//(call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x01 && NoOtherBeginningFound) || //(call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x01 && NoOtherBeginningFound) ||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))) (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))
{ {
@@ -291,7 +291,6 @@ static int writeData(void* _call)
unsigned int NalStart = 0; unsigned int NalStart = 0;
unsigned int VideoPosition = 0; unsigned int VideoPosition = 0;
ic = 0;
do { do {
unsigned int NalLength; unsigned int NalLength;
unsigned char NalData[4]; unsigned char NalData[4];
@@ -310,17 +309,12 @@ static int writeData(void* _call)
h264_printf(20, "NalStart = %u + NalLength = %u > SampleSize = %u\n", NalStart, NalLength, SampleSize); h264_printf(20, "NalStart = %u + NalLength = %u > SampleSize = %u\n", NalStart, NalLength, SampleSize);
if (NalStart + NalLength > SampleSize) { if (NalStart + NalLength > SampleSize) {
h264_printf(20, "nal length past end of buffer - size %u frame offset %u left %u\n", h264_printf(20, "nal length past end of buffer - size %u frame offset %u left %u\n",
NalLength, NalStart , SampleSize - NalStart ); NalLength, NalStart , SampleSize - NalStart );
NalStart = SampleSize; NalStart = SampleSize;
} else { } else {
NalStart += NalLength; NalStart += NalLength;
while (NalLength > 0) {
unsigned int PacketLength = (NalLength < BUFFER_SIZE) ? NalLength : BUFFER_SIZE;
NalLength -= PacketLength;
ic = 0; ic = 0;
iov[ic++].iov_base = PesHeader; iov[ic++].iov_base = PesHeader;
@@ -328,16 +322,15 @@ static int writeData(void* _call)
NalPresent = 0; NalPresent = 0;
iov[ic].iov_base = (char *)Head; iov[ic].iov_base = (char *)Head;
iov[ic++].iov_len = sizeof(Head); iov[ic++].iov_len = sizeof(Head);
PacketLength += sizeof(Head);
} }
iov[ic].iov_base = call->data + VideoPosition; iov[ic].iov_base = call->data + VideoPosition;
iov[ic++].iov_len = PacketLength; iov[ic++].iov_len = NalLength;
VideoPosition += PacketLength; VideoPosition += NalLength;
h264_printf (20, " pts=%llu\n", VideoPts); h264_printf (20, " pts=%llu\n", VideoPts);
iov[0].iov_len = InsertPesHeader (PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, VideoPts, 0); iov[0].iov_len = InsertPesHeader (PesHeader, NalLength, MPEG_VIDEO_PES_START_CODE, VideoPts, 0);
ssize_t l = writev(call->fd, iov, ic); ssize_t l = writev(call->fd, iov, ic);
if (l < 0) if (l < 0)
return l; return l;
@@ -345,7 +338,6 @@ static int writeData(void* _call)
VideoPts = INVALID_PTS_VALUE; VideoPts = INVALID_PTS_VALUE;
} }
}
} while (NalStart < SampleSize); } while (NalStart < SampleSize);
if (len < 0) if (len < 0)

View File

@@ -310,7 +310,7 @@ static int PlaybackOpen(Context_t *context, char * uri) {
} /* upnp */ } /* upnp */
else { else {
playback_err("Unknown stream!\n"); playback_err("Unknown stream (%s)\n", uri);
return cERR_PLAYBACK_ERROR; return cERR_PLAYBACK_ERROR;
} }
} }