2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-11-22 21:28:21 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_BOX_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_BOX_H_
|
2013-11-22 21:28:21 +00:00
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/compiler_specific.h"
|
2014-04-10 21:42:38 +00:00
|
|
|
#include "media/formats/mp4/fourccs.h"
|
2013-11-22 21:28:21 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-11-22 21:28:21 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class BufferWriter;
|
|
|
|
|
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
class BoxBuffer;
|
|
|
|
class BoxReader;
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Defines the base ISO BMFF box objects as defined in ISO 14496-12:2012
|
|
|
|
/// ISO BMFF section 4.2. All ISO BMFF compatible boxes inherit from either
|
|
|
|
/// Box or FullBox.
|
2013-11-22 21:28:21 +00:00
|
|
|
struct Box {
|
|
|
|
public:
|
|
|
|
Box();
|
|
|
|
virtual ~Box();
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Parse the mp4 box.
|
|
|
|
/// @param reader points to a BoxReader object which parses the box.
|
2013-11-22 21:28:21 +00:00
|
|
|
bool Parse(BoxReader* reader);
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Write the box to buffer.
|
|
|
|
/// This function calls ComputeSize internally to compute box size.
|
|
|
|
/// @param writer points to a BufferWriter object which wraps the buffer for
|
|
|
|
/// writing.
|
2013-11-22 21:28:21 +00:00
|
|
|
void Write(BufferWriter* writer);
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Compute the size of this box.
|
|
|
|
/// The calculated size will be saved in |atom_size| for later consumption.
|
2014-09-30 21:52:21 +00:00
|
|
|
virtual uint32_t ComputeSize() = 0;
|
2013-11-22 21:28:21 +00:00
|
|
|
virtual FourCC BoxType() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class BoxBuffer;
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Read/write the mp4 box from/to BoxBuffer.
|
2013-11-22 21:28:21 +00:00
|
|
|
virtual bool ReadWrite(BoxBuffer* buffer);
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// We don't support 64-bit atom sizes. 32-bit should be large enough for our
|
|
|
|
/// current needs.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t atom_size;
|
2013-11-22 21:28:21 +00:00
|
|
|
};
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Defines FullBox, the other base ISO BMFF box objects as defined in
|
|
|
|
/// ISO 14496-12:2012 ISO BMFF section 4.2. All ISO BMFF compatible boxes
|
|
|
|
/// inherit from either Box or FullBox.
|
2013-11-22 21:28:21 +00:00
|
|
|
struct FullBox : Box {
|
|
|
|
public:
|
|
|
|
FullBox();
|
|
|
|
virtual ~FullBox();
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t version;
|
|
|
|
uint32_t flags;
|
2013-11-22 21:28:21 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool ReadWrite(BoxBuffer* buffer) OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-11-22 21:28:21 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_BOX_H_
|