Commit b29bfda6 authored by Andrew de Quincey's avatar Andrew de Quincey

Fixed some more indentation problems

ps2ts should now cope with PS files which end abruptly
parent a5b1abeb
......@@ -2,7 +2,7 @@
* filereader.cpp: file reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: filereader.cpp,v 1.9 2003/08/13 23:04:21 adq Exp $
* $Id: filereader.cpp,v 1.10 2003/08/14 14:45:49 adq Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* ps2ts.cpp: threaded PS to TS converter
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: ps2ts.cpp,v 1.14 2003/08/13 23:04:21 adq Exp $
* $Id: ps2ts.cpp,v 1.15 2003/08/14 14:45:49 adq Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -106,7 +106,8 @@ C_Ps2TsMpegConverter::C_Ps2TsMpegConverter(C_Module* pModule,
m_cConverter(cConfig.m_pReader,
cConfig.m_pTsProvider, 2,
cConfig.m_pBroadcast->GetOption("mpegversion").ToInt(),
cConfig.m_pBroadcast->GetOption("loop").ToInt())
cConfig.m_pBroadcast->GetOption("loop").ToInt(),
m_hLog)
{
m_bPreParse = (cConfig.m_pBroadcast->GetOption("preparse") == "1");
......
......@@ -2,7 +2,7 @@
* ps2ts.cpp: MPEG1 and MPEG2 PS to MPEG2 TS converter
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: ps2ts.cpp,v 1.9 2003/08/13 23:25:13 adq Exp $
* $Id: ps2ts.cpp,v 1.10 2003/08/14 14:45:49 adq Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -44,6 +44,7 @@
#define UNKNOWN_DATA -98
#define END_OF_STREAM -99
#define SYNC_MAX_LENGTH (1024*1024)
//------------------------------------------------------------------------------
//
......@@ -52,7 +53,8 @@ template <class Reader, class TsProvider>
C_Ps2Ts<Reader, TsProvider>::C_Ps2Ts(Reader* pReader, TsProvider* pTsProvider,
unsigned int iMaxBufferedTs,
unsigned int iMpegVersion,
bool bLooping) :
bool bLooping,
handle hLog) :
m_cPgrmDescriptor(iMpegVersion),
m_cPat(0, 0, 0), m_cPmt(0, 0, 0, 0, 0x50),
m_cPendingTS(NO)
......@@ -79,6 +81,7 @@ C_Ps2Ts<Reader, TsProvider>::C_Ps2Ts(Reader* pReader, TsProvider* pTsProvider,
m_bLooping = bLooping;
m_bInMiddleOfPES = false;
m_bJustSynched = false;
m_hLog = hLog;
if(iMpegVersion == 1)
m_iPackHeaderLen = MPEG1_PACK_HEADER_LEN - START_CODE_LEN;
......@@ -111,7 +114,7 @@ C_Ps2Ts<Reader, TsProvider>::~C_Ps2Ts()
template <class Reader, class TsProvider>
int C_Ps2Ts<Reader, TsProvider>::Synch()
{
int iRc;
int iRc = NO_ERR;
u8 headerCode[4];
u64 startPos;
......@@ -144,8 +147,8 @@ template <class Reader, class TsProvider>
memcpy(headerCode, headerCode+1, 3);
// just give up if we haven't found one within a reasonable distance
if ((m_pReader->GetPos() - startPos) > 1024 * 1024) {
printf("Failed to find a PACK_HEADER within 1Mb.\n");
if ((m_pReader->GetPos() - startPos) > SYNC_MAX_LENGTH) {
Log(m_hLog, LOG_ERROR, "Failed to find start of MPEG file");
m_iStatus = GEN_ERR;
break;
}
......@@ -161,7 +164,7 @@ template <class Reader, class TsProvider>
template <class Reader, class TsProvider>
C_TsPacket* C_Ps2Ts<Reader, TsProvider>::GetPacket(bool bPreparsing)
{
int iRc;
int iRc = NO_ERR;
bool bStreamLooped = false;
// if there's nothing left in the buffer. we need to fill it
......@@ -298,7 +301,7 @@ template <class Reader, class TsProvider>
template <class Reader, class TsProvider>
int C_Ps2Ts<Reader, TsProvider>::FetchPackets(bool bPreparsing)
{
int iRc;
int iRc = NO_ERR;
// if we're in the middle of parsing a PES packet,
// just do that immediately with no further ado
......@@ -357,7 +360,7 @@ template <class Reader, class TsProvider>
template <class Reader, class TsProvider>
int C_Ps2Ts<Reader, TsProvider>::ParsePackHeader(bool bPreparsing)
{
int iRc;
int iRc = NO_ERR;
// try to read in the data for the pack header
if (iRc = ReadData(m_bBuff, m_iPackHeaderLen)) {
......@@ -421,7 +424,7 @@ template <class Reader, class TsProvider>
template <class Reader, class TsProvider>
int C_Ps2Ts<Reader, TsProvider>::ParseSystemHeader()
{
int iRc;
int iRc = NO_ERR;
// read size of the system header
if (iRc = ReadDataLength(&m_iDataLen)) {
......@@ -441,7 +444,7 @@ template <class Reader, class TsProvider>
{
int iPos = 0;
int iPesPos = 0;
int iRc;
int iRc = NO_ERR;
// read size of the PES packet
if (!m_bInMiddleOfPES) {
......@@ -487,7 +490,7 @@ template <class Reader, class TsProvider>
}
// process the PES data
while((m_iDataLen > 0) && (m_cPendingTS.Size() < m_iMaxBufferedTs)) {
while ((m_iDataLen > 0) && (m_cPendingTS.Size() < m_iMaxBufferedTs)) {
// check if a new PMT has appeared. If so, just exit this loop.
// The caller will take care of generating it and possibly calling us
// again to add in more PES data
......@@ -499,7 +502,7 @@ template <class Reader, class TsProvider>
C_TsPacket* pPacket = m_pTsProvider->GetPacket();
// build the start of the TS packet
if(!m_bInMiddleOfPES) { // we're at the start of the PES packet
if (!m_bInMiddleOfPES) { // we're at the start of the PES packet
// build the header
u16 iPid = curDesc->GetPid();
u8 iCounter = curDesc->GetCounter();
......@@ -513,7 +516,7 @@ template <class Reader, class TsProvider>
m_bNeedToSendPCR = false;
// handle any discontinuity
if(m_bDiscontinuity) {
if (m_bDiscontinuity) {
pPacket->SetDiscontinuityFlag();
m_bDiscontinuity = false;
}
......@@ -572,9 +575,17 @@ template <class Reader, class TsProvider>
// OK, read the data from the stream into the TS packet
if (readSize) {
if (iRc = ReadData(((byte*)(*pPacket)+iPos), readSize)) {
if (iRc == END_OF_STREAM) {
// generate a TS packet with the error flag set to warn
// the decoder
memset(((byte*)(*pPacket)+iPos), 0, readSize);
pPacket->SetErrorFlag();
} else {
// some other more fatal error.. just exit right away
m_pTsProvider->ReleasePacket(pPacket);
return iRc;
}
}
m_iDataLen -= readSize;
}
......@@ -592,6 +603,9 @@ template <class Reader, class TsProvider>
// if we're preparsing, we only ever deal with one packet at a time
if (bPreparsing) break;
// if the stream ended abruptly, abort the loop
if (iRc == END_OF_STREAM) break;
}
// if we're NOT still in the middle of a PES, clear the flag
......@@ -599,8 +613,8 @@ template <class Reader, class TsProvider>
m_bInMiddleOfPES = false;
}
// if we get here, there isn't a problem
return NO_ERR;
// OK, return the status. This will be either NO_ERR or END_OF_STREAM
return iRc;
}
......
......@@ -2,7 +2,7 @@
* ps2ts.h: MPEG1 and MPEG2 PS to TS converter
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: ps2ts.h,v 1.5 2003/08/13 23:04:22 adq Exp $
* $Id: ps2ts.h,v 1.6 2003/08/14 14:45:49 adq Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -37,7 +37,7 @@ template <class Reader, class TsProvider> class C_Ps2Ts
{
public:
C_Ps2Ts(Reader* pReader, TsProvider* pTsProvider, unsigned int iMaxBufferedTs,
unsigned int iMpegVersion, bool bLooping);
unsigned int iMpegVersion, bool bLooping, handle hLog);
~C_Ps2Ts();
// Find the first pack header in the stream
......@@ -67,6 +67,7 @@ template <class Reader, class TsProvider> class C_Ps2Ts
Reader* m_pReader;
TsProvider* m_pTsProvider;
unsigned int m_iMaxBufferedTs;
handle m_hLog;
// Parser configuration
u8 m_iPackHeaderLen;
......
......@@ -2,7 +2,7 @@
* tsstreamer.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: tsstreamer.cpp,v 1.20 2003/08/13 23:04:22 adq Exp $
* $Id: tsstreamer.cpp,v 1.21 2003/08/14 14:45:49 adq Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment