61
|
1 /*
|
|
2 * The contents of this file are subject to the Mozilla Public
|
|
3 * License Version 1.1 (the "License"); you may not use this file
|
|
4 * except in compliance with the License. You may obtain a copy of
|
|
5 * the License at http://www.mozilla.org/MPL/
|
|
6 *
|
|
7 * Software distributed under the License is distributed on an "AS
|
|
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
9 * implied. See the License for the specific language governing
|
|
10 * rights and limitations under the License.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
|
|
15 * Portions created by Cisco Systems Inc. are
|
|
16 * Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved.
|
|
17 *
|
|
18 * Contributor(s):
|
|
19 * Bill May wmay@cisco.com
|
|
20 */
|
|
21
|
|
22 #include "mp4common.h"
|
|
23
|
|
24 MP4SoundAtom::MP4SoundAtom(const char *atomid)
|
|
25 : MP4Atom(atomid)
|
|
26 {
|
|
27 AddReserved("reserved1", 6); /* 0 */
|
|
28
|
|
29 AddProperty( /* 1 */
|
|
30 new MP4Integer16Property("dataReferenceIndex"));
|
|
31 AddProperty( /* 2 */
|
|
32 new MP4Integer16Property("soundVersion"));
|
|
33 AddReserved( "reserved2", 6); /* 3 */
|
|
34
|
|
35 AddProperty( /* 4 */
|
|
36 new MP4Integer16Property("channels"));
|
|
37 AddProperty( /* 5 */
|
|
38 new MP4Integer16Property("sampleSize"));
|
|
39 AddProperty( /* 6 */
|
|
40 new MP4Integer16Property("packetSize"));
|
|
41 AddProperty( /* 7 */
|
|
42 new MP4Integer32Property("timeScale"));
|
|
43 }
|
|
44
|
|
45 void MP4SoundAtom::AddProperties (uint8_t version)
|
|
46 {
|
|
47 if (version > 0) {
|
|
48 AddProperty( /* 8 */
|
|
49 new MP4Integer32Property("samplesPerPacket"));
|
|
50 AddProperty( /* 9 */
|
|
51 new MP4Integer32Property("bytesPerPacket"));
|
|
52 AddProperty( /* 10 */
|
|
53 new MP4Integer32Property("bytesPerFrame"));
|
|
54 AddProperty( /* 11 */
|
|
55 new MP4Integer32Property("bytesPerSample"));
|
|
56 }
|
|
57 }
|
|
58 void MP4SoundAtom::Generate()
|
|
59 {
|
|
60 MP4Atom::Generate();
|
|
61
|
|
62 ((MP4Integer16Property*)m_pProperties[1])->SetValue(1);
|
|
63
|
|
64 // property reserved2 has non-zero fixed values
|
|
65 static u_int8_t reserved2[16] = {
|
|
66 0x00, 0x00, 0x00, 0x00,
|
|
67 0x00, 0x00, 0x00, 0x00,
|
|
68 0x00, 0x02, 0x00, 0x10,
|
|
69 0x00, 0x00, 0x00, 0x00,
|
|
70 };
|
|
71 m_pProperties[2]->SetReadOnly(false);
|
|
72 ((MP4BytesProperty*)m_pProperties[2])->
|
|
73 SetValue(reserved2, sizeof(reserved2));
|
|
74 m_pProperties[2]->SetReadOnly(true);
|
|
75 }
|
|
76
|
|
77 void MP4SoundAtom::Read()
|
|
78 {
|
|
79 ReadProperties(0, 3); // read first 3 properties
|
|
80 AddProperties(((MP4IntegerProperty *)m_pProperties[2])->GetValue());
|
|
81 ReadProperties(3); // continue
|
|
82 }
|