Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
710ad7ed
Commit
710ad7ed
authored
Aug 04, 2014
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc: add 3 libvlc events: MediaPlayerESAdded, MediaPlayerESDeleted, MediaPlayerESSelected
parent
ad24c4fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
0 deletions
+133
-0
include/vlc/libvlc_events.h
include/vlc/libvlc_events.h
+9
-0
lib/event.c
lib/event.c
+3
-0
lib/media_player.c
lib/media_player.c
+121
-0
No files found.
include/vlc/libvlc_events.h
View file @
710ad7ed
...
...
@@ -74,6 +74,9 @@ enum libvlc_event_e {
libvlc_MediaPlayerLengthChanged
,
libvlc_MediaPlayerVout
,
libvlc_MediaPlayerScrambledChanged
,
libvlc_MediaPlayerESAdded
,
libvlc_MediaPlayerESDeleted
,
libvlc_MediaPlayerESSelected
,
libvlc_MediaListItemAdded
=
0x200
,
libvlc_MediaListWillAddItem
,
...
...
@@ -230,6 +233,12 @@ typedef struct libvlc_event_t
{
libvlc_media_t
*
new_media
;
}
media_player_media_changed
;
struct
{
libvlc_track_type_t
i_type
;
int
i_id
;
}
media_player_es_changed
;
}
u
;
/**< Type-dependent event description */
}
libvlc_event_t
;
...
...
lib/event.c
View file @
710ad7ed
...
...
@@ -281,6 +281,9 @@ static const event_name_t event_list[] = {
DEF
(
MediaPlayerLengthChanged
)
DEF
(
MediaPlayerVout
)
DEF
(
MediaPlayerScrambledChanged
)
DEF
(
MediaPlayerESAdded
)
DEF
(
MediaPlayerESDeleted
)
DEF
(
MediaPlayerESSelected
)
DEF
(
MediaListItemAdded
)
DEF
(
MediaListWillAddItem
)
...
...
lib/media_player.c
View file @
710ad7ed
...
...
@@ -57,6 +57,22 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_userdata
);
static
int
input_es_changed
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
int
action
,
vlc_value_t
*
p_val
,
void
*
p_userdata
);
static
int
input_es_selected
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_userdata
);
static
void
add_es_callbacks
(
input_thread_t
*
p_input_thread
,
libvlc_media_player_t
*
p_mi
);
static
void
del_es_callbacks
(
input_thread_t
*
p_input_thread
,
libvlc_media_player_t
*
p_mi
);
static
int
snapshot_was_taken
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
);
...
...
@@ -125,6 +141,7 @@ static void release_input_thread( libvlc_media_player_t *p_mi, bool b_input_abor
input_scrambled_changed
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"intf-event"
,
input_event_changed
,
p_mi
);
del_es_callbacks
(
p_input_thread
,
p_mi
);
/* We owned this one */
input_Stop
(
p_input_thread
,
b_input_abort
);
...
...
@@ -347,6 +364,85 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
return
VLC_SUCCESS
;
}
static
int
track_type_from_name
(
const
char
*
psz_name
)
{
if
(
!
strcmp
(
psz_name
,
"video-es"
)
)
return
libvlc_track_video
;
else
if
(
!
strcmp
(
psz_name
,
"audio-es"
)
)
return
libvlc_track_audio
;
else
if
(
!
strcmp
(
psz_name
,
"spu-es"
)
)
return
libvlc_track_text
;
else
return
libvlc_track_unknown
;
}
static
int
input_es_changed
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
int
action
,
vlc_value_t
*
p_val
,
void
*
p_userdata
)
{
VLC_UNUSED
(
p_this
);
libvlc_media_player_t
*
mp
=
p_userdata
;
libvlc_event_t
event
;
/* Ignore the "Disable" element */
if
(
p_val
&&
p_val
->
i_int
<
0
)
return
VLC_EGENERIC
;
switch
(
action
)
{
case
VLC_VAR_ADDCHOICE
:
event
.
type
=
libvlc_MediaPlayerESAdded
;
break
;
case
VLC_VAR_DELCHOICE
:
case
VLC_VAR_CLEARCHOICES
:
event
.
type
=
libvlc_MediaPlayerESDeleted
;
break
;
default:
return
VLC_EGENERIC
;
}
event
.
u
.
media_player_es_changed
.
i_type
=
track_type_from_name
(
psz_cmd
);
int
i_id
;
if
(
action
!=
VLC_VAR_CLEARCHOICES
)
{
if
(
!
p_val
)
return
VLC_EGENERIC
;
i_id
=
p_val
->
i_int
;
}
else
{
/* -1 means all ES tracks of this type were deleted. */
i_id
=
-
1
;
}
event
.
u
.
media_player_es_changed
.
i_id
=
i_id
;
libvlc_event_send
(
mp
->
p_event_manager
,
&
event
);
return
VLC_SUCCESS
;
}
static
int
input_es_selected
(
vlc_object_t
*
p_this
,
char
const
*
psz_cmd
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_userdata
)
{
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
libvlc_media_player_t
*
mp
=
p_userdata
;
libvlc_event_t
event
;
event
.
type
=
libvlc_MediaPlayerESSelected
;
event
.
u
.
media_player_es_changed
.
i_type
=
track_type_from_name
(
psz_cmd
);
event
.
u
.
media_player_es_changed
.
i_id
=
newval
.
i_int
;
libvlc_event_send
(
mp
->
p_event_manager
,
&
event
);
return
VLC_SUCCESS
;
}
/**************************************************************************
* Snapshot Taken Event.
*
...
...
@@ -538,6 +634,9 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event
(
mp
,
Vout
);
register_event
(
mp
,
ScrambledChanged
);
register_event
(
mp
,
ESAdded
);
register_event
(
mp
,
ESDeleted
);
register_event
(
mp
,
ESSelected
);
/* Snapshot initialization */
register_event
(
mp
,
SnapshotTaken
);
...
...
@@ -710,6 +809,26 @@ libvlc_media_player_event_manager( libvlc_media_player_t *p_mi )
return
p_mi
->
p_event_manager
;
}
static
void
add_es_callbacks
(
input_thread_t
*
p_input_thread
,
libvlc_media_player_t
*
p_mi
)
{
var_AddListCallback
(
p_input_thread
,
"video-es"
,
input_es_changed
,
p_mi
);
var_AddListCallback
(
p_input_thread
,
"audio-es"
,
input_es_changed
,
p_mi
);
var_AddListCallback
(
p_input_thread
,
"spu-es"
,
input_es_changed
,
p_mi
);
var_AddCallback
(
p_input_thread
,
"video-es"
,
input_es_selected
,
p_mi
);
var_AddCallback
(
p_input_thread
,
"audio-es"
,
input_es_selected
,
p_mi
);
var_AddCallback
(
p_input_thread
,
"spu-es"
,
input_es_selected
,
p_mi
);
}
static
void
del_es_callbacks
(
input_thread_t
*
p_input_thread
,
libvlc_media_player_t
*
p_mi
)
{
var_DelListCallback
(
p_input_thread
,
"video-es"
,
input_es_changed
,
p_mi
);
var_DelListCallback
(
p_input_thread
,
"audio-es"
,
input_es_changed
,
p_mi
);
var_DelListCallback
(
p_input_thread
,
"spu-es"
,
input_es_changed
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"video-es"
,
input_es_selected
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"audio-es"
,
input_es_selected
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"spu-es"
,
input_es_selected
,
p_mi
);
}
/**************************************************************************
* Tell media player to start playing.
**************************************************************************/
...
...
@@ -751,10 +870,12 @@ int libvlc_media_player_play( libvlc_media_player_t *p_mi )
var_AddCallback
(
p_input_thread
,
"can-pause"
,
input_pausable_changed
,
p_mi
);
var_AddCallback
(
p_input_thread
,
"program-scrambled"
,
input_scrambled_changed
,
p_mi
);
var_AddCallback
(
p_input_thread
,
"intf-event"
,
input_event_changed
,
p_mi
);
add_es_callbacks
(
p_input_thread
,
p_mi
);
if
(
input_Start
(
p_input_thread
)
)
{
unlock_input
(
p_mi
);
del_es_callbacks
(
p_input_thread
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"intf-event"
,
input_event_changed
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"can-pause"
,
input_pausable_changed
,
p_mi
);
var_DelCallback
(
p_input_thread
,
"program-scrambled"
,
input_scrambled_changed
,
p_mi
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment