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
|
|
|
|
|
|
|
#ifndef MEDIA_MP4_BOX_H_
|
|
|
|
#define MEDIA_MP4_BOX_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "media/mp4/fourccs.h"
|
|
|
|
|
|
|
|
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.
|
2013-11-22 21:28:21 +00:00
|
|
|
virtual uint32 ComputeSize() = 0;
|
|
|
|
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.
|
2013-11-22 21:28:21 +00:00
|
|
|
uint32 atom_size;
|
|
|
|
};
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
uint8 version;
|
|
|
|
uint32 flags;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool ReadWrite(BoxBuffer* buffer) OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_MP4_BOX_H_
|