[asterisk-scf-commits] asterisk-scf/integration/file_media_service.git branch "initial_development" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Dec 2 14:17:04 CST 2011


branch "initial_development" has been updated
       via  968277e5293a89dd1afa8feb16a73f1eaedccead (commit)
      from  df5ac0294a5062be49a4269d0dbc65e20d8089c5 (commit)

Summary of changes:
 CMakeLists.txt                  |    7 --
 src/CMakeLists.txt              |    6 ++-
 src/Component.cpp               |   18 +-----
 src/ContainerImpl.cpp           |  137 ++++++++++++++++++++-------------------
 src/ContainerImpl.h             |    2 +-
 src/ContainerRepository.cpp     |    4 +-
 src/{Config.h => LocalConfig.h} |    0
 src/MatroskaUtil.cpp            |   39 ++++++++---
 src/MatroskaUtil.h              |   22 +++++-
 9 files changed, 127 insertions(+), 108 deletions(-)
 rename src/{Config.h => LocalConfig.h} (100%)


- Log -----------------------------------------------------------------
commit 968277e5293a89dd1afa8feb16a73f1eaedccead
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Nov 11 16:40:20 2011 -0330

    Fix several build errors.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61df955..2be9883 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,12 +6,5 @@ astscf_project(FileMediaService 3.4)
 
 add_subdirectory(slice)
 
-if(WIN32)
-    add_definitions(-DEBML_DLL -DMATROSKA_DLL)
-endif()
-
 add_subdirectory(src)
-if(BUILD_TESTING)
-    add_subdirectory(test)
-endif()
 astscf_slice_collection_install(PROJECT)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4a0c4c0..ed09944 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,15 @@
 include_directories(${logger_dir}/include)
 include_directories(${astscf-ice-util-cpp_dir}/include)
