| 1 |
#include "asffmt.h" |
| 2 |
#include "asf_guids.h" |
| 3 |
#include <string.h> // memcmp |
| 4 |
#include <stdio.h> // sprintf |
| 5 |
|
| 6 |
// Advanced System Format |
| 7 |
// |
| 8 |
// based upon ASF documentation made by Eugene and on M$ Documentation |
| 9 |
// discovered on mplayer list (Bertrand) |
| 10 |
// http://avifile.sourceforge.net/asf-1.0.htm |
| 11 |
// http://www.microsoft.com/windows/windowsmedia/WM7/format/asfspec11300e.asp |
| 12 |
// http://go.microsoft.com/fwlink/?LinkId=31334 |
| 13 |
|
| 14 |
static const struct |
| 15 |
{ |
| 16 |
const char name[32]; // save runtime relocation |
| 17 |
const GUID guid; |
| 18 |
} guids[] = |
| 19 |
{ |
| 20 |
{ "error", |
| 21 |
{ 0x0,} }, |
| 22 |
|
| 23 |
|
| 24 |
// base ASF objects |
| 25 |
{ "header", |
| 26 |
{ 0x75b22630, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, |
| 27 |
|
| 28 |
{ "data", |
| 29 |
{ 0x75b22636, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, |
| 30 |
|
| 31 |
{ "simple index", |
| 32 |
{ 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }} }, |
| 33 |
|
| 34 |
|
| 35 |
// header ASF objects |
| 36 |
{ "file properties", |
| 37 |
{ 0x8cabdca1, 0xa947, 0x11cf, { 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 38 |
|
| 39 |
{ "stream header", |
| 40 |
{ 0xb7dc0791, 0xa9b7, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 41 |
|
| 42 |
{ "stream bitrate properties", /* (http://get.to/sdp) */ |
| 43 |
{ 0x7bf875ce, 0x468d, 0x11d1, { 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 }} }, |
| 44 |
|
| 45 |
{ "content description", |
| 46 |
{ 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, |
| 47 |
|
| 48 |
{ "extended content encryption", |
| 49 |
{ 0x298ae614, 0x2622, 0x4c17, { 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c }} }, |
| 50 |
|
| 51 |
{ "script command", |
| 52 |
{ 0x1efb1a30, 0x0b62, 0x11d0, { 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, |
| 53 |
|
| 54 |
{ "marker", |
| 55 |
{ 0xf487cd01, 0xa951, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 56 |
|
| 57 |
{ "header extension", |
| 58 |
{ 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 59 |
|
| 60 |
{ "bitrate mutual exclusion", |
| 61 |
{ 0xd6e229dc, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, |
| 62 |
|
| 63 |
{ "codec list", |
| 64 |
{ 0x86d15240, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, |
| 65 |
|
| 66 |
{ "extended content description", |
| 67 |
{ 0xd2d0a440, 0xe307, 0x11d2, { 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50 }} }, |
| 68 |
|
| 69 |
{ "error correction", |
| 70 |
{ 0x75b22635, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} }, |
| 71 |
|
| 72 |
{ "padding", |
| 73 |
{ 0x1806d474, 0xcadf, 0x4509, { 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8 }} }, |
| 74 |
|
| 75 |
|
| 76 |
// stream properties object stream type |
| 77 |
{ "audio media", |
| 78 |
{ 0xf8699e40, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} }, |
| 79 |
|
| 80 |
{ "video media", |
| 81 |
{ 0xbc19efc0, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} }, |
| 82 |
|
| 83 |
{ "command media", |
| 84 |
{ 0x59dacfc0, 0x59e6, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, |
| 85 |
|
| 86 |
|
| 87 |
// stream properties object error correction |
| 88 |
{ "no error correction", |
| 89 |
{ 0x20fb5700, 0x5b55, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} }, |
| 90 |
|
| 91 |
{ "audio spread", |
| 92 |
{ 0xbfc3cd50, 0x618f, 0x11cf, { 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20 }} }, |
| 93 |
|
| 94 |
|
| 95 |
// mutual exclusion object exlusion type |
| 96 |
{ "mutex bitrate", |
| 97 |
{ 0xd6e22a01, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, |
| 98 |
|
| 99 |
{ "mutex unknown", |
| 100 |
{ 0xd6e22a02, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, |
| 101 |
|
| 102 |
|
| 103 |
// header extension |
| 104 |
{ "reserved_1", |
| 105 |
{ 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 106 |
|
| 107 |
|
| 108 |
// script command |
| 109 |
{ "reserved script command", |
| 110 |
{ 0x4B1ACBE3, 0x100B, 0x11D0, { 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 }} }, |
| 111 |
|
| 112 |
// marker object |
| 113 |
{ "reserved marker", |
| 114 |
{ 0x4CFEDB20, 0x75F6, 0x11CF, { 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB }} }, |
| 115 |
|
| 116 |
// various |
| 117 |
{ "head2", |
| 118 |
{ 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} }, |
| 119 |
|
| 120 |
{ "audio conceal none", |
| 121 |
{ 0x49f1a440, 0x4ece, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, |
| 122 |
|
| 123 |
{ "codec comment1 header", |
| 124 |
{ 0x86d15241, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} }, |
| 125 |
|
| 126 |
{ "asf 2.0 header", |
| 127 |
{ 0xd6e229d1, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, |
| 128 |
|
| 129 |
}; |
| 130 |
|
| 131 |
int guid_is_guidid(const GUID* u, guidid_t g) |
| 132 |
{ |
| 133 |
return (memcmp(u, &guids[g].guid, sizeof(GUID)) == 0); |
| 134 |
} |
| 135 |
|
| 136 |
guidid_t guid_get_guidid(const GUID* u) |
| 137 |
{ |
| 138 |
unsigned i; |
| 139 |
for (i = GUID_ASF_HEADER; i < GUID_END; i++) |
| 140 |
if (guid_is_guidid(u, (guidid_t) i)) |
| 141 |
return (guidid_t) i; |
| 142 |
return GUID_ERROR; |
| 143 |
} |
| 144 |
|
| 145 |
char* guid_to_string(char* buffer, const GUID* guid) |
| 146 |
{ |
| 147 |
sprintf(buffer, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", |
| 148 |
guid->f1, guid->f2, guid->f3, guid->f4[0], guid->f4[1], |
| 149 |
guid->f4[2], guid->f4[3], guid->f4[4], |
| 150 |
guid->f4[5], guid->f4[6], guid->f4[7]); |
| 151 |
|
| 152 |
return buffer; |
| 153 |
} |
| 154 |
|
| 155 |
const char* guidid_to_text(guidid_t g) |
| 156 |
{ |
| 157 |
return guids[g].name; |
| 158 |
} |