~ubuntu-branches/ubuntu/wily/xmms2/wily

« back to all changes in this revision

Viewing changes to src/plugins/asf/libasf/asf.h

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2008-07-04 16:23:34 UTC
  • mfrom: (1.1.5 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080704162334-b3esbkcapt8wbrk4
Tags: 0.5DrLecter-2ubuntu1
* Merge from debian unstable (LP: #241098), remaining changes:
  + debian/control:
    + Update Maintainer field
    + add lpia to xmms2-plugin-alsa supported architectures
    + Added liba52-0.7.4-dev to build depends
  + debian/rules: Added patch, patch-stamp and unpatch
  + changed 01_gcc4.3.patch:
    + src/include/xmmsclient/xmmsclient++/helpers.h: Added #include <climits>
* New upstream relase fixes LP: #212566, #222341

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
/* used int types for different platforms */
24
 
#if defined (_WIN32) && !defined (__MINGW_H)
 
24
#if !defined(__MINGW_H) && defined(_WIN32)
25
25
typedef char int8_t;
26
26
typedef unsigned char uint8_t;
27
27
typedef short int16_t;
37
37
 
38
38
 
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);
 
42
 
 
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);
 
45
 
 
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);
 
48
 
 
49
        /* opaque data pointer passed to each of the stream handling callbacks */
43
50
        void *opaque;
44
51
};
45
52
typedef struct asf_stream_s asf_stream_t;
46
53
 
47
54
struct asf_metadata_entry_s {
48
 
        char *key;
49
 
        char *value;
 
55
        char *key;      /* key of extended metadata entry */
 
56
        char *value;    /* value of extended metadata entry */
50
57
};
51
58
typedef struct asf_metadata_entry_s asf_metadata_entry_t;
52
59
 
 
60
/* all metadata entries are presented in UTF-8 character encoding */
53
61
struct asf_metadata_s {
54
 
        char *title;
55
 
        char *artist;
56
 
        char *copyright;
57
 
        char *description;
58
 
        char *rating;
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 */
61
69
};
62
70
typedef struct asf_metadata_s asf_metadata_t;
63
71
 
64
72
struct asf_payload_s {
65
 
        uint8_t stream_number;
66
 
        uint32_t media_object_number;
67
 
        uint32_t media_object_offset;
68
 
 
69
 
        uint32_t replicated_length;
70
 
        uint8_t *replicated_data;
71
 
 
72
 
        uint32_t datalen;
73
 
        uint8_t *data;
74
 
 
75
 
        uint32_t pts;
 
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 */
 
75
 
 
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 */
 
78
 
 
79
        uint32_t replicated_length;     /* length of some replicated data of a media object... */
 
80
        uint8_t *replicated_data;       /* the replicated data mentioned */
 
81
 
 
82
        uint32_t datalen;       /* length of the actual payload data */
 
83
        uint8_t *data;          /* the actual payload data to decode */
 
84
 
 
85
        uint32_t pts;           /* presentation time of this payload */
76
86
};
77
87
typedef struct asf_payload_s asf_payload_t;
78
88
 
79
89
struct asf_packet_s {
80
 
        uint8_t ec_length;
81
 
        uint8_t *ec_data;
82
 
        uint8_t ec_data_size;
83
 
 
84
 
        uint32_t length;
85
 
        uint32_t padding_length;
86
 
        uint32_t send_time;
87
 
        uint16_t duration;
88
 
 
89
 
        uint16_t payload_count;
90
 
        asf_payload_t *payloads;
91
 
        uint16_t payloads_size;
92
 
 
93
 
        uint32_t datalen;
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! */
 
93
 
 
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 */
 
98
 
 
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! */
 
102
 
 
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! */
96
106
};
97
107
typedef struct asf_packet_s asf_packet_t;
98
108
 
 
109
/* waveformatex fields specified in Microsoft documentation:
 
110
   http://msdn2.microsoft.com/en-us/library/ms713497.aspx */
 
111
struct asf_waveformatex_s {
 
112
        uint16_t wFormatTag;
 
113
        uint16_t nChannels;
 
114
        uint32_t nSamplesPerSec;
 
115
        uint32_t nAvgBytesPerSec;
 
116
        uint16_t nBlockAlign;
 
117
        uint16_t wBitsPerSample;
 
118
        uint16_t cbSize;
 
119
        uint8_t *data;
 
120
};
 
121
typedef struct asf_waveformatex_s asf_waveformatex_t;
 
122
 
 
123
/* bitmapinfoheader fields specified in Microsoft documentation:
 
124
   http://msdn2.microsoft.com/en-us/library/ms532290.aspx */
 
