Move files from gst-plugins-ugly into the "subprojects/gst-plugins-ugly/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-ugly / gst / asfdemux / asfheaders.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include <gst/gst.h>
21
22 #include "asfheaders.h"
23
24 const ASFGuidHash asf_payload_ext_guids[] = {
25   {ASF_PAYLOAD_EXTENSION_DURATION, "ASF_PAYLOAD_EXTENSION_DURATION",
26         {0xC6BD9450, 0x4907867F, 0x79C7A383, 0xAD33B721}
27       },
28   {ASF_PAYLOAD_EXTENSION_SYSTEM_CONTENT, "ASF_PAYLOAD_EXTENSION_SYSTEM_CONTENT",
29       {0xD590DC20, 0x436C07BC, 0xBBF3f79C, 0xDCA4F1FB}},
30   {ASF_PAYLOAD_EXTENSION_SYSTEM_PIXEL_ASPECT_RATIO,
31         "ASF_PAYLOAD_EXTENSION_SYSTEM_PIXEL_ASPECT_RATIO",
32       {0x1b1ee554, 0x4bc8f9ea, 0x6b371a82, 0xb8c4e474}},
33   {ASF_PAYLOAD_EXTENSION_TIMING, "ASF_PAYLOAD_EXTENSION_TIMING",
34       {0XFD3CC02A, 0X4CFA06DB, 0X12721C80, 0XE44587D3}},
35   {ASF_PAYLOAD_EXTENSION_UNDEFINED, "ASF_PAYLOAD_EXTENSION_UNDEFINED",
36         {0, 0, 0, 0}
37       }
38 };
39
40 const ASFGuidHash asf_correction_guids[] = {
41   {ASF_CORRECTION_ON, "ASF_CORRECTION_ON",
42         {0xBFC3CD50, 0x11CF618F, 0xAA00B28B, 0x20E2B400}
43       },
44   {ASF_CORRECTION_OFF, "ASF_CORRECTION_OFF",
45         {0x20FB5700, 0x11CF5B55, 0x8000FDA8, 0x2B445C5F}
46       },
47   /* CHECKME: where does this 49F1A440... GUID come from? (tpm) */
48   {ASF_CORRECTION_OFF, "ASF_CORRECTION_OFF",
49         {0x49F1A440, 0x11D04ECE, 0xA000ACA3, 0xF64803C9}
50       },
51   {ASF_CORRECTION_UNDEFINED, "ASF_CORRECTION_UNDEFINED",
52         {0, 0, 0, 0}
53       }
54 };
55
56 const ASFGuidHash asf_stream_guids[] = {
57   {ASF_STREAM_VIDEO, "ASF_STREAM_VIDEO",
58         {0xBC19EFC0, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F}
59       },
60   {ASF_STREAM_AUDIO, "ASF_STREAM_AUDIO",
61         {0xF8699E40, 0x11CF5B4D, 0x8000FDA8, 0x2B445C5F}
62       },
63   {ASF_STREAM_EXT_EMBED_HEADER, "ASF_STREAM_EXT_EMBED_HEADER",
64       {0X3AFB65E2, 0X40F247EF, 0XA9702CAC, 0X43D3710D}},
65   {ASF_STREAM_UNDEFINED, "ASF_STREAM_UNDEFINED",
66         {0, 0, 0, 0}
67       }
68 };
69
70 const ASFGuidHash asf_ext_stream_guids[] = {
71   {ASF_EXT_STREAM_AUDIO, "ASF_EXT_STREAM_AUDIO",
72         {0X31178C9D, 0X452803E1, 0XF93D82B5, 0X03F522DB}
73       },
74   {ASF_EXT_STREAM_UNDEFINED, "ASF_EXT_STREAM_UNDEFINED",
75         {0, 0, 0, 0}
76       }
77 };
78
79 const ASFGuidHash asf_object_guids[] = {
80   {ASF_OBJ_STREAM, "ASF_OBJ_STREAM",
81         {0xB7DC0791, 0x11CFA9B7, 0xC000E68E, 0x6553200C}
82       },
83   {ASF_OBJ_DATA, "ASF_OBJ_DATA",
84         {0x75b22636, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200}
85       },
86   {ASF_OBJ_FILE, "ASF_OBJ_FILE",
87         {0x8CABDCA1, 0x11CFA947, 0xC000E48E, 0x6553200C}
88       },
89   {ASF_OBJ_HEADER, "ASF_OBJ_HEADER",
90         {0x75B22630, 0x11CF668E, 0xAA00D9A6, 0x6CCE6200}
91       },
92   {ASF_OBJ_CONCEAL_NONE, "ASF_OBJ_CONCEAL_NONE",
93         {0x20fb5700, 0x11cf5b55, 0x8000FDa8, 0x2B445C5f}
94       },
95   {ASF_OBJ_COMMENT, "ASF_OBJ_COMMENT",
96         {0x75b22633, 0x11cf668e, 0xAA00D9a6, 0x6Cce6200}
97       },
98   {ASF_OBJ_CODEC_COMMENT, "ASF_OBJ_CODEC_COMMENT",
99         {0x86D15240, 0x11D0311D, 0xA000A4A3, 0xF64803C9}
100       },
101   {ASF_OBJ_CODEC_COMMENT1, "ASF_OBJ_CODEC_COMMENT1",
102         {0x86d15241, 0x11d0311d, 0xA000A4a3, 0xF64803c9}
103       },
104   {ASF_OBJ_SIMPLE_INDEX, "ASF_OBJ_SIMPLE_INDEX",
105         {0x33000890, 0x11cfe5b1, 0xA000F489, 0xCB4903c9}
106       },
107   {ASF_OBJ_INDEX, "ASF_OBJ_INDEX",
108         {0xd6e229d3, 0x11d135da, 0xa0003490, 0xbe4903c9}
109       },
110   {ASF_OBJ_HEAD1, "ASF_OBJ_HEAD1",
111         {0x5fbf03b5, 0x11cfa92e, 0xC000E38e, 0x6553200c}
112       },
113   {ASF_OBJ_HEAD2, "ASF_OBJ_HEAD2",
114         {0xabd3d211, 0x11cfa9ba, 0xC000E68e, 0x6553200c}
115       },
116   {ASF_OBJ_PADDING, "ASF_OBJ_PADDING",
117         {0x1806D474, 0x4509CADF, 0xAB9ABAA4, 0xE8AA96CB}
118       },
119   {ASF_OBJ_BITRATE_PROPS, "ASF_OBJ_BITRATE_PROPS",
120         {0x7bf875ce, 0x11d1468d, 0x6000828d, 0xb2a2c997}
121       },
122   {ASF_OBJ_EXT_CONTENT_DESC, "ASF_OBJ_EXT_CONTENT_DESC",
123         {0xd2d0a440, 0x11d2e307, 0xa000f097, 0x50a85ec9}
124       },
125   {ASF_OBJ_BITRATE_MUTEX, "ASF_OBJ_BITRATE_MUTEX",
126         {0xd6e229dc, 0x11d135da, 0xa0003490, 0xbe4903c9}
127       },
128   {ASF_OBJ_LANGUAGE_LIST, "ASF_OBJ_LANGUAGE_LIST",
129         {0x7c4346a9, 0x4bfcefe0, 0x3e3929b2, 0x855c41de}
130       },
131   {ASF_OBJ_METADATA_OBJECT, "ASF_OBJ_METADATA_OBJECT",
132         {0xc5f8cbea, 0x48775baf, 0x8caa6784, 0xca4cfa44}
133       },
134   {ASF_OBJ_EXTENDED_STREAM_PROPS, "ASF_OBJ_EXTENDED_STREAM_PROPS",
135         {0x14e6a5cb, 0x4332c672, 0x69a99983, 0x5a5b0652}
136       },
137   {ASF_OBJ_COMPATIBILITY, "ASF_OBJ_COMPATIBILITY",
138         {0x26f18b5d, 0x47ec4584, 0x650e5f9f, 0xc952041f}
139       },
140   {ASF_OBJ_INDEX_PLACEHOLDER, "ASF_OBJ_INDEX_PLACEHOLDER",
141         {0xd9aade20, 0x4f9c7c17, 0x558528bc, 0xa2e298dd}
142       },
143   {ASF_OBJ_INDEX_PARAMETERS, "ASF_OBJ_INDEX_PARAMETERS",
144         {0xd6e229df, 0x11d135da, 0xa0003490, 0xbe4903c9}
145       },
146   {ASF_OBJ_ADVANCED_MUTUAL_EXCLUSION, "ASF_OBJ_ADVANCED_MUTUAL_EXCLUSION",
147         {0xa08649cf, 0x46704775, 0x356e168a, 0xcd667535}
148       },
149   {ASF_OBJ_STREAM_PRIORITIZATION, "ASF_OBJ_STREAM_PRIORITIZATION",
150         {0xd4fed15b, 0x454f88d3, 0x5cedf081, 0x249e9945}
151       },
152   {ASF_OBJ_CONTENT_ENCRYPTION, "ASF_OBJ_CONTENT_ENCRYPTION",
153         {0x2211b3fb, 0x11d2bd23, 0xa000b7b4, 0x6efc55c9}
154       },
155   {ASF_OBJ_EXT_CONTENT_ENCRYPTION, "ASF_OBJ_EXT_CONTENT_ENCRYPTION",
156         {0x298ae614, 0x4c172622, 0xe0da35b9, 0x9c28e97e}
157       },
158   {ASF_OBJ_DIGITAL_SIGNATURE_OBJECT, "ASF_OBJ_DIGITAL_SIGNATURE_OBJECT",
159         {0x2211b3fc, 0x11d2bd23, 0xa000b7b4, 0x6efc55c9}
160       },
161   {ASF_OBJ_SCRIPT_COMMAND, "ASF_OBJ_SCRIPT_COMMAND",
162         {0x1efb1a30, 0x11d00b62, 0xa0009ba3, 0xf64803c9}
163       },
164   {ASF_OBJ_MARKER, "ASF_OBJ_MARKER",
165         {0xf487cd01, 0x11cfa951, 0xc000e68e, 0x6553200c}
166       },
167   /* This guid is definitely used for encryption (mentioned in MS smooth
168    * streaming docs) in new PlayReady (c) (tm) (wtf) system, but I haven't
169    * found a proper name for it.
170    * (Edward Jan 11 2011).*/
171   {ASF_OBJ_UNKNOWN_ENCRYPTION_OBJECT, "ASF_OBJ_UNKNOWN_ENCRYPTION_OBJECT",
172         {0x9a04f079, 0x42869840, 0x5be692ab, 0x955f88e0}
173       },
174   {ASF_OBJ_METADATA_LIBRARY_OBJECT, "ASF_OBJ_METADATA_LIBRARY_OBJECT",
175         {0x44231c94, 0x49d19498, 0x131d41a1, 0x5470454e}
176       },
177   {ASF_OBJ_UNDEFINED, "ASF_OBJ_UNDEFINED",
178         {0, 0, 0, 0}
179       }
180 };
181
182 guint32
183 gst_asf_identify_guid (const ASFGuidHash * guids, ASFGuid * guid)
184 {
185   gint i;
186
187   for (i = 0; guids[i].obj_id != ASF_OBJ_UNDEFINED; ++i) {
188     if (guids[i].guid.v1 == guid->v1 &&
189         guids[i].guid.v2 == guid->v2 &&
190         guids[i].guid.v3 == guid->v3 && guids[i].guid.v4 == guid->v4) {
191       return guids[i].obj_id;
192     }
193   }
194
195   /* The base case if none is found */
196   return ASF_OBJ_UNDEFINED;
197 }
198
199 const gchar *
200 gst_asf_get_guid_nick (const ASFGuidHash * guids, guint32 obj_id)
201 {
202   gint i;
203
204   for (i = 0; guids[i].obj_id != ASF_OBJ_UNDEFINED; ++i) {
205     if (guids[i].obj_id == obj_id) {
206       return guids[i].obj_id_str;
207     }
208   }
209
210   /* The base case if none is found */
211   return "ASF_OBJ_UNDEFINED";
212 }