1000
|
1 #ifndef __ASF_H
|
|
2 #define __ASF_H
|
833
|
3
|
1342
|
4 #include "config.h" /* for WORDS_BIGENDIAN */
|
833
|
5 #include <inttypes.h>
|
1342
|
6 #include "bswap.h"
|
|
7 #ifdef STREAMING
|
1000
|
8 #include "network.h"
|
1342
|
9 #endif
|
904
|
10
|
871
|
11 #ifndef MIN
|
|
12 #define MIN(a,b) ((a<b)?a:b)
|
|
13 #endif
|
|
14
|
833
|
15 ///////////////////////
|
|
16 // MS GUID definition
|
|
17 ///////////////////////
|
|
18 #ifndef GUID_DEFINED
|
|
19 #define GUID_DEFINED
|
|
20 // Size of GUID is 16 bytes!
|
|
21 typedef struct __attribute__((packed)) {
|
|
22 uint32_t Data1; // 4 bytes
|
|
23 uint16_t Data2; // 2 bytes
|
|
24 uint16_t Data3; // 2 bytes
|
|
25 uint8_t Data4[8]; // 8 bytes
|
|
26 } GUID_t;
|
|
27 #endif
|
|
28
|
|
29 ///////////////////////
|
|
30 // ASF Object Header
|
|
31 ///////////////////////
|
|
32 typedef struct __attribute__((packed)) {
|
|
33 uint8_t guid[16];
|
|
34 uint64_t size;
|
|
35 } ASF_obj_header_t;
|
|
36
|
|
37 ////////////////
|
|
38 // ASF Header
|
|
39 ////////////////
|
|
40 typedef struct __attribute__((packed)) {
|
|
41 ASF_obj_header_t objh;
|
|
42 uint32_t cno; // number of subchunks
|
|
43 uint8_t v1; // unknown (0x01)
|
|
44 uint8_t v2; // unknown (0x02)
|
|
45 } ASF_header_t;
|
|
46
|
|
47 /////////////////////
|
|
48 // ASF File Header
|
|
49 /////////////////////
|
|
50 typedef struct __attribute__((packed)) {
|
|
51 uint8_t client[16]; // Client GUID
|
|
52 uint64_t file_size;
|
|
53 uint64_t creat_time; //File creation time FILETIME 8
|
|
54 uint64_t packets; //Number of packets UINT64 8
|
|
55 uint64_t end_timestamp; //Timestamp of the end position UINT64 8
|
|
56 uint64_t duration; //Duration of the playback UINT64 8
|
|
57 uint32_t start_timestamp; //Timestamp of the start position UINT32 4
|
|
58 uint32_t unk1; //Unknown, maybe reserved ( usually contains 0 ) UINT32 4
|
|
59 uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
|
|
60 uint32_t packetsize; //Size of packet, in bytes UINT32 4
|
|
61 uint32_t packetsize2; //Size of packet ( confirm ) UINT32 4
|
|
62 uint32_t frame_size; //Size of uncompressed video frame UINT32 4
|
|
63 } ASF_file_header_t;
|
|
64
|
|
65 ///////////////////////
|
|
66 // ASF Stream Header
|
|
67 ///////////////////////
|
|
68 typedef struct __attribute__((packed)) {
|
|
69 uint8_t type[16]; // Stream type (audio/video) GUID 16
|
|
70 uint8_t concealment[16]; // Audio error concealment type GUID 16
|
|
71 uint64_t unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
|
|
72 uint32_t type_size; //Total size of type-specific data UINT32 4
|
|
73 uint32_t stream_size; //Size of stream-specific data UINT32 4
|
|
74 uint16_t stream_no; //Stream number UINT16 2
|
|
75 uint32_t unk2; //Unknown UINT32 4
|
|
76 } ASF_stream_header_t;
|
|
77
|
|
78 ///////////////////////////
|
|
79 // ASF Content Description
|
|
80 ///////////////////////////
|
|
81 typedef struct __attribute__((packed)) {
|
|
82 uint16_t title_size;
|
|
83 uint16_t author_size;
|
|
84 uint16_t copyright_size;
|
|
85 uint16_t comment_size;
|
|
86 uint16_t rating_size;
|
|
87 } ASF_content_description_t;
|
|
88
|
|
89 ////////////////////////
|
|
90 // ASF Segment Header
|
|
91 ////////////////////////
|
|
92 typedef struct __attribute__((packed)) {
|
|
93 uint8_t streamno;
|
|
94 uint8_t seq;
|
|
95 uint32_t x;
|
|
96 uint8_t flag;
|
|
97 } ASF_segmhdr_t;
|
|
98
|
|
99 //////////////////////
|
|
100 // ASF Stream Chunck
|
|
101 //////////////////////
|
|
102 typedef struct __attribute__((packed)) {
|
|
103 uint16_t type;
|
871
|
104 uint16_t size;
|
833
|
105 uint32_t sequence_number;
|
|
106 uint16_t unknown;
|
871
|
107 uint16_t size_confirm;
|
833
|
108 } ASF_stream_chunck_t;
|
|
109
|
|
110
|
|
111 // Definition of the differents type of ASF streaming
|
|
112 typedef enum {
|
|
113 ASF_Unknown_e,
|
|
114 ASF_Live_e,
|
|
115 ASF_Prerecorded_e,
|
|
116 ASF_Redirector_e
|
|
117 } ASF_StreamType_e;
|
|
118
|
904
|
119
|
1342
|
120 /*
|
|
121 * Some macros to swap little endian structures read from an ASF file
|
|
122 * into machine endian format
|
|
123 */
|
|
124 #ifdef WORDS_BIGENDIAN
|
|
125 #define le2me_ASF_obj_header_t(h) { \
|
|
126 (h)->size = le2me_64((h)->size); \
|
|
127 }
|
|
128 #define le2me_ASF_header_t(h) { \
|
|
129 le2me_ASF_obj_header_t(&(h)->objh); \
|
|
130 (h)->cno = le2me_32((h)->cno); \
|
|
131 }
|
|
132 #define le2me_ASF_stream_header_t(h) { \
|
|
133 (h)->unk1 = le2me_64((h)->unk1); \
|
|
134 (h)->type_size = le2me_32((h)->type_size); \
|
|
135 (h)->stream_size = le2me_32((h)->stream_size); \
|
|
136 (h)->stream_no = le2me_16((h)->stream_no); \
|
|
137 (h)->unk2 = le2me_32((h)->unk2); \
|
|
138 }
|
|
139 #define le2me_ASF_file_header_t(h) { \
|
|
140 (h)->file_size = le2me_64((h)->file_size); \
|
|
141 (h)->creat_time = le2me_64((h)->creat_time); \
|
|
142 (h)->packets = le2me_64((h)->packets); \
|
|
143 (h)->end_timestamp = le2me_64((h)->end_timestamp); \
|
|
144 (h)->duration = le2me_64((h)->duration); \
|
|
145 (h)->start_timestamp = le2me_32((h)->start_timestamp); \
|
|
146 (h)->unk1 = le2me_32((h)->unk1); \
|
|
147 (h)->flags = le2me_32((h)->flags); \
|
|
148 (h)->packetsize = le2me_32((h)->packetsize); \
|
|
149 (h)->packetsize2 = le2me_32((h)->packetsize2); \
|
|
150 (h)->frame_size = le2me_32((h)->frame_size); \
|
|
151 }
|
|
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); \
|
|
158 }
|
|
159 #else
|
|
160 #define le2me_ASF_obj_header_t(h) /**/
|
|
161 #define le2me_ASF_header_t(h) /**/
|
|
162 #define le2me_ASF_stream_header_t(h) /**/
|
|
163 #define le2me_ASF_file_header_t(h) /**/
|
|
164 #define le2me_ASF_content_description_t(h) /**/
|
|
165 #endif
|
|
166
|
|
167
|
|
168 #ifdef STREAMING
|
904
|
169 int asf_http_streaming_type(char *content_type, char *features);
|
1000
|
170 int asf_http_streaming_start( streaming_ctrl_t *streaming_ctrl );
|
|
171 int asf_http_streaming_read( streaming_ctrl_t *streaming_ctrl );
|
|
172
|
|
173 int asf_streaming(char *data, int length, int *drop_packet );
|
1342
|
174 #endif
|
904
|
175
|
833
|
176 #endif
|