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