Compiler warning and code style fixes. No functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,11 +22,15 @@
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "MP4Atom.h"
|
||||
|
||||
AtomBase::AtomBase(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize)
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
AtomBase::AtomBase(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType,
|
||||
uint64 patomSize)
|
||||
{
|
||||
theStream = pStream;
|
||||
streamOffset = pstreamOffset;
|
||||
@@ -35,13 +39,16 @@ AtomBase::AtomBase(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType,
|
||||
parentAtom = NULL;
|
||||
}
|
||||
|
||||
|
||||
AtomBase::~AtomBase()
|
||||
{
|
||||
theStream = NULL;
|
||||
parentAtom = NULL;
|
||||
}
|
||||
|
||||
char *AtomBase::GetAtomTypeAsFourcc()
|
||||
|
||||
char *
|
||||
AtomBase::GetAtomTypeAsFourcc()
|
||||
{
|
||||
fourcc[0] = (char)((atomType >> 24) & 0xff);
|
||||
fourcc[1] = (char)((atomType >> 16) & 0xff);
|
||||
@@ -52,9 +59,11 @@ char *AtomBase::GetAtomTypeAsFourcc()
|
||||
return fourcc;
|
||||
}
|
||||
|
||||
char *AtomBase::GetAtomName()
|
||||
|
||||
const char *
|
||||
AtomBase::GetAtomName()
|
||||
{
|
||||
char *_result;
|
||||
const char *_result;
|
||||
_result = OnGetAtomName();
|
||||
if (_result) {
|
||||
return _result;
|
||||
@@ -69,12 +78,16 @@ char *AtomBase::GetAtomName()
|
||||
return fourcc;
|
||||
}
|
||||
|
||||
char *AtomBase::OnGetAtomName()
|
||||
|
||||
const char *
|
||||
AtomBase::OnGetAtomName()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AtomBase::ProcessMetaData()
|
||||
|
||||
void
|
||||
AtomBase::ProcessMetaData()
|
||||
// ProcessMetaData() - Reads in the basic Atom Meta Data
|
||||
// - Calls OnProcessMetaData()
|
||||
// - Calls ProcessMetaData on each child atom
|
||||
@@ -87,12 +100,16 @@ void AtomBase::ProcessMetaData()
|
||||
MoveToEnd();
|
||||
}
|
||||
|
||||
void AtomBase::OnProcessMetaData()
|
||||
|
||||
void
|
||||
AtomBase::OnProcessMetaData()
|
||||
{
|
||||
MoveToEnd();
|
||||
}
|
||||
|
||||
bool AtomBase::MoveToEnd()
|
||||
|
||||
bool
|
||||
AtomBase::MoveToEnd()
|
||||
{
|
||||
off_t NewPosition = streamOffset + atomSize;
|
||||
|
||||
@@ -102,60 +119,79 @@ bool AtomBase::MoveToEnd()
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64 AtomBase::GetBytesRemaining()
|
||||
|
||||
uint64
|
||||
AtomBase::GetBytesRemaining()
|
||||
{
|
||||
off_t EndPosition = streamOffset + atomSize;
|
||||
off_t CurrPosition = GetStream()->Position();
|
||||
|
||||
if (CurrPosition > EndPosition) {
|
||||
printf("ERROR: Read past atom boundary by %Ld bytes\n",CurrPosition - EndPosition);
|
||||
printf("ERROR: Read past atom boundary by %Ld bytes\n",
|
||||
CurrPosition - EndPosition);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (EndPosition - CurrPosition);
|
||||
}
|
||||
|
||||
void AtomBase::DisplayAtoms()
|
||||
|
||||
void
|
||||
AtomBase::DisplayAtoms()
|
||||
{
|
||||
uint32 aindent = 0;
|
||||
DisplayAtoms(aindent);
|
||||
}
|
||||
|
||||
void AtomBase::DisplayAtoms(uint32 pindent)
|
||||
|
||||
void
|
||||
AtomBase::DisplayAtoms(uint32 pindent)
|
||||
{
|
||||
Indent(pindent);
|
||||
printf("(%s)\n",GetAtomName());
|
||||
}
|
||||
|
||||
void AtomBase::Indent(uint32 pindent)
|
||||
|
||||
void
|
||||
AtomBase::Indent(uint32 pindent)
|
||||
{
|
||||
for (uint32 i=0;i<pindent;i++) {
|
||||
printf("-");
|
||||
}
|
||||
}
|
||||
|
||||
bool AtomBase::IsKnown()
|
||||
|
||||
bool
|
||||
AtomBase::IsKnown()
|
||||
{
|
||||
return (OnGetAtomName() != NULL);
|
||||
}
|
||||
|
||||
void AtomBase::ReadArrayHeader(array_header *pHeader)
|
||||
|
||||
void
|
||||
AtomBase::ReadArrayHeader(array_header *pHeader)
|
||||
{
|
||||
Read(&pHeader->NoEntries);
|
||||
}
|
||||
|
||||
BPositionIO *AtomBase::OnGetStream()
|
||||
|
||||
BPositionIO *
|
||||
AtomBase::OnGetStream()
|
||||
{
|
||||
// default implementation
|
||||
return theStream;
|
||||
}
|
||||
|
||||
BPositionIO *AtomBase::GetStream()
|
||||
|
||||
BPositionIO *
|
||||
AtomBase::GetStream()
|
||||
{
|
||||
return OnGetStream();
|
||||
}
|
||||
|
||||
void AtomBase::Read(uint64 *value)
|
||||
|
||||
void
|
||||
AtomBase::Read(uint64 *value)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -166,7 +202,9 @@ void AtomBase::Read(uint64 *value)
|
||||
*value = B_BENDIAN_TO_HOST_INT64(*value);
|
||||
}
|
||||
|
||||
void AtomBase::Read(uint32 *value)
|
||||
|
||||
void
|
||||
AtomBase::Read(uint32 *value)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -177,7 +215,9 @@ void AtomBase::Read(uint32 *value)
|
||||
*value = B_BENDIAN_TO_HOST_INT32(*value);
|
||||
}
|
||||
|
||||
void AtomBase::Read(int32 *value)
|
||||
|
||||
void
|
||||
AtomBase::Read(int32 *value)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -188,7 +228,9 @@ void AtomBase::Read(int32 *value)
|
||||
*value = B_BENDIAN_TO_HOST_INT32(*value);
|
||||
}
|
||||
|
||||
void AtomBase::Read(uint16 *value)
|
||||
|
||||
void
|
||||
AtomBase::Read(uint16 *value)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -199,7 +241,9 @@ void AtomBase::Read(uint16 *value)
|
||||
*value = B_BENDIAN_TO_HOST_INT16(*value);
|
||||
}
|
||||
|
||||
void AtomBase::Read(uint8 *value)
|
||||
|
||||
void
|
||||
AtomBase::Read(uint8 *value)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -208,7 +252,9 @@ void AtomBase::Read(uint8 *value)
|
||||
// Assert((bytes_read == sizeof(uint8),"Read Error");
|
||||
}
|
||||
|
||||
void AtomBase::Read(char *value, uint32 maxread)
|
||||
|
||||
void
|
||||
AtomBase::Read(char *value, uint32 maxread)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -217,7 +263,9 @@ void AtomBase::Read(char *value, uint32 maxread)
|
||||
// Assert((bytes_read == maxread,"Read Error");
|
||||
}
|
||||
|
||||
void AtomBase::Read(uint8 *value, uint32 maxread)
|
||||
|
||||
void
|
||||
AtomBase::Read(uint8 *value, uint32 maxread)
|
||||
{
|
||||
uint32 bytes_read;
|
||||
|
||||
@@ -226,10 +274,13 @@ void AtomBase::Read(uint8 *value, uint32 maxread)
|
||||
// Assert((bytes_read == maxread,"Read Error");
|
||||
}
|
||||
|
||||
uint64 AtomBase::GetBits(uint64 buffer, uint8 startBit, uint8 totalBits)
|
||||
|
||||
uint64
|
||||
AtomBase::GetBits(uint64 buffer, uint8 startBit, uint8 totalBits)
|
||||
{
|
||||
// startBit should range from 0-63, totalBits should range from 1-64
|
||||
if ((startBit < 64) && (totalBits > 0) && (totalBits <= 64) && (startBit + totalBits <= 64)) {
|
||||
if ((startBit < 64) && (totalBits > 0) && (totalBits <= 64)
|
||||
&& (startBit + totalBits <= 64)) {
|
||||
// Ok pull from the buffer the bits wanted.
|
||||
buffer = buffer << startBit;
|
||||
buffer = buffer >> (64 - (totalBits + startBit) + startBit);
|
||||
@@ -240,10 +291,13 @@ uint64 AtomBase::GetBits(uint64 buffer, uint8 startBit, uint8 totalBits)
|
||||
return 0L;
|
||||
}
|
||||
|
||||
uint32 AtomBase::GetBits(uint32 buffer, uint8 startBit, uint8 totalBits)
|
||||
|
||||
uint32
|
||||
AtomBase::GetBits(uint32 buffer, uint8 startBit, uint8 totalBits)
|
||||
{
|
||||
// startBit should range from 0-31, totalBits should range from 1-32
|
||||
if ((startBit < 32) && (totalBits > 0) && (totalBits <= 32) && (startBit + totalBits <= 32)) {
|
||||
if ((startBit < 32) && (totalBits > 0) && (totalBits <= 32)
|
||||
&& (startBit + totalBits <= 32)) {
|
||||
// Ok pull from the buffer the bits wanted.
|
||||
buffer = buffer << startBit;
|
||||
buffer = buffer >> (32 - (startBit + totalBits) + startBit);
|
||||
@@ -254,15 +308,22 @@ uint32 AtomBase::GetBits(uint32 buffer, uint8 startBit, uint8 totalBits)
|
||||
return 0;
|
||||
}
|
||||
|
||||
FullAtom::FullAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomBase(pStream, pstreamOffset, patomType, patomSize)
|
||||
|
||||
FullAtom::FullAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType,
|
||||
uint64 patomSize)
|
||||
:
|
||||
AtomBase(pStream, pstreamOffset, patomType, patomSize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FullAtom::~FullAtom()
|
||||
{
|
||||
}
|
||||
|
||||
void FullAtom::OnProcessMetaData()
|
||||
|
||||
void
|
||||
FullAtom::OnProcessMetaData()
|
||||
{
|
||||
Read(&Version);
|
||||
Read(&Flags1);
|
||||
@@ -270,16 +331,23 @@ void FullAtom::OnProcessMetaData()
|
||||
Read(&Flags3);
|
||||
}
|
||||
|
||||
AtomContainer::AtomContainer(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomBase(pStream, pstreamOffset, patomType, patomSize)
|
||||
|
||||
AtomContainer::AtomContainer(BPositionIO *pStream, off_t pstreamOffset,
|
||||
uint32 patomType, uint64 patomSize)
|
||||
:
|
||||
AtomBase(pStream, pstreamOffset, patomType, patomSize)
|
||||
{
|
||||
TotalChildren = 0;
|
||||
}
|
||||
|
||||
|
||||
AtomContainer::~AtomContainer()
|
||||
{
|
||||
}
|
||||
|
||||
void AtomContainer::DisplayAtoms(uint32 pindent)
|
||||
|
||||
void
|
||||
AtomContainer::DisplayAtoms(uint32 pindent)
|
||||
{
|
||||
Indent(pindent);
|
||||
printf("%ld:(%s)\n",TotalChildren,GetAtomName());
|
||||
@@ -291,7 +359,9 @@ void AtomContainer::DisplayAtoms(uint32 pindent)
|
||||
|
||||
}
|
||||
|
||||
void AtomContainer::ProcessMetaData()
|
||||
|
||||
void
|
||||
AtomContainer::ProcessMetaData()
|
||||
{
|
||||
SetAtomOffset(GetStream()->Position());
|
||||
|
||||
@@ -310,7 +380,9 @@ void AtomContainer::ProcessMetaData()
|
||||
MoveToEnd();
|
||||
}
|
||||
|
||||
bool AtomContainer::AddChild(AtomBase *pChildAtom)
|
||||
|
||||
bool
|
||||
AtomContainer::AddChild(AtomBase *pChildAtom)
|
||||
{
|
||||
if (pChildAtom) {
|
||||
pChildAtom->SetParent(this);
|
||||
@@ -321,6 +393,7 @@ bool AtomContainer::AddChild(AtomBase *pChildAtom)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
AtomBase *AtomContainer::GetChildAtom(uint32 patomType, uint32 offset)
|
||||
{
|
||||
for (uint32 i=0;i<TotalChildren;i++) {
|
||||
@@ -334,7 +407,8 @@ AtomBase *AtomContainer::GetChildAtom(uint32 patomType, uint32 offset)
|
||||
} else {
|
||||
if (atomChildren[i]->IsContainer()) {
|
||||
// search container
|
||||
AtomBase *aAtomBase = (dynamic_cast<AtomContainer *>(atomChildren[i])->GetChildAtom(patomType, offset));
|
||||
AtomBase *aAtomBase = dynamic_cast<AtomContainer *>
|
||||
(atomChildren[i])->GetChildAtom(patomType, offset);
|
||||
if (aAtomBase) {
|
||||
// found in container
|
||||
return aAtomBase;
|
||||
@@ -346,6 +420,8 @@ AtomBase *AtomContainer::GetChildAtom(uint32 patomType, uint32 offset)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AtomContainer::OnProcessMetaData()
|
||||
|
||||
void
|
||||
AtomContainer::OnProcessMetaData()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef _MP4_ATOM_H
|
||||
#define _MP4_ATOM_H
|
||||
|
||||
|
||||
#include "MP4Structs.h"
|
||||
|
||||
#include <File.h>
|
||||
@@ -57,151 +58,154 @@ public
|
||||
|
||||
GetTypeAsString() - returns the type as something the user can read*/
|
||||
|
||||
|
||||
class AtomBase;
|
||||
|
||||
|
||||
typedef AtomBase* AtomBasePtr;
|
||||
typedef std::vector<AtomBasePtr> AtomArray;
|
||||
|
||||
|
||||
class AtomBase {
|
||||
|
||||
/*
|
||||
|
||||
This is the basic or standard atom. It contains data describing some aspect of the file/stream
|
||||
|
||||
*/
|
||||
|
||||
private:
|
||||
off_t streamOffset;
|
||||
off_t atomOffset;
|
||||
uint32 atomType;
|
||||
uint64 atomSize;
|
||||
char fourcc[5]; // make this an alias to atomType
|
||||
AtomBase *parentAtom;
|
||||
off_t streamOffset;
|
||||
off_t atomOffset;
|
||||
uint32 atomType;
|
||||
uint64 atomSize;
|
||||
char fourcc[5]; // make this an alias to atomType
|
||||
AtomBase* parentAtom;
|
||||
|
||||
protected:
|
||||
BPositionIO *theStream;
|
||||
void Indent(uint32 pindent);
|
||||
|
||||
BPositionIO *theStream;
|
||||
void Indent(uint32 pindent);
|
||||
|
||||
public:
|
||||
AtomBase(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize);
|
||||
virtual ~AtomBase();
|
||||
AtomBase(BPositionIO *pStream, off_t pstreamOffset,
|
||||
uint32 patomType, uint64 patomSize);
|
||||
virtual ~AtomBase();
|
||||
|
||||
virtual bool IsContainer() {return false;};
|
||||
virtual bool IsContainer() {return false;};
|
||||
|
||||
virtual BPositionIO *OnGetStream();
|
||||
BPositionIO *GetStream();
|
||||
virtual BPositionIO *OnGetStream();
|
||||
BPositionIO *GetStream();
|
||||
|
||||
bool IsExtended() {return false;};
|
||||
bool IsEndOfAtom() {return (GetStream()->Position() >= off_t(streamOffset + atomSize));};
|
||||
bool IsExtended() {return false;};
|
||||
bool IsEndOfAtom() {return (GetStream()->Position() >=
|
||||
off_t(streamOffset + atomSize));};
|
||||
|
||||
// Is this a known atom type
|
||||
bool IsKnown();
|
||||
bool IsKnown();
|
||||
|
||||
virtual void DisplayAtoms(uint32 pindent);
|
||||
virtual void DisplayAtoms(uint32 pindent);
|
||||
|
||||
uint64 GetAtomSize() {return atomSize;};
|
||||
uint32 GetAtomType() {return atomType;};
|
||||
char *GetAtomTypeAsFourcc();
|
||||
off_t GetAtomOffset() { return atomOffset; };
|
||||
off_t GetStreamOffset() { return streamOffset; };
|
||||
uint64 GetAtomSize() {return atomSize;};
|
||||
uint32 GetAtomType() {return atomType;};
|
||||
char* GetAtomTypeAsFourcc();
|
||||
off_t GetAtomOffset() { return atomOffset; };
|
||||
off_t GetStreamOffset() { return streamOffset; };
|
||||
|
||||
uint64 GetDataSize() { return atomSize - 8;};
|
||||
uint64 GetDataSize() { return atomSize - 8;};
|
||||
|
||||
uint64 GetBytesRemaining();
|
||||
uint64 GetBytesRemaining();
|
||||
|
||||
bool IsType(uint32 patomType) { return patomType == atomType; };
|
||||
bool IsType(uint32 patomType) { return patomType == atomType; };
|
||||
|
||||
void SetAtomOffset(off_t patomOffset) { atomOffset = patomOffset; };
|
||||
void SetStreamOffset(off_t pstreamOffset) { streamOffset = pstreamOffset; };
|
||||
void SetAtomOffset(off_t patomOffset) { atomOffset = patomOffset; };
|
||||
void SetStreamOffset(off_t pstreamOffset) { streamOffset = pstreamOffset; };
|
||||
|
||||
char *GetAtomName();
|
||||
const char *GetAtomName();
|
||||
|
||||
virtual char *OnGetAtomName();
|
||||
virtual const char *OnGetAtomName();
|
||||
|
||||
// ProcessMetaData() - Reads in the basic Atom Meta Data
|
||||
// - Calls OnProcessMetaData()
|
||||
virtual void ProcessMetaData();
|
||||
virtual void ProcessMetaData();
|
||||
|
||||
// OnProcessMetaData() - Subclass override to read/set meta data
|
||||
virtual void OnProcessMetaData();
|
||||
virtual void OnProcessMetaData();
|
||||
|
||||
// Move stream ptr to where atom ends in stream (return false on failure)
|
||||
bool MoveToEnd();
|
||||
bool MoveToEnd();
|
||||
|
||||
void DisplayAtoms();
|
||||
void DisplayAtoms();
|
||||
|
||||
// Many atoms use an array header
|
||||
void ReadArrayHeader(array_header *pHeader);
|
||||
void ReadArrayHeader(array_header *pHeader);
|
||||
|
||||
void SetParent(AtomBase *pParent) {parentAtom = pParent;};
|
||||
AtomBase *GetParent() { return parentAtom;};
|
||||
void SetParent(AtomBase *pParent) {parentAtom = pParent;};
|
||||
AtomBase* GetParent() { return parentAtom;};
|
||||
|
||||
void Read(uint64 *value);
|
||||
void Read(uint32 *value);
|
||||
void Read(int32 *value);
|
||||
void Read(uint16 *value);
|
||||
void Read(uint8 *value);
|
||||
void Read(char *value, uint32 maxread);
|
||||
void Read(uint8 *value, uint32 maxread);
|
||||
void Read(uint64 *value);
|
||||
void Read(uint32 *value);
|
||||
void Read(int32 *value);
|
||||
void Read(uint16 *value);
|
||||
void Read(uint8 *value);
|
||||
void Read(char *value, uint32 maxread);
|
||||
void Read(uint8 *value, uint32 maxread);
|
||||
|
||||
uint64 GetBits(uint64 buffer, uint8 startBit, uint8 totalBits);
|
||||
uint32 GetBits(uint32 buffer, uint8 startBit, uint8 totalBits);
|
||||
uint64 GetBits(uint64 buffer, uint8 startBit, uint8 totalBits);
|
||||
uint32 GetBits(uint32 buffer, uint8 startBit, uint8 totalBits);
|
||||
};
|
||||
|
||||
|
||||
class FullAtom : public AtomBase {
|
||||
public:
|
||||
FullAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize);
|
||||
virtual ~FullAtom();
|
||||
FullAtom(BPositionIO *pStream, off_t pstreamOffset,
|
||||
uint32 patomType, uint64 patomSize);
|
||||
virtual ~FullAtom();
|
||||
|
||||
virtual void OnProcessMetaData();
|
||||
uint8 GetVersion() {return Version;};
|
||||
uint8 GetFlags1() {return Flags1;};
|
||||
uint8 GetFlags2() {return Flags2;};
|
||||
uint8 GetFlags3() {return Flags3;};
|
||||
|
||||
virtual void OnProcessMetaData();
|
||||
uint8 GetVersion() {return Version;};
|
||||
uint8 GetFlags1() {return Flags1;};
|
||||
uint8 GetFlags2() {return Flags2;};
|
||||
uint8 GetFlags3() {return Flags3;};
|
||||
|
||||
private:
|
||||
uint8 Version;
|
||||
uint8 Flags1;
|
||||
uint8 Flags2;
|
||||
uint8 Flags3;
|
||||
uint8 Version;
|
||||
uint8 Flags1;
|
||||
uint8 Flags2;
|
||||
uint8 Flags3;
|
||||
};
|
||||
|
||||
|
||||
class AtomContainer : public AtomBase {
|
||||
|
||||
/*
|
||||
|
||||
This is an Atom that contains other atoms. It has children that may be Container Atoms or Standard Atoms
|
||||
|
||||
*/
|
||||
|
||||
private:
|
||||
AtomArray atomChildren;
|
||||
uint32 TotalChildren;
|
||||
AtomArray atomChildren;
|
||||
uint32 TotalChildren;
|
||||
|
||||
virtual void DisplayAtoms(uint32 pindent);
|
||||
virtual void DisplayAtoms(uint32 pindent);
|
||||
|
||||
public:
|
||||
AtomContainer(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize);
|
||||
virtual ~AtomContainer();
|
||||
AtomContainer(BPositionIO *pStream, off_t pstreamOffset,
|
||||
uint32 patomType, uint64 patomSize);
|
||||
virtual ~AtomContainer();
|
||||
|
||||
virtual bool IsContainer() {return true;};
|
||||
AtomBase *GetChildAtom(uint32 patomType, uint32 offset=0);
|
||||
uint32 CountChildAtoms(uint32 patomType);
|
||||
virtual bool IsContainer() {return true;};
|
||||
AtomBase *GetChildAtom(uint32 patomType, uint32 offset=0);
|
||||
uint32 CountChildAtoms(uint32 patomType);
|
||||
|
||||
// ProcessMetaData() - Reads in the basic Atom Meta Data
|
||||
// - Calls OnProcessMetaData()
|
||||
// - Calls ProcessMetaData on each child atom
|
||||
// (ensures stream is correct for child via offset)
|
||||
virtual void ProcessMetaData();
|
||||
virtual void ProcessMetaData();
|
||||
|
||||
// Add a atom to the children array (return false on failure)
|
||||
bool AddChild(AtomBase *pChildAtom);
|
||||
bool AddChild(AtomBase *pChildAtom);
|
||||
|
||||
// OnProcessMetaData() - Subclass override to read/set meta data
|
||||
virtual void OnProcessMetaData();
|
||||
virtual void OnChildProcessingComplete() {};
|
||||
virtual void OnProcessMetaData();
|
||||
virtual void OnChildProcessingComplete() {};
|
||||
};
|
||||
|
||||
|
||||
extern AtomBase *GetAtom(BPositionIO *pStream);
|
||||
|
||||
|
||||
#endif // _MP4_ATOM_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@
|
||||
#ifndef _MP4_PARSER_H
|
||||
#define _MP4_PARSER_H
|
||||
|
||||
|
||||
#include <File.h>
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaFormats.h>
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
#include "MP4Atom.h"
|
||||
|
||||
|
||||
typedef CompTimeToSample* CompTimeToSamplePtr;
|
||||
typedef std::map<uint32, CompTimeToSamplePtr, std::less<uint32> > CompTimeToSampleArray;
|
||||
typedef TimeToSample* TimeToSamplePtr;
|
||||
@@ -48,556 +50,660 @@ typedef std::vector<SyncSamplePtr> SyncSampleArray;
|
||||
typedef SampleSizeEntry* SampleSizePtr;
|
||||
typedef std::vector<SampleSizePtr> SampleSizeArray;
|
||||
|
||||
|
||||
// Atom class for reading the movie header atom
|
||||
class MVHDAtom : public FullAtom {
|
||||
public:
|
||||
MVHDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MVHDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
uint32 GetTimeScale() {return theHeader.TimeScale;};
|
||||
uint32 GetDuration() {return theHeader.Duration;};
|
||||
MVHDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MVHDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
uint32 GetTimeScale() {return theHeader.TimeScale;};
|
||||
uint32 GetDuration() {return theHeader.Duration;};
|
||||
|
||||
private:
|
||||
mvhdV1 theHeader;
|
||||
mvhdV1 theHeader;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the moov atom
|
||||
class MOOVAtom : public AtomContainer {
|
||||
public:
|
||||
MOOVAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MOOVAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
MOOVAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MOOVAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
MVHDAtom *GetMVHDAtom();
|
||||
MVHDAtom* GetMVHDAtom();
|
||||
|
||||
private:
|
||||
MVHDAtom *theMVHDAtom;
|
||||
MVHDAtom* theMVHDAtom;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the cmov atom
|
||||
class CMOVAtom : public AtomContainer {
|
||||
public:
|
||||
CMOVAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CMOVAtom();
|
||||
CMOVAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CMOVAtom();
|
||||
|
||||
BPositionIO *OnGetStream();
|
||||
void OnProcessMetaData();
|
||||
void OnChildProcessingComplete();
|
||||
BPositionIO *OnGetStream();
|
||||
void OnProcessMetaData();
|
||||
void OnChildProcessingComplete();
|
||||
|
||||
const char *OnGetAtomName();
|
||||
|
||||
char *OnGetAtomName();
|
||||
private:
|
||||
BMallocIO *theUncompressedStream;
|
||||
BMallocIO* theUncompressedStream;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the dcom atom
|
||||
class DCOMAtom : public AtomBase {
|
||||
public:
|
||||
DCOMAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DCOMAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
uint32 GetCompressionID() {return compressionID;};
|
||||
DCOMAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DCOMAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
uint32 GetCompressionID() {return compressionID;};
|
||||
|
||||
private:
|
||||
uint32 compressionID;
|
||||
uint32 compressionID;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the cmvd atom
|
||||
class CMVDAtom : public AtomBase {
|
||||
public:
|
||||
CMVDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CMVDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
uint32 GetUncompressedSize() {return UncompressedSize;};
|
||||
uint8 *GetCompressedData() {return Buffer;};
|
||||
uint32 GetBufferSize() {return BufferSize;};
|
||||
CMVDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CMVDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
uint32 GetUncompressedSize() {return UncompressedSize;};
|
||||
uint8* GetCompressedData() {return Buffer;};
|
||||
uint32 GetBufferSize() {return BufferSize;};
|
||||
|
||||
private:
|
||||
uint32 UncompressedSize;
|
||||
uint32 BufferSize;
|
||||
uint8 *Buffer;
|
||||
uint32 UncompressedSize;
|
||||
uint32 BufferSize;
|
||||
uint8* Buffer;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the ftyp atom
|
||||
class FTYPAtom : public AtomBase {
|
||||
public:
|
||||
FTYPAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~FTYPAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
FTYPAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~FTYPAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
bool HasBrand(uint32 brand);
|
||||
bool HasBrand(uint32 brand);
|
||||
|
||||
private:
|
||||
uint32 major_brand;
|
||||
uint32 minor_version;
|
||||
uint32 compatable_brands[32]; // Should be infinite but we will settle for max 32
|
||||
uint32 total_brands;
|
||||
uint32 major_brand;
|
||||
uint32 minor_version;
|
||||
uint32 compatable_brands[32];
|
||||
// Should be infinite but we will settle for max 32
|
||||
uint32 total_brands;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the wide atom
|
||||
class WIDEAtom : public AtomBase {
|
||||
public:
|
||||
WIDEAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~WIDEAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
WIDEAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~WIDEAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the free atom
|
||||
class FREEAtom : public AtomBase {
|
||||
public:
|
||||
FREEAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~FREEAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
FREEAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~FREEAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the preview atom
|
||||
class PNOTAtom : public AtomBase {
|
||||
public:
|
||||
PNOTAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~PNOTAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
PNOTAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~PNOTAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the time to sample atom
|
||||
class STTSAtom : public FullAtom {
|
||||
public:
|
||||
STTSAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STTSAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
uint64 GetSUMCounts() { return SUMCounts; };
|
||||
bigtime_t GetSUMDurations() { return SUMDurations; };
|
||||
uint32 GetSampleForTime(bigtime_t pTime);
|
||||
uint32 GetSampleForFrame(uint32 pFrame);
|
||||
void SetFrameRate(float pFrameRate) { FrameRate = pFrameRate; };
|
||||
STTSAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STTSAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint64 GetSUMCounts() { return SUMCounts; };
|
||||
bigtime_t GetSUMDurations() { return SUMDurations; };
|
||||
uint32 GetSampleForTime(bigtime_t pTime);
|
||||
uint32 GetSampleForFrame(uint32 pFrame);
|
||||
void SetFrameRate(float pFrameRate)
|
||||
{ FrameRate = pFrameRate; };
|
||||
|
||||
private:
|
||||
array_header theHeader;
|
||||
TimeToSampleArray theTimeToSampleArray;
|
||||
bigtime_t SUMDurations;
|
||||
uint64 SUMCounts;
|
||||
float FrameRate;
|
||||
array_header theHeader;
|
||||
TimeToSampleArray theTimeToSampleArray;
|
||||
bigtime_t SUMDurations;
|
||||
uint64 SUMCounts;
|
||||
float FrameRate;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the composition time to sample atom
|
||||
class CTTSAtom : public FullAtom {
|
||||
public:
|
||||
CTTSAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CTTSAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
CTTSAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~CTTSAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
private:
|
||||
array_header theHeader;
|
||||
CompTimeToSampleArray theCompTimeToSampleArray;
|
||||
array_header theHeader;
|
||||
CompTimeToSampleArray theCompTimeToSampleArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the sample to chunk atom
|
||||
class STSCAtom : public FullAtom {
|
||||
public:
|
||||
STSCAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSCAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STSCAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSCAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetChunkForSample(uint32 pSample, uint32 *pOffsetInChunk);
|
||||
uint32 GetFirstSampleInChunk(uint32 pChunkIndex);
|
||||
uint32 GetNoSamplesInChunk(uint32 pChunkIndex);
|
||||
uint32 GetChunkForSample(uint32 pSample,
|
||||
uint32 *pOffsetInChunk);
|
||||
uint32 GetFirstSampleInChunk(uint32 pChunkIndex);
|
||||
uint32 GetNoSamplesInChunk(uint32 pChunkIndex);
|
||||
|
||||
private:
|
||||
array_header theHeader;
|
||||
SampleToChunkArray theSampleToChunkArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the chunk to offset atom
|
||||
class STCOAtom : public FullAtom {
|
||||
public:
|
||||
STCOAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STCOAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STCOAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STCOAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint64 GetOffsetForChunk(uint32 pChunkIndex);
|
||||
uint32 GetTotalChunks() {return theHeader.NoEntries;};
|
||||
uint64 GetOffsetForChunk(uint32 pChunkIndex);
|
||||
uint32 GetTotalChunks() {return theHeader.NoEntries;};
|
||||
|
||||
protected:
|
||||
// Read a single chunk offset from Stream
|
||||
virtual uint64 OnGetChunkOffset();
|
||||
virtual uint64 OnGetChunkOffset();
|
||||
|
||||
private:
|
||||
array_header theHeader;
|
||||
ChunkToOffsetArray theChunkToOffsetArray;
|
||||
array_header theHeader;
|
||||
ChunkToOffsetArray theChunkToOffsetArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the sync sample atom
|
||||
class STSSAtom : public FullAtom {
|
||||
public:
|
||||
STSSAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSSAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STSSAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSSAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
bool IsSyncSample(uint32 pSampleNo);
|
||||
bool IsSyncSample(uint32 pSampleNo);
|
||||
|
||||
private:
|
||||
array_header theHeader;
|
||||
SyncSampleArray theSyncSampleArray;
|
||||
array_header theHeader;
|
||||
SyncSampleArray theSyncSampleArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the sample size atom
|
||||
class STSZAtom : public FullAtom {
|
||||
public:
|
||||
STSZAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSZAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STSZAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSZAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetSizeForSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
uint32 GetSizeForSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
|
||||
private:
|
||||
uint32 SampleSize;
|
||||
uint32 SampleCount;
|
||||
|
||||
SampleSizeArray theSampleSizeArray;
|
||||
uint32 SampleSize;
|
||||
uint32 SampleCount;
|
||||
|
||||
SampleSizeArray theSampleSizeArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the sample size 2 atom
|
||||
class STZ2Atom : public FullAtom {
|
||||
public:
|
||||
STZ2Atom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STZ2Atom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
uint32 GetSizeForSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
STZ2Atom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STZ2Atom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetSizeForSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
private:
|
||||
uint32 SampleSize;
|
||||
uint32 SampleCount;
|
||||
uint8 FieldSize;
|
||||
uint32 SampleSize;
|
||||
uint32 SampleCount;
|
||||
uint8 FieldSize;
|
||||
|
||||
SampleSizeArray theSampleSizeArray;
|
||||
SampleSizeArray theSampleSizeArray;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the skip atom
|
||||
class SKIPAtom : public AtomBase {
|
||||
public:
|
||||
SKIPAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~SKIPAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
SKIPAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~SKIPAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the media data atom
|
||||
class MDATAtom : public AtomBase {
|
||||
public:
|
||||
MDATAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDATAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
off_t GetEOF();
|
||||
MDATAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDATAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
off_t GetEOF();
|
||||
};
|
||||
|
||||
|
||||
// Subclass for handling special decoder config atoms like ESDS, ALAC, AVCC, AMR
|
||||
// ESDS is actually a FullAtom but others are not :-(
|
||||
class DecoderConfigAtom : public AtomBase {
|
||||
public:
|
||||
DecoderConfigAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DecoderConfigAtom();
|
||||
virtual void OnProcessMetaData();
|
||||
virtual char *OnGetAtomName();
|
||||
DecoderConfigAtom(BPositionIO *pStream,
|
||||
off_t pStreamOffset, uint32 pAtomType,
|
||||
uint64 pAtomSize);
|
||||
virtual ~DecoderConfigAtom();
|
||||
virtual void OnProcessMetaData();
|
||||
virtual const char *OnGetAtomName();
|
||||
|
||||
// The decoder config is what the decoder uses for it's setup
|
||||
// The values SHOULD mirror the Container values but often don't
|
||||
// So we have to parse the config and use the values as container overrides
|
||||
void OverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
virtual void OnOverrideAudioDescription(AudioDescription *pAudioDescription) {} ;
|
||||
void OverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
virtual void OnOverrideVideoDescription(VideoDescription *pVideoDescription) {} ;
|
||||
bool SkipTag(uint8 *ESDS, uint8 Tag, uint32 *offset);
|
||||
void OverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
virtual void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription) {};
|
||||
void OverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
virtual void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription) {};
|
||||
bool SkipTag(uint8 *ESDS, uint8 Tag, uint32 *offset);
|
||||
|
||||
uint8 *GetDecoderConfig();
|
||||
size_t GetDecoderConfigSize() { return DecoderConfigSize; } ;
|
||||
uint8 *GetDecoderConfig();
|
||||
size_t GetDecoderConfigSize() {return DecoderConfigSize;};
|
||||
|
||||
private:
|
||||
uint8 *theDecoderConfig;
|
||||
size_t DecoderConfigSize;
|
||||
uint8 *theDecoderConfig;
|
||||
size_t DecoderConfigSize;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the ESDS decoder config atom
|
||||
class ESDSAtom : public DecoderConfigAtom {
|
||||
public:
|
||||
ESDSAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~ESDSAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
ESDSAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~ESDSAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
|
||||
private:
|
||||
uint8 ESDSType;
|
||||
uint8 StreamType;
|
||||
uint32 NeededBufferSize;
|
||||
uint32 MaxBitRate;
|
||||
uint32 AvgBitRate;
|
||||
AACHeader theAACHeader;
|
||||
uint8 ESDSType;
|
||||
uint8 StreamType;
|
||||
uint32 NeededBufferSize;
|
||||
uint32 MaxBitRate;
|
||||
uint32 AvgBitRate;
|
||||
AACHeader theAACHeader;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the ALAC decoder config atom
|
||||
class ALACAtom : public DecoderConfigAtom {
|
||||
public:
|
||||
ALACAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~ALACAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
ALACAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~ALACAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the WAVE atom for mp3 decoder config
|
||||
class WAVEAtom : public DecoderConfigAtom {
|
||||
public:
|
||||
WAVEAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~WAVEAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
WAVEAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~WAVEAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the Sample Description atom
|
||||
class STSDAtom : public FullAtom {
|
||||
public:
|
||||
STSDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STSDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STSDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
VideoDescription GetAsVideo();
|
||||
AudioDescription GetAsAudio();
|
||||
|
||||
private:
|
||||
uint32 GetMediaHandlerType();
|
||||
VideoDescription GetAsVideo();
|
||||
AudioDescription GetAsAudio();
|
||||
|
||||
void ReadDecoderConfig(uint8 **pDecoderConfig, size_t *pDecoderConfigSize, AudioDescription *pAudioDescription, VideoDescription *pVideoDescription);
|
||||
void ReadSoundDescription();
|
||||
void ReadVideoDescription();
|
||||
void ReadHintDescription();
|
||||
private:
|
||||
uint32 GetMediaHandlerType();
|
||||
|
||||
void ReadDecoderConfig(uint8 **pDecoderConfig,
|
||||
size_t *pDecoderConfigSize,
|
||||
AudioDescription *pAudioDescription,
|
||||
VideoDescription *pVideoDescription);
|
||||
void ReadSoundDescription();
|
||||
void ReadVideoDescription();
|
||||
void ReadHintDescription();
|
||||
|
||||
uint32 codecid;
|
||||
uint32 codecid;
|
||||
|
||||
array_header theHeader;
|
||||
SampleEntry theSampleEntry;
|
||||
AudioDescription theAudioDescription;
|
||||
VideoDescription theVideoDescription;
|
||||
array_header theHeader;
|
||||
SampleEntry theSampleEntry;
|
||||
AudioDescription theAudioDescription;
|
||||
VideoDescription theVideoDescription;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the track header atom
|
||||
class TKHDAtom : public FullAtom {
|
||||
public:
|
||||
TKHDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TKHDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
TKHDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TKHDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetDuration() {return theHeader.Duration;}; // duration is in the scale of the media
|
||||
uint32 GetDuration() {return theHeader.Duration;};
|
||||
// duration is in the scale of the media
|
||||
|
||||
// Flags3 should contain the following
|
||||
// 0x001 Track enabled
|
||||
// 0x002 Track in Movie
|
||||
// 0x004 Track in Preview
|
||||
// 0x008 Track in Poster
|
||||
|
||||
bool IsActive() {return ((GetFlags3() && 0x01) || (GetFlags3() && 0x0f));};
|
||||
// Flags3 should contain the following
|
||||
// 0x001 Track enabled
|
||||
// 0x002 Track in Movie
|
||||
// 0x004 Track in Preview
|
||||
// 0x008 Track in Poster
|
||||
|
||||
bool IsActive() {return ((GetFlags3() && 0x01)
|
||||
|| (GetFlags3() && 0x0f));};
|
||||
|
||||
private:
|
||||
tkhdV1 theHeader;
|
||||
tkhdV1 theHeader;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the media header atom
|
||||
class MDHDAtom : public FullAtom {
|
||||
public:
|
||||
MDHDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDHDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
MDHDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDHDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
// return duration in ms
|
||||
bigtime_t GetDuration();
|
||||
uint32 GetTimeScale();
|
||||
|
||||
// return duration in ms
|
||||
bigtime_t GetDuration();
|
||||
uint32 GetTimeScale();
|
||||
|
||||
private:
|
||||
mdhdV1 theHeader;
|
||||
mdhdV1 theHeader;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the video media header atom
|
||||
class VMHDAtom : public FullAtom {
|
||||
public:
|
||||
VMHDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~VMHDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
VMHDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~VMHDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
bool IsCopyMode() {return theHeader.GraphicsMode == 0;};
|
||||
bool IsCopyMode() {return theHeader.GraphicsMode == 0;};
|
||||
private:
|
||||
vmhd theHeader ;
|
||||
vmhd theHeader ;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the sound media header atom
|
||||
class SMHDAtom : public FullAtom {
|
||||
public:
|
||||
SMHDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~SMHDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
SMHDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~SMHDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
private:
|
||||
smhd theHeader;
|
||||
smhd theHeader;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the track atom
|
||||
class TRAKAtom : public AtomContainer {
|
||||
public:
|
||||
TRAKAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TRAKAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnChildProcessingComplete();
|
||||
TRAKAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TRAKAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnChildProcessingComplete();
|
||||
|
||||
bigtime_t Duration(uint32 TimeScale); // Return duration of track
|
||||
bigtime_t Duration() { return Duration(timeScale); }
|
||||
uint32 FrameCount() { return frameCount; };
|
||||
bool IsVideo(); // Is this a video track
|
||||
bool IsAudio(); // Is this a audio track
|
||||
// GetAudioMetaData() // If this is a audio track Get the audio meta data
|
||||
// GetVideoMetaData() // If this is a video track Get the video meta data
|
||||
bigtime_t Duration(uint32 TimeScale); // Return duration of track
|
||||
bigtime_t Duration() { return Duration(timeScale); }
|
||||
uint32 FrameCount() { return frameCount; };
|
||||
bool IsVideo(); // Is this a video track
|
||||
bool IsAudio(); // Is this a audio track
|
||||
// GetAudioMetaData() // If this is a audio track Get the audio meta data
|
||||
// GetVideoMetaData() // If this is a video track Get the video meta data
|
||||
|
||||
bigtime_t GetTimeForFrame(uint32 pFrame);
|
||||
uint32 GetFrameForTime(bigtime_t time);
|
||||
uint32 GetSampleForTime(bigtime_t pTime);
|
||||
uint32 GetSampleForFrame(uint32 pFrame);
|
||||
uint32 GetChunkForSample(uint32 pSample, uint32 *pOffsetInChunk);
|
||||
uint64 GetOffsetForChunk(uint32 pChunkIndex);
|
||||
uint32 GetFirstSampleInChunk(uint32 pChunkIndex);
|
||||
uint32 GetSizeForSample(uint32 pSample);
|
||||
uint32 GetNoSamplesInChunk(uint32 pChunkIndex);
|
||||
uint32 GetTotalChunks();
|
||||
uint32 GetChunkSize(uint32 pChunkIndex);
|
||||
uint32 ChunkCount();
|
||||
bigtime_t GetTimeForFrame(uint32 pFrame);
|
||||
uint32 GetFrameForTime(bigtime_t time);
|
||||
uint32 GetSampleForTime(bigtime_t pTime);
|
||||
uint32 GetSampleForFrame(uint32 pFrame);
|
||||
uint32 GetChunkForSample(uint32 pSample,
|
||||
uint32 *pOffsetInChunk);
|
||||
uint64 GetOffsetForChunk(uint32 pChunkIndex);
|
||||
uint32 GetFirstSampleInChunk(uint32 pChunkIndex);
|
||||
uint32 GetSizeForSample(uint32 pSample);
|
||||
uint32 GetNoSamplesInChunk(uint32 pChunkIndex);
|
||||
uint32 GetTotalChunks();
|
||||
uint32 GetChunkSize(uint32 pChunkIndex);
|
||||
uint32 ChunkCount();
|
||||
|
||||
float GetSampleRate();
|
||||
float GetFrameRate();
|
||||
float GetSampleRate();
|
||||
float GetFrameRate();
|
||||
|
||||
bool IsSyncSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
bool IsActive();
|
||||
bool IsSyncSample(uint32 pSampleNo);
|
||||
bool IsSingleSampleSize();
|
||||
bool IsActive();
|
||||
|
||||
uint32 GetBytesPerSample();
|
||||
uint32 GetBytesPerSample();
|
||||
|
||||
TKHDAtom *GetTKHDAtom();
|
||||
MDHDAtom *GetMDHDAtom();
|
||||
TKHDAtom *GetTKHDAtom();
|
||||
MDHDAtom *GetMDHDAtom();
|
||||
private:
|
||||
TKHDAtom *theTKHDAtom;
|
||||
MDHDAtom *theMDHDAtom;
|
||||
|
||||
uint32 frameCount;
|
||||
uint32 bytesPerSample;
|
||||
uint32 timeScale;
|
||||
TKHDAtom *theTKHDAtom;
|
||||
MDHDAtom *theMDHDAtom;
|
||||
|
||||
uint32 frameCount;
|
||||
uint32 bytesPerSample;
|
||||
uint32 timeScale;
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the media container atom
|
||||
class MDIAAtom : public AtomContainer {
|
||||
public:
|
||||
MDIAAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDIAAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
MDIAAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MDIAAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetMediaHandlerType();
|
||||
uint32 GetMediaHandlerType();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the media information atom
|
||||
class MINFAtom : public AtomContainer {
|
||||
public:
|
||||
MINFAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MINFAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
MINFAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~MINFAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetMediaHandlerType();
|
||||
uint32 GetMediaHandlerType();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the stbl atom
|
||||
class STBLAtom : public AtomContainer {
|
||||
public:
|
||||
STBLAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STBLAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
STBLAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~STBLAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
uint32 GetMediaHandlerType();
|
||||
uint32 GetMediaHandlerType();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the dinf atom
|
||||
class DINFAtom : public AtomContainer {
|
||||
public:
|
||||
DINFAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DINFAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
DINFAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DINFAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the tmcd atom
|
||||
class TMCDAtom : public AtomBase {
|
||||
public:
|
||||
TMCDAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TMCDAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
TMCDAtom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~TMCDAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the dac3 atom
|
||||
class DAC3Atom : public DecoderConfigAtom {
|
||||
public:
|
||||
DAC3Atom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DAC3Atom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
DAC3Atom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DAC3Atom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the dec3 atom
|
||||
class DEC3Atom : public DecoderConfigAtom {
|
||||
public:
|
||||
DEC3Atom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DEC3Atom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(VideoDescription *pVideoDescription);
|
||||
DEC3Atom(BPositionIO *pStream, off_t pStreamOffset,
|
||||
uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~DEC3Atom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
void OnOverrideAudioDescription(
|
||||
AudioDescription *pAudioDescription);
|
||||
void OnOverrideVideoDescription(
|
||||
VideoDescription *pVideoDescription);
|
||||
};
|
||||
|
||||
|
||||
// Atom class for reading the Media Handler atom
|
||||
class HDLRAtom : public FullAtom {
|
||||
public:
|
||||
HDLRAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~HDLRAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
HDLRAtom(BPositionIO *pStream, off_t pStreamOffset, uint32 pAtomType, uint64 pAtomSize);
|
||||
virtual ~HDLRAtom();
|
||||
void OnProcessMetaData();
|
||||
const char *OnGetAtomName();
|
||||
|
||||
bool IsVideoHandler();
|
||||
bool IsAudioHandler();
|
||||
uint32 GetMediaHandlerType();
|
||||
bool IsVideoHandler();
|
||||
bool IsAudioHandler();
|
||||
uint32 GetMediaHandlerType();
|
||||
|
||||
private:
|
||||
hdlr theHeader;
|
||||
char *name;
|
||||
hdlr theHeader;
|
||||
char *name;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,9 +22,15 @@
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "MP4Parser.h"
|
||||
|
||||
TRAKAtom::TRAKAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomContainer(pStream, pstreamOffset, patomType, patomSize)
|
||||
|
||||
TRAKAtom::TRAKAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType,
|
||||
uint64 patomSize)
|
||||
:
|
||||
AtomContainer(pStream, pstreamOffset, patomType, patomSize)
|
||||
{
|
||||
theTKHDAtom = NULL;
|
||||
theMDHDAtom = NULL;
|
||||
@@ -33,20 +39,27 @@ TRAKAtom::TRAKAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType,
|
||||
timeScale = 1;
|
||||
}
|
||||
|
||||
|
||||
TRAKAtom::~TRAKAtom()
|
||||
{
|
||||
}
|
||||
|
||||
void TRAKAtom::OnProcessMetaData()
|
||||
|
||||
void
|
||||
TRAKAtom::OnProcessMetaData()
|
||||
{
|
||||
}
|
||||
|
||||
char *TRAKAtom::OnGetAtomName()
|
||||
|
||||
const char *
|
||||
TRAKAtom::OnGetAtomName()
|
||||
{
|
||||
return "MPEG-4 Track Atom";
|
||||
}
|
||||
|
||||
TKHDAtom *TRAKAtom::GetTKHDAtom()
|
||||
|
||||
TKHDAtom *
|
||||
TRAKAtom::GetTKHDAtom()
|
||||
{
|
||||
if (theTKHDAtom) {
|
||||
return theTKHDAtom;
|
||||
@@ -59,11 +72,12 @@ TKHDAtom *TRAKAtom::GetTKHDAtom()
|
||||
return theTKHDAtom;
|
||||
}
|
||||
|
||||
MDHDAtom *TRAKAtom::GetMDHDAtom()
|
||||
|
||||
MDHDAtom *
|
||||
TRAKAtom::GetMDHDAtom()
|
||||
{
|
||||
if (theMDHDAtom) {
|
||||
if (theMDHDAtom)
|
||||
return theMDHDAtom;
|
||||
}
|
||||
|
||||
theMDHDAtom = dynamic_cast<MDHDAtom *>(GetChildAtom(uint32('mdhd'),0));
|
||||
|
||||
@@ -72,21 +86,24 @@ MDHDAtom *TRAKAtom::GetMDHDAtom()
|
||||
return theMDHDAtom;
|
||||
}
|
||||
|
||||
// Return duration of track
|
||||
bigtime_t TRAKAtom::Duration(uint32 TimeScale)
|
||||
|
||||
bigtime_t
|
||||
TRAKAtom::Duration(uint32 TimeScale)
|
||||
{
|
||||
if (IsAudio() || IsVideo()) {
|
||||
if (IsAudio() || IsVideo())
|
||||
return GetMDHDAtom()->GetDuration();
|
||||
}
|
||||
|
||||
return bigtime_t(GetTKHDAtom()->GetDuration() * 1000000.0) / TimeScale;
|
||||
}
|
||||
|
||||
void TRAKAtom::OnChildProcessingComplete()
|
||||
|
||||
void
|
||||
TRAKAtom::OnChildProcessingComplete()
|
||||
{
|
||||
timeScale = GetMDHDAtom()->GetTimeScale();
|
||||
|
||||
STTSAtom *aSTTSAtom = dynamic_cast<STTSAtom *>(GetChildAtom(uint32('stts'),0));
|
||||
STTSAtom *aSTTSAtom = dynamic_cast<STTSAtom *>
|
||||
(GetChildAtom(uint32('stts'),0));
|
||||
|
||||
if (aSTTSAtom) {
|
||||
frameCount = aSTTSAtom->GetSUMCounts();
|
||||
@@ -95,22 +112,26 @@ void TRAKAtom::OnChildProcessingComplete()
|
||||
|
||||
}
|
||||
|
||||
// Is this a video track
|
||||
bool TRAKAtom::IsVideo()
|
||||
|
||||
bool
|
||||
TRAKAtom::IsVideo()
|
||||
{
|
||||
// video tracks have a vmhd atom
|
||||
return (GetChildAtom(uint32('vmhd'),0) != NULL);
|
||||
}
|
||||
|
||||
// Is this a audio track
|
||||
bool TRAKAtom::IsAudio()
|
||||
|
||||
bool
|
||||
TRAKAtom::IsAudio()
|
||||
{
|
||||
// audio tracks have a smhd atom
|
||||
return (GetChildAtom(uint32('smhd'),0) != NULL);
|
||||
}
|
||||
|
||||
|
||||
// frames per us
|
||||
float TRAKAtom::GetFrameRate()
|
||||
float
|
||||
TRAKAtom::GetFrameRate()
|
||||
{
|
||||
if (IsAudio()) {
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsd'),0);
|
||||
@@ -118,7 +139,8 @@ float TRAKAtom::GetFrameRate()
|
||||
STSDAtom *aSTSDAtom = dynamic_cast<STSDAtom *>(aAtomBase);
|
||||
|
||||
AudioDescription aAudioDescription = aSTSDAtom->GetAsAudio();
|
||||
return (aAudioDescription.theAudioSampleEntry.SampleRate) / aAudioDescription.FrameSize;
|
||||
return (aAudioDescription.theAudioSampleEntry.SampleRate)
|
||||
/ aAudioDescription.FrameSize;
|
||||
}
|
||||
} else if (IsVideo()) {
|
||||
return (frameCount * 1000000.0) / Duration();
|
||||
@@ -127,7 +149,9 @@ float TRAKAtom::GetFrameRate()
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
float TRAKAtom::GetSampleRate()
|
||||
|
||||
float
|
||||
TRAKAtom::GetSampleRate()
|
||||
{
|
||||
// Only valid for Audio
|
||||
if (IsAudio()) {
|
||||
@@ -143,6 +167,7 @@ float TRAKAtom::GetSampleRate()
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetFrameForTime(bigtime_t time) {
|
||||
// time / duration * frameCount?
|
||||
@@ -150,12 +175,16 @@ TRAKAtom::GetFrameForTime(bigtime_t time) {
|
||||
return time * frameCount / Duration();
|
||||
}
|
||||
|
||||
bigtime_t TRAKAtom::GetTimeForFrame(uint32 pFrame)
|
||||
|
||||
bigtime_t
|
||||
TRAKAtom::GetTimeForFrame(uint32 pFrame)
|
||||
{
|
||||
return bigtime_t((pFrame * 1000000LL) / GetFrameRate());
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetSampleForTime(bigtime_t pTime)
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetSampleForTime(bigtime_t pTime)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stts'),0);
|
||||
|
||||
@@ -166,40 +195,49 @@ uint32 TRAKAtom::GetSampleForTime(bigtime_t pTime)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetSampleForFrame(uint32 pFrame)
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetSampleForFrame(uint32 pFrame)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stts'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
return (dynamic_cast<STTSAtom *>(aAtomBase))->GetSampleForTime(GetTimeForFrame(pFrame));
|
||||
return (dynamic_cast<STTSAtom *>
|
||||
(aAtomBase))->GetSampleForTime(GetTimeForFrame(pFrame));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetChunkForSample(uint32 pSample, uint32 *pOffsetInChunk)
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetChunkForSample(uint32 pSample, uint32 *pOffsetInChunk)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsc'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
return (dynamic_cast<STSCAtom *>(aAtomBase))->GetChunkForSample(pSample, pOffsetInChunk);
|
||||
}
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STSCAtom *>(aAtomBase))->GetChunkForSample(pSample,
|
||||
pOffsetInChunk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetNoSamplesInChunk(uint32 pChunkIndex)
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetNoSamplesInChunk(uint32 pChunkIndex)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsc'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
return (dynamic_cast<STSCAtom *>(aAtomBase))->GetNoSamplesInChunk(pChunkIndex);
|
||||
}
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STSCAtom *>
|
||||
(aAtomBase))->GetNoSamplesInChunk(pChunkIndex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetSizeForSample(uint32 pSample)
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetSizeForSample(uint32 pSample)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsz'),0);
|
||||
|
||||
@@ -210,74 +248,84 @@ uint32 TRAKAtom::GetSizeForSample(uint32 pSample)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64 TRAKAtom::GetOffsetForChunk(uint32 pChunkIndex)
|
||||
|
||||
uint64
|
||||
TRAKAtom::GetOffsetForChunk(uint32 pChunkIndex)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stco'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
return (dynamic_cast<STCOAtom *>(aAtomBase))->GetOffsetForChunk(pChunkIndex);
|
||||
return (dynamic_cast<STCOAtom *>
|
||||
(aAtomBase))->GetOffsetForChunk(pChunkIndex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::ChunkCount() {
|
||||
|
||||
uint32
|
||||
TRAKAtom::ChunkCount()
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stco'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STCOAtom *>(aAtomBase))->GetTotalChunks();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint32 TRAKAtom::GetFirstSampleInChunk(uint32 pChunkIndex)
|
||||
uint32
|
||||
TRAKAtom::GetFirstSampleInChunk(uint32 pChunkIndex)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsc'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
return (dynamic_cast<STSCAtom *>(aAtomBase))->GetFirstSampleInChunk(pChunkIndex);
|
||||
}
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STSCAtom *>
|
||||
(aAtomBase))->GetFirstSampleInChunk(pChunkIndex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool TRAKAtom::IsSyncSample(uint32 pSampleNo)
|
||||
bool
|
||||
TRAKAtom::IsSyncSample(uint32 pSampleNo)
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stss'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STSSAtom *>(aAtomBase))->IsSyncSample(pSampleNo);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TRAKAtom::IsSingleSampleSize()
|
||||
|
||||
bool
|
||||
TRAKAtom::IsSingleSampleSize()
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stsz'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STSZAtom *>(aAtomBase))->IsSingleSampleSize();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TRAKAtom::IsActive()
|
||||
|
||||
bool
|
||||
TRAKAtom::IsActive()
|
||||
{
|
||||
return GetTKHDAtom()->IsActive();
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetBytesPerSample()
|
||||
{
|
||||
AtomBase *aAtomBase;
|
||||
|
||||
if (bytesPerSample > 0) {
|
||||
uint32
|
||||
TRAKAtom::GetBytesPerSample()
|
||||
{
|
||||
AtomBase *aAtomBase;
|
||||
|
||||
if (bytesPerSample > 0)
|
||||
return bytesPerSample;
|
||||
}
|
||||
|
||||
// calculate bytes per sample and cache it
|
||||
|
||||
@@ -289,13 +337,15 @@ AtomBase *aAtomBase;
|
||||
|
||||
AudioDescription aAudioDescription = aSTSDAtom->GetAsAudio();
|
||||
|
||||
bytesPerSample = aAudioDescription.theAudioSampleEntry.SampleSize / 8;
|
||||
bytesPerSample = aAudioDescription.theAudioSampleEntry.SampleSize
|
||||
/ 8;
|
||||
}
|
||||
}
|
||||
|
||||
return bytesPerSample;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetChunkSize(uint32 pChunkIndex)
|
||||
{
|
||||
@@ -319,13 +369,14 @@ TRAKAtom::GetChunkSize(uint32 pChunkIndex)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 TRAKAtom::GetTotalChunks()
|
||||
|
||||
uint32
|
||||
TRAKAtom::GetTotalChunks()
|
||||
{
|
||||
AtomBase *aAtomBase = GetChildAtom(uint32('stco'),0);
|
||||
|
||||
if (aAtomBase) {
|
||||
if (aAtomBase)
|
||||
return (dynamic_cast<STCOAtom *>(aAtomBase))->GetTotalChunks();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user