[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] mp4/filewriter cspkt.h, NONE, 1.1 Umakefil, 1.9,
From:       vkeinonen () helixcommunity ! org
Date:       2009-03-27 9:27:03
Message-ID: 200903271029.n2RATKEs025524 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/datatype/mp4/filewriter
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv5511

Modified Files:
	Umakefil mp4atoms.h mp4sm.cpp mp4sm.h 
Added Files:
	cspkt.h 
Log Message:
3GPP features for the MPEG 4 filewriter

 - New properties: 3GPPMode and GenerateHintTracks

 - Time-based interleaving for progressive downloads

 - Writing of hint tracks

 - Various bugfixes (add ctts if necessary, skip damr and d263 boxes left
   by the fileformat plugin)



Index: mp4sm.cpp
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4sm.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mp4sm.cpp	9 Mar 2009 18:36:51 -0000	1.8
+++ mp4sm.cpp	27 Mar 2009 09:27:00 -0000	1.9
@@ -53,6 +53,8 @@
 // Added for branching off to type specific atoms build
 #include "mp4atomgateway.h"
 
+#include "cspkt.h"
+
 #define MP4_RESERVE_BLOCK_SIZE    (1024)
 
 #define MP4_DEFAULT_METADATA_RESERVE_SIZE (2 * 1024)
@@ -67,15 +69,23 @@
 class CStblManager
 {
[...1406 lines suppressed...]
+	    hi->sdp->SetSDP(sdp, sdplen);
+	}
+    }
+
     return HXR_OK;
 }
 
@@ -2498,4 +3025,12 @@
     return retVal;
 }
 
+CHXRTPSample::CHXRTPSample()
+    : timestamp(0), ss_flag(FALSE), cur_size(0), data(NULL)
+{
+}
 
+CHXRTPSample::~CHXRTPSample()
+{
+    HX_VECTOR_DELETE(data);
+}

Index: mp4sm.h
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4sm.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mp4sm.h	9 Mar 2009 18:36:51 -0000	1.6
+++ mp4sm.h	27 Mar 2009 09:27:00 -0000	1.7
@@ -41,12 +41,16 @@
 #include "mp4fwplg.h"
 #include "proptools.h"
 
+#include "chxhintgen.h"
+
 // fdecl
 class CMP4Atom;
 class CMP4Atom_mvhd;
+class CMP4Atom_trak;
 class CMP4Atom_tkhd;
 class CMP4Atom_mdhd;
 class CMP4Atom_stsd;
+class CMP4Atom_sdp;
 class CMP4Archiver;
 
 class CMP4VersionedAtom;
