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     This PVA_FF_VideoMediaHeaderAtom Class contains general presentation information,
     20     independent of coding, about the visual media within the stream.
     21 */
     22 
     23 
     24 #define IMPLEMENT_VideoMediaHeaderAtom
     25 
     26 #include "videomediaheaderatom.h"
     27 #include "atomutils.h"
     28 #include "a_atomdefs.h"
     29 
     30 // Constructor
     31 PVA_FF_VideoMediaHeaderAtom::PVA_FF_VideoMediaHeaderAtom()
     32         : PVA_FF_MediaInformationHeaderAtom(VIDEO_MEDIA_HEADER_ATOM, (uint8)0, (uint32)1) // version=0 & flags=1!
     33 {
     34     _reserved = 0;
     35     recomputeSize();
     36 }
     37 
     38 // Destructor
     39 PVA_FF_VideoMediaHeaderAtom::~PVA_FF_VideoMediaHeaderAtom()
     40 {
     41     // Empty
     42 }
     43 
     44 uint32
     45 PVA_FF_VideoMediaHeaderAtom::getMediaInformationHeaderType() const
     46 {
     47     return (uint32)MEDIA_INFORMATION_HEADER_TYPE_VISUAL;
     48 }
     49 
     50 
     51 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
     52 bool
     53 PVA_FF_VideoMediaHeaderAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
     54 {
     55     uint32 rendered = 0;
     56 
     57     if (!renderAtomBaseMembers(fp))
     58     {
     59         return false;
     60     }
     61     rendered += getDefaultSize();
     62 
     63     // Render 64 bits of 0
     64     if (!PVA_FF_AtomUtils::render32(fp, _reserved))
     65     {
     66         return false;
     67     }
     68     if (!PVA_FF_AtomUtils::render32(fp, _reserved))
     69     {
     70         return false;
     71     }
     72     rendered += 8;
     73 
     74     return true;
     75 }
     76 
     77 
     78 
     79 
     80 void
     81 PVA_FF_VideoMediaHeaderAtom::recomputeSize()
     82 {
     83     int32 size = getDefaultSize();
     84     size += 8; // for 64 bit reserved
     85 
     86     _size = size;
     87 }
     88 
     89