[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-datatype-cvs
Subject: [Datatype-cvs] mpeg2ts/fileformat tsfformat.cpp, 1.20.2.11.2.17.2.4,
From: ching_li () helixcommunity ! org
Date: 2013-04-27 7:49:38
[Download RAW message or body]
Update of /cvsroot/datatype/mpeg2ts/fileformat
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv26548/fileformat
Modified Files:
Tag: hxclient_5_0_1_hebe
tsfformat.cpp
Log Message:
Summary:
merged from 310atlas to fix bug HXC-338, and removed some useless logic.
Branch:
501hebe
Index: tsfformat.cpp
===================================================================
RCS file: /cvsroot/datatype/mpeg2ts/fileformat/tsfformat.cpp,v
retrieving revision 1.20.2.11.2.17.2.4
retrieving revision 1.20.2.11.2.17.2.5
diff -u -d -r1.20.2.11.2.17.2.4 -r1.20.2.11.2.17.2.5
--- tsfformat.cpp 3 Dec 2012 03:53:35 -0000 1.20.2.11.2.17.2.4
+++ tsfformat.cpp 27 Apr 2013 07:49:15 -0000 1.20.2.11.2.17.2.5
@@ -72,6 +72,10 @@
const char* const CTSFileFormat::zm_pFileExtensions[] = {"ts", "tp", "m2ts", NULL};
const char* const CTSFileFormat::zm_pFileOpenNames[] = {"Transport Stream File \
(*.ts, *.tp, *.m2ts)", NULL};
+#define HX_TS_AVC1_MIME_TYPE "video/H264ES"
+#define HX_TS_AAC_ADTS_MIME_TYPE "audio/X-HX-AAC-ADTS"
+
+#define MAX_FILE_OFFSET_OF_FILE_HEADER 8000000
STDAPI ENTRYPOINTCALLTYPE ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** ppIUnknown)
{
@@ -94,8 +98,6 @@
return HXR_OK;
}
-#define MAX_FILE_OFFSET_OF_FILE_HEADER 8000000
-
/*
* constructor, destructor
*/
@@ -110,10 +112,8 @@
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
, m_pFileObject64(NULL)
#endif
-#ifdef ANDROID
, m_pScheduler(NULL)
, m_hPendingCallback(0)
-#endif
, m_ullFileSize(0)
, m_ullFileOffset(0)
, m_ullPendingSeekOffset(0)
@@ -132,6 +132,7 @@
, m_bUseRawDTS(FALSE)
, m_bFirstDTSBaseSet(FALSE)
, m_bPostPMTSeekPending(FALSE)
+ , m_bHasVideoStream(FALSE)
{
}
@@ -150,12 +151,8 @@
{
m_pContext = pContext;
m_pContext->AddRef();
-#ifdef ANDROID
HX_RESULT retVal = m_pContext->QueryInterface(IID_IHXScheduler, (void**) \
&m_pScheduler); return retVal;
-#else
- return HXR_OK;
-#endif
}
else
{
@@ -295,9 +292,7 @@
HX_RELEASE(m_pContext);
HX_RELEASE(m_pRequest);
HX_RELEASE(m_pFFResponse);
-#ifdef ANDROID
HX_RELEASE(m_pScheduler);
-#endif
return HXR_OK;
}
@@ -408,7 +403,7 @@
// seek to file start
m_eStatus = GetPacketSizeSeekPending;
- m_ullPendingSeekOffset = 0;
+ m_ullPendingSeekOffset = 0;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
if (m_pFileObject64)
return m_pFileObject64->Seek((UINT64)0, FALSE, FALSE);
@@ -459,7 +454,7 @@
m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize);
}
return retVal;
@@ -503,11 +498,20 @@
}
else if (m_eStatus == Ready)
{
- UINT64 ullReadSize = m_bUseRawDTS? m_ulTSReadSize: \
(m_ullFileSize - m_ullFileOffset);
- if (ullReadSize > m_ulTSReadSize)
+ UINT64 ullReadSize;
+ if ( IsPlayingStream() )
{
ullReadSize = m_ulTSReadSize;
}
+ else
+ {
+ ullReadSize = m_ullFileSize - m_ullFileOffset;
+ if (ullReadSize > m_ulTSReadSize)
+ {
+ ullReadSize = m_ulTSReadSize;
+ }
+ }
+
// need more TS packet
m_eStatus = GetPacketReadPending;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
@@ -560,20 +564,27 @@
// clear packet queues and reset TS demuxer state
m_bEndOfFileReached = FALSE;
m_pTSDemuxer->Reset();
- m_pTSDemuxer->SetFirstDTSBaseOffset(0);
+ m_pTSDemuxer->SetFirstDTSBaseOffset(0);
m_pTSDemuxer->SetSeekTime(requestedTime);
- m_bNeedKeyFrame = TRUE;
+ if (m_bHasVideoStream)
+ {
+ m_bNeedKeyFrame = TRUE;
+ }
// convert time to offset
UINT64 ullByteOffset = 0;
UINT64 noUse = 0;
HX_RESULT ConvertResult = ConvertSeekTimeToOffset( \
m_pTSDemuxer->GetSeekTime(), &ullByteOffset, &noUse);
+ if (m_ullFileSize && ullByteOffset > m_ullFileSize)
+ {
+ ullByteOffset = m_ullFileSize;
+ }
if ( HXR_OK == ConvertResult )
{
- // tell file obj to seek to the offset
- m_eStatus = SeekSeekPending;
+ // tell file obj to seek to the offset
+ m_eStatus = SeekSeekPending;
}
else if ( HXR_NO_DATA == ConvertResult )
{
@@ -639,7 +650,7 @@
STDMETHODIMP CTSFileFormat::ReadDone(HX_RESULT status, IHXBuffer* pBuffer)
{
HX_RESULT retVal = status;
-
+
if (status == HXR_AT_END && pBuffer == NULL)
{
m_bEndOfFileReached = TRUE;
@@ -782,16 +793,16 @@
return m_pFileObject->Seek( (ULONG32)m_ullPendingSeekOffset, FALSE );
}
}
-
+
// seek back to where it was
m_eStatus = ScanEndTimeSeekBackPending;
- m_ullPendingSeekOffset = m_ullFileOffsetBeforeScanEndTime ;
+ m_ullPendingSeekOffset = m_ullFileOffsetBeforeScanEndTime;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- return m_pFileObject64->Seek(m_ullPendingSeekOffset, FALSE, FALSE);
+ if (m_pFileObject64)
+ return m_pFileObject64->Seek(m_ullPendingSeekOffset, FALSE, FALSE);
#endif
- return m_pFileObject->Seek( (ULONG32)m_ullPendingSeekOffset, FALSE );
+ return m_pFileObject->Seek( (ULONG32)m_ullPendingSeekOffset, FALSE );
}
// process PAT
@@ -819,13 +830,13 @@
m_bPostPMTSeekPending = TRUE;
// read more data to scan for PAT
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- return m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
+ if (m_pFileObject64)
+ return m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
#endif
return m_pFileObject->Read(m_ulTSReadSize);
}
}
-
+
// process PMT
if (SUCCEEDED(retVal) && ulReadSize > 0 && m_pTSDemuxer->IsSeenPMT() == FALSE)
{
@@ -836,8 +847,8 @@
m_bPostPMTSeekPending = TRUE;
// read more data
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- return m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
+ if (m_pFileObject64)
+ return m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
#endif
return m_pFileObject->Read(m_ulTSReadSize);
}
@@ -849,8 +860,8 @@
m_eStatus = GetFileHeaderSeekPending;
m_ullPendingSeekOffset = 0;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- return m_pFileObject64->Seek((UINT64)0, FALSE, FALSE);
+ if (m_pFileObject64)
+ return m_pFileObject64->Seek((UINT64)0, FALSE, FALSE);
#endif
return m_pFileObject->Seek(0, FALSE);
}
@@ -898,7 +909,7 @@
if (bFileHeaderNeedMoreData)
{
- // workaround: we should break the loop if we have read too many data!!!
+ // we should break the loop if we have read too many data!!!
if (m_ullFileOffset > MAX_FILE_OFFSET_OF_FILE_HEADER)
{
retVal = HXR_UNEXPECTED;
@@ -911,7 +922,7 @@
m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize);
}
}
else
@@ -1008,7 +1019,7 @@
m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize \
); else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize);
HX_RELEASE(pStreamHeader);
break;
}
@@ -1055,25 +1066,18 @@
}
else
{
-// on android platform, the m_pFileObject64->Read is immplemented as sync mode
-#ifdef ANDROID
- // schedule this callback to read more data.
- m_hPendingCallback = m_pScheduler->RelativeEnter(this, \
0);
-#else
- UINT64 ullReadSize = m_bUseRawDTS? m_ulTSReadSize: \
(m_ullFileSize - m_ullFileOffset);
- if (ullReadSize > m_ulTSReadSize)
+ if ( IsPlayingStream() )
{
- ullReadSize = m_ulTSReadSize;
+ // read more TS packets
+ m_eStatus = GetPacketReadPending;
+ // in streaming mode, the m_pFileObject64 should \
always be NULL. + retVal = \
m_pFileObject->Read(m_ulTSReadSize); }
- // read more TS packets
- m_eStatus = GetPacketReadPending;
-#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- retVal = m_pFileObject64->Read(ullReadSize);
else
-#endif
- retVal = m_pFileObject->Read( (UINT32)ullReadSize );
-#endif
+ {
+ // schedule this callback to read more data.
+ m_hPendingCallback = \
m_pScheduler->RelativeEnter(this, 0); + }
break; // break the loop because we will process other \
streams when invoke ReadDone at next time. }
}
@@ -1139,7 +1143,7 @@
m_LastError = m_pFileObject64->Read( ProbeSize );
else
#endif
- m_LastError = m_pFileObject->Read( (INT32)ProbeSize );
+ m_LastError = m_pFileObject->Read( (INT32)ProbeSize );
}
break;
@@ -1161,7 +1165,7 @@
m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize);
}
else
{
@@ -1181,7 +1185,7 @@
m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize * 2 );
else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize * 2);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize * 2);
}
else
{
@@ -1193,14 +1197,14 @@
case ScanEndTimeSeekPending:
if (SUCCEEDED(status))
{
- // read the end of the file
- m_eStatus = ScanEndTimeReadPending;
+ // read the end of the file
+ m_eStatus = ScanEndTimeReadPending;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
- if (m_pFileObject64)
- m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
- else
+ if (m_pFileObject64)
+ m_LastError = m_pFileObject64->Read( (UINT64)m_ulTSReadSize );
+ else
#endif
- m_LastError = m_pFileObject->Read(m_ulTSReadSize);
+ m_LastError = m_pFileObject->Read(m_ulTSReadSize);
}
else
{
@@ -1254,10 +1258,10 @@
// save file size
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
if (m_pFileObject64)
- m_ullFileSize = m_pFileObject64->GetFileSize64();
- else
+ m_ullFileSize = m_pFileObject64->GetFileSize64();
+ else
#endif
- m_ullFileSize = nSize;
+ m_ullFileSize = nSize;
}
if (m_eStatus == InitPending)
@@ -1357,6 +1361,34 @@
// create a stream header
retVal = CreateValuesCCF(pStreamHeader, m_pContext);
+ if (SUCCEEDED(retVal))
+ {
+ // stream number
+ pStreamHeader->SetPropertyULONG32("StreamNumber", (UINT32)streamNo);
+
+ // ASMRuleBook
+ SetCStringPropertyCCF(pStreamHeader, "ASMRuleBook", \
"Marker=0;Marker=1;", m_pContext); +
+ // renderer MimeType
+ UINT32 ulStreamFormat = m_pTSDemuxer->GetStreamFormat(streamNo);
+ if (ulStreamFormat == TS_STREAM_TYPE_H264)
+ {
+ m_bHasVideoStream = TRUE;
+ SetCStringPropertyCCF(pStreamHeader, "MimeType", \
HX_TS_AVC1_MIME_TYPE, m_pContext); + }
+ else if (ulStreamFormat == TS_STREAM_TYPE_AAC_ADTS)
+ {
+ SetCStringPropertyCCF(pStreamHeader, "MimeType", \
HX_TS_AAC_ADTS_MIME_TYPE, m_pContext); + }
+ else
+ {
+ // TODO: add additional format support
+ retVal = HXR_NOT_SUPPORTED;
+ }
+
+ // timebase is 90k
+ pStreamHeader->SetPropertyULONG32("SamplesPerSecond", 90000);
+ }
// add stream specific values to the stream header
if (SUCCEEDED(retVal))
@@ -1402,7 +1434,7 @@
{
dRatio = (double)m_ullFileOffset / ulTimeSpan;
}
- else if (!m_bUseRawDTS)
+ else if ( !IsPlayingStream() )
{
ulTimeSpan = m_pTSDemuxer->GetDuration();
if (ulTimeSpan > 0)
@@ -1429,8 +1461,10 @@
void
CTSFileFormat::PreloadPacketsIfNeed()
{
-#ifdef ANDROID
- if (Ready == m_eStatus && !m_bEndOfFileReached && !m_hPendingCallback && \
!m_bUseRawDTS) + if ( !IsPlayingStream() &&
+ Ready == m_eStatus &&
+ !m_bEndOfFileReached &&
+ !m_hPendingCallback )
{
for (UINT16 i=0; i<(UINT16)m_ulStreamCount; i++)
{
@@ -1448,20 +1482,20 @@
}
}
}
-#endif
}
-#ifdef ANDROID
STDMETHODIMP CTSFileFormat::Func()
{
m_hPendingCallback = 0;
if (Ready == m_eStatus && !m_bEndOfFileReached && m_pFileObject)
{
- UINT64 ullReadSize = m_bUseRawDTS? m_ulTSReadSize: (m_ullFileSize - \
m_ullFileOffset); + // this callback is only invoked in local mode.
+ UINT64 ullReadSize = m_ullFileSize - m_ullFileOffset;
if (ullReadSize > m_ulTSReadSize)
{
ullReadSize = m_ulTSReadSize;
}
+
// read more TS packets
m_eStatus = GetPacketReadPending;
#ifdef HELIX_FEATURE_64_BIT_FILE_SUPPORT
@@ -1469,8 +1503,6 @@
m_pFileObject64->Read(ullReadSize);
else
#endif
- m_pFileObject->Read( (UINT32)ullReadSize );
+ m_pFileObject->Read( (UINT32)ullReadSize );
}
}
-#endif
-
_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic