• 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 Util: DecoderSpecificInfo                     */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
25     video stream
26 */
27 
28 #define __IMPLEMENT_DecoderSpecificInfo__
29 
30 #include "decoderspecificinfo.h"
31 
32 #include "atomutils.h"
33 
34 // Stream-in Constructor
DecoderSpecificInfo(MP4_FF_FILE * fp,bool o3GPPTrack,bool read_struct)35 DecoderSpecificInfo::DecoderSpecificInfo(MP4_FF_FILE *fp, bool o3GPPTrack, bool read_struct)
36         : BaseDescriptor(fp, o3GPPTrack)
37 {
38     _pinfo    = NULL;
39     _infoSize = 0;
40 
41     if (o3GPPTrack)
42     {
43         return;
44     }
45 
46     if (_success)
47     {
48         if (o3GPPTrack)
49         {
50             _infoSize = _sizeOfClass;
51         }
52         else
53         {
54             _infoSize = _sizeOfClass - 1 - getSizeOfSizeField();
55         }
56 
57         if (_infoSize > 0)
58         {
59             _pinfo = (uint8 *)oscl_malloc(_infoSize);
60 
61             if (read_struct)
62             {
63                 if (!AtomUtils::readByteData(fp, _infoSize, _pinfo))
64                 {
65                     _success = false;
66                     _mp4ErrorCode = READ_DECODER_SPECIFIC_INFO_FAILED;
67                 }
68             }
69             else
70             {
71                 if (!AtomUtils::readByteData(fp, _infoSize, _pinfo))
72                 {
73                     _success = false;
74                     _mp4ErrorCode = READ_DECODER_SPECIFIC_INFO_FAILED;
75                 }
76                 else
77                 {
78                     AtomUtils::rewindFilePointerByN(fp, _infoSize);
79                 }
80             }
81         }
82         else
83         {
84             _success = false;
85             _mp4ErrorCode = READ_DECODER_SPECIFIC_INFO_FAILED;
86         }
87 
88     }
89     else
90     {
91         _mp4ErrorCode = READ_DECODER_SPECIFIC_INFO_FAILED;
92     }
93 }
94 
95 // Destructor
~DecoderSpecificInfo()96 DecoderSpecificInfo::~DecoderSpecificInfo()
97 {
98     if (_pinfo != NULL)
99     {
100         oscl_free(_pinfo);
101     }
102 }
103 
104 
105 
106