annotate Input/aac/libmp4v2/atom_sdp.cpp @ 2:6efb9e514224 trunk

[svn] Import AAC stuff.
author nenolod
date Mon, 24 Oct 2005 10:44:27 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
1 /*
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
2 * The contents of this file are subject to the Mozilla Public
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
3 * License Version 1.1 (the "License"); you may not use this file
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
4 * except in compliance with the License. You may obtain a copy of
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
5 * the License at http://www.mozilla.org/MPL/
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
6 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
7 * Software distributed under the License is distributed on an "AS
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
9 * implied. See the License for the specific language governing
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
10 * rights and limitations under the License.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
11 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
12 * The Original Code is MPEG4IP.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
13 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
14 * The Initial Developer of the Original Code is Cisco Systems Inc.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
15 * Portions created by Cisco Systems Inc. are
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
16 * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
17 *
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
18 * Contributor(s):
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
19 * Dave Mackie dmackie@cisco.com
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
20 */
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
21
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
22 #include "mp4common.h"
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
23
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
24 MP4SdpAtom::MP4SdpAtom() : MP4Atom("sdp ")
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
25 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
26 AddProperty(
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
27 new MP4StringProperty("sdpText"));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
28 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
29
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
30 void MP4SdpAtom::Read()
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
31 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
32 // read sdp string, length is implicit in size of atom
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
33 u_int64_t size = GetEnd() - m_pFile->GetPosition();
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
34 char* data = (char*)MP4Malloc(size + 1);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
35 m_pFile->ReadBytes((u_int8_t*)data, size);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
36 data[size] = '\0';
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
37 ((MP4StringProperty*)m_pProperties[0])->SetValue(data);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
38 MP4Free(data);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
39 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
40
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
41 void MP4SdpAtom::Write()
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
42 {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
43 // since length of string is implicit in size of atom
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
44 // we need to handle this specially, and not write the terminating \0
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
45 MP4StringProperty* pSdp = (MP4StringProperty*)m_pProperties[0];
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
46 const char* sdpText = pSdp->GetValue();
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
47 if (sdpText) {
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
48 pSdp->SetFixedLength(strlen(sdpText));
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
49 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
50 MP4Atom::Write();
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
51 pSdp->SetFixedLength(0);
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
52 }
6efb9e514224 [svn] Import AAC stuff.
nenolod
parents:
diff changeset
53