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