39
39
struct asf_stream_s {
40
/* read function, returns -1 on error, 0 on EOF and read bytes otherwise */
40
41
int32_t (*read)(void *opaque, void *buffer, int32_t size);
43
/* write function, returns -1 on error, 0 on EOF and written bytes otherwise */
41
44
int32_t (*write)(void *opaque, void *buffer, int32_t size);
46
/* seek function, seeks to offset from beginning of the file, returns -1 on error, 0 on EOF */
42
47
int64_t (*seek)(void *opaque, int64_t offset);
49
/* opaque data pointer passed to each of the stream handling callbacks */
45
52
typedef struct asf_stream_s asf_stream_t;
47
54
struct asf_metadata_entry_s {
55
char *key; /* key of extended metadata entry */
56
char *value; /* value of extended metadata entry */
51
58
typedef struct asf_metadata_entry_s asf_metadata_entry_t;
60
/* all metadata entries are presented in UTF-8 character encoding */
53
61
struct asf_metadata_s {
59
uint16_t extended_count;
60
asf_metadata_entry_t *extended;
62
char *title; /* title of the stream */
63
char *artist; /* artist of the stream */
64
char *copyright; /* copyright holder */
65
char *description; /* description of the stream */
66
char *rating; /* rating of the stream */
67
uint16_t extended_count; /* number of extended entries */
68
asf_metadata_entry_t *extended; /* array of extended entries */
62
70
typedef struct asf_metadata_s asf_metadata_t;
64
72
struct asf_payload_s {
65
uint8_t stream_number;
66
uint32_t media_object_number;
67
uint32_t media_object_offset;
69
uint32_t replicated_length;
70
uint8_t *replicated_data;
73
uint8_t stream_number; /* the stream number this payload belongs to */
74
uint8_t key_frame; /* a flag indicating if this payload contains a key frame or not */
76
uint32_t media_object_number; /* number of media object this payload is part of */
77
uint32_t media_object_offset; /* byte offset from beginning of media object */
79
uint32_t replicated_length; /* length of some replicated data of a media object... */
80
uint8_t *replicated_data; /* the replicated data mentioned */
82
uint32_t datalen; /* length of the actual payload data */
83
uint8_t *data; /* the actual payload data to decode */
85
uint32_t pts; /* presentation time of this payload */
77
87
typedef struct asf_payload_s asf_payload_t;
79
89
struct asf_packet_s {
85
uint32_t padding_length;
89
uint16_t payload_count;
90
asf_payload_t *payloads;
91
uint16_t payloads_size;
94
uint8_t *payload_data;
95
uint32_t payload_data_size;
90
uint8_t ec_length; /* error correction data length */
91
uint8_t *ec_data; /* error correction data array */
92
uint8_t ec_data_size; /* for internal library use, not to be modified by applications! */
94
uint32_t length; /* length of this packet, usually constant per stream */
95
uint32_t padding_length; /* length of the padding after the data in this packet */
96
uint32_t send_time; /* send time of this packet in milliseconds */
97
uint16_t duration; /* duration of this packet in milliseconds */
99
uint16_t payload_count; /* number of payloads contained in this packet */
100
asf_payload_t *payloads; /* an array of payloads in this packet */
101
uint16_t payloads_size; /* for internal library use, not to be modified by applications! */
103
uint32_t payload_data_len; /* length of the raw payload data of this packet */
104
uint8_t *payload_data; /* the raw payload data of this packet, usually not useful */
105
uint32_t payload_data_size; /* for internal library use, not to be modified by applications! */
97
107
typedef struct asf_packet_s asf_packet_t;
109
/* waveformatex fields specified in Microsoft documentation:
110
http://msdn2.microsoft.com/en-us/library/ms713497.aspx */
111
struct asf_waveformatex_s {
114
uint32_t nSamplesPerSec;
115
uint32_t nAvgBytesPerSec;
116
uint16_t nBlockAlign;
117
uint16_t wBitsPerSample;
121
typedef struct asf_waveformatex_s asf_waveformatex_t;
123
/* bitmapinfoheader fields specified in Microsoft documentation:
124
http://msdn2.microsoft.com/en-us/library/ms532290.aspx */
125
struct asf_bitmapinfoheader_s {
131
uint32_t biCompression;
132
uint32_t biSizeImage;
133
uint32_t biXPelsPerMeter;
134
uint32_t biYPelsPerMeter;
136
uint32_t biClrImportant;
139
typedef struct asf_bitmapinfoheader_s asf_bitmapinfoheader_t;
99
141
enum asf_stream_type_e {
100
142
ASF_STREAM_TYPE_NONE = 0x00,
101
143
ASF_STREAM_TYPE_AUDIO = 0x01,
154
168
ASF_ERROR_SEEK = -10 /* file is seekable but seeking failed */
172
/* initialize the library using file on a local filesystem */
157
173
asf_file_t *asf_open_file(const char *filename);
175
/* initialize the library using callbacks defined on a stream structure,
176
the stream structure can be freed after calling this function */
158
177
asf_file_t *asf_open_cb(asf_stream_t *stream);
179
/* close the library handle and free all allocated memory */
159
180
void asf_close(asf_file_t *file);
183
/* initialize the library and read all header information of the ASF file */
161
184
int asf_init(asf_file_t *file);
186
/* create a packet structure for reading data packets */
162
187
asf_packet_t *asf_packet_create();
189
/* get next packet from the stream to the specified packet structure */
163
190
int asf_get_packet(asf_file_t *file, asf_packet_t *packet);
192
/* seek to the closest (key frame) packet specified by milliseconds position */
164
193
int64_t asf_seek_to_msec(asf_file_t *file, int64_t msec);
195
/* free the packet structure allocated earlier, need to be called only once */
165
196
void asf_free_packet(asf_packet_t *packet);
199
/* get metadata information of the ASF file handle */
167
200
asf_metadata_t *asf_get_metadata(asf_file_t *file);
202
/* free metadata structure received from the library */
168
203
void asf_free_metadata(asf_metadata_t *metadata);
206
/* calculate how many streams are available in current ASF file */
170
207
uint8_t asf_get_stream_count(asf_file_t *file);
209
/* get properties of a stream, the resulting pointer and its contents should NOT be freed */
171
210
asf_stream_properties_t *asf_get_stream_properties(asf_file_t *file, uint8_t track);
213
/* return non-zero if the file is broadcasted, 0 otherwise */
214
int asf_is_broadcast(asf_file_t *file);
216
/* return non-zero if the file is seekable, 0 otherwise */
217
int asf_is_seekable(asf_file_t *file);
219
/* get size of the ASF file in bytes */
173
220
uint64_t asf_get_file_size(asf_file_t *file);
222
/* get creation date in 100-nanosecond units since Jan 1, 1601 GMT
223
this value should be ignored for broadcasts */
174
224
uint64_t asf_get_creation_date(asf_file_t *file);
226
/* get number of data packets available in this file
227
this value should be ignored for broadcasts */
175
228
uint64_t asf_get_data_packets(asf_file_t *file);
230
/* get play duration of the file in 100-nanosecond units,
231
this value should be ignored for broadcasts */
176
232
uint64_t asf_get_duration(asf_file_t *file);
234
/* maximum bitrate as bits per second in the entire file */
177
235
uint32_t asf_get_max_bitrate(asf_file_t *file);