• 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_HintMediaHeaderAtom Class contains general presentation information,
20     independent of coding, about the audio media within the stream.
21 */
22 
23 
24 #define IMPLEMENT_HintMediaHeaderAtom
25 
26 #include "hintmediaheaderatom.h"
27 #include "atomutils.h"
28 #include "a_atomdefs.h"
29 
30 // Constructor
PVA_FF_HintMediaHeaderAtom()31 PVA_FF_HintMediaHeaderAtom::PVA_FF_HintMediaHeaderAtom()
32         : PVA_FF_MediaInformationHeaderAtom(HINT_MEDIA_HEADER_ATOM, (uint8)0, (uint32) 0) // version = 0!
33 {
34     init();
35     recomputeSize();
36 }
37 
38 
39 // Destructor
~PVA_FF_HintMediaHeaderAtom()40 PVA_FF_HintMediaHeaderAtom::~PVA_FF_HintMediaHeaderAtom()
41 {
42     // Empty
43 }
44 
45 void
init()46 PVA_FF_HintMediaHeaderAtom::init()
47 {
48     _maxPDUSize = 0;
49     _avgPDUSize = 0;
50     _maxBitrate = 0;
51     _avgBitrate = 0;
52     _slidingAvgBitrate = 0;
53 }
54 
55 uint32
getMediaInformationHeaderType() const56 PVA_FF_HintMediaHeaderAtom::getMediaInformationHeaderType() const
57 {
58     return (uint32)MEDIA_INFORMATION_HEADER_TYPE_HINT;
59 }
60 
61 
62 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
63 bool
renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP * fp)64 PVA_FF_HintMediaHeaderAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
65 {
66     int32 rendered = 0;
67 
68     if (!renderAtomBaseMembers(fp))
69     {
70         return false;
71     }
72     rendered += getDefaultSize();
73 
74     // Render member variables
75     if (!PVA_FF_AtomUtils::render16(fp, getMaxPDUSize()))
76     {
77         return false;
78     }
79     if (!PVA_FF_AtomUtils::render16(fp, getAvgPDUSize()))
80     {
81         return false;
82     }
83     rendered += 4;
84 
85     if (!PVA_FF_AtomUtils::render32(fp, getMaxBitrate()))
86     {
87         return false;
88     }
89     if (!PVA_FF_AtomUtils::render32(fp, getAvgBitrate()))
90     {
91         return false;
92     }
93     if (!PVA_FF_AtomUtils::render32(fp, getSlidingAvgBitrate()))
94     {
95         return false;
96     }
97     rendered += 12;
98 
99     return true;
100 }
101 
102 
103 
104 void
recomputeSize()105 PVA_FF_HintMediaHeaderAtom::recomputeSize()
106 {
107     int32 size = getDefaultSize();
108     size += 4; // for max and avf PDU sizes
109     size += 12; // for max, avg, and sliding bitrates
110 
111     _size = size;
112 }
113 
114