VLC
2.1.0-git
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
vlc
libvlc_media.h
Go to the documentation of this file.
1
/*****************************************************************************
2
* libvlc_media.h: libvlc external API
3
*****************************************************************************
4
* Copyright (C) 1998-2009 VLC authors and VideoLAN
5
* $Id: 5e4482ff9528e6735d54d861c3f9a397e90be537 $
6
*
7
* Authors: Clément Stenac <zorglub@videolan.org>
8
* Jean-Paul Saman <jpsaman@videolan.org>
9
* Pierre d'Herbemont <pdherbemont@videolan.org>
10
*
11
* This program is free software; you can redistribute it and/or modify it
12
* under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation; either version 2.1 of the License, or
14
* (at your option) any later version.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with this program; if not, write to the Free Software Foundation,
23
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24
*****************************************************************************/
25
26
/**
27
* \file
28
* This file defines libvlc_media external API
29
*/
30
31
#ifndef VLC_LIBVLC_MEDIA_H
32
#define VLC_LIBVLC_MEDIA_H 1
33
34
# ifdef __cplusplus
35
extern
"C"
{
36
# endif
37
38
/** \defgroup libvlc_media LibVLC media
39
* \ingroup libvlc
40
* @ref libvlc_media_t is an abstract representation of a playable media.
41
* It consists of a media location and various optional meta data.
42
* @{
43
*/
44
45
typedef
struct
libvlc_media_t
libvlc_media_t
;
46
47
/** defgroup libvlc_meta LibVLC meta data
48
* \ingroup libvlc_media
49
* @{
50
*/
51
52
/** Meta data types */
53
typedef
enum
libvlc_meta_t
{
54
libvlc_meta_Title
,
55
libvlc_meta_Artist
,
56
libvlc_meta_Genre
,
57
libvlc_meta_Copyright
,
58
libvlc_meta_Album
,
59
libvlc_meta_TrackNumber
,
60
libvlc_meta_Description
,
61
libvlc_meta_Rating
,
62
libvlc_meta_Date
,
63
libvlc_meta_Setting
,
64
libvlc_meta_URL
,
65
libvlc_meta_Language
,
66
libvlc_meta_NowPlaying
,
67
libvlc_meta_Publisher
,
68
libvlc_meta_EncodedBy
,
69
libvlc_meta_ArtworkURL
,
70
libvlc_meta_TrackID
71
/* Add new meta types HERE */
72
}
libvlc_meta_t
;
73
74
/** @}*/
75
76
/**
77
* Note the order of libvlc_state_t enum must match exactly the order of
78
* \see mediacontrol_PlayerStatus, \see input_state_e enums,
79
* and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
80
*
81
* Expected states by web plugins are:
82
* IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4,
83
* STOPPING=5, ENDED=6, ERROR=7
84
*/
85
typedef
enum
libvlc_state_t
86
{
87
libvlc_NothingSpecial
=0,
88
libvlc_Opening
,
89
libvlc_Buffering
,
90
libvlc_Playing
,
91
libvlc_Paused
,
92
libvlc_Stopped
,
93
libvlc_Ended
,
94
libvlc_Error
95
}
libvlc_state_t
;
96
97
enum
98
{
99
libvlc_media_option_trusted
= 0x2,
100
libvlc_media_option_unique
= 0x100
101
};
102
103
typedef
enum
libvlc_track_type_t
104
{
105
libvlc_track_unknown
= -1,
106
libvlc_track_audio
= 0,
107
libvlc_track_video
= 1,
108
libvlc_track_text
= 2
109
}
libvlc_track_type_t
;
110
111
/** defgroup libvlc_media_stats_t LibVLC media statistics
112
* \ingroup libvlc_media
113
* @{
114
*/
115
typedef
struct
libvlc_media_stats_t
116
{
117
/* Input */
118
int
i_read_bytes
;
119
float
f_input_bitrate
;
120
121
/* Demux */
122
int
i_demux_read_bytes
;
123
float
f_demux_bitrate
;
124
int
i_demux_corrupted
;
125
int
i_demux_discontinuity
;
126
127
/* Decoders */
128
int
i_decoded_video
;
129
int
i_decoded_audio
;
130
131
/* Video Output */
132
int
i_displayed_pictures
;
133
int
i_lost_pictures
;
134
135
/* Audio output */
136
int
i_played_abuffers
;
137
int
i_lost_abuffers
;
138
139
/* Stream output */
140
int
i_sent_packets
;
141
int
i_sent_bytes
;
142
float
f_send_bitrate
;
143
}
libvlc_media_stats_t
;
144
/** @}*/
145
146
typedef
struct
libvlc_media_track_info_t
147
{
148
/* Codec fourcc */
149
uint32_t
i_codec
;
150
int
i_id
;
151
libvlc_track_type_t
i_type
;
152
153
/* Codec specific */
154
int
i_profile
;
155
int
i_level
;
156
157
union
{
158
struct
{
159
/* Audio specific */
160
unsigned
i_channels
;
161
unsigned
i_rate
;
162
}
audio
;
163
struct
{
164
/* Video specific */
165
unsigned
i_height
;
166
unsigned
i_width
;
167
}
video
;
168
}
u
;
169
170
}
libvlc_media_track_info_t
;
171
172
173
typedef
struct
libvlc_audio_track_t
174
{
175
unsigned
i_channels
;
176
unsigned
i_rate
;
177
}
libvlc_audio_track_t
;
178
179
typedef
struct
libvlc_video_track_t
180
{
181
unsigned
i_height
;
182
unsigned
i_width
;
183
unsigned
i_sar_num
;
184
unsigned
i_sar_den
;
185
unsigned
i_frame_rate_num
;
186
unsigned
i_frame_rate_den
;
187
}
libvlc_video_track_t
;
188
189
typedef
struct
libvlc_subtitle_track_t
190
{
191
char
*
psz_encoding
;
192
}
libvlc_subtitle_track_t
;
193
194
typedef
struct
libvlc_media_track_t
195
{
196
/* Codec fourcc */
197
uint32_t
i_codec
;
198
uint32_t
i_original_fourcc
;
199
int
i_id
;
200
libvlc_track_type_t
i_type
;
201
202
/* Codec specific */
203
int
i_profile
;
204
int
i_level
;
205
206
union
{
207
libvlc_audio_track_t
*
audio
;
208
libvlc_video_track_t
*
video
;
209
libvlc_subtitle_track_t
*
subtitle
;
210
};
211
212
unsigned
int
i_bitrate
;
213
char
*
psz_language
;
214
char
*
psz_description
;
215
216
}
libvlc_media_track_t
;
217
218
219
/**
220
* Create a media with a certain given media resource location,
221
* for instance a valid URL.
222
*
223
* \note To refer to a local file with this function,
224
* the file://... URI syntax <b>must</b> be used (see IETF RFC3986).
225
* We recommend using libvlc_media_new_path() instead when dealing with
226
* local files.
227
*
228
* \see libvlc_media_release
229
*
230
* \param p_instance the instance
231
* \param psz_mrl the media location
232
* \return the newly created media or NULL on error
233
*/
234
LIBVLC_API
libvlc_media_t
*
libvlc_media_new_location
(
235
libvlc_instance_t
*p_instance,
236
const
char
* psz_mrl );
237
238
/**
239
* Create a media for a certain file path.
240
*
241
* \see libvlc_media_release
242
*
243
* \param p_instance the instance
244
* \param path local filesystem path
245
* \return the newly created media or NULL on error
246
*/
247
LIBVLC_API
libvlc_media_t
*
libvlc_media_new_path
(
248
libvlc_instance_t
*p_instance,
249
const
char
*path );
250
251
/**
252
* Create a media for an already open file descriptor.
253
* The file descriptor shall be open for reading (or reading and writing).
254
*
255
* Regular file descriptors, pipe read descriptors and character device
256
* descriptors (including TTYs) are supported on all platforms.
257
* Block device descriptors are supported where available.
258
* Directory descriptors are supported on systems that provide fdopendir().
259
* Sockets are supported on all platforms where they are file descriptors,
260
* i.e. all except Windows.
261
*
262
* \note This library will <b>not</b> automatically close the file descriptor
263
* under any circumstance. Nevertheless, a file descriptor can usually only be
264
* rendered once in a media player. To render it a second time, the file
265
* descriptor should probably be rewound to the beginning with lseek().
266
*
267
* \see libvlc_media_release
268
*
269
* \version LibVLC 1.1.5 and later.
270
*
271
* \param p_instance the instance
272
* \param fd open file descriptor
273
* \return the newly created media or NULL on error
274
*/
275
LIBVLC_API
libvlc_media_t
*
libvlc_media_new_fd
(
276
libvlc_instance_t
*p_instance,
277
int
fd );
278
279
280
/**
281
* Create a media as an empty node with a given name.
282
*
283
* \see libvlc_media_release
284
*
285
* \param p_instance the instance
286
* \param psz_name the name of the node
287
* \return the new empty media or NULL on error
288
*/
289
LIBVLC_API
libvlc_media_t
*
libvlc_media_new_as_node
(
290
libvlc_instance_t
*p_instance,
291
const
char
*
psz_name
);
292
293
/**
294
* Add an option to the media.
295
*
296
* This option will be used to determine how the media_player will
297
* read the media. This allows to use VLC's advanced
298
* reading/streaming options on a per-media basis.
299
*
300
* \note The options are listed in 'vlc --long-help' from the command line,
301
* e.g. "-sout-all". Keep in mind that available options and their semantics
302
* vary across LibVLC versions and builds.
303
* \warning Not all options affects libvlc_media_t objects:
304
* Specifically, due to architectural issues most audio and video options,
305
* such as text renderer options, have no effects on an individual media.
306
* These options must be set through libvlc_new() instead.
307
*
308
* \param p_md the media descriptor
309
* \param ppsz_options the options (as a string)
310
*/
311
LIBVLC_API
void
libvlc_media_add_option
(
312
libvlc_media_t
*p_md,
313
const
char
* ppsz_options );
314
315
/**
316
* Add an option to the media with configurable flags.
317
*
318
* This option will be used to determine how the media_player will
319
* read the media. This allows to use VLC's advanced
320
* reading/streaming options on a per-media basis.
321
*
322
* The options are detailed in vlc --long-help, for instance
323
* "--sout-all". Note that all options are not usable on medias:
324
* specifically, due to architectural issues, video-related options
325
* such as text renderer options cannot be set on a single media. They
326
* must be set on the whole libvlc instance instead.
327
*
328
* \param p_md the media descriptor
329
* \param ppsz_options the options (as a string)
330
* \param i_flags the flags for this option
331
*/
332
LIBVLC_API
void
libvlc_media_add_option_flag
(
333
libvlc_media_t
*p_md,
334
const
char
* ppsz_options,
335
unsigned
i_flags );
336
337
338
/**
339
* Retain a reference to a media descriptor object (libvlc_media_t). Use
340
* libvlc_media_release() to decrement the reference count of a
341
* media descriptor object.
342
*
343
* \param p_md the media descriptor
344
*/
345
LIBVLC_API
void
libvlc_media_retain
(
libvlc_media_t
*p_md );
346
347
/**
348
* Decrement the reference count of a media descriptor object. If the
349
* reference count is 0, then libvlc_media_release() will release the
350
* media descriptor object. It will send out an libvlc_MediaFreed event
351
* to all listeners. If the media descriptor object has been released it
352
* should not be used again.
353
*
354
* \param p_md the media descriptor
355
*/
356
LIBVLC_API
void
libvlc_media_release
(
libvlc_media_t
*p_md );
357
358
359
/**
360
* Get the media resource locator (mrl) from a media descriptor object
361
*
362
* \param p_md a media descriptor object
363
* \return string with mrl of media descriptor object
364
*/
365
LIBVLC_API
char
*
libvlc_media_get_mrl
(
libvlc_media_t
*p_md );
366
367
/**
368
* Duplicate a media descriptor object.
369
*
370
* \param p_md a media descriptor object.
371
*/
372
LIBVLC_API
libvlc_media_t
*
libvlc_media_duplicate
(
libvlc_media_t
*p_md );
373
374
/**
375
* Read the meta of the media.
376
*
377
* If the media has not yet been parsed this will return NULL.
378
*
379
* This methods automatically calls libvlc_media_parse_async(), so after calling
380
* it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
381
* version ensure that you call libvlc_media_parse() before get_meta().
382
*
383
* \see libvlc_media_parse
384
* \see libvlc_media_parse_async
385
* \see libvlc_MediaMetaChanged
386
*
387
* \param p_md the media descriptor
388
* \param e_meta the meta to read
389
* \return the media's meta
390
*/
391
LIBVLC_API
char
*
libvlc_media_get_meta
(
libvlc_media_t
*p_md,
392
libvlc_meta_t
e_meta );
393
394
/**
395
* Set the meta of the media (this function will not save the meta, call
396
* libvlc_media_save_meta in order to save the meta)
397
*
398
* \param p_md the media descriptor
399
* \param e_meta the meta to write
400
* \param psz_value the media's meta
401
*/
402
LIBVLC_API
void
libvlc_media_set_meta
(
libvlc_media_t
*p_md,
403
libvlc_meta_t
e_meta,
404
const
char
*
psz_value
);
405
406
407
/**
408
* Save the meta previously set
409
*
410
* \param p_md the media desriptor
411
* \return true if the write operation was successful
412
*/
413
LIBVLC_API
int
libvlc_media_save_meta
(
libvlc_media_t
*p_md );
414
415
416
/**
417
* Get current state of media descriptor object. Possible media states
418
* are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
419
* libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
420
* libvlc_Stopped, libvlc_Ended,
421
* libvlc_Error).
422
*
423
* \see libvlc_state_t
424
* \param p_md a media descriptor object
425
* \return state of media descriptor object
426
*/
427
LIBVLC_API
libvlc_state_t
libvlc_media_get_state
(
428
libvlc_media_t
*p_md );
429
430
431
/**
432
* Get the current statistics about the media
433
* \param p_md: media descriptor object
434
* \param p_stats: structure that contain the statistics about the media
435
* (this structure must be allocated by the caller)
436
* \return true if the statistics are available, false otherwise
437
*
438
* \libvlc_return_bool
439
*/
440
LIBVLC_API
int
libvlc_media_get_stats
(
libvlc_media_t
*p_md,
441
libvlc_media_stats_t
*p_stats );
442
443
/* The following method uses libvlc_media_list_t, however, media_list usage is optionnal
444
* and this is here for convenience */
445
#define VLC_FORWARD_DECLARE_OBJECT(a) struct a
446
447
/**
448
* Get subitems of media descriptor object. This will increment
449
* the reference count of supplied media descriptor object. Use
450
* libvlc_media_list_release() to decrement the reference counting.
451
*
452
* \param p_md media descriptor object
453
* \return list of media descriptor subitems or NULL
454
*/
455
LIBVLC_API
VLC_FORWARD_DECLARE_OBJECT
(
libvlc_media_list_t
*)
456
libvlc_media_subitems
(
libvlc_media_t
*p_md );
457
458
/**
459
* Get event manager from media descriptor object.
460
* NOTE: this function doesn't increment reference counting.
461
*
462
* \param p_md a media descriptor object
463
* \return event manager object
464
*/
465
LIBVLC_API
libvlc_event_manager_t
*
466
libvlc_media_event_manager
(
libvlc_media_t
*p_md );
467
468
/**
469
* Get duration (in ms) of media descriptor object item.
470
*
471
* \param p_md media descriptor object
472
* \return duration of media item or -1 on error
473
*/
474
LIBVLC_API
libvlc_time_t
475
libvlc_media_get_duration
(
libvlc_media_t
*p_md );
476
477
/**
478
* Parse a media.
479
*
480
* This fetches (local) meta data and tracks information.
481
* The method is synchronous.
482
*
483
* \see libvlc_media_parse_async
484
* \see libvlc_media_get_meta
485
* \see libvlc_media_get_tracks_info
486
*
487
* \param p_md media descriptor object
488
*/
489
LIBVLC_API
void
490
libvlc_media_parse
(
libvlc_media_t
*p_md );
491
492
/**
493
* Parse a media.
494
*
495
* This fetches (local) meta data and tracks information.
496
* The method is the asynchronous of libvlc_media_parse().
497
*
498
* To track when this is over you can listen to libvlc_MediaParsedChanged
499
* event. However if the media was already parsed you will not receive this
500
* event.
501
*
502
* \see libvlc_media_parse
503
* \see libvlc_MediaParsedChanged
504
* \see libvlc_media_get_meta
505
* \see libvlc_media_get_tracks_info
506
*
507
* \param p_md media descriptor object
508
*/
509
LIBVLC_API
void
510
libvlc_media_parse_async
(
libvlc_media_t
*p_md );
511
512
/**
513
* Get Parsed status for media descriptor object.
514
*
515
* \see libvlc_MediaParsedChanged
516
*
517
* \param p_md media descriptor object
518
* \return true if media object has been parsed otherwise it returns false
519
*
520
* \libvlc_return_bool
521
*/
522
LIBVLC_API
int
523
libvlc_media_is_parsed
(
libvlc_media_t
*p_md );
524
525
/**
526
* Sets media descriptor's user_data. user_data is specialized data
527
* accessed by the host application, VLC.framework uses it as a pointer to
528
* an native object that references a libvlc_media_t pointer
529
*
530
* \param p_md media descriptor object
531
* \param p_new_user_data pointer to user data
532
*/
533
LIBVLC_API
void
534
libvlc_media_set_user_data
(
libvlc_media_t
*p_md,
void
*p_new_user_data );
535
536
/**
537
* Get media descriptor's user_data. user_data is specialized data
538
* accessed by the host application, VLC.framework uses it as a pointer to
539
* an native object that references a libvlc_media_t pointer
540
*
541
* \param p_md media descriptor object
542
*/
543
LIBVLC_API
void
*
libvlc_media_get_user_data
(
libvlc_media_t
*p_md );
544
545
/**
546
* Get media descriptor's elementary streams description
547
*
548
* Note, you need to call libvlc_media_parse() or play the media at least once
549
* before calling this function.
550
* Not doing this will result in an empty array.
551
*
552
* \deprecated Use libvlc_media_tracks_get instead
553
*
554
* \param p_md media descriptor object
555
* \param tracks address to store an allocated array of Elementary Streams
556
* descriptions (must be freed by the caller) [OUT]
557
*
558
* \return the number of Elementary Streams
559
*/
560
LIBVLC_DEPRECATED
LIBVLC_API
561
int
libvlc_media_get_tracks_info
(
libvlc_media_t
*p_md,
562
libvlc_media_track_info_t
**tracks );
563
564
/**
565
* Get media descriptor's elementary streams description
566
*
567
* Note, you need to call libvlc_media_parse() or play the media at least once
568
* before calling this function.
569
* Not doing this will result in an empty array.
570
*
571
* \version LibVLC 2.1.0 and later.
572
*
573
* \param p_md media descriptor object
574
* \param tracks address to store an allocated array of Elementary Streams
575
* descriptions (must be freed with libvlc_media_tracks_release
576
by the caller) [OUT]
577
*
578
* \return the number of Elementary Streams (zero on error)
579
*/
580
LIBVLC_API
581
unsigned
libvlc_media_tracks_get
(
libvlc_media_t
*p_md,
582
libvlc_media_track_t
***tracks );
583
584
585
/**
586
* Release media descriptor's elementary streams description array
587
*
588
* \version LibVLC 2.1.0 and later.
589
*
590
* \param p_tracks tracks info array to release
591
* \param i_count number of elements in the array
592
*/
593
LIBVLC_API
594
void
libvlc_media_tracks_release
(
libvlc_media_track_t
**p_tracks,
595
unsigned
i_count );
596
597
/** @}*/
598
599
# ifdef __cplusplus
600
}
601
# endif
602
603
#endif
/* VLC_LIBVLC_MEDIA_H */
Generated by
1.8.1.2