+include_directories(${astscf-matroska-config})
+include_directories(${astscf-corec_dir})
+include_directories(${astscf-ebml2_dir})
+include_directories(${astscf-matroska2_dir})
 
 astscf_slice_include_collection(FILEMEDIASERVICE)
 astscf_component_init(FileMediaService)
 astscf_component_add_files(FileMediaService
 	Component.cpp
-	Config.h
+        LocalConfig.h
 	ContainerConfigurationAdapter.h
 	ContainerInfoImpl.cpp
 	ContainerInfoImpl.h
diff --git a/src/Component.cpp b/src/Component.cpp
index cc2c829..5c8aac9 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -31,13 +31,6 @@
 #include "ReplicationContext.h"
 #include "FileMediaServiceComponent.h"
 
-extern "C"
-{
-#include <libavcodec/avcodec.h>
-#include <libavformat/avformat.h>
-#include <libavutil/log.h>
-}
-
 using namespace std;
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Core::Discovery::V1;
@@ -70,16 +63,7 @@ public:
 
     void onPreInitialize()
     {
-        //
-        // Initialize the avX libraries.
-        //
-        av_register_all();
-        avcodec_register_all();
-
-        //
-        // TODO: Should be made configurable.
-        //
-        av_log_set_level(AV_LOG_DEBUG);
+       
     }
 
     void createReplicationStateListeners()
diff --git a/src/ContainerImpl.cpp b/src/ContainerImpl.cpp
index 6f14acf..6f52e74 100644
--- a/src/ContainerImpl.cpp
+++ b/src/ContainerImpl.cpp
@@ -17,16 +17,16 @@
 #include "ContainerImpl.h"
 #include "ContainerRepository.h"
 
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/filesystem.hpp>
+
 #include <AsteriskSCF/logger.h>
 
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
 #include <IceUtil/Thread.h>
 
-#define BOOST_FILESYSTEM_VERSION 3
-#include <boost/filesystem.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/lexical_cast.hpp>
 
 #include "MatroskaUtil.h"
 
@@ -58,6 +58,19 @@ namespace Implementation
 typedef boost::unique_lock<boost::shared_mutex> UniqueLock;
 typedef boost::shared_lock<boost::shared_mutex> SharedLock;
 
+struct TrackQueue
+{
+    IceUtil::Time earliest; 
+    IceUtil::Time latest;
+    FrameSeq frames;
+
+    TrackQueue() :
+        earliest(IceUtil::Time::seconds(0)),
+        latest(IceUtil::Time::seconds(0))
+    {
+    }
+};
+
 /**
  *
  * Base class for file session driver. Basically defines and implements methods that
@@ -352,9 +365,9 @@ public:
             // the next read or close of the avf context will invalidate the contents
             // of the packet.
             //
-            size_t bytesToDecode = data->frameData.Size;
+            unsigned long bytesToDecode = data->frameData.Size;
             unsigned char* buf = static_cast<unsigned char*>(data->frameData.Data);
-            timecode_t startTimecode = data->frameData.Timecode / mTimeScale;
+            timecode_t startTimecode = static_cast<timecode_t>(data->frameData.Timecode / mTimeScale);
             size_t sampleCount = 0;
             size_t durationFactor = (mFormat->sampleSize / sizeof(buf[0])) * mFormat->sampleRate; // bits per second
 
@@ -374,7 +387,9 @@ public:
                 frame->mediaFormat = mFormat;
 
                 unsigned long sampleRangeEnd  = 
-                        static_cast<size_t>(mFormat->frameSize) > bytesToDecode ? bytesToDecode: mFormat->frameSize;
+                        static_cast<unsigned long>(mFormat->frameSize) > bytesToDecode ? 
+                             bytesToDecode: 
+                             static_cast<unsigned long>(mFormat->frameSize);
                 sampleCount += sampleRangeEnd;
 
                 //
@@ -548,7 +563,7 @@ public:
         mId(id),
         mSpec(spec),
         mLogger(logger),
-        mInput(0),
+        mStream(0),
         mStarted(false)
     {
         //
@@ -576,9 +591,9 @@ public:
         //
         // This should never be called twice.
         //
-        assert(!mInput);
+        assert(!mStream);
 
-        mStream = StreamOpen(env->parserContext(), filename.c_str(), SFLAG_RDONLY);
+        mStream = StreamOpen(mMatroskaEnvironment->parserContext(), filename.c_str(), SFLAG_RDONLY);
 
         if (mStream)
         {
@@ -586,11 +601,11 @@ public:
             return false;
         }
 
-        mContainerReader.reset(new MatroskaReader(mStream));
+        mContainerReader.reset(new Matroska::ContainerReader(mStream));
 
         if (mContainerReader->trackCount() < 1)
         {
-            mLogger(Error) << "File " << filename < " has 0 tracks!";
+            mLogger(Error) << "File " << filename << " has 0 tracks!";
             //
             // We could let this clean up on it's own, but we might as well toast it now whilst we are
             // here.
@@ -615,8 +630,9 @@ public:
             //
             // TODO: replace codec 'figuring code' from avformat/avcodec.
             //
-
-            mSinkManagers[i] = new SinkManager(sourceId, mLogger, mObjectAdapter);
+            uint16_t trackNumber = static_cast<uint16_t>(i+1);
+            mSinkManagers[i] = new SinkManager(sourceId, mContainerReader->getFormatForTrack(trackNumber),
+                mContainerReader->getTimecodeScaleForTrack(trackNumber), mObjectAdapter, mLogger);
             Ice::Identity id = mObjectAdapter->getCommunicator()->stringToIdentity(sourceId);
             mSources.push_back(StreamSourcePrx::uncheckedCast(mObjectAdapter->add(mSinkManagers[i], id)));
         }
@@ -884,7 +900,7 @@ struct WritingRecord
 };
 
 
-static bool frameTimestampComparator(const WritingRecord& a, const WritingRecordr& b)
+static bool frameTimestampComparator(const WritingRecord& a, const WritingRecord& b)
 {
     StreamFramePtr streamA = StreamFramePtr::dynamicCast(a.frame);
     StreamFramePtr streamB = StreamFramePtr::dynamicCast(b.frame);
@@ -918,13 +934,13 @@ class FrameWriter : public IceUtil::Shared
 {
 public:
     FrameWriter(const boost::shared_ptr<ContainerWriter>& writer, unsigned trackCount) :
-        mWriter(writer)
+        mContainerWriter(writer)
     {
         //
         // TODO: exception for the assert so the problem can be handled in release builds as well.
         //
         assert(trackCount > 0);
-        assert(mWriter);
+        assert(mContainerWriter);
 
         mTrackQueues.resize(trackCount);
     }
@@ -934,7 +950,7 @@ public:
         //
         // Called from queueFrames when it is time
         //
-        mWriter->addFrames(trackIndex, frames);
+        mContainerWriter->addFrames(static_cast<uint16_t>(trackIndex), frames);
     }
 
     void queueFrames(unsigned trackIndex, const FrameSeq& frames)
@@ -944,7 +960,7 @@ public:
         if (mTrackQueues.size() == 1)
         {
             assert(trackIndex == 1);
-            writeFrames(1, frames);
+            write(1, frames);
             return;
         }
 
@@ -955,46 +971,45 @@ public:
         size_t index = trackIndex -1;
         assert (index < mTrackQueues.size());
         
-        bool alreadyHasQueuedFrames = ! mTrackQueues[index].frames.empty();
-        mTrackQueues[index].insert(mTrackQueues[index].frames.end(), frames.begin(), frames.end());
+        mTrackQueues[index].frames.insert(mTrackQueues[index].frames.end(), frames.begin(), frames.end());
 
         //
         // We are going to assume frames are in proper chronological/serial order.  This might actually be cool for
         // setting up test data, so let's not sweat it :)
         //
         IceUtil::Time earliestStamp(mTrackQueues[index].earliest);
-        for (FrameSeq::iterator iter = frames.begin(); iter != frames.end(); ++iter)
+        for (FrameSeq::const_iterator iter = frames.begin(); iter != frames.end(); ++iter)
         {
             StreamFramePtr streamFrame = StreamFramePtr::dynamicCast(*iter);
             if (streamFrame)
             {
-                earliestStamp = IceUtil::Time::milliseconds(streamFrame->timestamp);
+                earliestStamp = IceUtil::Time::milliSeconds(streamFrame->timestamp);
                 break;
             }
         }
 
         IceUtil::Time latestStamp(mTrackQueues[index].latest);
-        for (FrameSeq::reverse_iterator iter = frames.rbegin(); iter < frames.rend(); ++iter)
+        for (FrameSeq::const_reverse_iterator iter = frames.rbegin(); iter < frames.rend(); ++iter)
         {
             StreamFramePtr streamFrame = StreamFramePtr::dynamicCast(*iter);
             if (streamFrame)
             {
-                latestStamp = IceUtil::Time::milliseconds(streamFrame->timestamp);
+                latestStamp = IceUtil::Time::milliSeconds(streamFrame->timestamp);
                 break;
             }
         }
 
         bool earliestChanged  = false;
-        if (mTrackQueues[index].earliest.toSeconds() == 0 || earliestStamp < mTrackQueues[index].earliest.toSeconds())
+        if (mTrackQueues[index].earliest.toSeconds() == 0 || earliestStamp < mTrackQueues[index].earliest)
         {
             mTrackQueues[index].earliest = earliestStamp;
             earliestChanged = true;
         }
 
         bool latestChanged = false;
-        if (mTrackQueues[index].toSeconds() == 0 || latestStamp > mTrackQueues[index].latest.toSeconds())
+        if (mTrackQueues[index].latest.toSeconds() == 0 || latestStamp > mTrackQueues[index].latest)
         {
-            mTrackQeueus[index].latest = latestStamp;
+            mTrackQueues[index].latest = latestStamp;
             latestChanged = true;
         }
 
@@ -1013,7 +1028,7 @@ public:
         // orders them by timestamp (duration is important as well, but we need to figure that the
         // frames are going to arrive in some sensible size for interactive AV.
         //
-        IceUtil::Time earliestLastest(latestStamp); 
+        IceUtil::Time earliestLatest(latestStamp); 
         
         for (vector<TrackQueue>::iterator iter = mTrackQueues.begin(); iter != mTrackQueues.end(); ++iter)
         {
@@ -1040,7 +1055,7 @@ public:
             }
             if (iter->latest < earliestLatest)
             {
-                earliestLast = iter->latest;
+                earliestLatest = iter->latest;
             }
         }
 
@@ -1056,7 +1071,7 @@ public:
         //
         // So we have the window, collect the frames that fall in this window and then sort them. 
         //
-        size_t trackNumber = 1;
+        uint16_t trackNumber = 1;
         vector<WritingRecord> framesToWrite;
         for (vector<TrackQueue>::iterator iter = mTrackQueues.begin(); iter != mTrackQueues.end(); ++iter)
         {
@@ -1066,10 +1081,13 @@ public:
                 StreamFramePtr streamFrame = StreamFramePtr::dynamicCast(*frameIter);
                 if (streamFrame)
                 {
-                    IceUtil::Time t(IceUtil::Time::milliseconds(streamFrame->timeStamp));
+                    IceUtil::Time t(IceUtil::Time::milliSeconds(streamFrame->timestamp));
                     if (t < earliestLatest)
                     {
-                        framesToWrite.push_back(*frameIter);
+                        WritingRecord r;
+                        r.trackNumber = trackNumber;
+                        r.frame = *frameIter;
+                        framesToWrite.push_back(r);
                     }
                     else
                     {
@@ -1107,18 +1125,17 @@ public:
         //
         // If this happened then we something is either wrong with our frame picking or our trigger logic.
         //
-        assert (framesToWrite.size > 0);
+        assert (framesToWrite.size() > 0);
         muxAndWrite(framesToWrite);
     }
 
-
     void close()
     {
         //
         // We are closing, that means we need to collect, mux and write remaining frames.
         //
         boost::mutex::scoped_lock lock(mLock);
-        size_t trackNumber = 1;
+        uint16_t trackNumber = 1;
         vector<WritingRecord> framesToWrite;
         for (vector<TrackQueue>::iterator iter = mTrackQueues.begin(); iter != mTrackQueues.end(); ++iter)
         {
@@ -1141,19 +1158,6 @@ private:
     boost::mutex mLock;
     boost::shared_ptr<ContainerWriter> mContainerWriter;
 
-    struct TrackQueue
-    {
-        IceUtil::Time earliest; 
-        IceUtil::Time latest;
-        FrameSeq frames;
-
-        TrackQueue() :
-            earliest(IceUtil::Time::seconds(0)),
-            latest(IceUtil::Time::seconds(0))
-        {
-        }
-    };
-
     vector<TrackQueue> mTrackQueues;
     
     /**
@@ -1168,7 +1172,7 @@ private:
         // by timestamp. What we are not going to do is break frames up. We could, but hopefully this won't be
         // necessary.
         //
-        sort(framesToWrite.begin(); framesToWrite.end(), frameTimestampComparator);
+        sort(framesToWrite.begin(), framesToWrite.end(), frameTimestampComparator);
         unsigned currentTrack = 0;
         FrameSeq collectedFrames;
         for (vector<WritingRecord>::iterator w = framesToWrite.begin(); w != framesToWrite.end(); ++w)
@@ -1275,13 +1279,14 @@ public:
         IceUtil::Time mStartTime;
         bool mWriting;
         FrameSeq mQueuedFrames;
+        boost::shared_mutex mLock;
     };
     typedef IceUtil::Handle<SourceManager> SourceManagerPtr;
-    tyepdef vector<SourceManagerPtr> SourceManagers;
+    typedef vector<SourceManagerPtr> SourceManagers;
 
     RecordingSessionImpl(const Ice::ObjectAdapterPtr& adapter, const string& id, 
             const FileMediaSpecification& spec,
-            const Matroska::Environment* matroskaEnvironment) :
+            Matroska::Environment* matroskaEnvironment) :
         mObjectAdapter(adapter),
         mId(id),
         mSpec(spec),
@@ -1329,7 +1334,7 @@ public:
     {
         for (SourceManagers::const_iterator iter= mSourceManagers.begin(); iter != mSourceManagers.end(); ++iter)
         {
-            iter->startWriting(IceUtil::Time::now());
+            (*iter)->startWriting(IceUtil::Time::now());
         }
     }
 
@@ -1337,7 +1342,7 @@ public:
     {
         for (SourceManagers::const_iterator iter= mSourceManagers.begin(); iter != mSourceManagers.end(); ++iter)
         {
-            iter->stopWriting();
+            (*iter)->stopWriting();
         }
     }
 
@@ -1345,7 +1350,7 @@ public:
     {
         for (SourceManagers::const_iterator iter= mSourceManagers.begin(); iter != mSourceManagers.end(); ++iter)
         {
-            iter->startWriting(IceUtil::Time::now());
+            (*iter)->startWriting(IceUtil::Time::now());
         }
     }
 
@@ -1390,13 +1395,13 @@ public:
         //
         // Matroska related initialization!
         //
-        mStream = StreamOpen(env->parserContext(), filename.c_str(), SFLAG_WRONLY | SFLAG_CREATE);
+        mStream = StreamOpen(mMatroskaEnvironment->parserContext(), filename.c_str(), SFLAG_WRONLY | SFLAG_CREATE);
         if (!mStream)
         {
             //
             // XXX: error handling.
             //
-            assert("XXX: Error handling" == 0);
+            assert((const char*)"XXX: Error handling" == 0);
         }
         vector<string> trackIds;
         try
@@ -1413,7 +1418,7 @@ public:
                 trackIds.push_back(trackId);
                 mContainer->addTrack(*iter, containerId);
             }
-            mWriter = new FrameWriter(mContainer, mSpec.formats.size());
+            mWriter = new FrameWriter(mContainer, static_cast<unsigned int>(mSpec.formats.size()));
         }
         //
         // XXX exceptions should be logged.
@@ -1424,11 +1429,11 @@ public:
             {
                 StreamClose(mStream);
             }
-            mContainer.reset(0);
+            mContainer.reset();
         }
         catch (...)
         {
-            mContainer.reset(0);
+            mContainer.reset();
         }
 
         //
@@ -1441,8 +1446,8 @@ public:
         {
             SourceManagerPtr s = new SourceManager(*iter, mWriter, trackNumber++);
             mSourceManagers.push_back(s);
-            mSinks = StreamSinkPrx::uncheckedCast(mObjectAdapter->add(s,
-                            mObjectAdapter->getCommunicator()->stringToIdentity(*iter)));
+            mSinks.push_back(StreamSinkPrx::uncheckedCast(mObjectAdapter->add(s,
+                            mObjectAdapter->getCommunicator()->stringToIdentity(*iter))));
         }
     }
 
@@ -1451,9 +1456,9 @@ private:
     const string mId;
     FileMediaSpecification mSpec;
     CookieManager mCookieManager;
-    Matroska::Environment* matroskaEnvironment;
+    Matroska::Environment* mMatroskaEnvironment;
     boost::shared_ptr<Matroska::ContainerWriter> mContainer;
-    SinkSeq mSinks;
+    AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
     SourceManagers mSourceManagers;
     stream* mStream;
     FrameWriterPtr mWriter;
@@ -1464,7 +1469,7 @@ class ContainerServant : public ContainerImpl
 public:
     ContainerServant(const ContainerInfoImplPtr& info, 
         const FileMediaSpecification& spec,
-        const Matroska::Environment* matroskaEnvironment,
+        Matroska::Environment* matroskaEnvironment,
         const Ice::ObjectAdapterPtr& adapter, const Logger& logger) :
        mInfo(info),
        mSpec(spec),
@@ -1598,7 +1603,7 @@ typedef IceUtil::Handle<ContainerServant> ContainerServantPtr;
 ContainerImplPtr
 ContainerImpl::create(const ContainerInfoImplPtr& info,
     const FileMediaSpecification& spec,
-    const Matroska::Environment* matroskaEnvironment,
+    Matroska::Environment* matroskaEnvironment,
     const Ice::ObjectAdapterPtr& adapter,
     const AsteriskSCF::System::Logging::Logger& logger)
 {
diff --git a/src/ContainerImpl.h b/src/ContainerImpl.h
index ac44345..e75afba 100644
--- a/src/ContainerImpl.h
+++ b/src/ContainerImpl.h
@@ -43,7 +43,7 @@ public:
     static IceUtil::Handle<ContainerImpl> create(
         const ContainerInfoImplPtr& info,
         const AsteriskSCF::Media::File::V1::FileMediaSpecification& spec, 
-        const Matroska::Environment* matroskaEnvironment,
+        Matroska::Environment* matroskaEnvironment,
         const Ice::ObjectAdapterPtr& adapter,
         const AsteriskSCF::System::Logging::Logger& logger);
 };
diff --git a/src/ContainerRepository.cpp b/src/ContainerRepository.cpp
index 615e588..59ee7ed 100644
--- a/src/ContainerRepository.cpp
+++ b/src/ContainerRepository.cpp
@@ -34,7 +34,7 @@
 //
 // Use latest boost stuff.
 //
-#define BOOST_FILESYSTEM_VERSION 3
+
 #include <boost/filesystem.hpp>
 #include <boost/thread/shared_mutex.hpp>
 
@@ -489,7 +489,7 @@ void ContainerRepositoryServant::refresh()
         return;
     }
             
-    boost::filesystem::path p(getPath());
+    boost::filesystem::path p(pathString);
     try
     {
         if (boost::filesystem::exists(p))
diff --git a/src/Config.h b/src/LocalConfig.h
similarity index 100%
rename from src/Config.h
rename to src/LocalConfig.h
diff --git a/src/MatroskaUtil.cpp b/src/MatroskaUtil.cpp
index 71bfd65..bfc6be1 100644
--- a/src/MatroskaUtil.cpp
+++ b/src/MatroskaUtil.cpp
@@ -38,6 +38,7 @@ extern const nodemeta EBMLVoid_Class[];
 };
 
 #include <iostream>
+#include <time.h>
 
 using namespace AsteriskSCF::Media::V1;
 using namespace Matroska;
@@ -543,7 +544,7 @@ double ContainerReader::duration()
 
 size_t ContainerReader::trackCount()
 {
-    return mTrackCount;
+    return mTracks.size();
 }
 
 int64_t ContainerReader::clusterCount()
@@ -722,16 +723,14 @@ bool ContainerReader::validate()
         mDuration = EBML_FloatValue(duration);
     }
 
-    mTrackCount = 0;
-
     for (ebml_master* trackEntry = (ebml_master*)EBML_MasterFindChild(mSections.trackInformation, &MATROSKA_ContextTrackEntry);
         trackEntry != 0; trackEntry = (ebml_master*)EBML_MasterNextChild(mSections.trackInformation, trackEntry))
     {
         ebml_element* trackTypeElement = EBML_MasterFindChild(trackEntry, &MATROSKA_ContextTrackType);
-        int typeValue = EBML_IntegerValue((ebml_integer*)trackTypeElement);
+        int64_t typeValue = EBML_IntegerValue((ebml_integer*)trackTypeElement);
         if (typeValue == TRACK_TYPE_VIDEO || typeValue == TRACK_TYPE_AUDIO)
         {
-            ++mTrackCount;
+            mTracks.push_back((matroska_trackentry*)trackTypeElement);
         }
     }
     mCurrentCluster = mSections.clusterInformation.begin();
@@ -771,6 +770,26 @@ TrackFrame* ContainerReader::getNextFrame()
     return result;
 }
 
+AsteriskSCF::Media::V1::FormatPtr ContainerReader::getFormatForTrack(uint16_t trackNumber)
+{
+    if (trackNumber > trackCount() || trackNumber == 0)
+    {
+        throw InvalidTrackNumber();
+    }
+    return AsteriskSCF::Media::V1::FormatPtr(); // XXX
+}
+
+double ContainerReader::getTimecodeScaleForTrack(uint16_t trackNumber)
+{
+    if (trackNumber > trackCount() || trackNumber == 0)
+    {
+        throw InvalidTrackNumber();
+    }
+    matroska_trackentry* track = mTracks[trackNumber-1];
+    assert(track);
+    return MATROSKA_TrackTimecodeScale((ebml_master*)track);
+}
+
 Level1Groups::Level1Groups() :
     segmentInformation(0),
     trackInformation(0),
@@ -1022,7 +1041,7 @@ uint16_t ContainerWriter::addTrack(const AsteriskSCF::Media::V1::FormatPtr& form
             el = EBML_MasterFindFirstElt((ebml_master*)newTrack, &MATROSKA_ContextTrackType, true, false);
             EBML_IntegerSetValue((ebml_integer*)el, TRACK_TYPE_AUDIO);
             
-            return mTracks.size();;
+            return static_cast<uint16_t>(mTracks.size());
         }
     }
     //
@@ -1051,7 +1070,7 @@ void ContainerWriter::addFrames(uint16_t trackNumber, const AsteriskSCF::Media::
     StreamFramePtr streamFrame = StreamFramePtr::dynamicCast(frames[0]);
     if (streamFrame)
     {
-        timecode = streamFrame->timestamp * MATROSKA_TrackTimecodeScale((ebml_master*)track);
+        timecode = static_cast<timecode_t>(streamFrame->timestamp * MATROSKA_TrackTimecodeScale((ebml_master*)track));
     }
 
     if (!mCurrentCluster)
@@ -1148,7 +1167,7 @@ void ContainerWriter::addFrames(uint16_t trackNumber, const AsteriskSCF::Media::
         {
             frame->Data = (uint8_t*)malloc(bytes->payload.size());
             memcpy(frame->Data, (uint8_t*)&bytes->payload.front(), bytes->payload.size());
-            frame->Size = bytes->payload.size();
+            frame->Size = static_cast<uint32_t>(bytes->payload.size());
         }
         else 
         {
@@ -1158,7 +1177,7 @@ void ContainerWriter::addFrames(uint16_t trackNumber, const AsteriskSCF::Media::
                 size_t sz = shorts->payload.size() * sizeof(shorts->payload[0]);
                 frame->Data = (uint8_t*)malloc(sz);
                 memcpy(frame->Data, (uint8_t*)&bytes->payload.front(), sz);
-                frame->Size = sz;
+                frame->Size = static_cast<uint32_t>(sz);
                 //
                 // whoops! XXX add logging.
                 //
@@ -1168,7 +1187,7 @@ void ContainerWriter::addFrames(uint16_t trackNumber, const AsteriskSCF::Media::
         StreamFramePtr streamFrame = StreamFramePtr::dynamicCast(*f);
         if (streamFrame)
         {
-            frame->Timecode = streamFrame->timestamp * MATROSKA_TrackTimecodeScale((ebml_master*)track);
+            frame->Timecode = static_cast<timecode_t>(streamFrame->timestamp * MATROSKA_TrackTimecodeScale((ebml_master*)track));
         }
 
         //
diff --git a/src/MatroskaUtil.h b/src/MatroskaUtil.h
index cee3ab1..7352a54 100644
--- a/src/MatroskaUtil.h
+++ b/src/MatroskaUtil.h
@@ -182,6 +182,8 @@ private:
 
 };
 
+typedef std::vector<matroska_trackentry*> TrackSeq;
+
 class ContainerReader
 {
 public:
@@ -203,6 +205,20 @@ public:
 
     TrackFrame* getNextFrame();
 
+    /**
+     * Create an Asterisk SCF format object for the specified track number.
+     *
+     * @throws InvalidTrackNumber
+     */
+    AsteriskSCF::Media::V1::FormatPtr getFormatForTrack(uint16_t trackNumber);
+
+    /**
+     * Get the time code scale for the provided track.
+     *
+     * @throws InvalidTrackNumber
+     */
+    double getTimecodeScaleForTrack(uint16_t trackNumber);
+
 private:
 
     stream* mStream;
@@ -239,8 +255,6 @@ private:
     // Track count is determined by counting all of the video and audio tracks
     // in the trackInformation member of sections.
     //
-    size_t mTrackCount;
-
     typedef std::vector<matroska_cluster*> ClusterSeq;
 
     Level1Groups mSections;
@@ -248,11 +262,11 @@ private:
     ClusterSeq::iterator mCurrentCluster;
     ClusterCreeper* mCreeper; 
 
+    TrackSeq mTracks;
+
     void setFileSize();
 };
 
-typedef std::vector<matroska_trackentry*> TrackSeq;
-
 struct BlockGroupData
 {
     ebml_element* group;

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/file_media_service.git



More information about the asterisk-scf-commits mailing list