OSDN Git Service

RIO-7804: Add an API to the mp4 composer for adding movie fragment random access...
authorPacketVideo CM <engbuild@pv.com>
Thu, 12 Nov 2009 20:46:26 +0000 (12:46 -0800)
committerPacketVideo CM <engbuild@pv.com>
Thu, 12 Nov 2009 20:46:26 +0000 (12:46 -0800)
engines/2way/src/pv_2way_sdkinfo.h
engines/author/src/pv_author_sdkinfo.h
engines/player/src/pv_player_sdkinfo.h
fileformats/mp4/composer/include/a_impeg4file.h
fileformats/mp4/composer/include/moviefragmentrandomaccessatom.h
fileformats/mp4/composer/include/mpeg4file.h
fileformats/mp4/composer/include/trackfragmentrandomaccessatom.h
fileformats/mp4/composer/src/moviefragmentrandomaccessatom.cpp
fileformats/mp4/composer/src/mpeg4file.cpp
fileformats/mp4/composer/src/trackfragmentrandomaccessatom.cpp

index ec745fb..c09c127 100644 (file)
@@ -21,7 +21,7 @@
 // This header file is automatically generated at build-time
 // *** OFFICIAL RELEASE INFO -- Will not auto update
 
-#define PV2WAY_ENGINE_SDKINFO_LABEL "1058934"
-#define PV2WAY_ENGINE_SDKINFO_DATE 0x20091102
+#define PV2WAY_ENGINE_SDKINFO_LABEL "1060266"
+#define PV2WAY_ENGINE_SDKINFO_DATE 0x20091103
 
 #endif //PV_2WAY_SDKINFO_H_INCLUDED
index 56a0d8d..cb8fefb 100644 (file)
@@ -21,7 +21,7 @@
 // This header file is automatically generated at build-time
 // *** OFFICIAL RELEASE INFO -- Will not auto update
 
-#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1058934"
-#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20091102
+#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1060266"
+#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20091103
 
 #endif //PV_AUTHOR_SDKINFO_H_INCLUDED
index d08dd5a..3b51c0b 100644 (file)
@@ -21,7 +21,7 @@
 // This header file is automatically generated at build-time
 // *** OFFICIAL RELEASE INFO -- Will not auto update
 
-#define PVPLAYER_ENGINE_SDKINFO_LABEL "1058934"
-#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20091102
+#define PVPLAYER_ENGINE_SDKINFO_LABEL "1060266"
+#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20091103
 
 #endif //PV_PLAYER_SDKINFO_H_INCLUDED
index aeba40b..d34c9dc 100644 (file)
@@ -336,6 +336,10 @@ class PVA_FF_IMpeg4File : public PVA_FF_ISucceedFail
         virtual void setMovieFragmentDuration(uint32 duration) = 0;
         virtual uint32 getMovieFragmentDuration() = 0;
 
+        // movie fragment random access samples
+        virtual void addMovieFragmentRandAccessEntry(uint32 trackId, uint64 time, uint64 moofOffset,  uint32 trafNumber,
+                uint32 trunNumber,  uint32 sampleNumber) = 0;
+
         OSCL_IMPORT_REF static void DestroyMP4FileObject(PVA_FF_IMpeg4File* aMP4FileObject);
 };
 
