Modified IsSupported to identify MP4 and MOV files better
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17893 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -617,11 +617,26 @@ bool MOVFileReader::IsActive(uint32 stream_index)
|
||||
/* static */
|
||||
bool MOVFileReader::IsSupported(BPositionIO *source)
|
||||
{
|
||||
// MOV files normally do not have ftyp atoms
|
||||
// But when they do we need to check if they have a qt brand
|
||||
// No qt brand means the file is likely to be a MP4 file
|
||||
|
||||
AtomBase *aAtom;
|
||||
|
||||
aAtom = getAtom(source);
|
||||
|
||||
if (aAtom) {
|
||||
return (aAtom->IsKnown());
|
||||
if (dynamic_cast<FTYPAtom *>(aAtom)) {
|
||||
printf("ftyp atom found checking for qt brand\n");
|
||||
aAtom->ProcessMetaData();
|
||||
// MP4 files start with a ftyp atom that contains an isom brand
|
||||
// MOV files with a ftyp atom contain the qt brand
|
||||
return dynamic_cast<FTYPAtom *>(aAtom)->HasBrand(uint32('qt '));
|
||||
} else {
|
||||
// no ftyp atom so just see if we know the atom we have
|
||||
return (aAtom->IsKnown());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1438,9 +1438,41 @@ FTYPAtom::~FTYPAtom()
|
||||
|
||||
void FTYPAtom::OnProcessMetaData()
|
||||
{
|
||||
// ftyp is really an mp4 thing, but some mov encoders are adding it anyway.
|
||||
// but a mov file with an ftyp should define a brand of qt (I think)
|
||||
|
||||
Read(&major_brand);
|
||||
Read(&minor_version);
|
||||
|
||||
total_brands = getBytesRemaining() / sizeof(uint32);
|
||||
|
||||
if (total_brands > 32) {
|
||||
total_brands = 32; // restrict to 32
|
||||
}
|
||||
|
||||
for (uint32 i=0;i<total_brands;i++) {
|
||||
Read(&compatable_brands[i]);
|
||||
}
|
||||
}
|
||||
|
||||
char *FTYPAtom::OnGetAtomName()
|
||||
{
|
||||
return "Quicktime File Type";
|
||||
}
|
||||
|
||||
bool FTYPAtom::HasBrand(uint32 brand)
|
||||
{
|
||||
// return true if the specified brand is in the list
|
||||
|
||||
if (major_brand == brand) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint32 i=0;i<total_brands;i++) {
|
||||
if (compatable_brands[i] == brand) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -478,6 +478,13 @@ public:
|
||||
virtual ~FTYPAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -662,8 +662,14 @@ bool
|
||||
MP4FileReader::IsSupported(BPositionIO *source)
|
||||
{
|
||||
AtomBase *aAtom = getAtom(source);
|
||||
if (aAtom)
|
||||
return aAtom->IsKnown();
|
||||
|
||||
if (aAtom) {
|
||||
if (dynamic_cast<FTYPAtom *>(aAtom)) {
|
||||
aAtom->ProcessMetaData();
|
||||
printf("ftyp atom found checking brands\n");
|
||||
// MP4 files start with a ftyp atom that does not contain a qt brand
|
||||
return !(dynamic_cast<FTYPAtom *>(aAtom)->HasBrand(uint32('qt ')));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1148,6 +1148,23 @@ char *FTYPAtom::OnGetAtomName()
|
||||
return "File type Atom";
|
||||
}
|
||||
|
||||
bool FTYPAtom::HasBrand(uint32 brand)
|
||||
{
|
||||
|
||||
if (major_brand == brand) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// return true if the specified brand is in the list
|
||||
for (uint32 i=0;i<total_brands;i++) {
|
||||
if (compatable_brands[i] == brand) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FREEAtom::FREEAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomBase(pStream, pstreamOffset, patomType, patomSize)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ public:
|
||||
virtual ~FTYPAtom();
|
||||
void OnProcessMetaData();
|
||||
char *OnGetAtomName();
|
||||
|
||||
bool HasBrand(uint32 brand);
|
||||
private:
|
||||
uint32 major_brand;
|
||||
uint32 minor_version;
|
||||
|
||||
Reference in New Issue
Block a user