4
//#include "config.h" /* for WORDS_BIGENDIAN */
9
#define MIN(a,b) (((a)<(b))?(a):(b))
12
///////////////////////
14
///////////////////////
17
// Size of GUID is 16 bytes!
18
typedef struct __attribute__((packed)) {
19
uint32_t Data1; // 4 bytes
20
uint16_t Data2; // 2 bytes
21
uint16_t Data3; // 2 bytes
22
uint8_t Data4[8]; // 8 bytes
26
///////////////////////
28
///////////////////////
29
typedef struct __attribute__((packed)) {
37
typedef struct __attribute__((packed)) {
38
ASF_obj_header_t objh;
39
uint32_t cno; // number of subchunks
40
uint8_t v1; // unknown (0x01)
41
uint8_t v2; // unknown (0x02)
47
typedef struct __attribute__((packed)) {
48
uint8_t stream_id[16]; // stream GUID
50
uint64_t creation_time; //File creation time FILETIME 8
51
uint64_t num_packets; //Number of packets UINT64 8
52
uint64_t play_duration; //Timestamp of the end position UINT64 8
53
uint64_t send_duration; //Duration of the playback UINT64 8
54
uint64_t preroll; //Time to bufferize before playing UINT32 4
55
uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
56
uint32_t min_packet_size; //Min size of the packet, in bytes UINT32 4
57
uint32_t max_packet_size; //Max size of the packet UINT32 4
58
uint32_t max_bitrate; //Maximum bitrate of the media (sum of all the stream)
61
///////////////////////
63
///////////////////////
64
typedef struct __attribute__((packed)) {
65
uint8_t type[16]; // Stream type (audio/video) GUID 16
66
uint8_t concealment[16]; // Audio error concealment type GUID 16
67
uint64_t unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
68
uint32_t type_size; //Total size of type-specific data UINT32 4
69
uint32_t stream_size; //Size of stream-specific data UINT32 4
70
uint16_t stream_no; //Stream number UINT16 2
71
uint32_t unk2; //Unknown UINT32 4
72
} ASF_stream_header_t;
74
///////////////////////////
75
// ASF Content Description
76
///////////////////////////
77
typedef struct __attribute__((packed)) {
80
uint16_t copyright_size;
81
uint16_t comment_size;
83
} ASF_content_description_t;
85
////////////////////////
87
////////////////////////
88
typedef struct __attribute__((packed)) {
95
//////////////////////
97
//////////////////////
98
typedef struct __attribute__((packed)) {
101
uint32_t sequence_number;
103
uint16_t size_confirm;
104
} ASF_stream_chunck_t;
106
// Definition of the stream type
107
#ifdef WORDS_BIGENDIAN
108
#define ASF_STREAMING_CLEAR 0x2443 // $C
109
#define ASF_STREAMING_DATA 0x2444 // $D
110
#define ASF_STREAMING_END_TRANS 0x2445 // $E
111
#define ASF_STREAMING_HEADER 0x2448 // $H
113
#define ASF_STREAMING_CLEAR 0x4324 // $C
114
#define ASF_STREAMING_DATA 0x4424 // $D
115
#define ASF_STREAMING_END_TRANS 0x4524 // $E
116
#define ASF_STREAMING_HEADER 0x4824 // $H
119
// Definition of the differents type of ASF streaming
130
ASF_StreamType_e streaming_type;
133
int *audio_streams,n_audio,*video_streams,n_video;
134
int audio_id, video_id;
135
} asf_http_streaming_ctrl_t;
139
* Some macros to swap little endian structures read from an ASF file
140
* into machine endian format
142
#ifdef WORDS_BIGENDIAN
143
#define le2me_ASF_obj_header_t(h) { \
144
(h)->size = le2me_64((h)->size); \
146
#define le2me_ASF_header_t(h) { \
147
le2me_ASF_obj_header_t(&(h)->objh); \
148
(h)->cno = le2me_32((h)->cno); \
150
#define le2me_ASF_stream_header_t(h) { \
151
(h)->unk1 = le2me_64((h)->unk1); \
152
(h)->type_size = le2me_32((h)->type_size); \
153
(h)->stream_size = le2me_32((h)->stream_size); \
154
(h)->stream_no = le2me_16((h)->stream_no); \
155
(h)->unk2 = le2me_32((h)->unk2); \
157
#define le2me_ASF_file_header_t(h) { \
158
(h)->file_size = le2me_64((h)->file_size); \
159
(h)->creation_time = le2me_64((h)->creation_time); \
160
(h)->num_packets = le2me_64((h)->num_packets); \
161
(h)->play_duration = le2me_64((h)->play_duration); \
162
(h)->send_duration = le2me_64((h)->send_duration); \
163
(h)->preroll = le2me_64((h)->preroll); \
164
(h)->flags = le2me_32((h)->flags); \
165
(h)->min_packet_size = le2me_32((h)->min_packet_size); \
166
(h)->max_packet_size = le2me_32((h)->max_packet_size); \
167
(h)->max_bitrate = le2me_32((h)->max_bitrate); \
169
#define le2me_ASF_content_description_t(h) { \
170
(h)->title_size = le2me_16((h)->title_size); \
171
(h)->author_size = le2me_16((h)->author_size); \
172
(h)->copyright_size = le2me_16((h)->copyright_size); \
173
(h)->comment_size = le2me_16((h)->comment_size); \
174
(h)->rating_size = le2me_16((h)->rating_size); \
176
#define le2me_BITMAPINFOHEADER(h) { \
177
(h)->biSize = le2me_32((h)->biSize); \
178
(h)->biWidth = le2me_32((h)->biWidth); \
179
(h)->biHeight = le2me_32((h)->biHeight); \
180
(h)->biPlanes = le2me_16((h)->biPlanes); \
181
(h)->biBitCount = le2me_16((h)->biBitCount); \
182
(h)->biCompression = le2me_32((h)->biCompression); \
183
(h)->biSizeImage = le2me_32((h)->biSizeImage); \
184
(h)->biXPelsPerMeter = le2me_32((h)->biXPelsPerMeter); \
185
(h)->biYPelsPerMeter = le2me_32((h)->biYPelsPerMeter); \
186
(h)->biClrUsed = le2me_32((h)->biClrUsed); \
187
(h)->biClrImportant = le2me_32((h)->biClrImportant); \
189
#define le2me_WAVEFORMATEX(h) { \
190
(h)->wFormatTag = le2me_16((h)->wFormatTag); \
191
(h)->nChannels = le2me_16((h)->nChannels); \
192
(h)->nSamplesPerSec = le2me_32((h)->nSamplesPerSec); \
193
(h)->nAvgBytesPerSec = le2me_32((h)->nAvgBytesPerSec); \
194
(h)->nBlockAlign = le2me_16((h)->nBlockAlign); \
195
(h)->wBitsPerSample = le2me_16((h)->wBitsPerSample); \
196
(h)->cbSize = le2me_16((h)->cbSize); \
198
#define le2me_ASF_stream_chunck_t(h) { \
199
(h)->size = le2me_16((h)->size); \
200
(h)->sequence_number = le2me_32((h)->sequence_number); \
201
(h)->unknown = le2me_16((h)->unknown); \
202
(h)->size_confirm = le2me_16((h)->size_confirm); \
205
#define le2me_ASF_obj_header_t(h) /**/
206
#define le2me_ASF_header_t(h) /**/
207
#define le2me_ASF_stream_header_t(h) /**/
208
#define le2me_ASF_file_header_t(h) /**/
209
#define le2me_ASF_content_description_t(h) /**/
210
#define le2me_BITMAPINFOHEADER(h) /**/
211
#define le2me_WAVEFORMATEX(h) /**/
212
#define le2me_ASF_stream_chunck_t(h) /**/