Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsString.h"
7 #include "nsTArray.h"
9 #ifndef MuxerOperation_h_
10 #define MuxerOperation_h_
12 namespace mozilla {
14 /**
15 * The interface for ISO box. All Boxes inherit from this interface.
16 * Generate() and Write() are needed to be called to produce a complete box.
17 *
18 * Generate() will generate all the data structures and their size.
19 *
20 * Write() will write all data into muxing output stream (ISOControl actually)
21 * and update the data which can't be known at Generate() (for example, the
22 * offset of the video data in mp4 file).
23 *
24 * ISO base media format is composed of several container boxes and the contained
25 * boxes. The container boxes hold a list of MuxerOperation which is implemented
26 * by contained boxes. The contained boxes will be called via the list.
27 * For example:
28 * MovieBox (container) ---> boxes (array of MuxerOperation)
29 * |---> MovieHeaderBox (full box)
30 * |---> TrakBox (container)
31 * |---> MovieExtendsBox (container)
32 *
33 * The complete box structure can be found at 14496-12 E.2 "The‘isom’brand".
34 */
35 class MuxerOperation {
36 public:
37 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MuxerOperation)
39 // Generate data of this box and its contained box, and calculate box size.
40 virtual nsresult Generate(uint32_t* aBoxSize) = 0;
42 // Write data to stream.
43 virtual nsresult Write() = 0;
45 // Find the box type via its name (name is the box type defined in 14496-12;
46 // for example, 'moov' is the name of MovieBox).
47 // It can only look child boxes including itself and the box in the boxes
48 // list if exists. It can't look parent boxes.
49 virtual nsresult Find(const nsACString& aType,
50 nsTArray<nsRefPtr<MuxerOperation>>& aOperations) = 0;
52 virtual ~MuxerOperation() {}
53 };
55 }
56 #endif