content/media/encoder/fmp4_muxer/MuxerOperation.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/encoder/fmp4_muxer/MuxerOperation.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsString.h"
    1.10 +#include "nsTArray.h"
    1.11 +
    1.12 +#ifndef MuxerOperation_h_
    1.13 +#define MuxerOperation_h_
    1.14 +
    1.15 +namespace mozilla {
    1.16 +
    1.17 +/**
    1.18 + * The interface for ISO box. All Boxes inherit from this interface.
    1.19 + * Generate() and Write() are needed to be called to produce a complete box.
    1.20 + *
    1.21 + * Generate() will generate all the data structures and their size.
    1.22 + *
    1.23 + * Write() will write all data into muxing output stream (ISOControl actually)
    1.24 + * and update the data which can't be known at Generate() (for example, the
    1.25 + * offset of the video data in mp4 file).
    1.26 + *
    1.27 + * ISO base media format is composed of several container boxes and the contained
    1.28 + * boxes. The container boxes hold a list of MuxerOperation which is implemented
    1.29 + * by contained boxes. The contained boxes will be called via the list.
    1.30 + * For example:
    1.31 + *   MovieBox (container) ---> boxes (array of MuxerOperation)
    1.32 + *                              |---> MovieHeaderBox (full box)
    1.33 + *                              |---> TrakBox (container)
    1.34 + *                              |---> MovieExtendsBox (container)
    1.35 + *
    1.36 + * The complete box structure can be found at 14496-12 E.2 "The‘isom’brand".
    1.37 + */
    1.38 +class MuxerOperation {
    1.39 +public:
    1.40 +  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MuxerOperation)
    1.41 +
    1.42 +  // Generate data of this box and its contained box, and calculate box size.
    1.43 +  virtual nsresult Generate(uint32_t* aBoxSize) = 0;
    1.44 +
    1.45 +  // Write data to stream.
    1.46 +  virtual nsresult Write() = 0;
    1.47 +
    1.48 +  // Find the box type via its name (name is the box type defined in 14496-12;
    1.49 +  // for example, 'moov' is the name of MovieBox).
    1.50 +  // It can only look child boxes including itself and the box in the boxes
    1.51 +  // list if exists. It can't look parent boxes.
    1.52 +  virtual nsresult Find(const nsACString& aType,
    1.53 +                        nsTArray<nsRefPtr<MuxerOperation>>& aOperations) = 0;
    1.54 +
    1.55 +  virtual ~MuxerOperation() {}
    1.56 +};
    1.57 +
    1.58 +}
    1.59 +#endif

mercurial