[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-datatype-cvs
Subject: [Datatype-cvs] mp4/filewriter h263sh.cpp, NONE, 1.1.2.1 h263sh.h,
From: stanb () helixcommunity ! org
Date: 2008-09-26 16:39:38
Message-ID: 200809261645.m8QGjQJ7007459 () mailer ! progressive-comp ! com
[Download RAW message or body]
Update of /cvsroot/datatype/mp4/filewriter
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv22340/datatype/mp4/filewriter
Modified Files:
Tag: hxclient_3_1_0_atlas
Umakefil mp4atoms.h mp4sm.cpp mp4sm.h mp4wrtr.cpp
Added Files:
Tag: hxclient_3_1_0_atlas
h263sh.cpp h263sh.h
Log Message:
Support of h.263 video stream in 3gp files added to mp4 file writer.
Index: Umakefil
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/Umakefil,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -d -r1.5.2.1 -r1.5.2.2
--- Umakefil 21 Mar 2008 11:26:53 -0000 1.5.2.1
+++ Umakefil 26 Sep 2008 16:39:35 -0000 1.5.2.2
@@ -48,7 +48,8 @@
'mp4wrtr.cpp',
'ra10sh.cpp',
'm4avsh.cpp',
- 'avcsh.cpp',
+ 'avcsh.cpp',
+ 'h263sh.cpp',
'blist.cpp',
'mp4sm.cpp',
'mp4atomgateway.cpp'
Index: mp4sm.cpp
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4sm.cpp,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -d -r1.3.2.3 -r1.3.2.4
--- mp4sm.cpp 6 May 2008 10:08:13 -0000 1.3.2.3
+++ mp4sm.cpp 26 Sep 2008 16:39:35 -0000 1.3.2.4
@@ -2215,6 +2215,9 @@
case MP4_BUILD_ATOMID('a', 'v', 'c', '1'):
return BuildAVC1StsdEntry(pStsd, usStreamNum);
break;
+ case MP4_BUILD_ATOMID('h', '2', '6', '3'):
+ return BuildH263StsdEntry(pStsd, usStreamNum);
+ break;
default:
return HXR_INVALID_PARAMETER;
break;
@@ -2392,6 +2395,47 @@
return retVal;
}
+HX_RESULT CMP4StreamMixer::BuildH263StsdEntry( CMP4Atom_stsd* pStsd, UINT16 \
usStreamNum ) +{
+ IHXValues* pStreamHeader = m_pStreamInfo[usStreamNum].m_pStreamHeader;
+ HX_RESULT retVal = HXR_OUTOFMEMORY;
+
+ IHXBuffer* pDecoderInfo = NULL;
+ retVal = pStreamHeader->GetPropertyBuffer("DecoderInfo", pDecoderInfo);
+
+ if( SUCCEEDED( retVal ) )
+ {
+ UCHAR* pBuf = pDecoderInfo->GetBuffer();
+ UINT32 len = pDecoderInfo->GetSize();
+
+ CMP4Atom_s263* pS263 = new CMP4Atom_s263();
+ if( pS263 )
+ {
+ retVal = HXR_OK;
+
+ UINT32 ulWidth = 0, ulHeight = 0;
+ m_pStreamInfo[usStreamNum].m_pStreamHeader->GetPropertyULONG32("Width", \
ulWidth); + m_pStreamInfo[usStreamNum].m_pStreamHeader->GetPropertyULONG32("Height", \
ulHeight); +
+ pS263->SetWidth((UINT16) ulWidth);
+ pS263->SetHeight((UINT16) ulHeight);
+
+ CMP4Atom_d263* pD263 = new CMP4Atom_d263();
+ if( pD263 )
+ {
+ pD263->SetDecoderInfo( pBuf, len );
+ pS263->AddChild( pD263 );
+ }
+
+ pStsd->AddChild( pS263 );
+ }
+
+ HX_RELEASE( pDecoderInfo );
+ }
+
+ return retVal;
+}
+
HX_RESULT CMP4StreamMixer::UpdateTrackDuration( UINT16 usStreamNo, UINT32 ulDuration \
) {
Index: mp4wrtr.cpp
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4wrtr.cpp,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
--- mp4wrtr.cpp 21 Mar 2008 11:26:53 -0000 1.7.2.1
+++ mp4wrtr.cpp 26 Sep 2008 16:39:35 -0000 1.7.2.2
@@ -73,6 +73,7 @@
#include "ra10sh.h"
#include "m4avsh.h"
#include "avcsh.h"
+#include "h263sh.h"
//stream mixer
#include "mp4sm.h"
@@ -698,6 +699,20 @@
}
}
+ //h.263 stream handler
+ if( FAILED( retVal ) )
+ {
+ HX_RELEASE( pTempHandler );
+ retVal = HXR_OUTOFMEMORY;
+ pTempHandler = new CH263StreamHandler( m_pContext, m_pStreamMixer );
+
+ if( pTempHandler )
+ {
+ pTempHandler->AddRef();
+ retVal = TestForMimeSupport( pTempHandler, pStreamMimeType );
+ }
+ }
+
//default NULL stream handler, always true
if ( FAILED( retVal ) )
{
Index: mp4sm.h
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4sm.h,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -d -r1.2.2.3 -r1.2.2.4
--- mp4sm.h 6 May 2008 10:08:13 -0000 1.2.2.3
+++ mp4sm.h 26 Sep 2008 16:39:35 -0000 1.2.2.4
@@ -102,6 +102,7 @@
HX_RESULT BuildMP4AStsdEntry( CMP4Atom_stsd* pStsd, UINT16 usStreamNum );
HX_RESULT BuildMP4VStsdEntry( CMP4Atom_stsd* pStsd, UINT16 usStreamNum );
HX_RESULT BuildAVC1StsdEntry( CMP4Atom_stsd* pStsd, UINT16 usStreamNum );
+ HX_RESULT BuildH263StsdEntry( CMP4Atom_stsd* pStsd, UINT16 usStreamNum );
// 3GP Utilities
void Meta3GP_SetLanguageEncoding(C3GPAtom_LangBase* pAtom, const char* \
propertySpec = 0);
Index: mp4atoms.h
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4atoms.h,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -d -r1.5.2.1 -r1.5.2.2
--- mp4atoms.h 28 Apr 2008 02:07:31 -0000 1.5.2.1
+++ mp4atoms.h 26 Sep 2008 16:39:35 -0000 1.5.2.2
@@ -1656,6 +1656,75 @@
}
};
+// atom: d263
+// container: s263
+// purpose: h263 decoder info
+class CMP4Atom_d263 : public CMP4Atom
+{
+public:
+ CMP4Atom_d263() : CMP4Atom(MP4_BUILD_ATOMID('d','2','6','3'))
+ {
+ m_ulDecoderInfoSize = 0;
+ m_pDecoderInfo = NULL;
+ }
+
+ ~CMP4Atom_d263()
+ {
+ HX_VECTOR_DELETE(m_pDecoderInfo);
+ }
+
+ STDMETHOD_(UINT32, GetCurrentSize ) (THIS_ BOOL bIncludeChildren = FALSE)
+ {
+ return 8 + m_ulDecoderInfoSize;
+ }
+
+ STDMETHOD( WriteToBuffer ) (THIS_ UCHAR*& pBuffer,
+ BOOL bIncludeChildren=FALSE)
+ {
+ HX_RESULT retVal = HXR_OK;
+
+ if( pBuffer )
+ {
+ CMP4Atom::WriteToBufferAndInc( pBuffer, GetCurrentSize() );
+ CMP4Atom::WriteToBufferAndInc( pBuffer, m_ulAtomID );
+
+ CMP4Atom::WriteToBufferAndInc( pBuffer, m_pDecoderInfo, m_ulDecoderInfoSize);
+
+ if( bIncludeChildren )
+ {
+ ChildrenWriteToBuffer( pBuffer );
+ }
+ }
+ return retVal;
+ }
+
+ void SetDecoderInfo(UINT8* pData, int size)
+ {
+ HX_VECTOR_DELETE(m_pDecoderInfo);
+ m_pDecoderInfo = new UINT8[size];
+ memcpy(m_pDecoderInfo, pData, size);
+ m_ulDecoderInfoSize = size;
+ }
+
+private:
+
+ UINT32 m_ulDecoderInfoSize;
+ UINT8* m_pDecoderInfo;
+};
+
+
+// atom: s263
+// container: stsd
+// purpose: h263 video sample description entry
+class CMP4Atom_s263 : public CMP4Atom_VisualSampleEntry
+{
+public:
+ CMP4Atom_s263() : CMP4Atom_VisualSampleEntry(MP4_BUILD_ATOMID('s','2','6','3'))
+ {
+ }
+};
+
+
// atom: AudioSampleEntry base box
// container: stsd
// purpose: base box for AudioSampleEntry
--- NEW FILE: h263sh.h ---
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
// AVCsh.h: AVC streamhandler
// the initial version of this will plug directly into a streamhandler and output a \
AVC; later versions // would require a second component to be built up which would \
handle layout, and instead of calling archiver // routines to write a file, this \
component would feed packets to the layout object.
#ifndef _H263SH_H_
#define _H263SH_H_
#include "mp4fwplg.h"
typedef _INTERFACE IHXCommonClassFactory IHXCommonClassFactory;
class CH263StreamHandler : public IMP4StreamHandler
{
public:
CH263StreamHandler( IUnknown* pContext, IMP4StreamMixer* pMixer );
~CH263StreamHandler();
/*
* IUnknown
*/
STDMETHOD(QueryInterface) ( THIS_ REFIID riid, void** ppvObj );
STDMETHOD_(ULONG32,AddRef) ( THIS );
STDMETHOD_(ULONG32,Release) ( THIS );
/*
* IMP4StreamHandler
*/
STDMETHOD(GetFormatInfo) ( THIS_
const char*** /*OUT*/ pFileMimeTypes,
const char*** /*OUT*/ pFileExtensions,
const char*** /*OUT*/ pFileOpenNames
);
STDMETHOD(InitStreamHandler) ( THIS );
STDMETHOD(SetFileHeader) ( THIS_ IHXValues* pHeader );
STDMETHOD(SetStreamHeader) ( THIS_ IHXValues* pHeader );
STDMETHOD(SetPacket) ( THIS_ IHXPacket* pPacket );
STDMETHOD(StreamDone) ( THIS );
private:
static const char* m_pszFileMimeTypes[];
static const char* m_pszFileExtensions[];
static const char* m_pszFileOpenNames[];
LONG32 m_lRefCount;
UINT16 m_unStreamNumber;
IMP4StreamMixer* m_pStreamMixer;
IUnknown* m_pContext;
IHXCommonClassFactory* m_pCommonClassFactory;
};
#endif /* _H263SH_H_ */
--- NEW FILE: h263sh.cpp ---
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
// h263sh.cpp: H.263 stream handler
#include "hxcom.h"
#include "hxcomm.h"
#include "chxpckts.h"
#include "hxassert.h"
#include "mp4atoms.h"
#include "mp4sm.h"
#include "h263sh.h"
#include "rmfftype.h"
#include "netbyte.h" /* common/util/pub/netbyte.h, dwtohost */
// These are the mime types we support
const char* CH263StreamHandler::m_pszFileMimeTypes[] =
{
"video/X-HX-H263",
NULL
};
const char* CH263StreamHandler::m_pszFileExtensions[] =
{
NULL
};
const char* CH263StreamHandler::m_pszFileOpenNames[] =
{
NULL
};
// CH263StreamHandler code
CH263StreamHandler::CH263StreamHandler( IUnknown* pContext, IMP4StreamMixer* pMixer )
{
m_lRefCount = 0;
m_unStreamNumber = 0;
HX_ASSERT(pMixer);
pMixer->AddRef();
m_pStreamMixer = pMixer;
HX_ASSERT(pContext);
pContext->AddRef();
m_pContext = pContext;
m_pCommonClassFactory = NULL;
}
CH263StreamHandler::~CH263StreamHandler()
{
HX_RELEASE( m_pStreamMixer );
HX_RELEASE( m_pContext );
HX_RELEASE( m_pCommonClassFactory );
}
STDMETHODIMP CH263StreamHandler::QueryInterface( REFIID riid, void** ppvObj )
{
// dont support, for now
return HXR_NOINTERFACE;
}
STDMETHODIMP_(ULONG32) CH263StreamHandler::AddRef()
{
return InterlockedIncrement( &m_lRefCount );
}
STDMETHODIMP_(ULONG32) CH263StreamHandler::Release()
{
if( InterlockedDecrement( &m_lRefCount ) > 0 )
{
return m_lRefCount;
}
delete this;
return 0;
}
STDMETHODIMP CH263StreamHandler::GetFormatInfo( const char*** pppFileMimeTypes, const \
char*** pppFileExtensions, const char*** pppFileOpenNames ) {
if( pppFileMimeTypes )
{
*pppFileMimeTypes = m_pszFileMimeTypes;
}
if( pppFileExtensions )
{
*pppFileExtensions = m_pszFileExtensions;
}
if( pppFileOpenNames )
{
*pppFileOpenNames = m_pszFileOpenNames;
}
return HXR_OK;
}
// InitStreamHandler; this is called after the mp4 filewriter
// has determined it has a stream that actually matches our supported
// mime types, and allows us to do any initialization that would be
// inappropriate in the constructor (such as memory allocation)
STDMETHODIMP CH263StreamHandler::InitStreamHandler()
{
HX_RESULT retVal;
retVal = m_pContext->QueryInterface( IID_IHXCommonClassFactory, (void**) \
&m_pCommonClassFactory );
return retVal;
}
STDMETHODIMP CH263StreamHandler::SetFileHeader( IHXValues* pHeader )
{
// We dont need the fileheader at all
return HXR_OK;
}
// SetStreamHeader; called when the stream header for this stream is available
STDMETHODIMP CH263StreamHandler::SetStreamHeader( IHXValues* pHeader )
{
HX_RESULT retVal = HXR_OK;
UINT32 ulStreamNumber;
pHeader->GetPropertyULONG32("StreamNumber", ulStreamNumber);
m_unStreamNumber = (UINT16) ulStreamNumber;
IHXBuffer* pOpaqueData = NULL;
retVal = pHeader->GetPropertyBuffer("OpaqueData", pOpaqueData);
if(pOpaqueData)
{
UCHAR* pBuffer = pOpaqueData->GetBuffer();
UINT32 ulLen = pOpaqueData->GetSize();
if ( SUCCEEDED(retVal) )
{
// h263 encoder plugin puts decoder info in OpaqueData.
// Producer though always attaches a MultiStreamHeader to the front.
// Need to strip the MLTI header
UINT32 ulID = DwToHost(*(UINT32*)(pBuffer));
if( RM_MULTIHEADER_OBJECT == ulID )
{
MultiStreamHeader multiStreamHeader;
UCHAR* pOpaqueData = pBuffer;
pBuffer = multiStreamHeader.unpack( pBuffer, ulLen );
//bypass the size of header field, we should be at the H263 decoder block now
pBuffer += sizeof(UINT32);
ulLen -= (pBuffer - pOpaqueData);
}
}
IHXBuffer* pDecoderInfoBuffer = NULL;
if (SUCCEEDED(retVal))
{
retVal = m_pCommonClassFactory->CreateInstance( IID_IHXBuffer, (void**) \
&pDecoderInfoBuffer ); }
if (SUCCEEDED(retVal))
{
pDecoderInfoBuffer->Set(pBuffer, ulLen);
pHeader->SetPropertyBuffer("DecoderInfo", pDecoderInfoBuffer );
}
HX_RELEASE(pDecoderInfoBuffer);
HX_RELEASE(pOpaqueData);
}
if (SUCCEEDED(retVal))
{
// Indicate this is a video track with h263 sample format
pHeader->SetPropertyULONG32( "TrackType", MP4_BUILD_ATOMID('v','i','d','e') \
);
pHeader->SetPropertyULONG32( "SampleFormat", \
MP4_BUILD_ATOMID('h','2','6','3') );
m_pStreamMixer->SetStreamHeader( pHeader );
}
return retVal;
}
// SetPacket; called every time a packet comes in
STDMETHODIMP CH263StreamHandler::SetPacket( IHXPacket* pPacket )
{
HX_RESULT retVal = HXR_FAIL;
if( pPacket )
{
// pass through
retVal = m_pStreamMixer->SetPacket( pPacket );
}
return HXR_OK;
}
// StreamDone; called after the final SetPacket() call for this stream
STDMETHODIMP CH263StreamHandler::StreamDone()
{
m_pStreamMixer->StreamDone( m_unStreamNumber );
return HXR_OK;
}
_______________________________________________
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