125
struct asf_bitmapinfoheader_s {
 
126
        uint32_t biSize;
 
127
        uint32_t biWidth;
 
128
        uint32_t biHeight;
 
129
        uint16_t biPlanes;
 
130
        uint16_t biBitCount;
 
131
        uint32_t biCompression;
 
132
        uint32_t biSizeImage;
 
133
        uint32_t biXPelsPerMeter;
 
134
        uint32_t biYPelsPerMeter;
 
135
        uint32_t biClrUsed;
 
136
        uint32_t biClrImportant;
 
137
        uint8_t *data;
 
138
};
 
139
typedef struct asf_bitmapinfoheader_s asf_bitmapinfoheader_t;
 
140
 
99
141
enum asf_stream_type_e {
100
142
        ASF_STREAM_TYPE_NONE     = 0x00,
101
143
        ASF_STREAM_TYPE_AUDIO    = 0x01,
105
147
};
106
148
typedef enum asf_stream_type_e asf_stream_type_t;
107
149
 
108
 
struct asf_waveformatex_s {
109
 
        uint16_t codec_id;
110
 
        uint16_t channels;
111
 
        uint32_t rate;
112
 
        uint32_t bitrate;
113
 
        uint16_t blockalign;
114
 
        uint16_t bitspersample;
115
 
        uint16_t datalen;
116
 
        uint8_t *data;
117
 
};
118
 
typedef struct asf_waveformatex_s asf_waveformatex_t;
119
 
 
120
 
struct asf_bitmapinfoheader_s {
121
 
        uint32_t data_size;
122
 
        uint32_t width;
123
 
        uint32_t height;
124
 
        uint16_t reserved;
125
 
        uint16_t bpp;
126
 
        uint32_t codec;
127
 
        uint32_t image_size;
128
 
        uint32_t hppm;
129
 
        uint32_t vppm;
130
 
        uint32_t colors;
131
 
        uint32_t important_colors;
132
 
        uint8_t *data;
133
 
};
134
 
typedef struct asf_bitmapinfoheader_s asf_bitmapinfoheader_t;
135
 
 
136
150
struct asf_stream_properties_s {
137
 
        asf_stream_type_t type;
138
 
        void *properties;
 
151
        asf_stream_type_t type; /* type of this current stream */
 
152
        void *properties;       /* pointer to type specific data (ie. waveformatex or bitmapinfoheader) */
139
153
};
140
154
typedef struct asf_stream_properties_s asf_stream_properties_t;
141
155
 
154
168
        ASF_ERROR_SEEK           = -10  /* file is seekable but seeking failed */
155
169
};
156
170
 
 
171
 
 
172
/* initialize the library using file on a local filesystem */
157
173
asf_file_t *asf_open_file(const char *filename);
 
174
 
 
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);
 
178
 
 
179
/* close the library handle and free all allocated memory */
159
180
void asf_close(asf_file_t *file);
160
181
 
 
182
 
 
183
/* initialize the library and read all header information of the ASF file */
161
184
int asf_init(asf_file_t *file);
 
185
 
 
186
/* create a packet structure for reading data packets */
162
187
asf_packet_t *asf_packet_create();
 
188
 
 
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);
 
191
 
 
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);
 
194
 
 
195
/* free the packet structure allocated earlier, need to be called only once */
165
196
void asf_free_packet(asf_packet_t *packet);
166
197
 
 
198
 
 
199
/* get metadata information of the ASF file handle */
167
200
asf_metadata_t *asf_get_metadata(asf_file_t *file);
 
201
 
 
202
/* free metadata structure received from the library */
168
203
void asf_free_metadata(asf_metadata_t *metadata);
169
204
 
 
205
 
 
206
/* calculate how many streams are available in current ASF file */
170
207
uint8_t asf_get_stream_count(asf_file_t *file);
 
208
 
 
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);
172
211
 
 
212
 
 
213
/* return non-zero if the file is broadcasted, 0 otherwise */
 
214
int asf_is_broadcast(asf_file_t *file);
 
215
 
 
216
/* return non-zero if the file is seekable, 0 otherwise */
 
217
int asf_is_seekable(asf_file_t *file);
 
218
 
 
219
/* get size of the ASF file in bytes */
173
220
uint64_t asf_get_file_size(asf_file_t *file);
 
221
 
 
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);
 
225
 
 
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);
 
229
 
 
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);
 
233
 
 
234
/* maximum bitrate as bits per second in the entire file */
177
235
uint32_t asf_get_max_bitrate(asf_file_t *file);
178
236
 
179
237
#endif