1 /*****************************************************************************
2 * media_player.c: Libvlc API Media Instance management functions
3 *****************************************************************************
4 * Copyright (C) 2005-2015 VLC authors and VideoLAN
6 * Authors: Clément Stenac <zorglub@videolan.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
29 #include <vlc/libvlc.h>
30 #include <vlc/libvlc_renderer_discoverer.h>
31 #include <vlc/libvlc_picture.h>
32 #include <vlc/libvlc_media.h>
33 #include <vlc/libvlc_events.h>
35 #include <vlc_demux.h>
38 #include <vlc_actions.h>
40 #include "libvlc_internal.h"
41 #include "media_internal.h" // libvlc_media_set_state()
42 #include "media_player_internal.h"
43 #include "renderer_discoverer_internal.h"
45 #define ES_INIT (-2) /* -1 is reserved for ES deselect */
48 snapshot_was_taken( vlc_object_t
*p_this
, char const *psz_cmd
,
49 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
);
51 static void media_attach_preparsed_event(libvlc_media_t
*);
52 static void media_detach_preparsed_event(libvlc_media_t
*);
54 static void libvlc_media_player_destroy( libvlc_media_player_t
*p_mi
);
59 on_current_media_changed(vlc_player_t
*player
, input_item_t
*new_media
,
64 libvlc_media_player_t
*mp
= data
;
66 libvlc_media_t
*libmedia
;
67 if (new_media
!= NULL
)
69 libmedia
= new_media
->libvlc_owner
;
70 assert(libmedia
!= NULL
);
76 event
.type
= libvlc_MediaPlayerMediaChanged
;
77 event
.u
.media_player_media_changed
.new_media
= libmedia
;
78 libvlc_event_send(&mp
->event_manager
, &event
);
82 on_state_changed(vlc_player_t
*player
, enum vlc_player_state new_state
,
87 libvlc_media_player_t
*mp
= data
;
91 case VLC_PLAYER_STATE_STOPPED
:
92 event
.type
= libvlc_MediaPlayerStopped
;
94 case VLC_PLAYER_STATE_STOPPING
:
95 event
.type
= libvlc_MediaPlayerEndReached
;
97 case VLC_PLAYER_STATE_STARTED
:
98 event
.type
= libvlc_MediaPlayerOpening
;
100 case VLC_PLAYER_STATE_PLAYING
:
101 event
.type
= libvlc_MediaPlayerPlaying
;
103 case VLC_PLAYER_STATE_PAUSED
:
104 event
.type
= libvlc_MediaPlayerPaused
;
107 vlc_assert_unreachable();
110 libvlc_event_send(&mp
->event_manager
, &event
);
114 on_error_changed(vlc_player_t
*player
, enum vlc_player_error error
, void *data
)
118 libvlc_media_player_t
*mp
= data
;
120 libvlc_event_t event
;
122 case VLC_PLAYER_ERROR_NONE
:
123 event
.type
= libvlc_MediaPlayerNothingSpecial
;
125 case VLC_PLAYER_ERROR_GENERIC
:
126 event
.type
= libvlc_MediaPlayerEncounteredError
;
129 vlc_assert_unreachable();
132 libvlc_event_send(&mp
->event_manager
, &event
);
136 on_buffering_changed(vlc_player_t
*player
, float new_buffering
, void *data
)
140 libvlc_media_player_t
*mp
= data
;
142 libvlc_event_t event
;
143 event
.type
= libvlc_MediaPlayerBuffering
;
144 event
.u
.media_player_buffering
.new_cache
= 100 * new_buffering
;
146 libvlc_event_send(&mp
->event_manager
, &event
);
150 on_capabilities_changed(vlc_player_t
*player
, int old_caps
, int new_caps
, void *data
)
154 libvlc_media_player_t
*mp
= data
;
156 libvlc_event_t event
;
158 bool old_seekable
= old_caps
& VLC_PLAYER_CAP_SEEK
;
159 bool new_seekable
= new_caps
& VLC_PLAYER_CAP_SEEK
;
160 if (new_seekable
!= old_seekable
)
162 event
.type
= libvlc_MediaPlayerSeekableChanged
;
163 event
.u
.media_player_seekable_changed
.new_seekable
= new_seekable
;
164 libvlc_event_send(&mp
->event_manager
, &event
);
167 bool old_pauseable
= old_caps
& VLC_PLAYER_CAP_PAUSE
;
168 bool new_pauseable
= new_caps
& VLC_PLAYER_CAP_PAUSE
;
169 if (new_pauseable
!= old_pauseable
)
171 event
.type
= libvlc_MediaPlayerPausableChanged
;
172 event
.u
.media_player_pausable_changed
.new_pausable
= new_pauseable
;
173 libvlc_event_send(&mp
->event_manager
, &event
);
178 on_position_changed(vlc_player_t
*player
, vlc_tick_t new_time
, float new_pos
,
183 libvlc_media_player_t
*mp
= data
;
185 libvlc_event_t event
;
187 event
.type
= libvlc_MediaPlayerPositionChanged
;
188 event
.u
.media_player_position_changed
.new_position
= new_pos
;
189 libvlc_event_send(&mp
->event_manager
, &event
);
191 event
.type
= libvlc_MediaPlayerTimeChanged
;
192 event
.u
.media_player_time_changed
.new_time
= MS_FROM_VLC_TICK(new_time
);
193 libvlc_event_send(&mp
->event_manager
, &event
);
197 on_length_changed(vlc_player_t
*player
, vlc_tick_t new_length
, void *data
)
201 libvlc_media_player_t
*mp
= data
;
203 libvlc_event_t event
;
205 event
.type
= libvlc_MediaPlayerLengthChanged
;
206 event
.u
.media_player_length_changed
.new_length
=
207 MS_FROM_VLC_TICK(new_length
);
209 libvlc_event_send(&mp
->event_manager
, &event
);
213 track_type_from_cat(enum es_format_category_e cat
)
218 return libvlc_track_video
;
220 return libvlc_track_audio
;
222 return libvlc_track_text
;
224 return libvlc_track_unknown
;
229 on_track_list_changed(vlc_player_t
*player
, enum vlc_player_list_action action
,
230 const struct vlc_player_track
*track
, void *data
)
234 libvlc_media_player_t
*mp
= data
;
236 libvlc_event_t event
;
239 case VLC_PLAYER_LIST_ADDED
:
240 event
.type
= libvlc_MediaPlayerESAdded
; break;
241 case VLC_PLAYER_LIST_REMOVED
:
242 event
.type
= libvlc_MediaPlayerESDeleted
; break;
243 case VLC_PLAYER_LIST_UPDATED
:
244 event
.type
= libvlc_MediaPlayerESUpdated
; break;
247 event
.u
.media_player_es_changed
.i_type
=
248 track_type_from_cat(track
->fmt
.i_cat
);
249 event
.u
.media_player_es_changed
.i_id
= vlc_es_id_GetInputId(track
->es_id
);
250 event
.u
.media_player_es_changed
.psz_id
= vlc_es_id_GetStrId(track
->es_id
);
252 libvlc_event_send(&mp
->event_manager
, &event
);
256 on_track_selection_changed(vlc_player_t
*player
, vlc_es_id_t
*unselected_id
,
257 vlc_es_id_t
*selected_id
, void *data
)
260 (void) unselected_id
;
262 libvlc_media_player_t
*mp
= data
;
264 libvlc_event_t event
;
265 event
.type
= libvlc_MediaPlayerESSelected
;
269 enum es_format_category_e cat
= vlc_es_id_GetCat(unselected_id
);
270 event
.u
.media_player_es_selection_changed
.i_type
= track_type_from_cat(cat
);
274 enum es_format_category_e cat
= vlc_es_id_GetCat(selected_id
);
275 event
.u
.media_player_es_selection_changed
.i_type
= track_type_from_cat(cat
);
278 event
.u
.media_player_es_selection_changed
.psz_unselected_id
=
279 unselected_id
? vlc_es_id_GetStrId(unselected_id
) : NULL
;
281 event
.u
.media_player_es_selection_changed
.psz_selected_id
=
282 selected_id
? vlc_es_id_GetStrId(selected_id
) : NULL
;
284 libvlc_event_send(&mp
->event_manager
, &event
);
288 on_program_list_changed(vlc_player_t
*player
,
289 enum vlc_player_list_action action
,
290 const struct vlc_player_program
*prgm
, void* data
)
293 libvlc_media_player_t
*mp
= data
;
295 libvlc_event_t event
;
298 case VLC_PLAYER_LIST_ADDED
:
299 event
.type
= libvlc_MediaPlayerProgramAdded
;
301 case VLC_PLAYER_LIST_REMOVED
:
302 event
.type
= libvlc_MediaPlayerProgramDeleted
;
304 case VLC_PLAYER_LIST_UPDATED
:
305 event
.type
= libvlc_MediaPlayerProgramUpdated
;
309 event
.u
.media_player_program_changed
.i_id
= prgm
->group_id
;
310 libvlc_event_send(&mp
->event_manager
, &event
);
314 on_program_selection_changed(vlc_player_t
*player
, int unselected_id
,
315 int selected_id
, void *data
)
318 libvlc_media_player_t
*mp
= data
;
320 libvlc_event_t event
;
321 event
.type
= libvlc_MediaPlayerProgramSelected
;
322 event
.u
.media_player_program_selection_changed
.i_unselected_id
= unselected_id
;
323 event
.u
.media_player_program_selection_changed
.i_selected_id
= selected_id
;
325 libvlc_event_send(&mp
->event_manager
, &event
);
329 on_titles_changed(vlc_player_t
*player
,
330 vlc_player_title_list
*titles
, void *data
)
335 libvlc_media_player_t
*mp
= data
;
337 libvlc_event_t event
;
338 event
.type
= libvlc_MediaPlayerTitleListChanged
;
340 libvlc_event_send(&mp
->event_manager
, &event
);
344 on_title_selection_changed(vlc_player_t
*player
,
345 const struct vlc_player_title
*new_title
,
346 size_t new_idx
, void *data
)
351 libvlc_media_player_t
*mp
= data
;
353 const libvlc_title_description_t libtitle
= {
354 .i_duration
= MS_FROM_VLC_TICK(new_title
->length
),
355 .psz_name
= (char *) new_title
->name
,
356 .i_flags
= new_title
->flags
,
359 libvlc_event_t event
;
360 event
.type
= libvlc_MediaPlayerTitleSelectionChanged
;
361 event
.u
.media_player_title_selection_changed
.title
= &libtitle
;
362 event
.u
.media_player_title_selection_changed
.index
= new_idx
;
364 libvlc_event_send(&mp
->event_manager
, &event
);
368 on_chapter_selection_changed(vlc_player_t
*player
,
369 const struct vlc_player_title
*title
,
371 const struct vlc_player_chapter
*new_chapter
,
372 size_t new_chapter_idx
,
380 libvlc_media_player_t
*mp
= data
;
382 libvlc_event_t event
;
383 event
.type
= libvlc_MediaPlayerChapterChanged
;
384 event
.u
.media_player_chapter_changed
.new_chapter
= new_chapter_idx
;
386 libvlc_event_send(&mp
->event_manager
, &event
);
390 on_media_subitems_changed(vlc_player_t
*player
, input_item_t
*media
,
391 input_item_node_t
*new_subitems
, void *data
)
395 libvlc_media_player_t
*mp
= data
;
397 input_item_t
*current
= mp
->p_md
? mp
->p_md
->p_input_item
: NULL
;
398 if (media
== current
)
399 libvlc_media_add_subtree(mp
->p_md
, new_subitems
);
403 on_cork_changed(vlc_player_t
*player
, unsigned cork_count
, void *data
)
407 libvlc_media_player_t
*mp
= data
;
409 libvlc_event_t event
;
410 event
.type
= cork_count
? libvlc_MediaPlayerCorked
411 : libvlc_MediaPlayerUncorked
;
413 libvlc_event_send(&mp
->event_manager
, &event
);
417 on_vout_changed(vlc_player_t
*player
, enum vlc_player_vout_action action
,
418 vout_thread_t
*vout
, enum vlc_vout_order order
,
419 vlc_es_id_t
*es_id
, void *data
)
425 if (vlc_es_id_GetCat(es_id
) != VIDEO_ES
)
428 libvlc_media_player_t
*mp
= data
;
431 vout_thread_t
**vouts
= vlc_player_vout_HoldAll(player
, &count
);
434 for (size_t i
= 0; i
< count
; ++i
)
435 vout_Release(vouts
[i
]);
438 libvlc_event_t event
;
439 event
.type
= libvlc_MediaPlayerVout
;
440 event
.u
.media_player_vout
.new_count
= count
;
442 libvlc_event_send(&mp
->event_manager
, &event
);
445 // player aout callbacks
448 on_volume_changed(audio_output_t
*aout
, float new_volume
, void *data
)
452 libvlc_media_player_t
*mp
= data
;
454 libvlc_event_t event
;
455 event
.type
= libvlc_MediaPlayerAudioVolume
;
456 event
.u
.media_player_audio_volume
.volume
= new_volume
;
458 libvlc_event_send(&mp
->event_manager
, &event
);
462 on_mute_changed(audio_output_t
*aout
, bool new_muted
, void *data
)
466 libvlc_media_player_t
*mp
= data
;
468 libvlc_event_t event
;
469 event
.type
= new_muted
? libvlc_MediaPlayerMuted
470 : libvlc_MediaPlayerUnmuted
;
472 libvlc_event_send(&mp
->event_manager
, &event
);
476 on_audio_device_changed(audio_output_t
*aout
, const char *device
, void *data
)
480 libvlc_media_player_t
*mp
= data
;
482 libvlc_event_t event
;
483 event
.type
= libvlc_MediaPlayerAudioDevice
;
484 event
.u
.media_player_audio_device
.device
= device
;
486 libvlc_event_send(&mp
->event_manager
, &event
);
489 static const struct vlc_player_cbs vlc_player_cbs
= {
490 .on_current_media_changed
= on_current_media_changed
,
491 .on_state_changed
= on_state_changed
,
492 .on_error_changed
= on_error_changed
,
493 .on_buffering_changed
= on_buffering_changed
,
494 .on_capabilities_changed
= on_capabilities_changed
,
495 .on_position_changed
= on_position_changed
,
496 .on_length_changed
= on_length_changed
,
497 .on_track_list_changed
= on_track_list_changed
,
498 .on_track_selection_changed
= on_track_selection_changed
,
499 .on_program_list_changed
= on_program_list_changed
,
500 .on_program_selection_changed
= on_program_selection_changed
,
501 .on_titles_changed
= on_titles_changed
,
502 .on_title_selection_changed
= on_title_selection_changed
,
503 .on_chapter_selection_changed
= on_chapter_selection_changed
,
504 .on_media_subitems_changed
= on_media_subitems_changed
,
505 .on_cork_changed
= on_cork_changed
,
506 .on_vout_changed
= on_vout_changed
,
509 static const struct vlc_player_aout_cbs vlc_player_aout_cbs
= {
510 .on_volume_changed
= on_volume_changed
,
511 .on_mute_changed
= on_mute_changed
,
512 .on_device_changed
= on_audio_device_changed
,
515 /**************************************************************************
516 * Snapshot Taken Event.
518 * FIXME: This snapshot API interface makes no sense in media_player.
519 *************************************************************************/
520 static int snapshot_was_taken(vlc_object_t
*p_this
, char const *psz_cmd
,
521 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
523 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_this
);
525 libvlc_media_player_t
*mp
= p_data
;
526 libvlc_event_t event
;
527 event
.type
= libvlc_MediaPlayerSnapshotTaken
;
528 event
.u
.media_player_snapshot_taken
.psz_filename
= newval
.psz_string
;
529 libvlc_event_send(&mp
->event_manager
, &event
);
534 static void input_item_preparsed_changed( const vlc_event_t
*p_event
,
537 libvlc_media_t
*p_md
= user_data
;
538 if( p_event
->u
.input_item_preparsed_changed
.new_status
& ITEM_PREPARSED
)
541 libvlc_event_t event
;
542 event
.type
= libvlc_MediaParsedChanged
;
543 event
.u
.media_parsed_changed
.new_status
= libvlc_media_parsed_status_done
;
544 libvlc_event_send( &p_md
->event_manager
, &event
);
548 static void media_attach_preparsed_event( libvlc_media_t
*p_md
)
550 vlc_event_attach( &p_md
->p_input_item
->event_manager
,
551 vlc_InputItemPreparsedChanged
,
552 input_item_preparsed_changed
, p_md
);
555 static void media_detach_preparsed_event( libvlc_media_t
*p_md
)
557 vlc_event_detach( &p_md
->p_input_item
->event_manager
,
558 vlc_InputItemPreparsedChanged
,
559 input_item_preparsed_changed
,
563 /**************************************************************************
564 * Create a Media Instance object.
567 * - All items created by _new start with a refcount set to 1.
568 * - Accessor _release decrease the refcount by 1, if after that
569 * operation the refcount is 0, the object is destroyed.
570 * - Accessor _retain increase the refcount by 1 (XXX: to implement)
572 * Object locking strategy:
573 * - No lock held while in constructor.
574 * - When accessing any member variable this lock is held. (XXX who locks?)
575 * - When attempting to destroy the object the lock is also held.
576 **************************************************************************/
577 libvlc_media_player_t
*
578 libvlc_media_player_new( libvlc_instance_t
*instance
)
580 libvlc_media_player_t
* mp
;
584 mp
= vlc_object_create (instance
->p_libvlc_int
, sizeof(*mp
));
585 if (unlikely(mp
== NULL
))
587 libvlc_printerr("Not enough memory");
592 var_Create (mp
, "rate", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
593 var_Create (mp
, "sout", VLC_VAR_STRING
);
594 var_Create (mp
, "demux-filter", VLC_VAR_STRING
);
597 var_Create (mp
, "vout", VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
598 var_Create (mp
, "window", VLC_VAR_STRING
);
599 var_Create (mp
, "gl", VLC_VAR_STRING
);
600 var_Create (mp
, "gles2", VLC_VAR_STRING
);
601 var_Create (mp
, "vmem-lock", VLC_VAR_ADDRESS
);
602 var_Create (mp
, "vmem-unlock", VLC_VAR_ADDRESS
);
603 var_Create (mp
, "vmem-display", VLC_VAR_ADDRESS
);
604 var_Create (mp
, "vmem-data", VLC_VAR_ADDRESS
);
605 var_Create (mp
, "vmem-setup", VLC_VAR_ADDRESS
);
606 var_Create (mp
, "vmem-cleanup", VLC_VAR_ADDRESS
);
607 var_Create (mp
, "vmem-chroma", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
608 var_Create (mp
, "vmem-width", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
609 var_Create (mp
, "vmem-height", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
610 var_Create (mp
, "vmem-pitch", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
612 var_Create (mp
, "vout-cb-type", VLC_VAR_INTEGER
);
613 var_Create( mp
, "vout-cb-opaque", VLC_VAR_ADDRESS
);
614 var_Create( mp
, "vout-cb-setup", VLC_VAR_ADDRESS
);
615 var_Create( mp
, "vout-cb-cleanup", VLC_VAR_ADDRESS
);
616 var_Create( mp
, "vout-cb-resize-cb", VLC_VAR_ADDRESS
);
617 var_Create( mp
, "vout-cb-update-output", VLC_VAR_ADDRESS
);
618 var_Create( mp
, "vout-cb-swap", VLC_VAR_ADDRESS
);
619 var_Create( mp
, "vout-cb-get-proc-address", VLC_VAR_ADDRESS
);
620 var_Create( mp
, "vout-cb-make-current", VLC_VAR_ADDRESS
);
621 var_Create( mp
, "vout-cb-metadata", VLC_VAR_ADDRESS
);
622 var_Create( mp
, "vout-cb-select-plane", VLC_VAR_ADDRESS
);
624 var_Create (mp
, "dec-dev", VLC_VAR_STRING
);
625 var_Create (mp
, "drawable-xid", VLC_VAR_INTEGER
);
626 #if defined (_WIN32) || defined (__OS2__)
627 var_Create (mp
, "drawable-hwnd", VLC_VAR_INTEGER
);
630 var_Create (mp
, "drawable-nsobject", VLC_VAR_ADDRESS
);
633 var_Create (mp
, "drawable-androidwindow", VLC_VAR_ADDRESS
);
636 var_Create (mp
, "keyboard-events", VLC_VAR_BOOL
);
637 var_SetBool (mp
, "keyboard-events", true);
638 var_Create (mp
, "mouse-events", VLC_VAR_BOOL
);
639 var_SetBool (mp
, "mouse-events", true);
641 var_Create (mp
, "fullscreen", VLC_VAR_BOOL
);
642 var_Create (mp
, "autoscale", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
643 var_Create (mp
, "zoom", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
644 var_Create (mp
, "aspect-ratio", VLC_VAR_STRING
);
645 var_Create (mp
, "crop", VLC_VAR_STRING
);
646 var_Create (mp
, "deinterlace", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
647 var_Create (mp
, "deinterlace-mode", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
649 var_Create (mp
, "vbi-page", VLC_VAR_INTEGER
);
650 var_SetInteger (mp
, "vbi-page", 100);
652 var_Create (mp
, "video-filter", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
653 var_Create (mp
, "sub-source", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
654 var_Create (mp
, "sub-filter", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
656 var_Create (mp
, "marq-marquee", VLC_VAR_STRING
);
657 var_Create (mp
, "marq-color", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
658 var_Create (mp
, "marq-opacity", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
659 var_Create (mp
, "marq-position", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
660 var_Create (mp
, "marq-refresh", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
661 var_Create (mp
, "marq-size", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
662 var_Create (mp
, "marq-timeout", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
663 var_Create (mp
, "marq-x", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
664 var_Create (mp
, "marq-y", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
666 var_Create (mp
, "logo-file", VLC_VAR_STRING
);
667 var_Create (mp
, "logo-x", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
668 var_Create (mp
, "logo-y", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
669 var_Create (mp
, "logo-delay", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
670 var_Create (mp
, "logo-repeat", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
671 var_Create (mp
, "logo-opacity", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
672 var_Create (mp
, "logo-position", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
674 var_Create (mp
, "contrast", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
675 var_Create (mp
, "brightness", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
676 var_Create (mp
, "hue", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
677 var_Create (mp
, "saturation", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
678 var_Create (mp
, "gamma", VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
681 var_Create (mp
, "aout", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
682 var_Create (mp
, "audio-device", VLC_VAR_STRING
);
683 var_Create (mp
, "mute", VLC_VAR_BOOL
);
684 var_Create (mp
, "volume", VLC_VAR_FLOAT
);
685 var_Create (mp
, "corks", VLC_VAR_INTEGER
);
686 var_Create (mp
, "audio-filter", VLC_VAR_STRING
);
687 var_Create (mp
, "role", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
688 var_Create (mp
, "amem-data", VLC_VAR_ADDRESS
);
689 var_Create (mp
, "amem-setup", VLC_VAR_ADDRESS
);
690 var_Create (mp
, "amem-cleanup", VLC_VAR_ADDRESS
);
691 var_Create (mp
, "amem-play", VLC_VAR_ADDRESS
);
692 var_Create (mp
, "amem-pause", VLC_VAR_ADDRESS
);
693 var_Create (mp
, "amem-resume", VLC_VAR_ADDRESS
);
694 var_Create (mp
, "amem-flush", VLC_VAR_ADDRESS
);
695 var_Create (mp
, "amem-drain", VLC_VAR_ADDRESS
);
696 var_Create (mp
, "amem-set-volume", VLC_VAR_ADDRESS
);
697 var_Create (mp
, "amem-format", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
698 var_Create (mp
, "amem-rate", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
699 var_Create (mp
, "amem-channels", VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
702 var_Create (mp
, "video-title-show", VLC_VAR_BOOL
);
703 var_Create (mp
, "video-title-position", VLC_VAR_INTEGER
);
704 var_Create (mp
, "video-title-timeout", VLC_VAR_INTEGER
);
707 var_Create (mp
, "equalizer-preamp", VLC_VAR_FLOAT
);
708 var_Create (mp
, "equalizer-vlcfreqs", VLC_VAR_BOOL
);
709 var_Create (mp
, "equalizer-bands", VLC_VAR_STRING
);
712 mp
->p_libvlc_instance
= instance
;
713 /* use a reentrant lock to allow calling libvlc functions from callbacks */
714 mp
->player
= vlc_player_New(VLC_OBJECT(mp
), VLC_PLAYER_LOCK_REENTRANT
,
716 if (unlikely(!mp
->player
))
719 vlc_player_Lock(mp
->player
);
721 mp
->listener
= vlc_player_AddListener(mp
->player
, &vlc_player_cbs
, mp
);
722 if (unlikely(!mp
->listener
))
726 vlc_player_aout_AddListener(mp
->player
, &vlc_player_aout_cbs
, mp
);
727 if (unlikely(!mp
->aout_listener
))
730 vlc_player_Unlock(mp
->player
);
733 libvlc_event_manager_init(&mp
->event_manager
, mp
);
735 /* Snapshot initialization */
736 /* Attach a var callback to the global object to provide the glue between
737 * vout_thread that generates the event and media_player that re-emits it
738 * with its own event manager
740 * FIXME: It's unclear why we want to put this in public API, and why we
741 * want to expose it in such a limiting and ugly way.
743 var_AddCallback(vlc_object_instance(mp
),
744 "snapshot-file", snapshot_was_taken
, mp
);
746 libvlc_retain(instance
);
750 vlc_player_RemoveListener(mp
->player
, mp
->listener
);
752 vlc_player_Unlock(mp
->player
);
753 vlc_player_Delete(mp
->player
);
755 vlc_object_delete(mp
);
759 /**************************************************************************
760 * Create a Media Instance object with a media descriptor.
761 **************************************************************************/
762 libvlc_media_player_t
*
763 libvlc_media_player_new_from_media( libvlc_media_t
* p_md
)
765 libvlc_media_player_t
* p_mi
;
767 p_mi
= libvlc_media_player_new( p_md
->p_libvlc_instance
);
771 libvlc_media_retain( p_md
);
773 media_attach_preparsed_event(p_md
);
775 vlc_player_Lock(p_mi
->player
);
776 int ret
= vlc_player_SetCurrentMedia(p_mi
->player
, p_md
->p_input_item
);
777 vlc_player_Unlock(p_mi
->player
);
779 if (ret
!= VLC_SUCCESS
)
781 media_detach_preparsed_event(p_md
);
782 libvlc_media_release(p_md
);
790 /**************************************************************************
791 * Destroy a Media Instance object (libvlc internal)
793 * Warning: No lock held here, but hey, this is internal. Caller must lock.
794 **************************************************************************/
795 static void libvlc_media_player_destroy( libvlc_media_player_t
*p_mi
)
799 /* Detach Callback from the main libvlc object */
800 var_DelCallback( vlc_object_instance(p_mi
),
801 "snapshot-file", snapshot_was_taken
, p_mi
);
803 vlc_player_Lock(p_mi
->player
);
804 vlc_player_aout_RemoveListener(p_mi
->player
, p_mi
->aout_listener
);
805 vlc_player_RemoveListener(p_mi
->player
, p_mi
->listener
);
806 vlc_player_Unlock(p_mi
->player
);
808 vlc_player_Delete(p_mi
->player
);
811 media_detach_preparsed_event(p_mi
->p_md
);
812 libvlc_event_manager_destroy(&p_mi
->event_manager
);
813 libvlc_media_release( p_mi
->p_md
);
815 libvlc_instance_t
*instance
= p_mi
->p_libvlc_instance
;
816 vlc_object_delete(p_mi
);
817 libvlc_release(instance
);
820 /**************************************************************************
821 * Release a Media Instance object.
823 * Function does the locking.
824 **************************************************************************/
825 void libvlc_media_player_release( libvlc_media_player_t
*p_mi
)
830 vlc_player_Lock(p_mi
->player
);
831 destroy
= !--p_mi
->i_refcount
;
832 vlc_player_Unlock(p_mi
->player
);
835 libvlc_media_player_destroy( p_mi
);
838 /**************************************************************************
839 * Retain a Media Instance object.
841 * Caller must hold the lock.
842 **************************************************************************/
843 void libvlc_media_player_retain( libvlc_media_player_t
*p_mi
)
847 vlc_player_Lock(p_mi
->player
);
849 vlc_player_Unlock(p_mi
->player
);
852 /**************************************************************************
853 * Set the Media descriptor associated with the instance.
855 * Enter without lock -- function will lock the object.
856 **************************************************************************/
857 void libvlc_media_player_set_media(
858 libvlc_media_player_t
*p_mi
,
859 libvlc_media_t
*p_md
)
861 vlc_player_Lock(p_mi
->player
);
864 media_detach_preparsed_event(p_mi
->p_md
);
866 libvlc_media_release( p_mi
->p_md
);
870 libvlc_media_retain( p_md
);
871 media_attach_preparsed_event(p_md
);
875 vlc_player_SetCurrentMedia(p_mi
->player
, p_md
->p_input_item
);
877 vlc_player_Unlock(p_mi
->player
);
880 /**************************************************************************
881 * Get the Media descriptor associated with the instance.
882 **************************************************************************/
884 libvlc_media_player_get_media( libvlc_media_player_t
*p_mi
)
888 vlc_player_Lock(p_mi
->player
);
891 libvlc_media_retain( p_m
);
892 vlc_player_Unlock(p_mi
->player
);
897 /**************************************************************************
898 * Get the event Manager.
899 **************************************************************************/
900 libvlc_event_manager_t
*
901 libvlc_media_player_event_manager( libvlc_media_player_t
*p_mi
)
903 return &p_mi
->event_manager
;
906 /**************************************************************************
907 * Tell media player to start playing.
908 **************************************************************************/
909 int libvlc_media_player_play( libvlc_media_player_t
*p_mi
)
911 vlc_player_t
*player
= p_mi
->player
;
912 vlc_player_Lock(player
);
914 int ret
= vlc_player_Start(player
);
915 if (ret
== VLC_SUCCESS
)
917 if (vlc_player_IsPaused(player
))
918 vlc_player_Resume(player
);
921 vlc_player_Unlock(player
);
925 void libvlc_media_player_set_pause( libvlc_media_player_t
*p_mi
, int paused
)
927 vlc_player_t
*player
= p_mi
->player
;
928 vlc_player_Lock(player
);
932 if (vlc_player_CanPause(player
))
933 vlc_player_Pause(player
);
935 vlc_player_Stop(player
);
939 vlc_player_Resume(player
);
942 vlc_player_Unlock(player
);
945 /**************************************************************************
947 **************************************************************************/
948 void libvlc_media_player_pause( libvlc_media_player_t
*p_mi
)
950 vlc_player_t
*player
= p_mi
->player
;
951 vlc_player_Lock(player
);
953 vlc_player_TogglePause(player
);
955 vlc_player_Unlock(player
);
958 /**************************************************************************
959 * Tells whether the media player is currently playing.
960 **************************************************************************/
961 bool libvlc_media_player_is_playing(libvlc_media_player_t
*p_mi
)
963 vlc_player_t
*player
= p_mi
->player
;
964 vlc_player_Lock(player
);
966 bool ret
= vlc_player_IsStarted(player
) && !vlc_player_IsPaused(player
);
968 vlc_player_Unlock(player
);
972 /**************************************************************************
974 **************************************************************************/
975 int libvlc_media_player_stop_async( libvlc_media_player_t
*p_mi
)
977 vlc_player_t
*player
= p_mi
->player
;
978 vlc_player_Lock(player
);
980 int ret
= vlc_player_Stop(player
);
982 vlc_player_Unlock(player
);
987 int libvlc_media_player_set_renderer( libvlc_media_player_t
*p_mi
,
988 libvlc_renderer_item_t
*p_litem
)
990 vlc_player_t
*player
= p_mi
->player
;
991 vlc_player_Lock(player
);
993 vlc_renderer_item_t
*renderer
= libvlc_renderer_item_to_vlc(p_litem
);
994 vlc_player_SetRenderer(player
, renderer
);
996 vlc_player_Unlock(player
);
1000 void libvlc_video_set_callbacks( libvlc_media_player_t
*mp
,
1001 void *(*lock_cb
) (void *, void **),
1002 void (*unlock_cb
) (void *, void *, void *const *),
1003 void (*display_cb
) (void *, void *),
1006 var_SetAddress( mp
, "vmem-lock", lock_cb
);
1007 var_SetAddress( mp
, "vmem-unlock", unlock_cb
);
1008 var_SetAddress( mp
, "vmem-display", display_cb
);
1009 var_SetAddress( mp
, "vmem-data", opaque
);
1010 var_SetString( mp
, "dec-dev", "none" );
1011 var_SetString( mp
, "vout", "vmem" );
1012 var_SetString( mp
, "window", "dummy" );
1015 void libvlc_video_set_format_callbacks( libvlc_media_player_t
*mp
,
1016 libvlc_video_format_cb setup
,
1017 libvlc_video_cleanup_cb cleanup
)
1019 var_SetAddress( mp
, "vmem-setup", setup
);
1020 var_SetAddress( mp
, "vmem-cleanup", cleanup
);
1023 void libvlc_video_set_format( libvlc_media_player_t
*mp
, const char *chroma
,
1024 unsigned width
, unsigned height
, unsigned pitch
)
1026 var_SetString( mp
, "vmem-chroma", chroma
);
1027 var_SetInteger( mp
, "vmem-width", width
);
1028 var_SetInteger( mp
, "vmem-height", height
);
1029 var_SetInteger( mp
, "vmem-pitch", pitch
);
1032 bool libvlc_video_set_output_callbacks(libvlc_media_player_t
*mp
,
1033 libvlc_video_engine_t engine
,
1034 libvlc_video_output_setup_cb setup_cb
,
1035 libvlc_video_output_cleanup_cb cleanup_cb
,
1036 libvlc_video_output_set_resize_cb resize_cb
,
1037 libvlc_video_update_output_cb update_output_cb
,
1038 libvlc_video_swap_cb swap_cb
,
1039 libvlc_video_makeCurrent_cb makeCurrent_cb
,
1040 libvlc_video_getProcAddress_cb getProcAddress_cb
,
1041 libvlc_video_frameMetadata_cb metadata_cb
,
1042 libvlc_video_output_select_plane_cb select_plane_cb
,
1045 static_assert(libvlc_video_engine_disable
== 0, "No engine set must default to 0");
1047 //use the default android window
1048 var_SetString( mp
, "window", "");
1050 var_SetString( mp
, "window", "wextern");
1053 if( engine
== libvlc_video_engine_gles2
)
1055 var_SetString ( mp
, "vout", "gles2" );
1056 var_SetString ( mp
, "gles2", "vgl" );
1058 else if( engine
== libvlc_video_engine_opengl
)
1060 var_SetString ( mp
, "vout", "gl" );
1061 var_SetString ( mp
, "gl", "vgl");
1063 else if ( engine
== libvlc_video_engine_d3d11
)
1065 var_SetString ( mp
, "vout", "direct3d11" );
1066 var_SetString ( mp
, "dec-dev", "d3d11" );
1068 else if ( engine
== libvlc_video_engine_d3d9
)
1070 var_SetString ( mp
, "vout", "direct3d9" );
1071 var_SetString ( mp
, "dec-dev", "d3d9" );
1073 else if ( engine
== libvlc_video_engine_disable
)
1075 // use the default display module
1076 var_SetString ( mp
, "vout", "" );
1077 // use the default window
1078 var_SetString( mp
, "window", "");
1083 var_SetInteger( mp
, "vout-cb-type", engine
);
1084 var_SetAddress( mp
, "vout-cb-opaque", opaque
);
1085 var_SetAddress( mp
, "vout-cb-setup", setup_cb
);
1086 var_SetAddress( mp
, "vout-cb-cleanup", cleanup_cb
);
1087 var_SetAddress( mp
, "vout-cb-resize-cb", resize_cb
);
1088 var_SetAddress( mp
, "vout-cb-update-output", update_output_cb
);
1089 var_SetAddress( mp
, "vout-cb-swap", swap_cb
);
1090 var_SetAddress( mp
, "vout-cb-get-proc-address", getProcAddress_cb
);
1091 var_SetAddress( mp
, "vout-cb-make-current", makeCurrent_cb
);
1092 var_SetAddress( mp
, "vout-cb-metadata", metadata_cb
);
1093 var_SetAddress( mp
, "vout-cb-select-plane", select_plane_cb
);
1097 /**************************************************************************
1099 **************************************************************************/
1100 void libvlc_media_player_set_nsobject( libvlc_media_player_t
*p_mi
,
1103 assert (p_mi
!= NULL
);
1105 var_SetString (p_mi
, "dec-dev", "");
1106 var_SetString (p_mi
, "vout", "");
1107 var_SetString (p_mi
, "window", "");
1108 var_SetAddress (p_mi
, "drawable-nsobject", drawable
);
1111 libvlc_printerr ("can't set nsobject: APPLE build required");
1113 var_SetString (p_mi
, "vout", "none");
1114 var_SetString (p_mi
, "window", "none");
1118 /**************************************************************************
1120 **************************************************************************/
1121 void * libvlc_media_player_get_nsobject( libvlc_media_player_t
*p_mi
)
1123 assert (p_mi
!= NULL
);
1125 return var_GetAddress (p_mi
, "drawable-nsobject");
1132 /**************************************************************************
1134 **************************************************************************/
1135 void libvlc_media_player_set_xwindow( libvlc_media_player_t
*p_mi
,
1138 assert (p_mi
!= NULL
);
1140 var_SetString (p_mi
, "dec-dev", "");
1141 var_SetString (p_mi
, "vout", "");
1142 var_SetString (p_mi
, "window", drawable
? "embed-xid,any" : "");
1143 var_SetInteger (p_mi
, "drawable-xid", drawable
);
1146 /**************************************************************************
1148 **************************************************************************/
1149 uint32_t libvlc_media_player_get_xwindow( libvlc_media_player_t
*p_mi
)
1151 return var_GetInteger (p_mi
, "drawable-xid");
1154 /**************************************************************************
1156 **************************************************************************/
1157 void libvlc_media_player_set_hwnd( libvlc_media_player_t
*p_mi
,
1160 assert (p_mi
!= NULL
);
1161 #if defined (_WIN32) || defined (__OS2__)
1162 var_SetString (p_mi
, "dec-dev", "");
1163 var_SetString (p_mi
, "vout", "");
1164 var_SetString (p_mi
, "window",
1165 (drawable
!= NULL
) ? "embed-hwnd,any" : "");
1166 var_SetInteger (p_mi
, "drawable-hwnd", (uintptr_t)drawable
);
1169 libvlc_printerr ("can't set hwnd: WIN32 build required");
1171 var_SetString (p_mi
, "vout", "none");
1172 var_SetString (p_mi
, "window", "none");
1176 /**************************************************************************
1178 **************************************************************************/
1179 void *libvlc_media_player_get_hwnd( libvlc_media_player_t
*p_mi
)
1181 assert (p_mi
!= NULL
);
1182 #if defined (_WIN32) || defined (__OS2__)
1183 return (void *)(uintptr_t)var_GetInteger (p_mi
, "drawable-hwnd");
1190 /**************************************************************************
1191 * set_android_context
1192 **************************************************************************/
1193 void libvlc_media_player_set_android_context( libvlc_media_player_t
*p_mi
,
1194 void *p_awindow_handler
)
1196 assert (p_mi
!= NULL
);
1198 var_SetAddress (p_mi
, "drawable-androidwindow", p_awindow_handler
);
1200 (void) p_awindow_handler
;
1201 libvlc_printerr ("can't set android context: ANDROID build required");
1203 var_SetString (p_mi
, "vout", "none");
1204 var_SetString (p_mi
, "window", "none");
1208 void libvlc_audio_set_callbacks( libvlc_media_player_t
*mp
,
1209 libvlc_audio_play_cb play_cb
,
1210 libvlc_audio_pause_cb pause_cb
,
1211 libvlc_audio_resume_cb resume_cb
,
1212 libvlc_audio_flush_cb flush_cb
,
1213 libvlc_audio_drain_cb drain_cb
,
1216 var_SetAddress( mp
, "amem-play", play_cb
);
1217 var_SetAddress( mp
, "amem-pause", pause_cb
);
1218 var_SetAddress( mp
, "amem-resume", resume_cb
);
1219 var_SetAddress( mp
, "amem-flush", flush_cb
);
1220 var_SetAddress( mp
, "amem-drain", drain_cb
);
1221 var_SetAddress( mp
, "amem-data", opaque
);
1222 var_SetString( mp
, "aout", "amem,none" );
1224 vlc_player_aout_Reset( mp
->player
);
1227 void libvlc_audio_set_volume_callback( libvlc_media_player_t
*mp
,
1228 libvlc_audio_set_volume_cb cb
)
1230 var_SetAddress( mp
, "amem-set-volume", cb
);
1232 vlc_player_aout_Reset( mp
->player
);
1235 void libvlc_audio_set_format_callbacks( libvlc_media_player_t
*mp
,
1236 libvlc_audio_setup_cb setup
,
1237 libvlc_audio_cleanup_cb cleanup
)
1239 var_SetAddress( mp
, "amem-setup", setup
);
1240 var_SetAddress( mp
, "amem-cleanup", cleanup
);
1242 vlc_player_aout_Reset( mp
->player
);
1245 void libvlc_audio_set_format( libvlc_media_player_t
*mp
, const char *format
,
1246 unsigned rate
, unsigned channels
)
1248 var_SetString( mp
, "amem-format", format
);
1249 var_SetInteger( mp
, "amem-rate", rate
);
1250 var_SetInteger( mp
, "amem-channels", channels
);
1252 vlc_player_aout_Reset( mp
->player
);
1256 /**************************************************************************
1257 * Getters for stream information
1258 **************************************************************************/
1259 libvlc_time_t
libvlc_media_player_get_length(
1260 libvlc_media_player_t
*p_mi
)
1262 vlc_player_t
*player
= p_mi
->player
;
1263 vlc_player_Lock(player
);
1265 vlc_tick_t length
= vlc_player_GetLength(player
);
1266 libvlc_time_t i_time
= from_mtime(length
);
1268 vlc_player_Unlock(player
);
1272 libvlc_time_t
libvlc_media_player_get_time( libvlc_media_player_t
*p_mi
)
1274 vlc_player_t
*player
= p_mi
->player
;
1275 vlc_player_Lock(player
);
1277 vlc_tick_t tick
= vlc_player_GetTime(player
);
1278 libvlc_time_t i_time
= from_mtime(tick
);
1280 vlc_player_Unlock(player
);
1284 int libvlc_media_player_set_time( libvlc_media_player_t
*p_mi
,
1285 libvlc_time_t i_time
, bool b_fast
)
1287 vlc_tick_t tick
= to_mtime(i_time
);
1289 vlc_player_t
*player
= p_mi
->player
;
1290 vlc_player_Lock(player
);
1292 enum vlc_player_seek_speed speed
= b_fast
? VLC_PLAYER_SEEK_FAST
1293 : VLC_PLAYER_SEEK_PRECISE
;
1294 vlc_player_SeekByTime(player
, tick
, speed
, VLC_PLAYER_WHENCE_ABSOLUTE
);
1296 vlc_player_Unlock(player
);
1298 /* may not fail anymore, keep int not to break the API */
1302 int libvlc_media_player_set_position( libvlc_media_player_t
*p_mi
,
1303 float position
, bool b_fast
)
1305 vlc_player_t
*player
= p_mi
->player
;
1306 vlc_player_Lock(player
);
1308 enum vlc_player_seek_speed speed
= b_fast
? VLC_PLAYER_SEEK_FAST
1309 : VLC_PLAYER_SEEK_PRECISE
;
1310 vlc_player_SeekByPos(player
, position
, speed
, VLC_PLAYER_WHENCE_ABSOLUTE
);
1312 vlc_player_Unlock(player
);
1314 /* may not fail anymore, keep int not to break the API */
1318 float libvlc_media_player_get_position( libvlc_media_player_t
*p_mi
)
1320 vlc_player_t
*player
= p_mi
->player
;
1321 vlc_player_Lock(player
);
1323 float f_position
= vlc_player_GetPosition(player
);
1325 vlc_player_Unlock(player
);
1329 void libvlc_media_player_set_chapter( libvlc_media_player_t
*p_mi
,
1332 vlc_player_t
*player
= p_mi
->player
;
1333 vlc_player_Lock(player
);
1335 vlc_player_SelectChapterIdx(player
, chapter
);
1337 vlc_player_Unlock(player
);
1340 int libvlc_media_player_get_chapter( libvlc_media_player_t
*p_mi
)
1342 vlc_player_t
*player
= p_mi
->player
;
1343 vlc_player_Lock(player
);
1345 ssize_t i_chapter
= vlc_player_GetSelectedChapterIdx(player
);
1347 vlc_player_Unlock(player
);
1351 int libvlc_media_player_get_chapter_count( libvlc_media_player_t
*p_mi
)
1353 vlc_player_t
*player
= p_mi
->player
;
1354 vlc_player_Lock(player
);
1356 const struct vlc_player_title
*title
= vlc_player_GetSelectedTitle(player
);
1357 int ret
= title
? (int) title
->chapter_count
: -1;
1359 vlc_player_Unlock(player
);
1363 int libvlc_media_player_get_chapter_count_for_title(
1364 libvlc_media_player_t
*p_mi
,
1367 assert(i_title
>= 0);
1368 size_t idx
= i_title
;
1371 vlc_player_t
*player
= p_mi
->player
;
1372 vlc_player_Lock(player
);
1374 vlc_player_title_list
*titles
= vlc_player_GetTitleList(player
);
1378 size_t titles_count
= vlc_player_title_list_GetCount(titles
);
1379 if (idx
< titles_count
)
1382 const struct vlc_player_title
*title
=
1383 vlc_player_title_list_GetAt(titles
, idx
);
1386 ret
= title
->chapter_count
;
1389 vlc_player_Unlock(player
);
1393 void libvlc_media_player_set_title( libvlc_media_player_t
*p_mi
,
1396 vlc_player_t
*player
= p_mi
->player
;
1397 vlc_player_Lock(player
);
1399 vlc_player_SelectTitleIdx(player
, i_title
);
1401 vlc_player_Unlock(player
);
1404 int libvlc_media_player_get_title( libvlc_media_player_t
*p_mi
)
1406 vlc_player_t
*player
= p_mi
->player
;
1407 vlc_player_Lock(player
);
1409 ssize_t i_title
= vlc_player_GetSelectedTitleIdx(player
);
1411 vlc_player_Unlock(player
);
1415 int libvlc_media_player_get_title_count( libvlc_media_player_t
*p_mi
)
1417 vlc_player_t
*player
= p_mi
->player
;
1418 vlc_player_Lock(player
);
1420 vlc_player_title_list
*titles
= vlc_player_GetTitleList(player
);
1421 int ret
= titles
? (int) vlc_player_title_list_GetCount(titles
) : -1;
1423 vlc_player_Unlock(player
);
1427 int libvlc_media_player_get_full_title_descriptions( libvlc_media_player_t
*p_mi
,
1428 libvlc_title_description_t
*** pp_titles
)
1434 vlc_player_t
*player
= p_mi
->player
;
1435 vlc_player_Lock(player
);
1437 vlc_player_title_list
*titles
= vlc_player_GetTitleList(player
);
1441 size_t count
= vlc_player_title_list_GetCount(titles
);
1443 libvlc_title_description_t
**descs
= vlc_alloc(count
, sizeof(*descs
));
1444 if (count
> 0 && !descs
)
1447 for (size_t i
= 0; i
< count
; i
++)
1449 const struct vlc_player_title
*title
=
1450 vlc_player_title_list_GetAt(titles
, i
);
1451 libvlc_title_description_t
*desc
= malloc(sizeof(*desc
));
1454 libvlc_title_descriptions_release(descs
, i
);
1460 /* we want to return milliseconds to match the rest of the API */
1461 desc
->i_duration
= MS_FROM_VLC_TICK(title
->length
);
1462 desc
->i_flags
= title
->flags
;
1463 desc
->psz_name
= title
->name
? strdup(title
->name
) : NULL
;
1470 vlc_player_Unlock(player
);
1474 void libvlc_title_descriptions_release( libvlc_title_description_t
**p_titles
,
1477 for (unsigned i
= 0; i
< i_count
; i
++ )
1482 free( p_titles
[i
]->psz_name
);
1483 free( p_titles
[i
] );
1488 int libvlc_media_player_get_full_chapter_descriptions( libvlc_media_player_t
*p_mi
,
1489 int i_chapters_of_title
,
1490 libvlc_chapter_description_t
*** pp_chapters
)
1496 vlc_player_t
*player
= p_mi
->player
;
1497 vlc_player_Lock(player
);
1499 vlc_player_title_list
*titles
= vlc_player_GetTitleList(player
);
1503 size_t titles_count
= vlc_player_title_list_GetCount(titles
);
1504 if (i_chapters_of_title
< (int) titles_count
)
1507 const struct vlc_player_title
*title
=
1508 vlc_player_title_list_GetAt(titles
, i_chapters_of_title
);
1511 size_t i_chapter_count
= title
->chapter_count
;
1513 libvlc_chapter_description_t
**descs
=
1514 vlc_alloc(i_chapter_count
, sizeof(*descs
));
1515 if (i_chapter_count
> 0 && !descs
)
1518 for (size_t i
= 0; i
< i_chapter_count
; i
++)
1520 const struct vlc_player_chapter
*chapter
= &title
->chapters
[i
];
1521 libvlc_chapter_description_t
*desc
= malloc(sizeof(*desc
));
1524 libvlc_chapter_descriptions_release(descs
, i
);
1530 vlc_tick_t chapter_end
= i
< i_chapter_count
- 1
1531 ? title
->chapters
[i
+ 1].time
1533 desc
->i_time_offset
= MS_FROM_VLC_TICK(chapter
->time
);
1534 desc
->psz_name
= chapter
->name
? strdup(chapter
->name
) : NULL
;
1535 desc
->i_duration
= MS_FROM_VLC_TICK(chapter_end
) - desc
->i_time_offset
;
1538 ret
= i_chapter_count
;
1539 *pp_chapters
= descs
;
1542 vlc_player_Unlock(player
);
1546 void libvlc_chapter_descriptions_release( libvlc_chapter_description_t
**p_chapters
,
1549 for (unsigned i
= 0; i
< i_count
; i
++ )
1551 if ( !p_chapters
[i
] )
1554 free( p_chapters
[i
]->psz_name
);
1555 free( p_chapters
[i
] );
1560 void libvlc_media_player_next_chapter( libvlc_media_player_t
*p_mi
)
1562 vlc_player_t
*player
= p_mi
->player
;
1563 vlc_player_Lock(player
);
1565 vlc_player_SelectNextChapter(player
);
1567 vlc_player_Unlock(player
);
1570 void libvlc_media_player_previous_chapter( libvlc_media_player_t
*p_mi
)
1572 vlc_player_t
*player
= p_mi
->player
;
1573 vlc_player_Lock(player
);
1575 vlc_player_SelectPrevChapter(player
);
1577 vlc_player_Unlock(player
);
1580 int libvlc_media_player_set_rate( libvlc_media_player_t
*p_mi
, float rate
)
1582 vlc_player_t
*player
= p_mi
->player
;
1583 vlc_player_Lock(player
);
1585 vlc_player_ChangeRate(player
, rate
);
1587 vlc_player_Unlock(player
);
1591 float libvlc_media_player_get_rate( libvlc_media_player_t
*p_mi
)
1593 vlc_player_t
*player
= p_mi
->player
;
1594 vlc_player_Lock(player
);
1596 float rate
= vlc_player_GetRate(player
);
1598 vlc_player_Unlock(player
);
1602 libvlc_state_t
libvlc_media_player_get_state( libvlc_media_player_t
*p_mi
)
1604 vlc_player_t
*player
= p_mi
->player
;
1605 vlc_player_Lock(player
);
1607 enum vlc_player_error error
= vlc_player_GetError(player
);
1608 enum vlc_player_state state
= vlc_player_GetState(player
);
1610 vlc_player_Unlock(player
);
1612 if (error
!= VLC_PLAYER_ERROR_NONE
)
1613 return libvlc_Error
;
1615 case VLC_PLAYER_STATE_STOPPED
:
1616 return libvlc_Stopped
;
1617 case VLC_PLAYER_STATE_STOPPING
:
1618 return libvlc_Ended
;
1619 case VLC_PLAYER_STATE_STARTED
:
1620 return libvlc_Opening
;
1621 case VLC_PLAYER_STATE_PLAYING
:
1622 return libvlc_Playing
;
1623 case VLC_PLAYER_STATE_PAUSED
:
1624 return libvlc_Paused
;
1626 vlc_assert_unreachable();
1630 bool libvlc_media_player_is_seekable(libvlc_media_player_t
*p_mi
)
1632 vlc_player_t
*player
= p_mi
->player
;
1633 vlc_player_Lock(player
);
1635 bool b_seekable
= vlc_player_CanSeek(player
);
1637 vlc_player_Unlock(player
);
1641 void libvlc_media_player_navigate( libvlc_media_player_t
* p_mi
,
1644 static const enum vlc_player_nav map
[] =
1646 VLC_PLAYER_NAV_ACTIVATE
, VLC_PLAYER_NAV_UP
, VLC_PLAYER_NAV_DOWN
,
1647 VLC_PLAYER_NAV_LEFT
, VLC_PLAYER_NAV_RIGHT
, VLC_PLAYER_NAV_POPUP
,
1650 if( navigate
>= sizeof(map
) / sizeof(map
[0]) )
1653 vlc_player_t
*player
= p_mi
->player
;
1654 vlc_player_Lock(player
);
1656 vlc_player_Navigate(player
, map
[navigate
]);
1658 vlc_player_Unlock(player
);
1661 /* internal function, used by audio, video */
1662 libvlc_track_description_t
*
1663 libvlc_get_track_description( libvlc_media_player_t
*p_mi
,
1664 enum es_format_category_e cat
)
1666 vlc_player_t
*player
= p_mi
->player
;
1667 vlc_player_Lock(player
);
1669 libvlc_track_description_t
*ret
, **pp
= &ret
;
1671 size_t count
= vlc_player_GetTrackCount(player
, cat
);
1672 for (size_t i
= 0; i
< count
; i
++)
1674 libvlc_track_description_t
*tr
= malloc(sizeof (*tr
));
1675 if (unlikely(tr
== NULL
))
1677 libvlc_printerr("Not enough memory");
1681 const struct vlc_player_track
*track
=
1682 vlc_player_GetTrackAt(player
, cat
, i
);
1685 tr
->i_id
= vlc_es_id_GetInputId(track
->es_id
);
1686 tr
->psz_name
= strdup(track
->name
);
1687 if (unlikely(!tr
->psz_name
))
1697 vlc_player_Unlock(player
);
1701 void libvlc_track_description_list_release( libvlc_track_description_t
*p_td
)
1703 libvlc_track_description_t
*p_actual
, *p_before
;
1708 free( p_actual
->psz_name
);
1709 p_before
= p_actual
;
1710 p_actual
= p_before
->p_next
;
1715 bool libvlc_media_player_can_pause(libvlc_media_player_t
*p_mi
)
1717 vlc_player_t
*player
= p_mi
->player
;
1718 vlc_player_Lock(player
);
1720 bool b_can_pause
= vlc_player_CanPause(player
);
1722 vlc_player_Unlock(player
);
1726 bool libvlc_media_player_program_scrambled(libvlc_media_player_t
*p_mi
)
1728 bool b_program_scrambled
= false;
1730 vlc_player_t
*player
= p_mi
->player
;
1731 vlc_player_Lock(player
);
1733 const struct vlc_player_program
*program
=
1734 vlc_player_GetSelectedProgram(player
);
1738 b_program_scrambled
= program
->scrambled
;
1740 vlc_player_Unlock(player
);
1742 return b_program_scrambled
;
1745 void libvlc_media_player_next_frame( libvlc_media_player_t
*p_mi
)
1747 vlc_player_t
*player
= p_mi
->player
;
1748 vlc_player_Lock(player
);
1750 vlc_player_NextVideoFrame(player
);
1752 vlc_player_Unlock(player
);
1756 * Private lookup table to get subpicture alignment flag values corresponding
1757 * to a libvlc_position_t enumerated value.
1759 static const unsigned char position_subpicture_alignment
[] = {
1760 [libvlc_position_center
] = 0,
1761 [libvlc_position_left
] = SUBPICTURE_ALIGN_LEFT
,
1762 [libvlc_position_right
] = SUBPICTURE_ALIGN_RIGHT
,
1763 [libvlc_position_top
] = SUBPICTURE_ALIGN_TOP
,
1764 [libvlc_position_top_left
] = SUBPICTURE_ALIGN_TOP
| SUBPICTURE_ALIGN_LEFT
,
1765 [libvlc_position_top_right
] = SUBPICTURE_ALIGN_TOP
| SUBPICTURE_ALIGN_RIGHT
,
1766 [libvlc_position_bottom
] = SUBPICTURE_ALIGN_BOTTOM
,
1767 [libvlc_position_bottom_left
] = SUBPICTURE_ALIGN_BOTTOM
| SUBPICTURE_ALIGN_LEFT
,
1768 [libvlc_position_bottom_right
] = SUBPICTURE_ALIGN_BOTTOM
| SUBPICTURE_ALIGN_RIGHT
1771 void libvlc_media_player_set_video_title_display( libvlc_media_player_t
*p_mi
, libvlc_position_t position
, unsigned timeout
)
1773 assert( position
>= libvlc_position_disable
&& position
<= libvlc_position_bottom_right
);
1775 if ( position
!= libvlc_position_disable
)
1777 var_SetBool( p_mi
, "video-title-show", true );
1778 var_SetInteger( p_mi
, "video-title-position", position_subpicture_alignment
[position
] );
1779 var_SetInteger( p_mi
, "video-title-timeout", timeout
);
1783 var_SetBool( p_mi
, "video-title-show", false );
1787 libvlc_media_tracklist_t
*
1788 libvlc_media_player_get_tracklist(libvlc_media_player_t
*p_mi
,
1789 libvlc_track_type_t type
)
1791 vlc_player_t
*player
= p_mi
->player
;
1793 vlc_player_Lock(player
);
1795 libvlc_media_tracklist_t
*list
=
1796 libvlc_media_tracklist_from_player(player
, type
);
1798 vlc_player_Unlock(player
);
1803 libvlc_media_track_t
*
1804 libvlc_media_player_get_selected_track(libvlc_media_player_t
*p_mi
,
1805 libvlc_track_type_t type
)
1807 vlc_player_t
*player
= p_mi
->player
;
1809 vlc_player_Lock(player
);
1811 const enum es_format_category_e cat
= libvlc_track_type_to_escat(type
);
1812 const struct vlc_player_track
*track
=
1813 vlc_player_GetSelectedTrack(player
, cat
);
1817 vlc_player_Unlock(player
);
1821 libvlc_media_track_t
*libtrack
=
1822 libvlc_media_track_create_from_player_track(track
);
1823 vlc_player_Unlock(player
);
1828 libvlc_media_track_t
*
1829 libvlc_media_player_get_track_from_id( libvlc_media_player_t
*p_mi
,
1830 const char *psz_id
)
1832 vlc_player_t
*player
= p_mi
->player
;
1834 vlc_player_Lock(player
);
1836 enum es_format_category_e cats
[] = { VIDEO_ES
, AUDIO_ES
, SPU_ES
};
1837 for (size_t i
= 0; i
< ARRAY_SIZE(cats
); ++i
)
1839 enum es_format_category_e cat
= cats
[i
];
1840 size_t count
= vlc_player_GetTrackCount(player
, cat
);
1842 for (size_t j
= 0; j
< count
; ++j
)
1844 const struct vlc_player_track
*track
=
1845 vlc_player_GetTrackAt(player
, cat
, j
);
1846 if (strcmp(psz_id
, vlc_es_id_GetStrId(track
->es_id
)) == 0)
1848 libvlc_media_track_t
*libtrack
=
1849 libvlc_media_track_create_from_player_track(track
);
1850 vlc_player_Unlock(player
);
1857 vlc_player_Unlock(player
);
1862 libvlc_media_player_select_track(libvlc_media_player_t
*p_mi
,
1863 const libvlc_media_track_t
*track
)
1865 assert( track
!= NULL
);
1866 vlc_player_t
*player
= p_mi
->player
;
1868 vlc_player_Lock(player
);
1870 const libvlc_media_trackpriv_t
*trackpriv
=
1871 libvlc_media_track_to_priv(track
);
1872 vlc_player_SelectEsId(player
, trackpriv
->es_id
,
1873 VLC_PLAYER_SELECT_EXCLUSIVE
);
1875 vlc_player_Unlock(player
);
1879 libvlc_media_player_unselect_track_type( libvlc_media_player_t
*p_mi
,
1880 libvlc_track_type_t type
)
1882 vlc_player_t
*player
= p_mi
->player
;
1883 const enum es_format_category_e cat
= libvlc_track_type_to_escat(type
);
1885 vlc_player_Lock(player
);
1886 vlc_player_UnselectTrackCategory(player
, cat
);
1887 vlc_player_Unlock(player
);
1891 libvlc_media_player_select_tracks(libvlc_media_player_t
*p_mi
,
1892 libvlc_track_type_t type
,
1893 const libvlc_media_track_t
**tracks
,
1896 vlc_player_t
*player
= p_mi
->player
;
1898 vlc_es_id_t
**es_id_list
= vlc_alloc(track_count
+ 1, sizeof(vlc_es_id_t
*));
1899 size_t es_id_idx
= 0;
1901 if (es_id_list
== NULL
)
1904 const enum es_format_category_e cat
= libvlc_track_type_to_escat(type
);
1906 vlc_player_Lock(player
);
1908 for (size_t i
= 0; i
< track_count
; ++i
)
1910 const libvlc_media_track_t
*track
= tracks
[i
];
1911 const libvlc_media_trackpriv_t
*trackpriv
=
1912 libvlc_media_track_to_priv(track
);
1914 es_id_list
[es_id_idx
++] = trackpriv
->es_id
;
1916 es_id_list
[es_id_idx
++] = NULL
;
1917 vlc_player_SelectEsIdList(player
, cat
, es_id_list
);
1919 vlc_player_Unlock(player
);
1925 libvlc_media_player_select_tracks_by_ids( libvlc_media_player_t
*p_mi
,
1926 libvlc_track_type_t type
,
1927 const char *psz_ids
)
1929 const enum es_format_category_e cat
= libvlc_track_type_to_escat(type
);
1931 vlc_player_t
*player
= p_mi
->player
;
1933 vlc_player_Lock(player
);
1935 vlc_player_SelectTracksByStringIds(player
, cat
, psz_ids
);
1937 vlc_player_Unlock(player
);
1940 int libvlc_media_player_add_slave( libvlc_media_player_t
*p_mi
,
1941 libvlc_media_slave_type_t i_type
,
1942 const char *psz_uri
, bool b_select
)
1944 vlc_player_t
*player
= p_mi
->player
;
1945 vlc_player_Lock(player
);
1947 enum es_format_category_e cat
= i_type
== libvlc_media_slave_type_subtitle
1951 int ret
= vlc_player_AddAssociatedMedia(player
, cat
, psz_uri
, b_select
,
1954 vlc_player_Unlock(player
);
1959 * Maximum size of a formatted equalizer amplification band frequency value.
1961 * The allowed value range is supposed to be constrained from -20.0 to 20.0.
1963 * The format string " %.07f" with a minimum value of "-20" gives a maximum
1964 * string length of e.g. " -19.1234567", i.e. 12 bytes (not including the null
1967 #define EQZ_BAND_VALUE_SIZE 12
1969 int libvlc_media_player_set_equalizer( libvlc_media_player_t
*p_mi
, libvlc_equalizer_t
*p_equalizer
)
1971 char bands
[EQZ_BANDS_MAX
* EQZ_BAND_VALUE_SIZE
+ 1];
1973 if( p_equalizer
!= NULL
)
1975 for( unsigned i
= 0, c
= 0; i
< EQZ_BANDS_MAX
; i
++ )
1977 c
+= snprintf( bands
+ c
, sizeof(bands
) - c
, " %.07f",
1978 p_equalizer
->f_amp
[i
] );
1979 if( unlikely(c
>= sizeof(bands
)) )
1983 var_SetFloat( p_mi
, "equalizer-preamp", p_equalizer
->f_preamp
);
1984 var_SetString( p_mi
, "equalizer-bands", bands
);
1986 var_SetString( p_mi
, "audio-filter", p_equalizer
? "equalizer" : "" );
1988 audio_output_t
*p_aout
= vlc_player_aout_Hold( p_mi
->player
);
1989 if( p_aout
!= NULL
)
1991 if( p_equalizer
!= NULL
)
1993 var_SetFloat( p_aout
, "equalizer-preamp", p_equalizer
->f_preamp
);
1994 var_SetString( p_aout
, "equalizer-bands", bands
);
1997 var_SetString( p_aout
, "audio-filter", p_equalizer
? "equalizer" : "" );
1998 aout_Release(p_aout
);
2005 static libvlc_player_program_t
*
2006 libvlc_player_program_new(const struct vlc_player_program
*program
)
2008 libvlc_player_program_t
*libprogram
= malloc(sizeof(*libprogram
));
2009 if (libprogram
== NULL
)
2012 libprogram
->i_group_id
= program
->group_id
;
2013 libprogram
->psz_name
= strdup(program
->name
);
2014 libprogram
->b_selected
= program
->selected
;
2015 libprogram
->b_scrambled
= program
->scrambled
;
2021 libvlc_player_program_delete( libvlc_player_program_t
*program
)
2023 free( program
->psz_name
);
2027 void libvlc_media_player_select_program_id( libvlc_media_player_t
*p_mi
,
2030 vlc_player_t
*player
= p_mi
->player
;
2032 vlc_player_Lock(player
);
2034 vlc_player_SelectProgram(player
, program_id
);
2036 vlc_player_Unlock(player
);
2039 libvlc_player_program_t
*
2040 libvlc_media_player_get_selected_program( libvlc_media_player_t
*p_mi
)
2042 vlc_player_t
*player
= p_mi
->player
;
2044 vlc_player_Lock(player
);
2046 const struct vlc_player_program
*program
= vlc_player_GetSelectedProgram( player
);
2047 if( program
== NULL
)
2049 vlc_player_Unlock(player
);
2052 libvlc_player_program_t
*libprogram
= libvlc_player_program_new(program
);
2054 vlc_player_Unlock(player
);
2059 libvlc_player_program_t
*
2060 libvlc_media_player_get_program_from_id( libvlc_media_player_t
*p_mi
, int i_group_id
)
2062 vlc_player_t
*player
= p_mi
->player
;
2064 vlc_player_Lock(player
);
2066 libvlc_player_program_t
*libprogram
= NULL
;
2068 size_t count
= vlc_player_GetProgramCount(player
);
2069 for (size_t i
= 0; i
< count
; ++i
)
2071 const struct vlc_player_program
*program
=
2072 vlc_player_GetProgramAt(player
, i
);
2074 if (program
->group_id
== i_group_id
)
2076 libprogram
= libvlc_player_program_new(program
);
2081 vlc_player_Unlock(player
);
2086 struct libvlc_player_programlist_t
2089 libvlc_player_program_t
*programs
[];
2093 libvlc_player_programlist_count( const libvlc_player_programlist_t
*list
)
2098 libvlc_player_program_t
*
2099 libvlc_player_programlist_at( libvlc_player_programlist_t
*list
, size_t index
)
2101 assert(index
< list
->count
);
2102 return list
->programs
[index
];
2106 libvlc_player_programlist_delete( libvlc_player_programlist_t
*list
)
2108 for (size_t i
= 0; i
< list
->count
; ++i
)
2109 libvlc_player_program_delete(list
->programs
[i
]);
2113 libvlc_player_programlist_t
*
2114 libvlc_media_player_get_programlist( libvlc_media_player_t
*p_mi
)
2116 vlc_player_t
*player
= p_mi
->player
;
2118 vlc_player_Lock(player
);
2120 size_t count
= vlc_player_GetProgramCount(player
);
2125 if( mul_overflow( count
, sizeof(libvlc_player_program_t
*), &size
) )
2127 if( add_overflow( size
, sizeof(libvlc_player_programlist_t
), &size
) )
2130 libvlc_player_programlist_t
*list
= malloc( size
);
2135 for (size_t i
= 0; i
< count
; ++i
)
2137 const struct vlc_player_program
*program
=
2138 vlc_player_GetProgramAt(player
, i
);
2140 list
->programs
[i
] = libvlc_player_program_new(program
);
2141 if (list
->programs
[i
] == NULL
)
2143 libvlc_player_programlist_delete(list
);
2150 vlc_player_Unlock(player
);
2155 vlc_player_Unlock(player
);
2159 static const char roles
[][16] =
2161 [libvlc_role_Music
] = "music",
2162 [libvlc_role_Video
] = "video",
2163 [libvlc_role_Communication
] = "communication",
2164 [libvlc_role_Game
] = "game",
2165 [libvlc_role_Notification
] = "notification",
2166 [libvlc_role_Animation
] = "animation",
2167 [libvlc_role_Production
] = "production",
2168 [libvlc_role_Accessibility
] = "accessibility",
2169 [libvlc_role_Test
] = "test",
2172 int libvlc_media_player_set_role(libvlc_media_player_t
*mp
, unsigned role
)
2174 if (role
>= ARRAY_SIZE(roles
)
2175 || var_SetString(mp
, "role", roles
[role
]) != VLC_SUCCESS
)
2180 int libvlc_media_player_get_role(libvlc_media_player_t
*mp
)
2183 char *str
= var_GetString(mp
, "role");
2187 for (size_t i
= 0; i
< ARRAY_SIZE(roles
); i
++)
2188 if (!strcmp(roles
[i
], str
))
2198 #include <vlc_vout_display.h>
2200 /* make sure surface structures from libvlc can be passed as such to vlc
2201 otherwise we will need wrappers between what libvlc understands and what vlc uses */
2202 #define cast_ libvlc_video_color_space_t
2203 static_assert(libvlc_video_colorspace_BT601
== (cast_
)COLOR_SPACE_BT601
&&
2204 libvlc_video_colorspace_BT709
== (cast_
)COLOR_SPACE_BT709
&&
2205 libvlc_video_colorspace_BT2020
== (cast_
)COLOR_SPACE_BT2020
2206 , "libvlc video colorspace mismatch");
2209 #define cast_ libvlc_video_transfer_func_t
2210 static_assert(libvlc_video_transfer_func_LINEAR
== (cast_
)TRANSFER_FUNC_LINEAR
&&
2211 libvlc_video_transfer_func_SRGB
== (cast_
)TRANSFER_FUNC_SRGB
&&
2212 libvlc_video_transfer_func_BT470_BG
== (cast_
)TRANSFER_FUNC_BT470_BG
&&
2213 libvlc_video_transfer_func_BT470_M
== (cast_
)TRANSFER_FUNC_BT470_M
&&
2214 libvlc_video_transfer_func_BT709
== (cast_
)TRANSFER_FUNC_BT709
&&
2215 libvlc_video_transfer_func_PQ
== (cast_
)TRANSFER_FUNC_SMPTE_ST2084
&&
2216 libvlc_video_transfer_func_SMPTE_240
== (cast_
)TRANSFER_FUNC_SMPTE_240
&&
2217 libvlc_video_transfer_func_HLG
== (cast_
)TRANSFER_FUNC_HLG
2218 , "libvlc video transfer function mismatch");
2221 #define cast_ libvlc_video_color_primaries_t
2222 static_assert(libvlc_video_primaries_BT601_525
== (cast_
)COLOR_PRIMARIES_BT601_525
&&
2223 libvlc_video_primaries_BT601_625
== (cast_
)COLOR_PRIMARIES_BT601_625
&&
2224 libvlc_video_primaries_BT709
== (cast_
)COLOR_PRIMARIES_BT709
&&
2225 libvlc_video_primaries_BT2020
== (cast_
)COLOR_PRIMARIES_BT2020
&&
2226 libvlc_video_primaries_DCI_P3
== (cast_
)COLOR_PRIMARIES_DCI_P3
&&
2227 libvlc_video_primaries_BT470_M
== (cast_
)COLOR_PRIMARIES_BT470_M
2228 , "libvlc video color primaries mismatch");