remove useless 'else'
[mplayer/glamo.git] / libmpdemux / asf.h
blob1f89edf7fb8921659a3195c0fa347bd17f8e934c
1 #ifndef MPLAYER_ASF_H
2 #define MPLAYER_ASF_H
4 //#include "config.h" /* for WORDS_BIGENDIAN */
5 #include <inttypes.h>
6 #include "libavutil/common.h"
7 #include "mpbswap.h"
9 ///////////////////////
10 // MS GUID definition
11 ///////////////////////
12 #ifndef GUID_DEFINED
13 #define GUID_DEFINED
14 // Size of GUID is 16 bytes!
15 typedef struct __attribute__((packed)) {
16 uint32_t Data1; // 4 bytes
17 uint16_t Data2; // 2 bytes
18 uint16_t Data3; // 2 bytes
19 uint8_t Data4[8]; // 8 bytes
20 } GUID_t;
21 #endif
23 ///////////////////////
24 // ASF Object Header
25 ///////////////////////
26 typedef struct __attribute__((packed)) {
27 uint8_t guid[16];
28 uint64_t size;
29 } ASF_obj_header_t;
31 ////////////////
32 // ASF Header
33 ////////////////
34 typedef struct __attribute__((packed)) {
35 ASF_obj_header_t objh;
36 uint32_t cno; // number of subchunks
37 uint8_t v1; // unknown (0x01)
38 uint8_t v2; // unknown (0x02)
39 } ASF_header_t;
41 /////////////////////
42 // ASF File Header
43 /////////////////////
44 typedef struct __attribute__((packed)) {
45 uint8_t stream_id[16]; // stream GUID
46 uint64_t file_size;
47 uint64_t creation_time; //File creation time FILETIME 8
48 uint64_t num_packets; //Number of packets UINT64 8
49 uint64_t play_duration; //Timestamp of the end position UINT64 8
50 uint64_t send_duration; //Duration of the playback UINT64 8
51 uint64_t preroll; //Time to bufferize before playing UINT32 4
52 uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
53 uint32_t min_packet_size; //Min size of the packet, in bytes UINT32 4
54 uint32_t max_packet_size; //Max size of the packet UINT32 4
55 uint32_t max_bitrate; //Maximum bitrate of the media (sum of all the stream)
56 } ASF_file_header_t;
58 ///////////////////////
59 // ASF Stream Header
60 ///////////////////////
61 typedef struct __attribute__((packed)) {
62 uint8_t type[16]; // Stream type (audio/video) GUID 16
63 uint8_t concealment[16]; // Audio error concealment type GUID 16
64 uint64_t unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
65 uint32_t type_size; //Total size of type-specific data UINT32 4
66 uint32_t stream_size; //Size of stream-specific data UINT32 4
67 uint16_t stream_no; //Stream number UINT16 2
68 uint32_t unk2; //Unknown UINT32 4
69 } ASF_stream_header_t;
71 ///////////////////////////
72 // ASF Content Description
73 ///////////////////////////
74 typedef struct __attribute__((packed)) {
75 uint16_t title_size;
76 uint16_t author_size;
77 uint16_t copyright_size;
78 uint16_t comment_size;
79 uint16_t rating_size;
80 } ASF_content_description_t;
82 ////////////////////////
83 // ASF Segment Header
84 ////////////////////////
85 typedef struct __attribute__((packed)) {
86 uint8_t streamno;
87 uint8_t seq;
88 uint32_t x;
89 uint8_t flag;
90 } ASF_segmhdr_t;
92 //////////////////////
93 // ASF Stream Chunck
94 //////////////////////
95 typedef struct __attribute__((packed)) {
96 uint16_t type;
97 uint16_t size;
98 uint32_t sequence_number;
99 uint16_t unknown;
100 uint16_t size_confirm;
101 } ASF_stream_chunck_t;
103 // Definition of the stream type
104 #ifdef WORDS_BIGENDIAN
105 #define ASF_STREAMING_CLEAR 0x2443 // $C
106 #define ASF_STREAMING_DATA 0x2444 // $D
107 #define ASF_STREAMING_END_TRANS 0x2445 // $E
108 #define ASF_STREAMING_HEADER 0x2448 // $H
109 #else
110 #define ASF_STREAMING_CLEAR 0x4324 // $C
111 #define ASF_STREAMING_DATA 0x4424 // $D
112 #define ASF_STREAMING_END_TRANS 0x4524 // $E
113 #define ASF_STREAMING_HEADER 0x4824 // $H
114 #endif
116 // Definition of the differents type of ASF streaming
117 typedef enum {
118 ASF_Unknown_e,
119 ASF_Live_e,
120 ASF_Prerecorded_e,
121 ASF_Redirector_e,
122 ASF_PlainText_e,
123 ASF_Authenticate_e
124 } ASF_StreamType_e;
126 typedef struct {
127 ASF_StreamType_e streaming_type;
128 int request;
129 int packet_size;
130 int *audio_streams,n_audio,*video_streams,n_video;
131 int audio_id, video_id;
132 } asf_http_streaming_ctrl_t;
136 * Some macros to swap little endian structures read from an ASF file
137 * into machine endian format
139 #ifdef WORDS_BIGENDIAN
140 #define le2me_ASF_obj_header_t(h) { \
141 (h)->size = le2me_64((h)->size); \
143 #define le2me_ASF_header_t(h) { \
144 le2me_ASF_obj_header_t(&(h)->objh); \
145 (h)->cno = le2me_32((h)->cno); \
147 #define le2me_ASF_stream_header_t(h) { \
148 (h)->unk1 = le2me_64((h)->unk1); \
149 (h)->type_size = le2me_32((h)->type_size); \
150 (h)->stream_size = le2me_32((h)->stream_size); \
151 (h)->stream_no = le2me_16((h)->stream_no); \
152 (h)->unk2 = le2me_32((h)->unk2); \
154 #define le2me_ASF_file_header_t(h) { \
155 (h)->file_size = le2me_64((h)->file_size); \
156 (h)->creation_time = le2me_64((h)->creation_time); \
157 (h)->num_packets = le2me_64((h)->num_packets); \
158 (h)->play_duration = le2me_64((h)->play_duration); \
159 (h)->send_duration = le2me_64((h)->send_duration); \
160 (h)->preroll = le2me_64((h)->preroll); \
161 (h)->flags = le2me_32((h)->flags); \
162 (h)->min_packet_size = le2me_32((h)->min_packet_size); \
163 (h)->max_packet_size = le2me_32((h)->max_packet_size); \
164 (h)->max_bitrate = le2me_32((h)->max_bitrate); \
166 #define le2me_ASF_content_description_t(h) { \
167 (h)->title_size = le2me_16((h)->title_size); \
168 (h)->author_size = le2me_16((h)->author_size); \
169 (h)->copyright_size = le2me_16((h)->copyright_size); \
170 (h)->comment_size = le2me_16((h)->comment_size); \
171 (h)->rating_size = le2me_16((h)->rating_size); \
173 #define le2me_BITMAPINFOHEADER(h) { \
174 (h)->biSize = le2me_32((h)->biSize); \
175 (h)->biWidth = le2me_32((h)->biWidth); \
176 (h)->biHeight = le2me_32((h)->biHeight); \
177 (h)->biPlanes = le2me_16((h)->biPlanes); \
178 (h)->biBitCount = le2me_16((h)->biBitCount); \
179 (h)->biCompression = le2me_32((h)->biCompression); \
180 (h)->biSizeImage = le2me_32((h)->biSizeImage); \
181 (h)->biXPelsPerMeter = le2me_32((h)->biXPelsPerMeter); \
182 (h)->biYPelsPerMeter = le2me_32((h)->biYPelsPerMeter); \
183 (h)->biClrUsed = le2me_32((h)->biClrUsed); \
184 (h)->biClrImportant = le2me_32((h)->biClrImportant); \
186 #define le2me_WAVEFORMATEX(h) { \
187 (h)->wFormatTag = le2me_16((h)->wFormatTag); \
188 (h)->nChannels = le2me_16((h)->nChannels); \
189 (h)->nSamplesPerSec = le2me_32((h)->nSamplesPerSec); \
190 (h)->nAvgBytesPerSec = le2me_32((h)->nAvgBytesPerSec); \
191 (h)->nBlockAlign = le2me_16((h)->nBlockAlign); \
192 (h)->wBitsPerSample = le2me_16((h)->wBitsPerSample); \
193 (h)->cbSize = le2me_16((h)->cbSize); \
195 #define le2me_ASF_stream_chunck_t(h) { \
196 (h)->size = le2me_16((h)->size); \
197 (h)->sequence_number = le2me_32((h)->sequence_number); \
198 (h)->unknown = le2me_16((h)->unknown); \
199 (h)->size_confirm = le2me_16((h)->size_confirm); \
201 #else
202 #define le2me_ASF_obj_header_t(h) /**/
203 #define le2me_ASF_header_t(h) /**/
204 #define le2me_ASF_stream_header_t(h) /**/
205 #define le2me_ASF_file_header_t(h) /**/
206 #define le2me_ASF_content_description_t(h) /**/
207 #define le2me_BITMAPINFOHEADER(h) /**/
208 #define le2me_WAVEFORMATEX(h) /**/
209 #define le2me_ASF_stream_chunck_t(h) /**/
210 #endif
212 // priv struct for the demuxer
213 struct asf_priv {
214 ASF_header_t header;
215 unsigned char* packet;
216 int scrambling_h;
217 int scrambling_w;
218 int scrambling_b;
219 unsigned packetsize;
220 double packetrate;
221 unsigned movielength;
222 int asf_is_dvr_ms;
223 uint32_t asf_frame_state;
224 int asf_frame_start_found;
225 double dvr_last_vid_pts;
226 uint64_t vid_frame_ct;
227 uint64_t play_duration;
228 uint64_t num_packets;
229 int new_vid_frame_seg;
230 int *vid_repdata_sizes;
231 int *aud_repdata_sizes;
232 int vid_repdata_count;
233 int aud_repdata_count;
234 uint64_t avg_vid_frame_time;
235 uint64_t last_key_payload_time;
236 uint64_t last_aud_pts;
237 uint64_t last_aud_diff;
238 int found_first_key_frame;
239 uint32_t last_vid_seq;
240 int vid_ext_timing_index;
241 int aud_ext_timing_index;
242 int vid_ext_frame_index;
243 int know_frame_time;
244 unsigned bps;
247 #endif /* MPLAYER_ASF_H */