Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*********************************************************************************/
     19 /*     -------------------------------------------------------------------       */
     20 /*                            MPEG-4 FullAtom Class                              */
     21 /*     -------------------------------------------------------------------       */
     22 /*********************************************************************************/
     23 /*
     24     This FullAtom Class is the base class for some Atoms in the MPEG-4 File
     25     Format.
     26 */
     27 
     28 
     29 #define IMPLEMENT_FullAtom
     30 
     31 #include "fullatom.h"
     32 #include "atomutils.h"
     33 #include "atomdefs.h"
     34 
     35 // Constructor
     36 FullAtom::FullAtom(uint32 type, uint8 version, uint32 flags)
     37         : Atom(type)
     38 {
     39     _version = version;
     40     _flags = flags;
     41 }
     42 
     43 FullAtom::FullAtom(MP4_FF_FILE *fp)
     44         : Atom(fp)
     45 {
     46     if (_success)
     47     {
     48 
     49         // Size and type set in Atom constructor
     50         uint32 data;
     51 
     52         if (!AtomUtils::read32(fp, data))
     53         {
     54             _mp4ErrorCode = READ_FAILED;
     55             _success = false;
     56             return;
     57         }
     58 
     59         _version = (uint8)(data >> 24);
     60         _flags = data & 0x00ffffff;
     61 
     62         // Version 1 atoms supported
     63         //we support version 0 & 1
     64         if (_version)
     65         {
     66             if ((_type == MOVIE_HEADER_ATOM) || (_type == TRACK_HEADER_ATOM) || (_type == MEDIA_HEADER_ATOM))
     67                 ;
     68             else
     69             {
     70                 _success = false;
     71                 _mp4ErrorCode = ATOM_VERSION_NOT_SUPPORTED;
     72             }
     73         }
     74     }
     75 }
     76 
     77 FullAtom::FullAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
     78         : Atom(fp, size, type)
     79 {
     80     if (_success)
     81     {
     82         // Size and type set in Atom constructor
     83         uint32 data;
     84 
     85         if (!AtomUtils::read32(fp, data))
     86         {
     87             _mp4ErrorCode = READ_FAILED;
     88             _success = false;
     89             return;
     90         }
     91 
     92         _version = (uint8)(data >> 24);
     93         _flags = data & 0x00ffffff;
     94 
     95         // Version 1 atoms supported
     96         //we support version 0 & 1
     97         if (_version)
     98         {
     99             if ((_type == MOVIE_HEADER_ATOM) || (_type == TRACK_HEADER_ATOM) || (_type == MEDIA_HEADER_ATOM))
    100                 ;
    101             else
    102             {
    103                 _success = false;
    104                 _mp4ErrorCode = ATOM_VERSION_NOT_SUPPORTED;
    105             }
    106         }
    107     }
    108 }
    109 
    110 
    111 // Destructor
    112 OSCL_EXPORT_REF FullAtom::~FullAtom()
    113 {
    114     // Empty
    115 }
    116 
    117 //Note: ARM linker can't find this symbol if it's declared "inline"
    118 #ifndef __CC_ARM
    119 inline
    120 #endif
    121 OSCL_EXPORT_REF uint32
    122 FullAtom::getDefaultSize() const
    123 {
    124     return DEFAULT_FULL_ATOM_SIZE;
    125 }
    126 
    127 
    128