index 947b16d..6161a71 100644 (file)
@@ -30,7 +30,7 @@ class PVA_FF_MovieFragmentRandomAccessAtom : public PVA_FF_Atom
 {
 
     public:
-        PVA_FF_MovieFragmentRandomAccessAtom();
+        PVA_FF_MovieFragmentRandomAccessAtom(uint8 trackFragVersion = (uint8)0);
 
         virtual ~PVA_FF_MovieFragmentRandomAccessAtom();
 
@@ -38,7 +38,7 @@ class PVA_FF_MovieFragmentRandomAccessAtom : public PVA_FF_Atom
 
         PVA_FF_TfraAtom*    getTfraAtom(uint32 trackId);
 
-        void    addSampleEntry(uint32 trackId, uint32 time, uint32 moofOffset,
+        void    addSampleEntry(uint32 trackId, uint64 time, uint64 moofOffset,
                                uint32 trafNumber, uint32 trunNumber,
                                uint32 sampleNumber);
 
@@ -49,6 +49,7 @@ class PVA_FF_MovieFragmentRandomAccessAtom : public PVA_FF_Atom
     private:
         PVA_FF_MfroAtom                                     *_pMfroAtom;
         Oscl_Vector <PVA_FF_TfraAtom*, OsclMemAllocator>    *_pTfraList;
+        uint8 trackFragmentVersion;
 
         virtual void recomputeSize();
 };
index 25f4a0b..c6ef1ef 100644 (file)
@@ -265,6 +265,10 @@ class PVA_FF_Mpeg4File : public PVA_FF_IMpeg4File, public PVA_FF_Parentable
         void setMovieFragmentDuration(uint32 duration);
         uint32 getMovieFragmentDuration();
 
+        // movie fragment random access samples
+        void addMovieFragmentRandAccessEntry(uint32 trackId, uint64 time, uint64 moofOffset,
+                                             uint32 trafNumber, uint32 trunNumber,  uint32 sampleNumber);
+
         bool renderMoovAtom();
         bool renderMovieFragments();
 
index 1648a43..383cebe 100644 (file)
@@ -26,8 +26,8 @@
 
 struct PVA_FF_RandomAccessEntry
 {
-    uint32  time;
-    uint32  moofOffset;
+    uint64  time;
+    uint64  moofOffset;
     uint16  trafNumber;
     uint16  trunNumber;
     uint16  sampleNumber;
@@ -36,11 +36,11 @@ struct PVA_FF_RandomAccessEntry
 class PVA_FF_TfraAtom : public PVA_FF_FullAtom
 {
     public:
-        PVA_FF_TfraAtom(uint32 trackId);
+        PVA_FF_TfraAtom(uint32 trackId, uint8 version);
 
         virtual ~PVA_FF_TfraAtom();
 
-        void    addSampleEntry(uint32 ts, uint32 moofOffset,
+        void    addSampleEntry(uint64 ts, uint64 moofOffset,
                                uint32 trafNumber, uint32 trunNumber,
                                uint32 sampleNumber);
 
index 6909972..4a85dfd 100644 (file)
@@ -23,8 +23,8 @@ typedef Oscl_Vector <PVA_FF_TfraAtom*, OsclMemAllocator>
 PVA_FF_TrackFragmentRandomAccessAtomVecType;
 
 // constructor
-PVA_FF_MovieFragmentRandomAccessAtom::PVA_FF_MovieFragmentRandomAccessAtom()
-        : PVA_FF_Atom(MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM)
+PVA_FF_MovieFragmentRandomAccessAtom::PVA_FF_MovieFragmentRandomAccessAtom(uint8 trackFragVersion)
+        : PVA_FF_Atom(MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM), trackFragmentVersion(trackFragVersion)
 {
     // Initialise movie fragment random access offset atom
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MfroAtom, (), _pMfroAtom);
@@ -58,7 +58,7 @@ void
 PVA_FF_MovieFragmentRandomAccessAtom::addTrackFragmentRandomAccessAtom(uint32 trackId)
 {
     PVA_FF_TfraAtom*    pTfraAtom;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TfraAtom, ((trackId)), pTfraAtom);
+    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TfraAtom, (trackId, trackFragmentVersion), pTfraAtom);
 
     _pTfraList->push_back(pTfraAtom);
     pTfraAtom->setParent(this);
@@ -86,8 +86,8 @@ PVA_FF_MovieFragmentRandomAccessAtom::getTfraAtom(uint32 trackId)
 
 // add new random access entry for given track
 void
-PVA_FF_MovieFragmentRandomAccessAtom::addSampleEntry(uint32 trackId, uint32 time,
-        uint32 moofOffset,  uint32 trafNumber,
+PVA_FF_MovieFragmentRandomAccessAtom::addSampleEntry(uint32 trackId, uint64 time,
+        uint64 moofOffset,  uint32 trafNumber,
         uint32 trunNumber,  uint32 sampleNumber)
 {
     if (_pTfraList->size() != 0)
index d2705aa..31dfb53 100644 (file)
@@ -312,7 +312,11 @@ PVA_FF_Mpeg4File::init(int32 mediaType,
     // Movie fragment atom vectors initialised
     if (_oMovieFragmentEnabled)
     {
-        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MovieFragmentRandomAccessAtom, (), _pMfraAtom);
+        // use version 1 of the track fragment rand access box only for PVMP4FF_LIVE_MOVIE_FRAGMENT_MODE
+        uint8 tfraversion = (uint8)0;
+        if (_oLiveMovieFragmentEnabled)
+            tfraversion = (uint8)1;
+        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MovieFragmentRandomAccessAtom, (tfraversion), _pMfraAtom);
     }
 
     // Create miscellaneous vector of atoms
@@ -562,6 +566,11 @@ PVA_FF_Mpeg4File::addTrack(int32 mediaType, int32 codecType, uint8 profile,
         // just added (with a 1-based index NOT a zero-based index)
         TrackID = pmediatrack->getTrackID();
     }
+
+    // Add a new track fragment rand. access box for live movie fragment mode
+    if (_oLiveMovieFragmentEnabled)
+        _pMfraAtom->addTrackFragmentRandomAccessAtom(TrackID);
+
     recomputeSize();
     return (TrackID);
 }
@@ -1468,6 +1477,10 @@ PVA_FF_Mpeg4File::renderToFile(PVA_FF_UNICODE_STRING_PARAM filename)
             status = false;
         }
 
+        // Render mfra always for _oLiveMovieFragmentEnabled
+        if (_oLiveMovieFragmentEnabled)
+            _pMfraAtom->renderToFileStream(&fp);
+
         fp._filePtr->Flush();
 
         if (_oIsFileOpen)
@@ -2515,7 +2528,9 @@ PVA_FF_Mpeg4File::addMediaSampleInterleave(uint32 trackID, PVMP4FFComposerSample
                                                                 pTrack->getMediaTimeScale());
 
                             // add random access atom for each track
-                            _pMfraAtom->addTrackFragmentRandomAccessAtom(pTrack->getTrackID());
+                            // make sure it hasn't been added yet.
+                            if (_pMfraAtom->getTfraAtom(pTrack->getTrackID()) == NULL)
+                                _pMfraAtom->addTrackFragmentRandomAccessAtom(pTrack->getTrackID());
                         }
                     }
                 }
