source: titan/minidlna-1.0.22/tagutils/tagutils-asf.h @ 13567

Last change on this file since 13567 was 13567, checked in by obi, 11 years ago

[titan] add minidlna-1.0.22 first step

File size: 9.7 KB
Line 
1//=========================================================================
2// FILENAME     : tagutils-asf.h
3// DESCRIPTION  : ASF (wma/wmv) metadata reader
4//=========================================================================
5// Copyright (c) 2008- NETGEAR, Inc. All Rights Reserved.
6//=========================================================================
7
8/*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23
24#define __PACKED__  __attribute__((packed))
25
26#include <endian.h>
27
28typedef struct _GUID {
29        __u32 l;
30        __u16 w[2];
31        __u8 b[8];
32} __PACKED__ GUID;
33
34#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
35        GUID name = { l, { w1, w2 }, { b1, b2, b3, b4, b5, b6, b7, b8 } }
36#define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
37
38#if __BYTE_ORDER == __LITTLE_ENDIAN
39#define SWAP32(l) (l)
40#define SWAP16(w) (w)
41#else
42#define SWAP32(l) ( (((l) >> 24) & 0x000000ff) | (((l) >> 8) & 0x0000ff00) | (((l) << 8) & 0x00ff0000) | (((l) << 24) & 0xff000000) )
43#define SWAP16(w) ( (((w) >> 8) & 0x00ff) | (((w) << 8) & 0xff00) )
44#endif
45
46DEFINE_GUID(ASF_StreamHeader, SWAP32(0xb7dc0791), SWAP16(0xa9b7), SWAP16(0x11cf),
47            0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65);
48
49DEFINE_GUID(ASF_VideoStream, SWAP32(0xbc19efc0), SWAP16(0x5b4d), SWAP16(0x11cf),
50            0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b);
51
52DEFINE_GUID(ASF_AudioStream, SWAP32(0xf8699e40), SWAP16(0x5b4d), SWAP16(0x11cf),
53            0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b);
54
55DEFINE_GUID(ASF_HeaderObject, SWAP32(0x75b22630), SWAP16(0x668e), SWAP16(0x11cf),
56            0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c);
57
58DEFINE_GUID(ASF_FileProperties, SWAP32(0x8cabdca1), SWAP16(0xa947), SWAP16(0x11cf),
59            0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65);
60
61DEFINE_GUID(ASF_ContentDescription, SWAP32(0x75b22633), SWAP16(0x668e), SWAP16(0x11cf),
62            0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c);
63
64DEFINE_GUID(ASF_ExtendedContentDescription, SWAP32(0xd2d0a440), SWAP16(0xe307), SWAP16(0x11d2),
65            0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50);
66
67DEFINE_GUID(ASF_ClientGuid, SWAP32(0x8d262e32), SWAP16(0xfc28), SWAP16(0x11d7),
68            0xa9, 0xea, 0x00, 0x04, 0x5a, 0x6b, 0x76, 0xc2);
69
70DEFINE_GUID(ASF_HeaderExtension, SWAP32(0x5fbf03b5), SWAP16(0xa92e), SWAP16(0x11cf),
71            0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65);
72
73DEFINE_GUID(ASF_CodecList, SWAP32(0x86d15240), SWAP16(0x311d), SWAP16(0x11d0),
74            0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6);
75
76DEFINE_GUID(ASF_DataObject, SWAP32(0x75b22636), SWAP16(0x668e), SWAP16(0x11cf),
77            0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c);
78
79DEFINE_GUID(ASF_PaddingObject, SWAP32(0x1806d474), SWAP16(0xcadf), SWAP16(0x4509),
80            0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8);
81
82DEFINE_GUID(ASF_SimpleIndexObject, SWAP32(0x33000890), SWAP16(0xe5b1), SWAP16(0x11cf),
83            0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb);
84
85DEFINE_GUID(ASF_NoErrorCorrection, SWAP32(0x20fb5700), SWAP16(0x5b55), SWAP16(0x11cf),
86            0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b);
87
88DEFINE_GUID(ASF_AudioSpread, SWAP32(0xbfc3cd50), SWAP16(0x618f), SWAP16(0x11cf),
89            0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20);
90
91DEFINE_GUID(ASF_Reserved1, SWAP32(0xabd3d211), SWAP16(0xa9ba), SWAP16(0x11cf),
92            0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65);
93
94DEFINE_GUID(ASF_Reserved2, SWAP32(0x86d15241), SWAP16(0x311d), SWAP16(0x11d0),
95            0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6);
96
97DEFINE_GUID(ASF_ContentEncryptionObject, SWAP32(0x2211B3FB), SWAP16(0xBD23), SWAP16(0x11D2),
98            0xB4, 0xB7, 0x00, 0xA0, 0xC9, 0x55, 0xFC, 0x6E);
99
100DEFINE_GUID(ASF_ExtendedContentEncryptionObject, SWAP32(0x298AE614), SWAP16(0x2622), SWAP16(0x4C17),
101            0xB9, 0x35, 0xDA, 0xE0, 0x7E, 0xE9, 0x28, 0x9C);
102
103DEFINE_GUID(ASF_ExtendedStreamPropertiesObject, SWAP32(0x14E6A5CB), SWAP16(0xC672), SWAP16(0x4332),
104            0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A);
105
106DEFINE_GUID(ASF_MediaTypeAudio, SWAP32(0x31178C9D), SWAP16(0x03E1), SWAP16(0x4528),
107            0xB5, 0x82, 0x3D, 0xF9, 0xDB, 0x22, 0xF5, 0x03);
108
109DEFINE_GUID(ASF_FormatTypeWave, SWAP32(0xC4C4C4D1), SWAP16(0x0049), SWAP16(0x4E2B),
110            0x98, 0xFB, 0x95, 0x37, 0xF6, 0xCE, 0x51, 0x6D);
111
112DEFINE_GUID(ASF_StreamBufferStream, SWAP32(0x3AFB65E2), SWAP16(0x47EF), SWAP16(0x40F2),
113            0xAC, 0x2C, 0x70, 0xA9, 0x0D, 0x71, 0xD3, 0x43);
114
115typedef struct _BITMAPINFOHEADER {
116        __u32 biSize;
117        __s32 biWidth;
118        __s32 biHeight;
119        __u16 biPlanes;
120        __u16 biBitCount;
121        __u32 biCompression;
122        __u32 biSizeImage;
123        __s32 biXPelsPerMeter;
124        __s32 biYPelsPerMeter;
125        __u32 biClrUsed;
126        __u32 biClrImportant;
127} __PACKED__ BITMAPINFOHEADER;
128
129typedef struct _WAVEFORMATEX {
130        __u16 wFormatTag;
131        __u16 nChannels;
132        __u32 nSamplesPerSec;
133        __u32 nAvgBytesPerSec;
134        __u16 nBlockAlign;
135        __u16 wBitsPerSample;
136        __u16 cbSize;
137} __PACKED__ WAVEFORMATEX;
138
139typedef struct _asf_stream_object_t {
140        GUID ID;
141        __u64 Size;
142        GUID StreamType;
143        GUID ErrorCorrectionType;
144        __u64 TimeOffset;
145        __u32 TypeSpecificSize;
146        __u32 ErrorCorrectionSize;
147        __u16 StreamNumber;
148        __u32 Reserved;
149} __PACKED__ asf_stream_object_t;
150
151typedef struct _asf_media_stream_t {
152        asf_stream_object_t Hdr;
153        GUID MajorType;
154        GUID SubType;
155        __u32 FixedSizeSamples;
156        __u32 TemporalCompression;
157        __u32 SampleSize;
158        GUID FormatType;
159        __u32 FormatSize;
160} __PACKED__ asf_media_stream_t;
161
162typedef struct _avi_audio_format_t {
163        __u16 wFormatTag;
164        __u16 nChannels;
165        __u32 nSamplesPerSec;
166        __u32 nAvgBytesPerSec;
167        __u16 nBlockAlign;
168        __u16 wBitsPerSample;
169        __u16 cbSize;
170} __PACKED__ avi_audio_format_t;
171
172typedef struct _asf_extended_stream_object_t {
173        GUID ID;
174        __u64 Size;
175        __u64 StartTime;
176        __u64 EndTime;
177        __u32 DataBitrate;
178        __u32 BufferSize;
179        __u32 InitialBufferFullness;
180        __u32 AltDataBitrate;
181        __u32 AltBufferSize;
182        __u32 AltInitialBufferFullness;
183        __u32 MaximumObjectSize;
184        __u32 Flags;
185        __u16 StreamNumber;
186        __u16 LanguageIDIndex;
187        __u64 AvgTimePerFrame;
188        __u16 StreamNameCount;
189        __u16 PayloadExtensionSystemCount;
190} __PACKED__ asf_extended_stream_object_t;
191
192typedef struct _asf_stream_name_t {
193        __u16 ID;
194        __u16 Length;
195} __PACKED__ asf_stream_name_t;
196
197typedef struct _asf_payload_extension_t {
198        GUID ID;
199        __u16 Size;
200        __u32 InfoLength;
201} __PACKED__ asf_payload_extension_t;
202
203
204
205typedef struct _asf_object_t {
206        GUID ID;
207        __u64 Size;
208} __PACKED__ asf_object_t;
209
210typedef struct _asf_codec_entry_t {
211        __u16 Type;
212        __u16 NameLen;
213        __u32 Name;
214        __u16 DescLen;
215        __u32 Desc;
216        __u16 InfoLen;
217        __u32 Info;
218} __PACKED__ asf_codec_entry_t;
219
220typedef struct _asf_codec_list_t {
221        GUID ID;
222        __u64 Size;
223        GUID Reserved;
224        __u64 NumEntries;
225        asf_codec_entry_t Entries[2];
226        asf_codec_entry_t VideoCodec;
227} __PACKED__ asf_codec_list_t;
228
229typedef struct _asf_content_description_t {
230        GUID ID;
231        __u64 Size;
232        __u16 TitleLength;
233        __u16 AuthorLength;
234        __u16 CopyrightLength;
235        __u16 DescriptionLength;
236        __u16 RatingLength;
237        __u32 Title;
238        __u32 Author;
239        __u32 Copyright;
240        __u32 Description;
241        __u32 Rating;
242} __PACKED__ asf_content_description_t;
243
244typedef struct _asf_file_properties_t {
245        GUID ID;
246        __u64 Size;
247        GUID FileID;
248        __u64 FileSize;
249        __u64 CreationTime;
250        __u64 TotalPackets;
251        __u64 PlayDuration;
252        __u64 SendDuration;
253        __u64 Preroll;
254        __u32 Flags;
255        __u32 MinPacketSize;
256        __u32 MaxPacketSize;
257        __u32 MaxBitrate;
258} __PACKED__ asf_file_properties_t;
259
260typedef struct _asf_header_extension_t {
261        GUID ID;
262        __u64 Size;
263        GUID Reserved1;
264        __u16 Reserved2;
265        __u32 DataSize;
266} __PACKED__ asf_header_extension_t;
267
268typedef struct _asf_video_stream_t {
269        asf_stream_object_t Hdr;
270        __u32 Width;
271        __u32 Height;
272        __u8 ReservedFlags;
273        __u16 FormatSize;
274        BITMAPINFOHEADER bmi;
275        __u8 ebih[1];
276} __PACKED__ asf_video_stream_t;
277
278typedef struct _asf_audio_stream_t {
279        asf_stream_object_t Hdr;
280        WAVEFORMATEX wfx;
281} __PACKED__ asf_audio_stream_t;
282
283typedef struct _asf_payload_t {
284        __u8 StreamNumber;
285        __u8 MediaObjectNumber;
286        __u32 MediaObjectOffset;
287        __u8 ReplicatedDataLength;
288        __u32 ReplicatedData[2];
289        __u32 PayloadLength;
290} __PACKED__ asf_payload_t;
291
292typedef struct _asf_packet_t {
293        __u8 TypeFlags;
294        __u8 ECFlags;
295        __u8 ECType;
296        __u8 ECCycle;
297        __u8 PropertyFlags;
298        __u32 PacketLength;
299        __u32 Sequence;
300        __u32 PaddingLength;
301        __u32 SendTime;
302        __u16 Duration;
303        __u8 PayloadFlags;
304        asf_payload_t Payload;
305} __PACKED__ asf_packet_t;
306
307typedef struct _asf_data_object_t {
308        GUID ID;
309        __u64 Size;
310        GUID FileID;
311        __u64 TotalPackets;
312        unsigned short Reserved;
313} __PACKED__ asf_data_object_t;
314
315typedef struct _asf_padding_object_t {
316        GUID ID;
317        __u64 Size;
318} __PACKED__ asf_padding_object_t;
319
320typedef struct _asf_simple_index_object_t {
321        GUID ID;
322        __u64 Size;
323        GUID FileID;
324        __u32 IndexEntryTimeInterval;
325        __u32 MaximumPacketCount;
326        __u32 IndexEntriesCount;
327} __PACKED__ asf_simple_index_object_t;
328
329typedef struct _asf_header_object_t {
330        GUID ID;
331        __u64 Size;
332        __u32 NumObjects;
333        __u16 Reserved;
334        asf_header_extension_t HeaderExtension;
335        asf_content_description_t ContentDescription;
336        asf_file_properties_t FileProperties;
337        asf_video_stream_t *        VideoStream;
338        asf_audio_stream_t *        AudioStream;
339        asf_codec_list_t CodecList;
340        asf_padding_object_t PaddingObject;
341} __PACKED__ asf_header_object_t;
342
343
344#define ASF_VT_UNICODE          (0)
345#define ASF_VT_BYTEARRAY        (1)
346#define ASF_VT_BOOL             (2)
347#define ASF_VT_DWORD            (3)
348#define ASF_VT_QWORD            (4)
349#define ASF_VT_WORD             (5)
350
351static int _get_asffileinfo(char *file, struct song_metadata *psong);
Note: See TracBrowser for help on using the repository browser.