VLC 4.0.0-dev
Loading...
Searching...
No Matches
player.h
Go to the documentation of this file.
1/*****************************************************************************
2 * player.h: Player internal interface
3 *****************************************************************************
4 * Copyright © 2018-2019 VLC authors and VideoLAN
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#ifndef VLC_PLAYER_INTERNAL_H
22#define VLC_PLAYER_INTERNAL_H
23
24#include <vlc_player.h>
25#include <vlc_list.h>
26#include <vlc_vector.h>
27#include <vlc_atomic.h>
28#include <vlc_media_library.h>
29
31
33{
35 vout_thread_t *vout; /* weak reference */
37 /* only valid if selected and if category is VIDEO_ES or SPU_ES */
39 /* Used to save or not the track selection */
41};
42
43typedef struct VLC_VECTOR(struct vlc_player_program *)
45
46typedef struct VLC_VECTOR(struct vlc_player_track_priv *)
48
55
57{
60 bool started;
61
62 /* Monitor the OPENING_S -> PLAYING_S transition. */
63 bool playing;
64
67 float rate;
70
71 double position;
74
76
78
81 float cache;
82
84
86
92
94
97
98 struct vlc_list node;
99
103
104 struct
105 {
107 double pos;
108 bool set;
110
111 struct
112 {
114 enum
115 {
120 float pos;
123 /* Keep a trace of tracks as they appear since they won't be available
124 * for probing when the input gets stopped
125 */
128 } ml;
129};
130
132{
133 const struct vlc_player_cbs *cbs;
134 void *cbs_data;
136};
137
150
157
164
171
186
188{
189 struct vlc_list listeners; /* list of struct vlc_player_timer_id */
190 vlc_es_id_t *es; /* weak reference */
192 union
193 {
194 struct {
195 unsigned long last_framenum;
196 unsigned frame_rate;
199 unsigned df_fps;
200 int df;
203 };
204};
205
212
214{
216
218
223
227
229#define best_source sources[VLC_PLAYER_TIMER_TYPE_BEST]
230#define smpte_source sources[VLC_PLAYER_TIMER_TYPE_SMPTE]
231};
232
234{
241
244
247
249 bool corked;
250
255
258
261
265
269
272
273 /**
274 * Playing a tiny stream (either empty, or with unreported errors) in a loop
275 * would cause high CPU usage. To mitigate the problem, temporize if
276 * several EOS are received too quickly.
277 */
278#define VLC_PLAYER_EOS_BURST_THRESHOLD VLC_TICK_FROM_MS(250)
281
283 struct
284 {
292
294};
295
296#ifndef NDEBUG
297/*
298 * Assert that the player mutex is locked.
299 *
300 * This is exposed in this internal header because the playlist and its
301 * associated player share the lock to avoid lock-order inversion issues.
302 */
303static inline void
305{
306 assert(player);
307 vlc_mutex_assert(&player->lock);
308}
309#else
310#define vlc_player_assert_locked(x) ((void) (0))
311#endif
312
313static inline struct vlc_player_input *
319
320#define vlc_player_SendEvent(player, event, ...) do { \
321 vlc_player_listener_id *listener; \
322 vlc_list_foreach(listener, &player->listeners, node) \
323 { \
324 if (listener->cbs->event) \
325 listener->cbs->event(player, ##__VA_ARGS__, listener->cbs_data); \
326 } \
327} while(0)
328
329static inline const char *
331{
332 switch (cat)
333 {
334 case VIDEO_ES: return "Video";
335 case AUDIO_ES: return "Audio";
336 case SPU_ES: return "Subtitle";
337 default: return NULL;
338 }
339}
340
341/*
342 * player.c
343 */
344
347
348int
350
351void
353
354void
356 struct vlc_player_input *input);
357
358void
360 struct vlc_player_input *input);
361
362/*
363 * player_track.c
364 */
365
366struct vlc_player_program *
367vlc_player_program_New(int id, const char *name);
368
369int
371 const char *name);
372
373struct vlc_player_program *
375 size_t *idx);
376
378vlc_player_track_priv_New(vlc_es_id_t *id, const char *name, const es_format_t *fmt);
379
380void
382
383int
385 const char *name, const es_format_t *fmt);
386
389 size_t *idx);
390
391int
393
394/*
395 * player_title.c
396 */
397
400 int title_offset, int chapter_offset);
401
402/*
403 * player_input.c
404 */
405
406static inline vlc_player_track_vector *
408 enum es_format_category_e cat)
409{
410 switch (cat)
411 {
412 case VIDEO_ES:
413 return &input->video_track_vector;
414 case AUDIO_ES:
415 return &input->audio_track_vector;
416 case SPU_ES:
417 return &input->spu_track_vector;
418 default:
419 return NULL;
420 }
421}
422
425 size_t *idx);
426
427struct vlc_player_input *
429
430void
432
433void
435 enum es_format_category_e cat,
436 const char *str_ids);
437
438char *
441
443vlc_player_input_GetTime(struct vlc_player_input *input, bool seeking,
444 vlc_tick_t system_now);
445
446double
447vlc_player_input_GetPos(struct vlc_player_input *input, bool seeking,
448 vlc_tick_t system_now);
449
450int
452
453void
455 enum vlc_player_seek_speed speed,
456 enum vlc_player_whence whence);
457
458void
460 enum vlc_player_seek_speed speed,
461 enum vlc_player_whence whence);
462
463void
465 const vlc_viewpoint_t *viewpoint,
466 enum vlc_player_whence whence);
467
468void
470 vlc_tick_t state_date);
471
472/*
473 * player_timer.c
474*/
475
476void
478
479void
481
482void
484
485void
488 vlc_tick_t system_date);
489
490void
492 double position);
493
494void
496 bool es_source_is_master,
497 const struct vlc_player_timer_point *point,
499 unsigned frame_rate, unsigned frame_rate_base);
500
501void
503
504int
506 vlc_tick_t system_now,
507 vlc_tick_t *out_ts, double *out_pos);
508
509/*
510 * player_vout.c
511 */
512
513void
515
516void
518
519/*
520 * player_aout.c
521 */
522
525
526void
528
529/*
530 * player_osd.c
531 */
532
533void
534vlc_player_osd_Message(vlc_player_t *player, const char *fmt, ...);
535
536void
538
539void
541 struct vlc_player_input *input, vlc_tick_t time,
542 double position);
543void
544vlc_player_osd_Volume(vlc_player_t *player, bool mute_action);
545
546int
548 vlc_value_t oldval, vlc_value_t newval, void *data);
549
550void
552
553void
555
556void
558
559/*
560 * player/medialib.c
561 */
562
563void
564vlc_player_input_RestoreMlStates(struct vlc_player_input* input, bool force_pos);
565
566void
568
569#endif
size_t count
Definition core.c:403
#define VLC_MALLOC
Definition vlc_common.h:157
#define vlc_mutex_assert(m)
Asserts that a mutex is locked by the calling thread.
Definition vlc_threads.h:248
#define VLC_VECTOR(type)
Vector struct body.
Definition vlc_vector.h:66
vlc_vout_order
vout or spu_channel order
Definition vlc_vout.h:70
vlc_player_media_stopped_action
Action when the player is stopped.
Definition vlc_player.h:96
vlc_player_metadata_option
Player metadata option.
Definition vlc_player.h:2202
vlc_player_state
State of the player.
Definition vlc_player.h:245
vlc_player_whence
Player seek/delay directive.
Definition vlc_player.h:318
vlc_player_seek_speed
Seek speed type.
Definition vlc_player.h:303
vlc_player_error
Error of the player.
Definition vlc_player.h:291
const char name[16]
Definition httpd.c:1298
static thread_local struct @81 state
const char var[sizeof("video")]
Definition player.c:1712
vlc_tick_t vlc_player_input_GetTime(struct vlc_player_input *input, bool seeking, vlc_tick_t system_now)
Definition input.c:62
struct vlc_player_program * vlc_player_program_New(int id, const char *name)
Definition track.c:42
void vlc_player_ResetTimer(vlc_player_t *player)
Definition timer.c:30
static struct vlc_player_input * vlc_player_get_input_locked(vlc_player_t *player)
Definition player.h:314
int vlc_player_vout_OSDCallback(vlc_object_t *this, const char *var, vlc_value_t oldval, vlc_value_t newval, void *data)
Definition osd.c:282
void vlc_player_osd_Tracks(vlc_player_t *player, vlc_es_id_t *const *selected, vlc_es_id_t *unselect)
Definition osd.c:189
static void vlc_player_assert_locked(vlc_player_t *player)
Definition player.h:304
struct vlc_player_program * vlc_player_program_vector_FindById(vlc_player_program_vector *vec, int id, size_t *idx)
Definition track.c:89
void vlc_player_PrepareNextMedia(vlc_player_t *player)
Definition player.c:55
void vlc_player_input_SelectTracksByStringIds(struct vlc_player_input *input, enum es_format_category_e cat, const char *str_ids)
Definition input.c:1062
void vlc_player_input_RestoreMlStates(struct vlc_player_input *input, bool force_pos)
Definition medialib.c:30
void vlc_player_destructor_AddStoppingInput(vlc_player_t *player, struct vlc_player_input *input)
Definition player.c:168
int vlc_player_OpenNextMedia(vlc_player_t *player)
Definition player.c:71
struct vlc_player_track_priv * vlc_player_track_priv_New(vlc_es_id_t *id, const char *name, const es_format_t *fmt)
Definition track.c:106
struct vlc_player_track_priv * vlc_player_input_FindTrackById(struct vlc_player_input *input, vlc_es_id_t *id, size_t *idx)
Definition input.c:31
void vlc_player_destructor_AddJoinableInput(vlc_player_t *player, struct vlc_player_input *input)
Definition player.c:182
void vlc_player_UpdateTimerState(vlc_player_t *player, vlc_es_id_t *es_source, enum vlc_player_timer_state state, vlc_tick_t system_date)
Definition timer.c:193
void vlc_player_osd_Message(vlc_player_t *player, const char *fmt,...)
Definition osd.c:89
void vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input *input)
Definition medialib.c:171
void vlc_player_osd_Position(vlc_player_t *player, struct vlc_player_input *input, vlc_tick_t time, double position)
Definition osd.c:120
double vlc_player_input_GetPos(struct vlc_player_input *input, bool seeking, vlc_tick_t system_now)
Definition input.c:75
char * vlc_player_input_GetSelectedTrackStringIds(struct vlc_player_input *input, enum es_format_category_e cat)
Definition input.c:1070
void vlc_player_input_HandleState(struct vlc_player_input *, enum vlc_player_state, vlc_tick_t state_date)
Definition input.c:214
vlc_object_t * vlc_player_GetObject(vlc_player_t *player)
Definition player.c:2022
void vlc_player_UpdateTimer(vlc_player_t *player, vlc_es_id_t *es_source, bool es_source_is_master, const struct vlc_player_timer_point *point, vlc_tick_t normal_time, unsigned frame_rate, unsigned frame_rate_base)
Definition timer.c:332
void vlc_player_input_SeekByPos(struct vlc_player_input *input, double position, enum vlc_player_seek_speed speed, enum vlc_player_whence whence)
Definition input.c:121
struct vlc_player_title_list * vlc_player_title_list_Create(input_title_t *const *array, size_t count, int title_offset, int chapter_offset)
Definition title.c:99
void vlc_player_osd_Track(vlc_player_t *player, vlc_es_id_t *id, bool select)
Definition osd.c:175
int vlc_player_program_Update(struct vlc_player_program *prgm, int id, const char *name)
Definition track.c:60
vlc_player_timer_state
Definition player.h:207
@ VLC_PLAYER_TIMER_STATE_PAUSED
Definition player.h:209
@ VLC_PLAYER_TIMER_STATE_PLAYING
Definition player.h:208
@ VLC_PLAYER_TIMER_STATE_DISCONTINUITY
Definition player.h:210
void vlc_player_DestroyTimer(vlc_player_t *player)
Definition timer.c:661
struct vlc_player_track_priv * vlc_player_track_vector_FindById(vlc_player_track_vector *vec, vlc_es_id_t *id, size_t *idx)
Definition track.c:194
audio_output_t * vlc_player_aout_Init(vlc_player_t *player)
Definition aout.c:224
void vlc_player_vout_AddCallbacks(vlc_player_t *player, vout_thread_t *vout)
Definition vout.c:140
struct vlc_player_input * vlc_player_input_New(vlc_player_t *player, input_item_t *item)
Definition input.c:1102
void vlc_player_RemoveTimerSource(vlc_player_t *player, vlc_es_id_t *es_source)
Definition timer.c:468
int vlc_player_GetFirstSelectedTrackId(const vlc_player_track_vector *tracks)
Definition track.c:212
void vlc_player_input_Delete(struct vlc_player_input *input)
Definition input.c:1200
void vlc_player_input_SeekByTime(struct vlc_player_input *input, vlc_tick_t time, enum vlc_player_seek_speed speed, enum vlc_player_whence whence)
Definition input.c:149
void vlc_player_track_priv_Delete(struct vlc_player_track_priv *trackpriv)
Definition track.c:139
void vlc_player_input_UpdateViewpoint(struct vlc_player_input *input, const vlc_viewpoint_t *viewpoint, enum vlc_player_whence whence)
Definition input.c:175
void vlc_player_osd_Program(vlc_player_t *player, const char *name)
Definition osd.c:246
void vlc_player_osd_Icon(vlc_player_t *player, short type)
Definition osd.c:109
void vlc_player_vout_DelCallbacks(vlc_player_t *player, vout_thread_t *vout)
Definition vout.c:150
void vlc_player_aout_Deinit(vlc_player_t *player)
Definition aout.c:236
void vlc_player_osd_Volume(vlc_player_t *player, bool mute_action)
Definition osd.c:155
void vlc_player_UpdateTimerSeekState(vlc_player_t *player, vlc_tick_t time, double position)
Definition timer.c:264
int vlc_player_track_priv_Update(struct vlc_player_track_priv *trackpriv, const char *name, const es_format_t *fmt)
Definition track.c:169
static vlc_player_track_vector * vlc_player_input_GetTrackVector(struct vlc_player_input *input, enum es_format_category_e cat)
Definition player.h:407
void vlc_player_InitTimer(vlc_player_t *player)
Definition timer.c:647
int vlc_player_input_Start(struct vlc_player_input *input)
Definition input.c:100
static const char * es_format_category_to_string(enum es_format_category_e cat)
Definition player.h:330
vlc_player_timer_source_type
Definition player.h:166
@ VLC_PLAYER_TIMER_TYPE_SMPTE
Definition player.h:168
@ VLC_PLAYER_TIMER_TYPE_COUNT
Definition player.h:169
@ VLC_PLAYER_TIMER_TYPE_BEST
Definition player.h:167
int vlc_player_GetTimerPoint(vlc_player_t *player, bool seeking, vlc_tick_t system_now, vlc_tick_t *out_ts, double *out_pos)
Definition timer.c:493
Audio output object.
Definition vlc_aout.h:155
Definition vlc_es.h:633
Describes an input and is used to spawn input_thread_t objects.
Definition vlc_input_item.h:98
Definition resource.c:58
Definition vlc_input_item.h:551
Main structure representing an input thread.
Definition input_internal.h:42
Definition vlc_input.h:103
Definition vlc_atomic.h:48
Definition meter.c:34
Condition variable.
Definition vlc_threads.h:270
Opaque structure representing an ES (Elementary Stream) track.
Definition es_out.c:99
Doubly-linked list node.
Definition vlc_list.h:44
Definition vlc_media_library.h:644
Mutex.
Definition vlc_threads.h:143
VLC object common members.
Definition vlc_objects.h:53
Player aout callbacks.
Definition vlc_player.h:2319
Definition player.h:159
struct vlc_list node
Definition player.h:162
void * cbs_data
Definition player.h:161
const struct vlc_player_aout_cbs * cbs
Definition player.h:160
Player callbacks.
Definition vlc_player.h:2776
Definition player.h:57
@ VLC_RESTOREPOINT_NONE
Definition player.h:118
bool set
Definition player.h:108
vlc_tick_t pause_date
Definition player.h:75
unsigned teletext_page
Definition player.h:102
bool has_audio_tracks
Definition player.h:127
const struct vlc_player_track_priv * teletext_source
Definition player.h:91
vlc_player_t * player
Definition player.h:59
vlc_player_track_vector spu_track_vector
Definition player.h:90
bool started
Definition player.h:60
float signal_quality
Definition player.h:79
vlc_tick_t time
Definition player.h:72
float signal_strength
Definition player.h:80
size_t title_selected
Definition player.h:95
vlc_player_program_vector program_vector
Definition player.h:87
size_t chapter_selected
Definition player.h:96
struct vlc_player_input::@108 ml
struct input_stats_t stats
Definition player.h:83
vlc_player_track_vector audio_track_vector
Definition player.h:89
bool restore_states
Definition player.h:121
vlc_player_track_vector video_track_vector
Definition player.h:88
vlc_tick_t cat_delays[DATA_ES]
Definition player.h:85
int capabilities
Definition player.h:68
double position
Definition player.h:71
@ VLC_RESTOREPOINT_POSITION
Definition player.h:117
enum vlc_player_state state
Definition player.h:65
vlc_tick_t length
Definition player.h:69
struct vlc_list node
Definition player.h:98
vlc_tick_t normal_time
Definition player.h:73
bool playing
Definition player.h:63
float rate
Definition player.h:67
bool teletext_transparent
Definition player.h:101
@ VLC_RESTOREPOINT_TITLE
Definition player.h:116
bool recording
Definition player.h:77
bool has_video_tracks
Definition player.h:126
struct vlc_player_input::@107 abloop_state[2]
float cache
Definition player.h:81
bool teletext_enabled
Definition player.h:100
enum vlc_player_input::@108::@109 restore
struct vlc_player_title_list * titles
Definition player.h:93
vlc_ml_playback_states_all states
Definition player.h:113
input_thread_t * thread
Definition player.h:58
bool delay_restore
Definition player.h:122
float pos
Definition player.h:120
double pos
Definition player.h:107
enum vlc_player_error error
Definition player.h:66
Definition player.h:132
struct vlc_list node
Definition player.h:135
const struct vlc_player_cbs * cbs
Definition player.h:133
void * cbs_data
Definition player.h:134
Callbacks for the owner of the player.
Definition vlc_player.h:118
Definition player.h:139
vlc_audio_meter_plugin * audio_meter
Definition player.h:146
enum vlc_player_metadata_option option
Definition player.h:143
struct vlc_list node
Definition player.h:148
void * cbs_data
Definition player.h:141
const union vlc_player_metadata_cbs * cbs
Definition player.h:140
Definition player.h:43
Player program structure.
Definition vlc_player.h:1187
Definition player.h:234
void * media_provider_data
Definition player.h:246
vlc_cond_t wait
Definition player.h:286
bool releasing_media
Definition player.h:262
struct vlc_player_t::@117 destructor
enum vlc_player_media_stopped_action media_stopped_action
Definition player.h:242
struct vlc_object_t obj
Definition player.h:235
bool next_media_requested
Definition player.h:263
struct vlc_list joinable_inputs
Definition player.h:290
vlc_mutex_t vout_listeners_lock
Definition player.h:239
vlc_mutex_t metadata_listeners_lock
Definition player.h:237
struct vlc_list listeners
Definition player.h:251
input_item_t * next_media
Definition player.h:264
vlc_thread_t thread
Definition player.h:285
bool started
Definition player.h:271
unsigned eos_burst_count
Definition player.h:280
struct vlc_player_timer timer
Definition player.h:293
vlc_cond_t notify
Definition player.h:287
struct vlc_list stopping_inputs
Definition player.h:289
bool deleting
Definition player.h:282
struct vlc_list aout_listeners
Definition player.h:253
struct vlc_list vout_listeners
Definition player.h:254
struct vlc_list inputs
Definition player.h:288
vlc_mutex_t lock
Definition player.h:236
char * audio_string_ids
Definition player.h:267
bool corked
Definition player.h:249
vlc_mutex_t aout_listeners_lock
Definition player.h:238
input_resource_t * resource
Definition player.h:256
enum vlc_player_state global_state
Definition player.h:270
bool start_paused
Definition player.h:243
char * video_string_ids
Definition player.h:266
vlc_tick_t last_eos
Definition player.h:279
vlc_renderer_item_t * renderer
Definition player.h:257
const struct vlc_player_media_provider * media_provider
Definition player.h:245
char * sub_string_ids
Definition player.h:268
input_item_t * media
Definition player.h:259
vlc_cond_t start_delay_cond
Definition player.h:240
struct vlc_list metadata_listeners
Definition player.h:252
struct vlc_player_input * input
Definition player.h:260
bool pause_on_cork
Definition player.h:248
Player timer callbacks.
Definition vlc_player.h:3371
Definition player.h:173
struct vlc_list node
Definition player.h:184
const struct vlc_player_timer_smpte_cbs * smpte_cbs
Definition player.h:180
vlc_tick_t period
Definition player.h:174
void * data
Definition player.h:182
const struct vlc_player_timer_cbs * cbs
Definition player.h:179
vlc_tick_t last_update_date
Definition player.h:175
Player timer point.
Definition vlc_player.h:3326
Player smpte timer callbacks.
Definition vlc_player.h:3420
Definition player.h:188
unsigned long last_framenum
Definition player.h:195
unsigned frame_resolution
Definition player.h:198
int df
Definition player.h:200
int frames_per_10mins
Definition player.h:201
struct vlc_player_timer_point point
Definition player.h:191
unsigned frame_rate
Definition player.h:196
unsigned frame_rate_base
Definition player.h:197
struct vlc_list listeners
Definition player.h:189
vlc_es_id_t * es
Definition player.h:190
unsigned df_fps
Definition player.h:199
struct vlc_player_timer_source::@114::@116 smpte
Definition player.h:214
vlc_tick_t last_ts
Definition player.h:221
vlc_tick_t input_normal_time
Definition player.h:220
double seek_position
Definition player.h:225
bool seeking
Definition player.h:226
double input_position
Definition player.h:222
enum vlc_player_timer_state state
Definition player.h:217
struct vlc_player_timer_source sources[VLC_PLAYER_TIMER_TYPE_COUNT]
Definition player.h:228
vlc_tick_t seek_ts
Definition player.h:224
vlc_mutex_t lock
Definition player.h:215
vlc_tick_t input_length
Definition player.h:219
Definition player.h:50
struct vlc_player_title array[]
Definition player.h:53
vlc_atomic_rc_t rc
Definition player.h:51
size_t count
Definition player.h:52
Player title structure.
Definition vlc_player.h:968
Definition player.h:33
bool selected_by_user
Definition player.h:40
struct vlc_player_track t
Definition player.h:34
vout_thread_t * vout
Definition player.h:35
vlc_tick_t delay
Definition player.h:36
enum vlc_vout_order vout_order
Definition player.h:38
Definition player.h:46
Player track structure.
Definition vlc_player.h:1347
Player vout callbacks.
Definition vlc_player.h:2546
Definition player.h:152
struct vlc_list node
Definition player.h:155
void * cbs_data
Definition player.h:154
const struct vlc_player_vout_cbs * cbs
Definition player.h:153
Definition renderer_discovery.c:36
Thread handle.
Definition vlc_threads.h:108
Viewpoints.
Definition vlc_viewpoint.h:41
Video output thread descriptor.
Definition vlc_vout.h:54
Player metadata callbacks.
Definition vlc_player.h:2229
VLC value structure.
Definition vlc_variables.h:122
Atomic operations do not require locking, but they are not very powerful.
es_format_category_e
ES Categories.
Definition vlc_es.h:616
@ SPU_ES
Definition vlc_es.h:620
@ DATA_ES
Definition vlc_es.h:621
@ AUDIO_ES
Definition vlc_es.h:619
@ VIDEO_ES
Definition vlc_es.h:618
This provides convenience helpers for linked lists.
VLC Player API.
int64_t vlc_tick_t
High precision date or time interval.
Definition vlc_tick.h:47
This provides convenience helpers for vectors.