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