1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
diff -Naur mpeg4ip/lib/mp4v2/Makefile.am mpeg4ip-patched/lib/mp4v2/Makefile.am
--- mpeg4ip/lib/mp4v2/Makefile.am 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/Makefile.am 2008-02-13 15:50:50.000000000 +1300
@@ -10,6 +10,7 @@
libmp4v2_la_SOURCES = \
3gp.cpp \
+ atom_ac3.cpp \
atom_amr.cpp \
atom_avc1.cpp \
atom_avcC.cpp \
@@ -33,6 +34,7 @@
atom_mp4s.cpp \
atom_mp4v.cpp \
atom_mvhd.cpp \
+ atom_name.cpp \
atom_pasp.cpp \
atom_root.cpp \
atom_rtp.cpp \
diff -Naur mpeg4ip/lib/mp4v2/Makefile.in mpeg4ip-patched/lib/mp4v2/Makefile.in
--- mpeg4ip/lib/mp4v2/Makefile.in 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/Makefile.in 2008-02-14 14:38:05.000000000 +1300
@@ -55,7 +55,7 @@
am_libmp4v2_la_OBJECTS = 3gp.lo atom_amr.lo atom_avc1.lo atom_avcC.lo \
atom_d263.lo atom_damr.lo atom_dref.lo atom_elst.lo \
atom_enca.lo atom_encv.lo atom_free.lo atom_ftyp.lo \
- atom_gmin.lo atom_text.lo \
+ atom_gmin.lo atom_text.lo atom_ac3.lo \
atom_hdlr.lo atom_hinf.lo atom_hnti.lo atom_href.lo \
atom_mdat.lo atom_mdhd.lo atom_meta.lo atom_mp4a.lo \
atom_mp4s.lo atom_mp4v.lo atom_mvhd.lo atom_pasp.lo atom_root.lo \
@@ -73,6 +73,7 @@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/3gp.Plo ./$(DEPDIR)/atom_amr.Plo \
+@AMDEP_TRUE@ ./$(DEPDIR)/atom_ac3.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/atom_avc1.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/atom_avcC.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/atom_d263.Plo \
@@ -342,6 +343,7 @@
include_HEADERS = mp4.h
libmp4v2_la_SOURCES = \
3gp.cpp \
+ atom_ac3.cpp \
atom_amr.cpp \
atom_avc1.cpp \
atom_avcC.cpp \
@@ -497,6 +499,7 @@
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3gp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_ac3.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_amr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_avc1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_avcC.Plo@am__quote@
diff -Naur mpeg4ip/lib/mp4v2/atom_ac3.cpp mpeg4ip-patched/lib/mp4v2/atom_ac3.cpp
--- mpeg4ip/lib/mp4v2/atom_ac3.cpp 1970-01-01 12:00:00.000000000 +1200
+++ mpeg4ip-patched/lib/mp4v2/atom_ac3.cpp 2008-02-14 14:29:52.000000000 +1300
@@ -0,0 +1,51 @@
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is MPEG4IP.
+ *
+ * The Initial Developer of the Original Code is Cisco Systems Inc.
+ * Portions created by Cisco Systems Inc. are
+ * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Dave Mackie dmackie@cisco.com
+ */
+
+#include "mp4common.h"
+
+MP4Ac3Atom::MP4Ac3Atom()
+ : MP4Atom("ac-3")
+{
+
+ AddProperty( new MP4BytesProperty("data", 47));
+}
+
+void MP4Ac3Atom::Generate()
+{
+ MP4Atom::Generate();
+
+ // This is a nasty nasty hack because Apple haven't told us what is
+ // in the AC3 atom. So I've just copied this raw data from a sample
+ // file.
+ // I believe most of this is actually the same as the mp4a atom.
+ // I can play with this later to get it 100% right, for now this works.
+ static u_int8_t ac3[39] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xbb,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
+ 0x64, 0x61, 0x63, 0x33, 0x10, 0x3d, 0x40,
+ };
+
+ m_pProperties[0]->SetReadOnly(false);
+ ((MP4BytesProperty*)m_pProperties[0])->
+ SetValue(ac3, sizeof(ac3));
+}
diff -Naur mpeg4ip/lib/mp4v2/atom_meta.cpp mpeg4ip-patched/lib/mp4v2/atom_meta.cpp
--- mpeg4ip/lib/mp4v2/atom_meta.cpp 2004-12-15 10:35:35.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/atom_meta.cpp 2008-02-13 16:49:16.000000000 +1300
@@ -43,20 +43,33 @@
MP4NameAtom::MP4NameAtom()
: MP4Atom("name")
{
- AddVersionAndFlags(); /* 0, 1 */
-
- AddProperty(
- new MP4BytesProperty("metadata")); /* 2 */
+
}
void MP4NameAtom::Read()
{
+ if (ATOMID(m_pParentAtom->GetType()) != ATOMID("udta")) {
// calculate size of the metadata from the atom size
((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 4);
+ }
- MP4Atom::Read();
+ MP4Atom::Read();
}
+void MP4NameAtom::Generate()
+{
+ if (ATOMID(m_pParentAtom->GetType()) == ATOMID("udta")) {
+ AddProperty(new MP4BytesProperty("value"));
+ } else {
+ AddVersionAndFlags(); /* 0, 1 */
+
+ AddProperty(
+ new MP4BytesProperty("metadata")); /* 2 */
+ }
+ MP4Atom::Generate();
+}
+
+
MP4DataAtom::MP4DataAtom()
: MP4Atom("data")
{
diff -Naur mpeg4ip/lib/mp4v2/atom_stsd.cpp mpeg4ip-patched/lib/mp4v2/atom_stsd.cpp
--- mpeg4ip/lib/mp4v2/atom_stsd.cpp 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/atom_stsd.cpp 2008-02-13 14:52:10.000000000 +1300
@@ -51,6 +51,7 @@
ExpectChildAtom("avc1", Optional, Many);
ExpectChildAtom("text", Optional, Many);
ExpectChildAtom("pasp", Optional, Many);
+ ExpectChildAtom("ac-3", Optional, Many);
}
void MP4StsdAtom::Read()
diff -Naur mpeg4ip/lib/mp4v2/atom_udta.cpp mpeg4ip-patched/lib/mp4v2/atom_udta.cpp
--- mpeg4ip/lib/mp4v2/atom_udta.cpp 2003-08-05 09:59:56.000000000 +1200
+++ mpeg4ip-patched/lib/mp4v2/atom_udta.cpp 2008-02-13 16:25:08.000000000 +1300
@@ -33,6 +33,7 @@
{
if (ATOMID(m_pParentAtom->GetType()) == ATOMID("trak")) {
ExpectChildAtom("hinf", Optional, OnlyOne);
+ ExpectChildAtom("name", Optional, OnlyOne);
}
MP4Atom::Read();
diff -Naur mpeg4ip/lib/mp4v2/atoms.h mpeg4ip-patched/lib/mp4v2/atoms.h
--- mpeg4ip/lib/mp4v2/atoms.h 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/atoms.h 2008-02-14 14:54:20.000000000 +1300
@@ -146,6 +146,12 @@
void Generate();
};
+class MP4Ac3Atom : public MP4Atom {
+public:
+ MP4Ac3Atom();
+ void Generate();
+};
+
class MP4Mp4sAtom : public MP4Atom {
public:
MP4Mp4sAtom();
@@ -267,6 +273,7 @@
public:
MP4NameAtom();
void Read();
+ void Generate();
};
class MP4RtpAtom : public MP4Atom {
diff -Naur mpeg4ip/lib/mp4v2/mp4.cpp mpeg4ip-patched/lib/mp4v2/mp4.cpp
--- mpeg4ip/lib/mp4v2/mp4.cpp 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/mp4.cpp 2008-02-13 17:16:33.000000000 +1300
@@ -592,6 +592,25 @@
return MP4_INVALID_TRACK_ID;
}
+extern "C" MP4TrackId MP4AddAC3AudioTrack(
+ MP4FileHandle hFile,
+ u_int32_t timeScale,
+ MP4Duration sampleDuration,
+ u_int8_t audioType)
+{
+ if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
+ try {
+ return ((MP4File*)hFile)->
+ AddAC3AudioTrack(timeScale, sampleDuration, audioType);
+ }
+ catch (MP4Error* e) {
+ PRINT_ERROR(e);
+ delete e;
+ }
+ }
+ return MP4_INVALID_TRACK_ID;
+}
+
extern "C" MP4TrackId MP4AddEncAudioTrack(MP4FileHandle hFile,
u_int32_t timeScale,
MP4Duration sampleDuration,
diff -Naur mpeg4ip/lib/mp4v2/mp4.h mpeg4ip-patched/lib/mp4v2/mp4.h
--- mpeg4ip/lib/mp4v2/mp4.h 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/mp4.h 2008-02-13 17:15:24.000000000 +1300
@@ -432,6 +432,12 @@
MP4Duration sampleDuration,
u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+MP4TrackId MP4AddAC3AudioTrack(
+ MP4FileHandle hFile,
+ u_int32_t timeScale,
+ MP4Duration sampleDuration,
+ u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
+
typedef struct mp4v2_ismacryp_session_params {
u_int32_t scheme_type;
u_int16_t scheme_version;
diff -Naur mpeg4ip/lib/mp4v2/mp4atom.cpp mpeg4ip-patched/lib/mp4v2/mp4atom.cpp
--- mpeg4ip/lib/mp4v2/mp4atom.cpp 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/mp4atom.cpp 2008-02-13 16:03:41.000000000 +1300
@@ -76,6 +76,8 @@
case 'a':
if (ATOMID(type) == ATOMID("avc1")) {
pAtom = new MP4Avc1Atom();
+ } else if (ATOMID(type) == ATOMID("ac-3")) {
+ pAtom = new MP4Ac3Atom();
} else if (ATOMID(type) == ATOMID("avcC")) {
pAtom = new MP4AvcCAtom();
} else if (ATOMID(type) == ATOMID("alis")) {
diff -Naur mpeg4ip/lib/mp4v2/mp4file.cpp mpeg4ip-patched/lib/mp4v2/mp4file.cpp
--- mpeg4ip/lib/mp4v2/mp4file.cpp 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/mp4file.cpp 2008-02-13 17:47:11.000000000 +1300
@@ -1301,6 +1301,8 @@
AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "mp4a");
+ AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name");
+
// stsd is a unique beast in that it has a count of the number
// of child atoms that needs to be incremented after we add the mp4a atom
MP4Integer32Property* pStsdCountProperty;
@@ -1337,6 +1339,60 @@
return trackId;
}
+MP4TrackId MP4File::AddAC3AudioTrack(
+ u_int32_t timeScale,
+ MP4Duration sampleDuration,
+ u_int8_t audioType)
+{
+ MP4TrackId trackId = AddTrack(MP4_AUDIO_TRACK_TYPE, timeScale);
+
+ AddTrackToOd(trackId);
+
+ SetTrackFloatProperty(trackId, "tkhd.volume", 1.0);
+
+ InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "smhd", 0);
+
+ AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "ac-3");
+
+ AddDescendantAtoms(MakeTrackName(trackId, NULL), "udta.name");
+
+ // stsd is a unique beast in that it has a count of the number
+ // of child atoms that needs to be incremented after we add the mp4a atom
+ MP4Integer32Property* pStsdCountProperty;
+ FindIntegerProperty(
+ MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
+ (MP4Property**)&pStsdCountProperty);
+ pStsdCountProperty->IncrementValue();
+
+ //SetTrackIntegerProperty(trackId,
+ // "mdia.minf.stbl.stsd.ac-3.timeScale", timeScale);
+
+ //
+ //SetTrackIntegerProperty(trackId,
+ // "mdia.minf.stbl.stsd.ac-3.esds.ESID",
+#if 0
+ // note - for a file, these values need to
+ // be 0 - wmay - 04/16/2003
+ // trackId
+#else
+ // 0
+#endif
+ // );
+
+ //SetTrackIntegerProperty(trackId,
+ // "mdia.minf.stbl.stsd.ac-3.esds.decConfigDescr.objectTypeId",
+ // audioType);
+
+ //SetTrackIntegerProperty(trackId,
+ // "mdia.minf.stbl.stsd.ac-3.esds.decConfigDescr.streamType",
+ // MP4AudioStreamType);
+
+ m_pTracks[FindTrackIndex(trackId)]->
+ SetFixedSampleDuration(sampleDuration);
+
+ return trackId;
+}
+
MP4TrackId MP4File::AddEncAudioTrack(u_int32_t timeScale,
MP4Duration sampleDuration,
u_int8_t audioType,
diff -Naur mpeg4ip/lib/mp4v2/mp4file.h mpeg4ip-patched/lib/mp4v2/mp4file.h
--- mpeg4ip/lib/mp4v2/mp4file.h 2008-02-14 14:44:36.000000000 +1300
+++ mpeg4ip-patched/lib/mp4v2/mp4file.h 2008-02-13 17:17:11.000000000 +1300
@@ -203,6 +203,11 @@
MP4Duration sampleDuration,
u_int8_t audioType);
+ MP4TrackId AddAC3AudioTrack(
+ u_int32_t timeScale,
+ MP4Duration sampleDuration,
+ u_int8_t audioType);
+
MP4TrackId AddEncAudioTrack( // ismacryp
u_int32_t timeScale,
MP4Duration sampleDuration,
|