diff --git a/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp b/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp index 96cdc7b723..a5516cbb83 100644 --- a/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp +++ b/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp @@ -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(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(aAtom)->HasBrand(uint32('qt ')); + } else { + // no ftyp atom so just see if we know the atom we have + return (aAtom->IsKnown()); + } } + return false; } diff --git a/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp b/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp index 7fc5d92d1b..831b4be42c 100644 --- a/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp +++ b/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp @@ -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;iIsKnown(); - + if (aAtom) { + if (dynamic_cast(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(aAtom)->HasBrand(uint32('qt '))); + } + } + return false; } diff --git a/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp b/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp index 2c895bf876..69bc25922c 100644 --- a/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp +++ b/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp @@ -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