@@ -57,6 +61,8 @@
 
 class CMP4StreamMixer : public IMP4StreamMixer
 {
+private:
+    struct HintInfo;
 public:
     CMP4StreamMixer( IUnknown* pContext, CMP4Archiver* pArchiver );
     ~CMP4StreamMixer();
@@ -94,6 +100,9 @@
     // Build the trak subtree
     HX_RESULT BuildTrack( UINT16 usStreamNum, CMP4Atom* pTrak );
 
+    // Build the mdia subtree
+    HX_RESULT BuildMdia(UINT16 usStreamNum, CMP4Atom *pTrak, HintInfo *pHinfo);
+
     // Build out an stsd entry for a specific stream
     HX_RESULT BuildStsdEntry( CMP4Atom_stsd* pStsd, UINT16 usStreamNum );
     
@@ -118,6 +127,7 @@
     HX_RESULT UpdateTrackDuration( UINT16 usStreamNo, UINT32 ulDuration );
 
     HX_RESULT FlushPackets( UINT16 uiStreamNo );
+    HX_RESULT FlushHintPackets( UINT16 uiStreamNo );
 
     // Routine to dump out atom contents
     HX_RESULT DumpAtoms();
@@ -145,6 +155,22 @@
     UINT32     m_ulStreamHeaderReceived;
     UINT32     m_ulStreamDoneReceived;
 
+    struct HintInfo {
+	CHXHintGenerator hinting;
+	CHXSimpleList pktlist;
+	CMP4Atom_trak *trak;
+	CMP4Atom_tkhd *tkhd;
+	CMP4Atom_mdhd *mdhd;
+	CMP4Atom_sdp *sdp;
+	CStblManager *stblmgr;
+	UINT32 trackid;
+
+	HintInfo(CHXHintContext &);
+	~HintInfo();
+    };
+
+    CHXHintContext m_HintContext;
+
     struct StreamInfo {
         IHXValues* m_pStreamHeader;
         CStblManager* m_pStblManager;
@@ -155,6 +181,7 @@
         CHXSimpleList* m_pPacketList;
         CMP4Atom_tkhd* m_pTkhd;
         CMP4Atom_mdhd* m_pMdhd;
+	HintInfo *m_pHintInfo;
 
         StreamInfo();
         ~StreamInfo();
@@ -187,6 +214,25 @@
 
     BOOL m_bUTF16Output;
     EncodedString m_spCompatibility;
+
+protected:
+    enum ThreeGPPMode
+    {
+	M3GPP_NONE,
+	M3GPP_GENERAL,
+	M3GPP_BASIC,
+	M3GPP_STREAMING,
+	M3GPP_PROGDL
+    };
+    ThreeGPPMode m_e3gpMode;
+    HXBOOL m_bTSInterleave;
+    HXBOOL m_bGenerateHintTracks;
+
+    friend class CStblManager;
+
+    UINT32 m_uiBaseWriteOffset;
+    UINT32 m_uiCurrentOffset;
+    UINT32 m_uiGlobalFlush;
 };
 
 

Index: mp4atoms.h
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/mp4atoms.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mp4atoms.h	9 Mar 2009 18:36:51 -0000	1.9
+++ mp4atoms.h	27 Mar 2009 09:27:00 -0000	1.10
@@ -2656,4 +2656,228 @@
 
 
 
+// atom:	ctts
+// container:	stbl
+// purpose:	composition offset box
+class CMP4Atom_ctts: public CMP4Atom_stts
+{
+public:
+    CMP4Atom_ctts()
+    {
+	m_ulAtomID = MP4_BUILD_ATOMID('c', 't', 't', 's');
+    }
+};
+
+// atom:	tref
+// container:	trak
+// purpose:	contains references to other tracks
+class CMP4Atom_tref: public CMP4ContainerAtom 
+{
+public:
+    CMP4Atom_tref()
+	: CMP4ContainerAtom(MP4_BUILD_ATOMID('t', 'r', 'e', 'f'))
+    {
+    }
+};
+
+// atom:	tref_type
+// container:	tref
+// purpose:	references another track
+// note:	currently limited to one reference
+class CMP4Atom_tref_type: public CMP4Atom
+{
+public:
+    CMP4Atom_tref_type(UINT32 type)
+	: CMP4Atom(type), trackID(0)
+    {
+    }
+    STDMETHOD_(UINT32, GetCurrentSize)(THIS_ BOOL bIncludeChildren = FALSE)
+    {
+	return 8 + 4;
+    }
+    STDMETHOD(WriteToBuffer)(THIS_ UCHAR *&buf, BOOL bIncludeChildren = FALSE)
+    {
+	if (buf)
+	{
+	    CMP4Atom::WriteToBufferAndInc(buf, GetCurrentSize());
+	    CMP4Atom::WriteToBufferAndInc(buf, m_ulAtomID);
+	    CMP4Atom::WriteToBufferAndInc(buf, trackID);
+	}
+	return HXR_OK;
+    }
+
+    MP4_ATOM_PROPERTY(TrackID, UINT32, trackID);
+private:
+    UINT32	trackID;
+};
+
+// atom:	hmhd
+// container:	minf
+// purpose:	hint media header box
+class CMP4Atom_hmhd: public CMP4VersionedAtom
+{
+public:
+    CMP4Atom_hmhd()
+	: CMP4VersionedAtom(MP4_BUILD_ATOMID('h', 'm', 'h', 'd')),
+	  maxPDUsize(0), avgPDUsize(0), maxbitrate(0), avgbitrate(0),
+	  reserved(0)
+    {
+    }
+    STDMETHOD_(UINT32, GetCurrentSize)(THIS_ BOOL bIncludeChildren = FALSE)
+    {
+	return CMP4VersionedAtom::GetCurrentSize(bIncludeChildren)
+	    + 2 + 2 + 4 + 4 + 4;
+    }
+    STDMETHOD(WriteToBuffer)(THIS_ UCHAR *&buf, BOOL bIncludeChildren = FALSE)
+    {
+	HX_RESULT res = HXR_OK;
+
+	if (buf)
+	{
+	    CMP4VersionedAtom::WriteAtomAndVersionInfo(buf);
+	    CMP4Atom::WriteToBufferAndInc(buf, maxPDUsize);
+	    CMP4Atom::WriteToBufferAndInc(buf, avgPDUsize);
+	    CMP4Atom::WriteToBufferAndInc(buf, maxbitrate);
+	    CMP4Atom::WriteToBufferAndInc(buf, avgbitrate);
+	    CMP4Atom::WriteToBufferAndInc(buf, reserved);
+	    if (bIncludeChildren)
+		res = ChildrenWriteToBuffer(buf);
+	}
+	return res;
+    }
+
+    MP4_ATOM_PROPERTY(MaxPDUSize, UINT16, maxPDUsize);
+    MP4_ATOM_PROPERTY(AvgPDUSize, UINT16, avgPDUsize);
+    MP4_ATOM_PROPERTY(MaxBitRate, UINT32, maxbitrate);
+    MP4_ATOM_PROPERTY(AvgBitRate, UINT32, avgbitrate);
+private:
+    UINT16	maxPDUsize;
+    UINT16	avgPDUsize;
+    UINT32	maxbitrate;
+    UINT32	avgbitrate;
+    UINT32	reserved;
+};
+
+// atom:	rtp
+// container:	stsd
+// purpose:	rtp hint sample entry
+class CMP4Atom_rtp: public CMP4Atom_SampleEntry
+{
+public:
+    CMP4Atom_rtp()
+	: CMP4Atom_SampleEntry(MP4_BUILD_ATOMID('r', 't', 'p', ' ')),
+	  hinttrackversion(1), highestcompatibleversion(1)
+    {
+    }
+    STDMETHOD_(UINT32, GetCurrentSize)(THIS_ BOOL bIncludeChildren = FALSE)
+    {
+	return CMP4Atom_SampleEntry::GetCurrentSize(bIncludeChildren) + 2 + 2 + 4;
+    }
+    STDMETHOD(WriteToBuffer)(THIS_ UCHAR *&buf, BOOL bIncludeChildren = FALSE)
+    {
+	HX_RESULT res = HXR_OK;
+
+	if (buf)
+	{
+	    CMP4Atom_SampleEntry::WriteToBuffer(buf, FALSE);
+	    CMP4Atom::WriteToBufferAndInc(buf, hinttrackversion);
+	    CMP4Atom::WriteToBufferAndInc(buf, highestcompatibleversion);
+	    CMP4Atom::WriteToBufferAndInc(buf, maxpacketsize);
+	    if (bIncludeChildren)
+		res = ChildrenWriteToBuffer(buf);
+	}
+	return res;
+    }
+    MP4_ATOM_PROPERTY(MaxPacketSize, UINT32, maxpacketsize);
+private:
+    UINT16	hinttrackversion;
+    UINT16	highestcompatibleversion;
+    UINT32	maxpacketsize;
+};
+
+// atom:	tims
+// container:	rtp
+// purpose:	timescale information
+class CMP4Atom_tims: public CMP4Atom {
+public:
+    CMP4Atom_tims()
+	: CMP4Atom(MP4_BUILD_ATOMID('t', 'i', 'm', 's')),
+	  timescale(0)
+    {
+    }
+    STDMETHOD_(UINT32, GetCurrentSize)(THIS_ BOOL bIncludeChildren = FALSE)
+    {
+	return 8 + 4;
+    }
+    STDMETHOD(WriteToBuffer)(THIS_ UCHAR *&buf, BOOL bIncludeChildren = FALSE)
+    {
+	if (buf)
+	{
+	    CMP4Atom::WriteToBufferAndInc(buf, GetCurrentSize());
+	    CMP4Atom::WriteToBufferAndInc(buf, m_ulAtomID);
+	    CMP4Atom::WriteToBufferAndInc(buf, timescale);
+	}
+	return HXR_OK;
+    }
+    MP4_ATOM_PROPERTY(Timescale, UINT32, timescale);
+private:
+    UINT32	timescale;
+};
+
+// atom:	hnti
+// container:	udta
+// purpose:	hint information container (for SDP fragments)
+class CMP4Atom_hnti: public CMP4ContainerAtom {
+public:
+    CMP4Atom_hnti()
+	: CMP4ContainerAtom(MP4_BUILD_ATOMID('h', 'n', 't', 'i'))
+    {
+    }
+};
+
+// atom:	sdp
+// container:	hnti
+// purpose:	track-level SDP fragment
+class CMP4Atom_sdp: public CMP4Atom {
+public:
+    CMP4Atom_sdp()
+	: CMP4Atom(MP4_BUILD_ATOMID('s', 'd', 'p', ' ')), text(NULL), length(0)
+    {
+    }
+    ~CMP4Atom_sdp()
+    {
+	HX_VECTOR_DELETE(text);
+    }
+    STDMETHOD_(UINT32, GetCurrentSize)(THIS_ BOOL bIncludeChildren = FALSE)
+    {
+	return 8 + length;
+    }
+    STDMETHOD(WriteToBuffer)(THIS_ UCHAR *&buf, BOOL bIncludeChildren = FALSE)
+    {
+	if (buf)
+	{
+	    CMP4Atom::WriteToBufferAndInc(buf, GetCurrentSize());
+	    CMP4Atom::WriteToBufferAndInc(buf, m_ulAtomID);
+	    CMP4Atom::WriteToBufferAndInc(buf, text, length);
+	}
+	return HXR_OK;
+    }
+    STDMETHOD(SetSDP)(THIS_ const char *sdptext, UINT32 sdplength)
+    {
+	HX_VECTOR_DELETE(text);
+	text = new UCHAR[sdplength];
+	if (text == NULL)
+	{
+	    length = 0;
+	    return HXR_OUTOFMEMORY;
+	}
+	memcpy(text, sdptext, sdplength);
+	length = sdplength;
+	return HXR_OK;
+    }
+private:
+    UCHAR	*text;
+    UINT32	length;
+};
+
 #endif /* _MP4ATOMS_H_ */

Index: Umakefil
===================================================================
RCS file: /cvsroot/datatype/mp4/filewriter/Umakefil,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Umakefil	11 Mar 2009 17:27:38 -0000	1.9
+++ Umakefil	27 Mar 2009 09:27:00 -0000	1.10
@@ -56,11 +56,12 @@
 	'amrsh.cpp',	
 	'blist.cpp',
 	'mp4sm.cpp',
-	'mp4atomgateway.cpp'
+	'mp4atomgateway.cpp',
+	'hintstubs/hintstubs.cpp'
 	)
 
 project.AddSources('3gpmeta.cpp')
