• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MediaHeaderAtom Class                           */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This MediaHeaderAtom Class contains all the objects that declare information
25     about the media data within the stream.
26 */
27 
28 
29 #define IMPLEMENT_MediaHeaderAtom
30 
31 #include "mediaheaderatom.h"
32 #include "atomutils.h"
33 #include "atomdefs.h"
34 
35 // Stream-in ctor
MediaHeaderAtom(MP4_FF_FILE * fp,uint32 size,uint32 type)36 MediaHeaderAtom::MediaHeaderAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
37         : FullAtom(fp, size, type)
38 {
39     if (_success)
40     {
41 
42         _pparent = NULL;
43         if (getVersion() == 1)
44         {
45             if (!AtomUtils::read64(fp, _creationTime64))
46                 _success = false;
47             if (!AtomUtils::read64(fp, _modificationTime64))
48                 _success = false;
49             if (!AtomUtils::read32(fp, _timeScale))
50                 _success = false;
51             if (!AtomUtils::read64(fp, _duration64))
52                 _success = false;
53         }
54         else
55         {
56             if (!AtomUtils::read32(fp, _creationTime))
57                 _success = false;
58             if (!AtomUtils::read32(fp, _modificationTime))
59                 _success = false;
60             if (!AtomUtils::read32(fp, _timeScale))
61                 _success = false;
62             if (!AtomUtils::read32(fp, _duration))
63                 _success = false;
64 
65         }
66         if (!AtomUtils::read16(fp, _language))
67             _success = false;
68 
69         // Read the last two bytes of reserved
70         if (!AtomUtils::read16(fp, _reserved))
71             _success = false;
72 
73         if (!_success)
74             _mp4ErrorCode = READ_MEDIA_HEADER_ATOM_FAILED;
75     }
76     else
77     {
78         if (_mp4ErrorCode != ATOM_VERSION_NOT_SUPPORTED)
79             _mp4ErrorCode = READ_MEDIA_HEADER_ATOM_FAILED;
80     }
81 }
82 
83 
84 // Destructor
~MediaHeaderAtom()85 MediaHeaderAtom::~MediaHeaderAtom()
86 {
87     // Empty
88 }
89