• 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     This PVA_FF_MediaAtom Class contains all the objects that declare information
20     about the media data within the stream.
21 */
22 
23 #ifndef __MediaAtom_H__
24 #define __MediaAtom_H__
25 
26 #include "atom.h"
27 #include "mediaheaderatom.h"
28 #include "handleratom.h"
29 #include "mediainformationatom.h"
30 #include "esdescriptor.h"
31 
32 class PVA_FF_MediaAtom : public PVA_FF_Atom
33 {
34 
35     public:
36         // The protocol parameter is used when creating a HINT track.  It is passed
37         // down to the PVA_FF_SampleDescriptionAtom so it can create the appropriate PVA_FF_HintSampleEntry.
38         // If this constructor is used to create any other typ eof track atom, the protocol
39         // parameter is ignored - hence the default parameter value.
40         PVA_FF_MediaAtom(int32 mediaType,
41                          int32 codecType,
42                          uint32 fileAuthoringFlags,
43                          uint32 protocol = 0,
44                          uint8 profile = 1,
45                          uint8 profileComp = 0xFF,
46                          uint8 level = 0xFF); // Constructor
47 
48         virtual ~PVA_FF_MediaAtom();
49 
50         // Member get and set methods
getMediaHeaderAtomPtr()51         PVA_FF_MediaHeaderAtom *getMediaHeaderAtomPtr()
52         {
53             return _pmediaHeader;
54         }
55 
56         // Update members based on next sample received
57         void nextSample(int32 mediaType,
58                         void *psample,
59                         uint32 size,
60                         uint32 ts,
61                         uint8 flags = 0,
62                         uint32 baseOffset = 0,
63                         bool oChunkStart = false);
64 
65         void nextTextSample(int32 mediaType,
66                             void *psample,
67                             uint32 size,
68                             uint32 ts,
69                             uint8 flags = 0,
70                             int32 index = 0,
71                             uint32 baseOffset = 0,
72                             bool oChunkStart = false);
73 
74         void nextSample(int32 mediaType,
75                         Oscl_Vector <OsclMemoryFragment, OsclMemAllocator>& fragmentList,
76                         uint32 size,
77                         uint32 ts,
78                         uint8 flags = 0,
79                         uint32 baseOffset = 0,
80                         bool oChunkStart = false);
81 
82         void nextTextSample(int32 mediaType,
83                             Oscl_Vector <OsclMemoryFragment, OsclMemAllocator>& fragmentList,
84                             uint32 size,
85                             uint32 ts,
86                             uint8 flags = 0,
87                             int32 index = 0,
88                             uint32 baseOffset = 0,
89                             bool oChunkStart = false);
90 
91         bool reAuthorFirstSample(uint32 size,
92                                  uint32 baseOffset);
93         void updateLastTSEntry(uint32 ts);
94 
95         // Called to update the member atoms if they depend on the actual
96         // file offsets where the media data atom (for which this track stores
97         // the meta data) is stored
updateAtomFileOffsets(uint32 offset)98         void updateAtomFileOffsets(uint32 offset)
99         {
100             _pmediaInformation->updateAtomFileOffsets(offset);
101         }
102 
setTimeScale(uint32 ts)103         void setTimeScale(uint32 ts)
104         {
105             _pmediaInformation->setTimeScale(ts);
106             _pmediaHeader->setTimeScale(ts);
107         }
108 
getTimeScale()109         uint32 getTimeScale() const
110         {
111             return _pmediaHeader->getTimeScale();
112         }
113 
114         // Stream properties
setTargetBitrate(uint32 avgBitRate,uint32 maxBitRate,uint32 bufferSizeDB)115         void setTargetBitrate(uint32 avgBitRate, uint32 maxBitRate, uint32 bufferSizeDB)
116         {
117             _pmediaInformation->setTargetBitrate(avgBitRate, maxBitRate, bufferSizeDB);
118         }
119 
120         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
121         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
122 
123         // Getting and setting the Mpeg4 VOL header
addDecoderSpecificInfo(PVA_FF_DecoderSpecificInfo * pinfo)124         void addDecoderSpecificInfo(PVA_FF_DecoderSpecificInfo *pinfo)
125         {
126             _pmediaInformation->addDecoderSpecificInfo(pinfo);
127         }
128 
129         // Getting and setting the Mpeg4 VOL header in timed text case
addTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo * pinfo)130         void addTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pinfo)
131         {
132             _pmediaInformation->addTextDecoderSpecificInfo(pinfo);
133         }
134 
setMaxBufferSizeDB(uint32 max)135         void setMaxBufferSizeDB(uint32 max)
136         {
137             _pmediaInformation->setMaxBufferSizeDB(max);
138         }
139 
setVideoParams(uint32 frame_width,uint32 frame_height)140         void setVideoParams(uint32 frame_width, uint32 frame_height)
141         {
142             _pmediaInformation->setVideoParams(frame_width, frame_height);
143         }
144 
setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams & audioParams)145         void setAudioEncodeParams(PVMP4FFComposerAudioEncodeParams &audioParams)
146         {
147             _pmediaInformation->setAudioEncodeParams(audioParams);
148         }
149 
setH263ProfileLevel(uint8 profile,uint8 level)150         void setH263ProfileLevel(uint8 profile, uint8 level)
151         {
152             _pmediaInformation->setH263ProfileLevel(profile, level);
153         }
154 
setDuration(uint32 duration)155         void setDuration(uint32 duration)
156         {
157             _pmediaHeader->setDuration(duration);
158         }
159 
setLanguage(uint32 language)160         void setLanguage(uint32 language)
161         {
162             _pmediaHeader->setLanguage(language);
163         }
164 
setESID(uint16 esid)165         void setESID(uint16 esid)
166         {
167             _pmediaInformation->setESID(esid);
168         }
169 
170         void SetMaxSampleSize(uint32);
171         void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
172 
getSampleCount()173         uint32 getSampleCount() const
174         {
175             return _pmediaInformation->getSampleCount();
176         }
177 
178     private:
179         virtual void recomputeSize();
180 
181         PVA_FF_MediaHeaderAtom *_pmediaHeader;
182         PVA_FF_HandlerAtom *_phandler;
183         PVA_FF_MediaInformationAtom *_pmediaInformation;
184 
185 };
186 
187 
188 
189 #endif
190 
191