-	
+
 project.AddExportedFunctions('RMACreateInstance')
 
 DLLTarget('mp4wrtr')

--- NEW FILE: cspkt.h ---
/* ***** BEGIN LICENSE BLOCK *****
 * Version: RCSL 1.0/RPSL 1.0
 *
 * Portions Copyright (c) 1995-2009 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 ***** */

#ifndef CSPKT_H
#define CSPKT_H

#include <chxhintgen.h>

class CCommonSamplePacket: public CommonSample {
    IHXPacket *packet;
    IHXBuffer *buffer;
    UINT32 ctime;
    UINT32 dtime;
    HXBOOL keyframe;
public:
    CCommonSamplePacket(CHXHintGenerator *hg, IHXPacket *pkt, HXBOOL kf)
	: packet(pkt), keyframe(kf)
    {
	IHXRTPPacket *rp = 0;

	dtime = hg->ConvertMSTime(packet->GetTime());
	packet->QueryInterface(IID_IHXRTPPacket, (void **)&rp);
	if (rp != 0) {
	    ctime = hg->ConvertSampleTime(rp->GetRTPTime());
	    HX_RELEASE(rp);

	    if (abs((int)(((UINT64)ctime * 1000) / hg->GetTimescale() - packet->GetTime())) <= 1)
		dtime = ctime;
	} else
	    ctime = dtime;
	buffer = packet->GetBuffer();
    }
    ~CCommonSamplePacket()
    {
	HX_RELEASE(buffer);
    }
    UINT32
    GetSize() const
    {
	return (UINT32)buffer->GetSize();
    }
    const void *
    GetData() const
    {
	return (const void *)buffer->GetBuffer();
    }
    UINT32
    GetDTime() const
    {
	return dtime;
    }
    UINT32
    GetCTime() const
    {
	return ctime;
    }
    HXBOOL
    IsKeyframe() const
    {
	return keyframe;
    }
};

#endif	/* !CSPKT_H */


_______________________________________________
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