[Matroska-devel] yet another matroska api

Pavel Koshevoy pkoshevoy at sorensonmedia.com
Wed Apr 21 00:26:35 CEST 2010


Hi,

I'd like to announce Yet Another Matroska API --
https://sourceforge.net/projects/yamka/

It's not quiet complete yet -- CRC-32 isn't done right, and default 
payload values are not set for most of the elements.

It's cross-platform, written in C++, depends on Boost (headers only, at 
least right now). It's concise and straight forward to use, something 
like this (note: I didn't try to compile this example)


> // yamka includes:
> #include <yamka.h>
>
> // yamka shortcuts:
> typedef Yamka::MatroskaDoc::TSegment TSegment;
> typedef Yamka::Segment::TInfo TSegInfo;
> typedef Yamka::Segment::TTracks TTracks;
> typedef Yamka::Segment::TSeekHead TSeekHead;
> typedef Yamka::Segment::TCluster TCluster;
> typedef Yamka::Segment::TCues TCues;
> typedef Yamka::Cues::TCuePoint TCuePoint;
> typedef Yamka::Tracks::TTrack TTrackEntry;
>
> using Yamka::File;
> using Yamka::FileStorage;
> using Yamka::uint64;
> using Yamka::MatroskaDoc;
> using Yamka::SimpleBlock
> using Yamka::Cluster;
>
> void blah()
> {
>   // load matroska document from "testYamka.mkv"
>   FileStorage mkvSrc(std::string("testYamka.mkv"), File::kReadOnly);
>   uint64 mkvSrcSize = mkvSrc.file_.size();
>
>   MatroskaDoc matroska;
>   uint64 bytesRead = matroska.load(mkvSrc, mkvSrcSize);
>
>   // in the first cluster only -- dump SimpleBlock payload attributes
>   // (trackNo, lacing, frame sizes, etc...) to stdout:
>   typedef std::deque<Cluster::TSimpleBlock>::const_iterator TSimpleBlockIter;
>   for (TSimpleBlockIter i = matroska.
>          segments_.front().payload_.
>          clusters_.front().payload_.
>          simpleBlocks_.begin();
>        i != matroska.
>          segments_.front().payload_.
>          clusters_.front().payload_.
>          simpleBlocks_.end();
>        ++i)
>   {
>     const Cluster::TSimpleBlock & elt = *i;
>
>     Bytes importData;
>     if (elt.payload_.get(importData))
>     {
>       SimpleBlock sb;
>       if (sb.importData(importData))
>       {
>         std::cout << sb << std::endl;
>       }
>     }
>   }
>
>   // modify the document:
>   TSegment & segment = matroska.segments_.back();
>   TSegInfo & segInfo = segment.payload_.info_;
>   segInfo.payload_.writingApp_.payload_.
>     set("Sorenson Media Matroska formatter SCAPI plugin");
>
>   // save matroska document to "testYamkaOut.mkv"
>   FileStorage mkvSrcOut(std::string("testYamkaOut.mkv"), File::kReadWrite);
>   FileStorage::IReceiptPtr receipt = matroska.save(mkvSrcOut);
>
>   std::cout << "bytes saved: " << receipt->numBytes() << std::endl;
> }



Hope this is useful to someone besides me.
	Pavel.



More information about the Matroska-devel mailing list