@@ -3257,6 +3272,14 @@ PVA_FF_Mpeg4File::renderMovieFragments()
     return true;
 }
 
+void PVA_FF_Mpeg4File::addMovieFragmentRandAccessEntry(uint32 trackId, uint64 time, uint64 moofOffset,
+        uint32 trafNumber, uint32 trunNumber,  uint32 sampleNumber)
+{
+    // Add a new track fragment rand. access box for live movie fragment mode
+    if (_oLiveMovieFragmentEnabled)
+        _pMfraAtom->addSampleEntry(trackId, time, moofOffset, trafNumber, trunNumber,  sampleNumber);
+}
+
 
 void
 PVA_FF_Mpeg4File::addInterLeaveBuffer(PVA_FF_InterLeaveBuffer *pInterLeaveBuffer)
index ea3d730..d97ea35 100644 (file)
 #define IMPLEMENT_TrackFragmentRandomAccessAtom
 
 #include "trackfragmentrandomaccessatom.h"
+#include "oscl_int64_utils.h"
+
 typedef Oscl_Vector<PVA_FF_RandomAccessEntry, OsclMemAllocator> PVA_FF_RandomAccessEntryVecType;
 
 // constructor
-PVA_FF_TfraAtom::PVA_FF_TfraAtom(uint32 trackId)
-        : PVA_FF_FullAtom(TRACK_FRAGMENT_RANDOM_ACCESS_ATOM, (uint8)0, (uint32)0)
+PVA_FF_TfraAtom::PVA_FF_TfraAtom(uint32 trackId, uint8 version)
+        : PVA_FF_FullAtom(TRACK_FRAGMENT_RANDOM_ACCESS_ATOM, version, (uint32)0)
 {
     _trackId = trackId;
     _reserved = TFRA_LENGTH_SIZE;
@@ -48,7 +50,7 @@ PVA_FF_TfraAtom::~PVA_FF_TfraAtom()
 
 // add new entry to TFRA
 void
-PVA_FF_TfraAtom::addSampleEntry(uint32 ts, uint32 moofOffset, uint32 trafNumber,
+PVA_FF_TfraAtom::addSampleEntry(uint64 ts, uint64 moofOffset, uint32 trafNumber,
                                 uint32 trunNumber, uint32 sampleNumber)
 {
     PVA_FF_RandomAccessEntry sampleEntry;
@@ -102,18 +104,24 @@ PVA_FF_TfraAtom::recomputeSize()
     size += 4;  // reserved
     size += 4;  // entry count
 
-    if (_entryCount != 0)
+    // calculate the rand. access table size
+    int32 entrysize = 0;
+    if (getVersion() == 0)
     {
-        for (uint32 ii = 0; ii < _entryCount; ii++)
-        {
-            size += 4;  // time
-            size += 4;  // MoofOffset
-            size += 2;  // traf number
-            size += 2;  // trun number
-            size += 2;  // sample number
-        }
+        entrysize += 4;  // time
+        entrysize += 4;  // MoofOffset
+    }
+    else
+    {
+        entrysize += 8;  // time
+        entrysize += 8;  // MoofOffset
     }
 
+    entrysize += 2;  // traf number
+    entrysize += 2;  // trun number
+    entrysize += 2;  // sample number
+
+    size += entrysize * (_entryCount);
     _size = size;
 
     // Update the parent atom size
@@ -157,17 +165,36 @@ PVA_FF_TfraAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP* fp)
     for (uint32 ii = 0; ii < _entryCount; ii++)
     {
 
-        if (!PVA_FF_AtomUtils::render32(fp, (*_pSampleEntries)[ii].time))
+        if (getVersion() == 0)
         {
-            return false;
-        }
-        rendered += 4;
+            if (!PVA_FF_AtomUtils::render32(fp,
+                                            Oscl_Int64_Utils::get_uint64_lower32((*_pSampleEntries)[ii].time)))
+            {
+                return false;
+            }
+            rendered += 4;
 
-        if (!PVA_FF_AtomUtils::render32(fp, (*_pSampleEntries)[ii].moofOffset))
+            if (!PVA_FF_AtomUtils::render32(fp,
+                                            Oscl_Int64_Utils::get_uint64_lower32((*_pSampleEntries)[ii].moofOffset)))
+            {
+                return false;
+            }
+            rendered += 4;
+        }
+        else
         {
-            return false;
+            if (!PVA_FF_AtomUtils::render64(fp, (*_pSampleEntries)[ii].time))
+            {
+                return false;
+            }
+            rendered += 8;
+
+            if (!PVA_FF_AtomUtils::render64(fp, (*_pSampleEntries)[ii].moofOffset))
+            {
+                return false;
+            }
+            rendered += 8;
         }
-        rendered += 4;
 
         if (!PVA_FF_AtomUtils::render16(fp, (*_pSampleEntries)[ii].trafNumber))
         {