2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 //#include "config.h" /* for HAVE_BIGENDIAN */
24 #include "libavutil/common.h"
27 ///////////////////////
29 ///////////////////////
30 typedef struct __attribute__((packed
)) {
38 typedef struct __attribute__((packed
)) {
39 ASF_obj_header_t objh
;
40 uint32_t cno
; // number of subchunks
41 uint8_t v1
; // unknown (0x01)
42 uint8_t v2
; // unknown (0x02)
48 typedef struct __attribute__((packed
)) {
49 uint8_t stream_id
[16]; // stream GUID
51 uint64_t creation_time
; //File creation time FILETIME 8
52 uint64_t num_packets
; //Number of packets UINT64 8
53 uint64_t play_duration
; //Timestamp of the end position UINT64 8
54 uint64_t send_duration
; //Duration of the playback UINT64 8
55 uint64_t preroll
; //Time to bufferize before playing UINT32 4
56 uint32_t flags
; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
57 uint32_t min_packet_size
; //Min size of the packet, in bytes UINT32 4
58 uint32_t max_packet_size
; //Max size of the packet UINT32 4
59 uint32_t max_bitrate
; //Maximum bitrate of the media (sum of all the stream)
62 ///////////////////////
64 ///////////////////////
65 typedef struct __attribute__((packed
)) {
66 uint8_t type
[16]; // Stream type (audio/video) GUID 16
67 uint8_t concealment
[16]; // Audio error concealment type GUID 16
68 uint64_t unk1
; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
69 uint32_t type_size
; //Total size of type-specific data UINT32 4
70 uint32_t stream_size
; //Size of stream-specific data UINT32 4
71 uint16_t stream_no
; //Stream number UINT16 2
72 uint32_t unk2
; //Unknown UINT32 4
73 } ASF_stream_header_t
;
75 ///////////////////////////
76 // ASF Content Description
77 ///////////////////////////
78 typedef struct __attribute__((packed
)) {
81 uint16_t copyright_size
;
82 uint16_t comment_size
;
84 } ASF_content_description_t
;
86 ////////////////////////
88 ////////////////////////
89 typedef struct __attribute__((packed
)) {
96 //////////////////////
98 //////////////////////
99 typedef struct __attribute__((packed
)) {
102 uint32_t sequence_number
;
104 uint16_t size_confirm
;
105 } ASF_stream_chunck_t
;
107 // Definition of the stream type
109 #define ASF_STREAMING_CLEAR 0x2443 // $C
110 #define ASF_STREAMING_DATA 0x2444 // $D
111 #define ASF_STREAMING_END_TRANS 0x2445 // $E
112 #define ASF_STREAMING_HEADER 0x2448 // $H
114 #define ASF_STREAMING_CLEAR 0x4324 // $C
115 #define ASF_STREAMING_DATA 0x4424 // $D
116 #define ASF_STREAMING_END_TRANS 0x4524 // $E
117 #define ASF_STREAMING_HEADER 0x4824 // $H
120 // Definition of the differents type of ASF streaming
131 ASF_StreamType_e streaming_type
;
134 int *audio_streams
,n_audio
,*video_streams
,n_video
;
135 int audio_id
, video_id
;
136 } asf_http_streaming_ctrl_t
;
140 * Some macros to swap little endian structures read from an ASF file
141 * into machine endian format
144 #define le2me_ASF_obj_header_t(h) { \
145 (h)->size = le2me_64((h)->size); \
147 #define le2me_ASF_header_t(h) { \
148 le2me_ASF_obj_header_t(&(h)->objh); \
149 (h)->cno = le2me_32((h)->cno); \
151 #define le2me_ASF_stream_header_t(h) { \
152 (h)->unk1 = le2me_64((h)->unk1); \
153 (h)->type_size = le2me_32((h)->type_size); \
154 (h)->stream_size = le2me_32((h)->stream_size); \
155 (h)->stream_no = le2me_16((h)->stream_no); \
156 (h)->unk2 = le2me_32((h)->unk2); \
158 #define le2me_ASF_file_header_t(h) { \
159 (h)->file_size = le2me_64((h)->file_size); \
160 (h)->creation_time = le2me_64((h)->creation_time); \
161 (h)->num_packets = le2me_64((h)->num_packets); \
162 (h)->play_duration = le2me_64((h)->play_duration); \
163 (h)->send_duration = le2me_64((h)->send_duration); \
164 (h)->preroll = le2me_64((h)->preroll); \
165 (h)->flags = le2me_32((h)->flags); \
166 (h)->min_packet_size = le2me_32((h)->min_packet_size); \
167 (h)->max_packet_size = le2me_32((h)->max_packet_size); \
168 (h)->max_bitrate = le2me_32((h)->max_bitrate); \
170 #define le2me_ASF_content_description_t(h) { \
171 (h)->title_size = le2me_16((h)->title_size); \
172 (h)->author_size = le2me_16((h)->author_size); \
173 (h)->copyright_size = le2me_16((h)->copyright_size); \
174 (h)->comment_size = le2me_16((h)->comment_size); \
175 (h)->rating_size = le2me_16((h)->rating_size); \
177 #define le2me_BITMAPINFOHEADER(h) { \
178 (h)->biSize = le2me_32((h)->biSize); \
179 (h)->biWidth = le2me_32((h)->biWidth); \
180 (h)->biHeight = le2me_32((h)->biHeight); \
181 (h)->biPlanes = le2me_16((h)->biPlanes); \
182 (h)->biBitCount = le2me_16((h)->biBitCount); \
183 (h)->biCompression = le2me_32((h)->biCompression); \
184 (h)->biSizeImage = le2me_32((h)->biSizeImage); \
185 (h)->biXPelsPerMeter = le2me_32((h)->biXPelsPerMeter); \
186 (h)->biYPelsPerMeter = le2me_32((h)->biYPelsPerMeter); \
187 (h)->biClrUsed = le2me_32((h)->biClrUsed); \
188 (h)->biClrImportant = le2me_32((h)->biClrImportant); \
190 #define le2me_WAVEFORMATEX(h) { \
191 (h)->wFormatTag = le2me_16((h)->wFormatTag); \
192 (h)->nChannels = le2me_16((h)->nChannels); \
193 (h)->nSamplesPerSec = le2me_32((h)->nSamplesPerSec); \
194 (h)->nAvgBytesPerSec = le2me_32((h)->nAvgBytesPerSec); \
195 (h)->nBlockAlign = le2me_16((h)->nBlockAlign); \
196 (h)->wBitsPerSample = le2me_16((h)->wBitsPerSample); \
197 (h)->cbSize = le2me_16((h)->cbSize); \
199 #define le2me_ASF_stream_chunck_t(h) { \
200 (h)->size = le2me_16((h)->size); \
201 (h)->sequence_number = le2me_32((h)->sequence_number); \
202 (h)->unknown = le2me_16((h)->unknown); \
203 (h)->size_confirm = le2me_16((h)->size_confirm); \
206 #define le2me_ASF_obj_header_t(h) /**/
207 #define le2me_ASF_header_t(h) /**/
208 #define le2me_ASF_stream_header_t(h) /**/
209 #define le2me_ASF_file_header_t(h) /**/
210 #define le2me_ASF_content_description_t(h) /**/
211 #define le2me_BITMAPINFOHEADER(h) /**/
212 #define le2me_WAVEFORMATEX(h) /**/
213 #define le2me_ASF_stream_chunck_t(h) /**/
216 // priv struct for the demuxer
219 unsigned char* packet
;
227 uint32_t asf_frame_state
;
228 int asf_frame_start_found
;
229 double dvr_last_vid_pts
;
230 uint64_t vid_frame_ct
;
231 uint64_t play_duration
;
232 uint64_t num_packets
;
233 int new_vid_frame_seg
;
234 int *vid_repdata_sizes
;
235 int *aud_repdata_sizes
;
236 int vid_repdata_count
;
237 int aud_repdata_count
;
238 uint64_t avg_vid_frame_time
;
239 uint64_t last_key_payload_time
;
240 uint64_t last_aud_pts
;
241 uint64_t last_aud_diff
;
242 int found_first_key_frame
;
243 uint32_t last_vid_seq
;
244 int vid_ext_timing_index
;
245 int aud_ext_timing_index
;
246 int vid_ext_frame_index
;
251 #endif /* MPLAYER_ASF_H */