forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vlc_player.h
3507 lines (3208 loc) · 103 KB
/
vlc_player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************
* vlc_player.h: player interface
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_PLAYER_H
#define VLC_PLAYER_H 1
#include <vlc_input.h>
#include <vlc_aout.h>
/**
* @defgroup vlc_player Player
* @ingroup input
* VLC Player API
* @brief
@dot
digraph player_states {
label="Player state diagram";
new [style="invis"];
started [label="Started" URL="@ref VLC_PLAYER_STATE_STARTED"];
playing [label="Playing" URL="@ref VLC_PLAYER_STATE_PLAYING"];
paused [label="Paused" URL="@ref VLC_PLAYER_STATE_PAUSED"];
stopping [label="Stopping" URL="@ref VLC_PLAYER_STATE_STOPPING"];
stopped [label="Stopped" URL="@ref VLC_PLAYER_STATE_STOPPED"];
new -> stopped [label="vlc_player_New()" URL="@ref vlc_player_New" fontcolor="green3"];
started -> playing [style="dashed" label=<<i>internal transition</i>>];
started -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
playing -> paused [label="vlc_player_Pause()" URL="@ref vlc_player_Pause" fontcolor="blue"];
paused -> playing [label="vlc_player_Resume()" URL="@ref vlc_player_Resume" fontcolor="blue3"];
paused -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
playing -> stopping [label="vlc_player_Stop()" URL="@ref vlc_player_Stop" fontcolor="red"];
stopping -> stopped [style="dashed" label=<<i>internal transition</i>>];
stopped -> started [label="vlc_player_Start()" URL="@ref vlc_player_Start" fontcolor="darkgreen"];
}
@enddot
* @{
* @file
* VLC Player API
*/
/**
* @defgroup vlc_player__instance Player instance
* @{
*/
/**
* Player opaque structure.
*/
typedef struct vlc_player_t vlc_player_t;
/**
* Player lock type (normal or reentrant)
*/
enum vlc_player_lock_type
{
/**
* Normal lock
*
* If the player is already locked, subsequent calls to vlc_player_Lock()
* will deadlock.
*/
VLC_PLAYER_LOCK_NORMAL,
/**
* Reentrant lock
*
* If the player is already locked, subsequent calls to vlc_player_Lock()
* will still succeed. To unlock the player, one call to
* vlc_player_Unlock() per vlc_player_Lock() is necessary.
*/
VLC_PLAYER_LOCK_REENTRANT,
};
/**
* Create a new player instance
*
* @param parent parent VLC object
* @param lock_type whether the player lock is reentrant or not
* @param media_provider pointer to a media_provider structure or NULL, the
* structure must be valid during the lifetime of the player
* @param media_provider_data opaque data used by provider callbacks
* @return a pointer to a valid player instance or NULL in case of error
*/
VLC_API vlc_player_t *
vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type);
/**
* Delete a player instance
*
* This function stop any playback previously started and wait for their
* termination.
*
* @warning Blocking function if the player state is not STOPPED, don't call it
* from an UI thread in that case.
*
* @param player unlocked player instance created by vlc_player_New()
*/
VLC_API void
vlc_player_Delete(vlc_player_t *player);
/**
* Lock the player.
*
* All player functions (except vlc_player_Delete()) need to be called while
* the player lock is held.
*
* @param player unlocked player instance
*/
VLC_API void
vlc_player_Lock(vlc_player_t *player);
/**
* Unlock the player
*
* @param player locked player instance
*/
VLC_API void
vlc_player_Unlock(vlc_player_t *player);
/**
* Wait on a condition variable
*
* This call allow users to use their own condition with the player mutex.
*
* @param player locked player instance
* @param cond external condition
*/
VLC_API void
vlc_player_CondWait(vlc_player_t *player, vlc_cond_t *cond);
/**
* Ask to start in a paused state
*
* This function can be used before vlc_player_Start()
*
* @param player locked player instance
* @param start_paused true to start in a paused state, false to cancel it
*/
VLC_API void
vlc_player_SetStartPaused(vlc_player_t *player, bool start_paused);
/**
* Enable or disable pause on cork event
*
* If enabled, the player will automatically pause and resume on cork events.
* In that case, cork events won't be propagated via callbacks.
* @see vlc_player_cbs.on_cork_changed
*
* @param player locked player instance
* @param enabled true to enable
*/
VLC_API void
vlc_player_SetPauseOnCork(vlc_player_t *player, bool enabled);
/** @} vlc_player__instance */
/**
* @defgroup vlc_player__playback Playback control
* @{
*/
/**
* State of the player
*
* During a normal playback (no errors), the user is expected to receive all
* events in the following order: STARTED, PLAYING, STOPPING, STOPPED.
*
* @note When playing more than one media in a row, the player stay at the
* PLAYING state when doing the transition from the current media to the next
* media (that can be gapless). This means that STOPPING, STOPPED states (for
* the current media) and STARTED, PLAYING states (for the next one) won't be
* sent. Nevertheless, the vlc_player_cbs.on_current_media_changed callback
* will be called during this transition.
*/
enum vlc_player_state
{
/**
* The player is stopped
*
* Initial state, or triggered by an internal transition from the STOPPING
* state.
*/
VLC_PLAYER_STATE_STOPPED,
/**
* The player is started
*
* Triggered by vlc_player_Start()
*/
VLC_PLAYER_STATE_STARTED,
/**
* The player is playing
*
* Triggered by vlc_player_Resume() or by an internal transition from the
* STARTED state.
*/
VLC_PLAYER_STATE_PLAYING,
/**
* The player is paused
*
* Triggered by vlc_player_Pause().
*/
VLC_PLAYER_STATE_PAUSED,
/**
* The player is stopping
*
* Triggered by vlc_player_Stop(), vlc_player_SetCurrentMedia() or by an
* internal transition (when the media reach the end of file for example).
*/
VLC_PLAYER_STATE_STOPPING,
};
/**
* Error of the player
*
* @see vlc_player_GetError()
*/
enum vlc_player_error
{
VLC_PLAYER_ERROR_NONE,
VLC_PLAYER_ERROR_GENERIC,
};
/**
* Seek speed type
*
* @see vlc_player_SeekByPos()
* @see vlc_player_SeekByTime()
*/
enum vlc_player_seek_speed
{
/** Do a precise seek */
VLC_PLAYER_SEEK_PRECISE,
/** Do a fast seek */
VLC_PLAYER_SEEK_FAST,
};
/**
* Player seek/delay directive
*
* @see vlc_player_SeekByPos()
* @see vlc_player_SeekByTime()
* @see vlc_player_SetCategoryDelay()
*/
enum vlc_player_whence
{
/** Given time/position */
VLC_PLAYER_WHENCE_ABSOLUTE,
/** The current position +/- the given time/position */
VLC_PLAYER_WHENCE_RELATIVE,
};
/**
* Menu (VCD/DVD/BD) and viewpoint navigations
*
* @see vlc_player_Navigate()
*/
enum vlc_player_nav
{
/** Activate the navigation item selected */
VLC_PLAYER_NAV_ACTIVATE,
/** Select a navigation item above or move the viewpoint up */
VLC_PLAYER_NAV_UP,
/** Select a navigation item under or move the viewpoint down */
VLC_PLAYER_NAV_DOWN,
/** Select a navigation item on the left or move the viewpoint left */
VLC_PLAYER_NAV_LEFT,
/** Select a navigation item on the right or move the viewpoint right */
VLC_PLAYER_NAV_RIGHT,
/** Activate the popup Menu (for BD) */
VLC_PLAYER_NAV_POPUP,
/** Activate disc Root Menu */
VLC_PLAYER_NAV_MENU,
};
/**
* A to B loop state
*/
enum vlc_player_abloop
{
VLC_PLAYER_ABLOOP_NONE,
VLC_PLAYER_ABLOOP_A,
VLC_PLAYER_ABLOOP_B,
};
/** Player capability: can seek */
#define VLC_PLAYER_CAP_SEEK (1<<0)
/** Player capability: can pause */
#define VLC_PLAYER_CAP_PAUSE (1<<1)
/** Player capability: can change the rate */
#define VLC_PLAYER_CAP_CHANGE_RATE (1<<2)
/** Player capability: can seek back */
#define VLC_PLAYER_CAP_REWIND (1<<3)
/** Player teletext key: Red */
#define VLC_PLAYER_TELETEXT_KEY_RED ('r' << 16)
/** Player teletext key: Green */
#define VLC_PLAYER_TELETEXT_KEY_GREEN ('g' << 16)
/** Player teletext key: Yellow */
#define VLC_PLAYER_TELETEXT_KEY_YELLOW ('y' << 16)
/** Player teletext key: Blue */
#define VLC_PLAYER_TELETEXT_KEY_BLUE ('b' << 16)
/** Player teletext key: Index */
#define VLC_PLAYER_TELETEXT_KEY_INDEX ('i' << 16)
enum vlc_player_restore_playback_pos
{
VLC_PLAYER_RESTORE_PLAYBACK_POS_NEVER,
VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK,
VLC_PLAYER_RESTORE_PLAYBACK_POS_ALWAYS,
};
/**
* Set the current media
*
* This function replaces the current and next medias.
*
* @note A successful call will always result of
* vlc_player_cbs.on_current_media_changed being called. This function is not
* blocking. If a media is currently being played, this media will be stopped
* and the requested media will be set after.
*
* @note The function will open the media, without starting it, allowing the
* user to send controls (like seek requests) before Starting the player.
*
* @warning This function is either synchronous (if the player state is
* STOPPED) or asynchronous. In the later case, vlc_player_GetCurrentMedia()
* will return the old media, even after this call, and until the
* vlc_player_cbs.on_current_media_changed is called.
*
* @param player locked player instance
* @param media new media to play (will be held by the player)
* @return VLC_SUCCESS or a VLC error code
*/
VLC_API int
vlc_player_SetCurrentMedia(vlc_player_t *player, input_item_t *media);
/**
* Set the next media
*
* This function replaces the next media to be played.
* The user should set the next media from the
* vlc_player_cbs.current_media_changed callback or anytime before the current
* media is stopped.
*
* @note The media won't be opened directly by this function. If there is no
* current media, the next media will be opened from vlc_player_Start(). If
* there is a current playing media, the next media will be opened and played
* automatically.
*
* @param player locked player instance
* @param media next media to play (will be held by the player)
*/
VLC_API void
vlc_player_SetNextMedia(vlc_player_t *player, input_item_t *media);
/**
* Get the current played media.
*
* @see vlc_player_cbs.on_current_media_changed
*
* @param player locked player instance
* @return a valid media or NULL (if no media is set)
*/
VLC_API input_item_t *
vlc_player_GetCurrentMedia(vlc_player_t *player);
/**
* Get the next played media.
*
* This function return the media set by vlc_player_SetNextMedia()
*
* @param player locked player instance
* @return a valid media or NULL (if no next media is set)
*/
VLC_API input_item_t *
vlc_player_GetNextMedia(vlc_player_t *player);
/**
* Helper that hold the current media
*/
static inline input_item_t *
vlc_player_HoldCurrentMedia(vlc_player_t *player)
{
input_item_t *item = vlc_player_GetCurrentMedia(player);
return item ? input_item_Hold(item) : NULL;
}
/**
* Start the playback of the current media.
*
* @param player locked player instance
* @return VLC_SUCCESS or a VLC error code
*/
VLC_API int
vlc_player_Start(vlc_player_t *player);
/**
* Stop the playback of the current media
*
* @note This function is asynchronous. In case of success, the user should wait
* for the STOPPED state event to know when the stop is finished.
*
* @param player locked player instance
* @return VLC_SUCCESS if the player is being stopped, VLC_EGENERIC otherwise
* (no-op)
*/
VLC_API int
vlc_player_Stop(vlc_player_t *player);
/**
* Pause the playback
*
* @param player locked player instance
*/
VLC_API void
vlc_player_Pause(vlc_player_t *player);
/**
* Resume the playback from a pause
*
* @param player locked player instance
*/
VLC_API void
vlc_player_Resume(vlc_player_t *player);
/**
* Pause and display the next video frame
*
* @param player locked player instance
*/
VLC_API void
vlc_player_NextVideoFrame(vlc_player_t *player);
/**
* Get the state of the player
*
* @note Since all players actions are asynchronous, this function won't
* reflect the new state immediately. Wait for the
* vlc_players_cbs.on_state_changed event to be notified.
*
* @see vlc_player_state
* @see vlc_player_cbs.on_state_changed
*
* @param player locked player instance
* @return the current player state
*/
VLC_API enum vlc_player_state
vlc_player_GetState(vlc_player_t *player);
/**
* Get the error state of the player
*
* @see vlc_player_cbs.on_capabilities_changed
*
* @param player locked player instance
* @return the current error state
*/
VLC_API enum vlc_player_error
vlc_player_GetError(vlc_player_t *player);
/**
* Helper to get the started state
*/
static inline bool
vlc_player_IsStarted(vlc_player_t *player)
{
switch (vlc_player_GetState(player))
{
case VLC_PLAYER_STATE_STARTED:
case VLC_PLAYER_STATE_PLAYING:
case VLC_PLAYER_STATE_PAUSED:
return true;
default:
return false;
}
}
/**
* Helper to get the paused state
*/
static inline bool
vlc_player_IsPaused(vlc_player_t *player)
{
return vlc_player_GetState(player) == VLC_PLAYER_STATE_PAUSED;
}
/**
* Helper to toggle the pause state
*/
static inline void
vlc_player_TogglePause(vlc_player_t *player)
{
if (vlc_player_IsStarted(player))
{
if (vlc_player_IsPaused(player))
vlc_player_Resume(player);
else
vlc_player_Pause(player);
}
}
/**
* Get the player capabilities
*
* @see vlc_player_cbs.on_capabilities_changed
*
* @param player locked player instance
* @return the player capabilities, a bitwise mask of @ref VLC_PLAYER_CAP_SEEK,
* @ref VLC_PLAYER_CAP_PAUSE, @ref VLC_PLAYER_CAP_CHANGE_RATE, @ref
* VLC_PLAYER_CAP_REWIND
*/
VLC_API int
vlc_player_GetCapabilities(vlc_player_t *player);
/**
* Helper to get the seek capability
*/
static inline bool
vlc_player_CanSeek(vlc_player_t *player)
{
return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_SEEK;
}
/**
* Helper to get the pause capability
*/
static inline bool
vlc_player_CanPause(vlc_player_t *player)
{
return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_PAUSE;
}
/**
* Helper to get the change-rate capability
*/
static inline bool
vlc_player_CanChangeRate(vlc_player_t *player)
{
return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_CHANGE_RATE;
}
/**
* Helper to get the rewindable capability
*/
static inline bool
vlc_player_CanRewind(vlc_player_t *player)
{
return vlc_player_GetCapabilities(player) & VLC_PLAYER_CAP_REWIND;
}
/**
* Get the rate of the player
*
* @see vlc_player_cbs.on_rate_changed
*
* @param player locked player instance
* @return rate of the player (< 1.f is slower, > 1.f is faster)
*/
VLC_API float
vlc_player_GetRate(vlc_player_t *player);
/**
* Change the rate of the player
*
* @note The rate is saved across several medias
*
* @param player locked player instance
* @param rate new rate (< 1.f is slower, > 1.f is faster)
*/
VLC_API void
vlc_player_ChangeRate(vlc_player_t *player, float rate);
/**
* Increment the rate of the player (faster)
*
* @param player locked player instance
*/
VLC_API void
vlc_player_IncrementRate(vlc_player_t *player);
/**
* Decrement the rate of the player (Slower)
*
* @param player locked player instance
*/
VLC_API void
vlc_player_DecrementRate(vlc_player_t *player);
/**
* Get the length of the current media
*
* @note A started and playing media doesn't have necessarily a valid length.
*
* @see vlc_player_cbs.on_length_changed
*
* @param player locked player instance
* @return a valid length or VLC_TICK_INVALID (if no media is set,
* playback is not yet started or in case of error)
*/
VLC_API vlc_tick_t
vlc_player_GetLength(vlc_player_t *player);
/**
* Get the time of the current media
*
* @note A started and playing media doesn't have necessarily a valid time.
*
* @see vlc_player_cbs.on_position_changed
*
* @param player locked player instance
* @return a valid time or VLC_TICK_INVALID (if no media is set, the media
* doesn't have any time, if playback is not yet started or in case of error)
*/
VLC_API vlc_tick_t
vlc_player_GetTime(vlc_player_t *player);
/**
* Get the position of the current media
*
* @see vlc_player_cbs.on_position_changed
*
* @param player locked player instance
* @return a valid position in the range [0.f;1.f] or -1.f (if no media is
* set,if playback is not yet started or in case of error)
*/
VLC_API double
vlc_player_GetPosition(vlc_player_t *player);
/**
* Seek the current media by position
*
* @note This function can be called before vlc_player_Start() in order to set
* a starting position.
*
* @param player locked player instance
* @param position position in the range [0.f;1.f]
* @param speed precise of fast
* @param whence absolute or relative
*/
VLC_API void
vlc_player_SeekByPos(vlc_player_t *player, double position,
enum vlc_player_seek_speed speed,
enum vlc_player_whence whence);
/**
* Seek the current media by time
*
* @note This function can be called before vlc_player_Start() in order to set
* a starting position.
*
* @warning This function has an effect only if the media has a valid length.
*
* @param player locked player instance
* @param time a time in the range [0;length]
* @param speed precise of fast
* @param whence absolute or relative
*/
VLC_API void
vlc_player_SeekByTime(vlc_player_t *player, vlc_tick_t time,
enum vlc_player_seek_speed speed,
enum vlc_player_whence whence);
/**
* Helper to set the absolute position precisely
*/
static inline void
vlc_player_SetPosition(vlc_player_t *player, double position)
{
vlc_player_SeekByPos(player, position, VLC_PLAYER_SEEK_PRECISE,
VLC_PLAYER_WHENCE_ABSOLUTE);
}
/**
* Helper to set the absolute position fast
*/
static inline void
vlc_player_SetPositionFast(vlc_player_t *player, double position)
{
vlc_player_SeekByPos(player, position, VLC_PLAYER_SEEK_FAST,
VLC_PLAYER_WHENCE_ABSOLUTE);
}
/**
* Helper to jump the position precisely
*/
static inline void
vlc_player_JumpPos(vlc_player_t *player, double jumppos)
{
/* No fask seek for jumps. Indeed, jumps can seek to the current position
* if not precise enough or if the jump value is too small. */
vlc_player_SeekByPos(player, jumppos, VLC_PLAYER_SEEK_PRECISE,
VLC_PLAYER_WHENCE_RELATIVE);
}
/**
* Helper to set the absolute time precisely
*/
static inline void
vlc_player_SetTime(vlc_player_t *player, vlc_tick_t time)
{
vlc_player_SeekByTime(player, time, VLC_PLAYER_SEEK_PRECISE,
VLC_PLAYER_WHENCE_ABSOLUTE);
}
/**
* Helper to set the absolute time fast
*/
static inline void
vlc_player_SetTimeFast(vlc_player_t *player, vlc_tick_t time)
{
vlc_player_SeekByTime(player, time, VLC_PLAYER_SEEK_FAST,
VLC_PLAYER_WHENCE_ABSOLUTE);
}
/**
* Helper to jump the time precisely
*/
static inline void
vlc_player_JumpTime(vlc_player_t *player, vlc_tick_t jumptime)
{
/* No fask seek for jumps. Indeed, jumps can seek to the current position
* if not precise enough or if the jump value is too small. */
vlc_player_SeekByTime(player, jumptime, VLC_PLAYER_SEEK_PRECISE,
VLC_PLAYER_WHENCE_RELATIVE);
}
/**
* Display the player position on the vout OSD
*
* @param player locked player instance
*/
VLC_API void
vlc_player_DisplayPosition(vlc_player_t *player);
/**
* Enable A to B loop of the current media
*
* This function need to be called 2 times with VLC_PLAYER_ABLOOP_A and
* VLC_PLAYER_ABLOOP_B to setup an A to B loop. It uses and stores the
* current time/position when called. The B time must be higher than the
* A time.
*
* @param player locked player instance
* @param abloop select which A/B cursor to set
* @return VLC_SUCCESS or a VLC error code
*/
VLC_API int
vlc_player_SetAtoBLoop(vlc_player_t *player, enum vlc_player_abloop abloop);
/**
* Get the A to B loop status
*
* @note If the returned status is VLC_PLAYER_ABLOOP_A, then a_time and a_pos
* will be valid. If the returned status is VLC_PLAYER_ABLOOP_B, then all
* output parameters are valid. If the returned status is
* VLC_PLAYER_ABLOOP_NONE, then all output parameters are invalid.
*
* @see vlc_player_cbs.on_atobloop_changed
*
* @param player locked player instance
* @param a_time A time or VLC_TICK_INVALID (if the media doesn't have valid
* times)
* @param a_pos A position
* @param b_time B time or VLC_TICK_INVALID (if the media doesn't have valid
* times)
* @param b_pos B position
* @return A to B loop status
*/
VLC_API enum vlc_player_abloop
vlc_player_GetAtoBLoop(vlc_player_t *player, vlc_tick_t *a_time, double *a_pos,
vlc_tick_t *b_time, double *b_pos);
/**
* Navigate (for DVD/Bluray menus or viewpoint)
*
* @param player locked player instance
* @param nav navigation key
*/
VLC_API void
vlc_player_Navigate(vlc_player_t *player, enum vlc_player_nav nav);
/**
* Update the viewpoint
*
* @param player locked player instance
* @param viewpoint the viewpoint value
* @param whence absolute or relative
*/
VLC_API void
vlc_player_UpdateViewpoint(vlc_player_t *player,
const vlc_viewpoint_t *viewpoint,
enum vlc_player_whence whence);
/**
* Check if the playing is recording
*
* @see vlc_player_cbs.on_recording_changed
*
* @param player locked player instance
* @return true if the player is recording
*/
VLC_API bool
vlc_player_IsRecording(vlc_player_t *player);
/**
* Enable or disable recording for the current media
*
* @note A successful call will trigger the vlc_player_cbs.on_recording_changed
* event.
*
* @param player locked player instance
* @param enabled true to enable recording
* @param dir_path path of the recording directory or NULL (use default path),
* has only an effect when first enabling recording.
*/
VLC_API void
vlc_player_SetRecordingEnabled(vlc_player_t *player, bool enabled,
const char *dir_path);
/**
* Helper to toggle the recording state
*/
static inline void
vlc_player_ToggleRecording(vlc_player_t *player)
{
vlc_player_SetRecordingEnabled(player, !vlc_player_IsRecording(player), NULL);
}
/**
* Add an associated (or external) media to the current media
*
* @param player locked player instance
* @param cat SPU_ES or UNKNOWN_ES
* @param uri absolute uri of the external media
* @param select true to select the track of this external media
* @param notify true to notify the OSD
* @param check_ext true to check subtitles extension
*/
VLC_API int
vlc_player_AddAssociatedMedia(vlc_player_t *player,
enum es_format_category_e cat, const char *uri,
bool select, bool notify, bool check_ext);
/**
* Get the signal quality and strength of the current media
*
* @param player locked player instance
* @param quality a pointer that will be assigned with the signal quality
* @param strength a pointer that will be assigned with the signal strength
* @retval VLC_SUCCESS when quality and strength have been assigned
* @retval VLC_EGENERIC in case of error (strength and quality are not assigned)
*/
VLC_API int
vlc_player_GetSignal(vlc_player_t *player, float *quality, float *strength);
/**
* Get the statistics of the current media
*
* @warning The returned pointer becomes invalid when the player is unlocked.
* The referenced structure can be safely copied.
*
* @see vlc_player_cbs.on_statistics_changed
*
* @param player locked player instance
* @return pointer to the player stats structure or NULL
*/
VLC_API const struct input_stats_t *
vlc_player_GetStatistics(vlc_player_t *player);
/**
* Restore the previous playback position of the current media
*/
VLC_API void
vlc_player_RestorePlaybackPos(vlc_player_t *player);
/**
* Get the V4L2 object used to do controls
*
* @param player locked player instance
* @return the V4L2 object or NULL if not any. This object must be used with
* the player lock held.
*/
VLC_API vlc_object_t *
vlc_player_GetV4l2Object(vlc_player_t *player) VLC_DEPRECATED;
/** @} vlc_player__playback */
/**
* @defgroup vlc_player__titles Title and chapter control
* @{
*/
/**
* Player chapter structure
*/
struct vlc_player_chapter
{
/** Chapter name, always valid */
const char *name;
/** Position of this chapter */
vlc_tick_t time;
};
/** vlc_player_title.flags: The title is a menu. */
#define VLC_PLAYER_TITLE_MENU 0x01
/** vlc_player_title.flags: The title is interactive. */
#define VLC_PLAYER_TITLE_INTERACTIVE 0x02
/** vlc_player_title.flags: The title is the main one. */
#define VLC_PLAYER_TITLE_MAIN 0x04
/** Player title structure */
struct vlc_player_title
{
/** Title name, always valid */
const char *name;
/** Length of the title */
vlc_tick_t length;
/** Bit flag of @ref VLC_PLAYER_TITLE_MENU and @ref
* VLC_PLAYER_TITLE_INTERACTIVE */
unsigned flags;
/** Number of chapters, can be 0 */
size_t chapter_count;
/** Array of chapters, can be NULL */
const struct vlc_player_chapter *chapters;
};
/**
* Opaque structure representing a list of @ref vlc_player_title.
*
* @see vlc_player_GetTitleList()
* @see vlc_player_title_list_GetCount()
* @see vlc_player_title_list_GetAt()
*/
typedef struct vlc_player_title_list vlc_player_title_list;
/**
* Hold the title list of the player
*
* This function can be used to pass this title list from a callback to an
* other thread.
*
* @see vlc_player_cbs.on_titles_changed
*
* @return the same instance
*/
VLC_API vlc_player_title_list *
vlc_player_title_list_Hold(vlc_player_title_list *titles);
/**
* Release of previously held title list
*/
VLC_API void
vlc_player_title_list_Release(vlc_player_title_list *titles);
/**
* Get the number of title of a list
*/
VLC_API size_t
vlc_player_title_list_GetCount(vlc_player_title_list *titles);
/**
* Get the title at a given index
*
* @param titles a valid title list
* @param idx index in the range [0; count[
* @return a valid title (can't be NULL)
*/
VLC_API const struct vlc_player_title *
vlc_player_title_list_GetAt(vlc_player_title_list *titles, size_t idx);
/**
* Get the title list of the current media
*
* @see vlc_player_cbs.on_titles_changed
*
* @param player locked player instance
*/
VLC_API vlc_player_title_list *
vlc_player_GetTitleList(vlc_player_t *player);