• 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 MediaDataAtom Class                           */
21 /*     -------------------------------------------------------------------       */
22 /*********************************************************************************/
23 /*
24     This MediaDataAtom Class contains the media data.  This class can operate in
25     either one of two ways - 1. it can store all it's data in memory (such as
26     during the creation of ObjectDescriptor streams), or 2. it can maintain all
27     it's data on disk (such as during the creation ofmedia streams - i.e. audio
28     and video).
29 
30     Note that during reading in this atom from a file stream, the type is forced
31     to MEDIA_DATA_ON_DISK thereby keeping all the object data in the physical
32     file.
33 */
34 
35 #define IMPLEMENT_MediaDataAtom
36 
37 #include "mediadataatom.h"
38 
39 #include "atomutils.h"
40 #include "atomdefs.h"
41 
42 // Stream-in Constructor
MediaDataAtom(MP4_FF_FILE * fp,OSCL_wString & filename)43 MediaDataAtom::MediaDataAtom(MP4_FF_FILE *fp, OSCL_wString& filename)
44         : Atom(fp)
45 {
46     OSCL_UNUSED_ARG(filename);
47     if (_success)
48     {
49 
50         _type = MEDIA_DATA_ON_DISK;
51 
52         // Seek past the end of the MEDIA_DATA_ATOM atom
53         int32 offset = getSize() - getDefaultSize();
54         int32 filePointer;
55         filePointer = AtomUtils::getCurrentFilePosition(fp);
56 
57         if ((filePointer + offset) == fp->_fileSize)
58         {
59             // LAST MDAT IN THE FILE
60             _success = true;
61         }
62         AtomUtils::seekFromStart(fp, (filePointer + offset));
63     }
64     else
65     {
66         _mp4ErrorCode = READ_MEDIA_DATA_ATOM_FAILED;
67     }
68 }
69 
70 // Destructor
~MediaDataAtom()71 MediaDataAtom::~MediaDataAtom()
72 {
73 
74 }
75 
76