michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: #ifndef MuxerOperation_h_ michael@0: #define MuxerOperation_h_ michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * The interface for ISO box. All Boxes inherit from this interface. michael@0: * Generate() and Write() are needed to be called to produce a complete box. michael@0: * michael@0: * Generate() will generate all the data structures and their size. michael@0: * michael@0: * Write() will write all data into muxing output stream (ISOControl actually) michael@0: * and update the data which can't be known at Generate() (for example, the michael@0: * offset of the video data in mp4 file). michael@0: * michael@0: * ISO base media format is composed of several container boxes and the contained michael@0: * boxes. The container boxes hold a list of MuxerOperation which is implemented michael@0: * by contained boxes. The contained boxes will be called via the list. michael@0: * For example: michael@0: * MovieBox (container) ---> boxes (array of MuxerOperation) michael@0: * |---> MovieHeaderBox (full box) michael@0: * |---> TrakBox (container) michael@0: * |---> MovieExtendsBox (container) michael@0: * michael@0: * The complete box structure can be found at 14496-12 E.2 "The‘isom’brand". michael@0: */ michael@0: class MuxerOperation { michael@0: public: michael@0: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MuxerOperation) michael@0: michael@0: // Generate data of this box and its contained box, and calculate box size. michael@0: virtual nsresult Generate(uint32_t* aBoxSize) = 0; michael@0: michael@0: // Write data to stream. michael@0: virtual nsresult Write() = 0; michael@0: michael@0: // Find the box type via its name (name is the box type defined in 14496-12; michael@0: // for example, 'moov' is the name of MovieBox). michael@0: // It can only look child boxes including itself and the box in the boxes michael@0: // list if exists. It can't look parent boxes. michael@0: virtual nsresult Find(const nsACString& aType, michael@0: nsTArray>& aOperations) = 0; michael@0: michael@0: virtual ~MuxerOperation() {} michael@0: }; michael@0: michael@0: } michael@0: #endif