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
68cc74c5
Commit
68cc74c5
authored
Feb 01, 2016
by
Thomas Guillem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc: add dialog API
parent
c89f9674
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
440 additions
and
0 deletions
+440
-0
include/vlc/libvlc_dialog.h
include/vlc/libvlc_dialog.h
+241
-0
lib/Makefile.am
lib/Makefile.am
+2
-0
lib/dialog.c
lib/dialog.c
+185
-0
lib/libvlc.sym
lib/libvlc.sym
+6
-0
lib/libvlc_internal.h
lib/libvlc_internal.h
+6
-0
No files found.
include/vlc/libvlc_dialog.h
0 → 100644
View file @
68cc74c5
/*****************************************************************************
* libvlc_dialog.h: libvlc dialog API
*****************************************************************************
* Copyright © 2016 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 LIBVLC_DIALOG_H
#define LIBVLC_DIALOG_H 1
#include <stdbool.h>
# ifdef __cplusplus
extern
"C"
{
# endif
typedef
struct
libvlc_dialog_id
libvlc_dialog_id
;
/**
* @defgroup libvlc_dialog LibVLC dialog
* @ingroup libvlc
* @{
* @file
* LibVLC dialog external API
*/
typedef
enum
libvlc_dialog_question_type
{
LIBVLC_DIALOG_QUESTION_NORMAL
,
LIBVLC_DIALOG_QUESTION_WARNING
,
LIBVLC_DIALOG_QUESTION_CRITICAL
,
}
libvlc_dialog_question_type
;
/**
* Dialog callbacks to be implemented
*/
typedef
struct
libvlc_dialog_cbs
{
/**
* Called when an error message needs to be displayed
*
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_display_error
)(
const
char
*
psz_title
,
const
char
*
psz_text
,
void
*
p_data
);
/**
* Called when a login dialog needs to be displayed
*
* You can interact with this dialog by calling libvlc_dialog_post_login()
* to post an answer or libvlc_dialog_dismiss() to cancel this dialog.
*
* @note to receive this callack, libvlc_dialog_cbs.pf_cancel should not be
* NULL.
*
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param psz_default_username user name that should be set on the user form
* @param b_ask_store if true, ask the user if he wants to save the
* credentials
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_display_login
)(
libvlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
const
char
*
psz_default_username
,
bool
b_ask_store
,
void
*
p_data
);
/**
* Called when a question dialog needs to be displayed
*
* You can interact with this dialog by calling libvlc_dialog_post_action()
* to post an answer or libvlc_dialog_dismiss() to cancel this dialog.
*
* @note to receive this callack, libvlc_dialog_cbs.pf_cancel should not be
* NULL.
*
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param i_type question type (or severity) of the dialog
* @param psz_cancel text of the cancel button
* @param psz_action1 text of the first button, if NULL, don't display this
* button
* @param psz_action2 text of the second button, if NULL, don't display
* this button
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_display_question
)(
libvlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
libvlc_dialog_question_type
i_type
,
const
char
*
psz_cancel
,
const
char
*
psz_action1
,
const
char
*
psz_action2
,
void
*
p_data
);
/**
* Called when a progress dialog needs to be displayed
*
* If cancellable (psz_cancel != NULL), you can cancel this dialog by
* calling libvlc_dialog_dismiss()
*
* @note to receive this callack, libvlc_dialog_cbs.pf_cancel and
* libvlc_dialog_cbs.pf_update_progress should not be NULL.
*
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param b_indeterminate true if the progress dialog is indeterminate
* @param f_position initial position of the progress bar (between 0.0 and
* 1.0)
* @param psz_cancel text of the cancel button, if NULL the dialog is not
* cancellable
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_display_progress
)(
libvlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
bool
b_indeterminate
,
float
f_position
,
const
char
*
psz_cancel
,
void
*
p_data
);
/**
* Called when a displayed dialog needs to be cancelled
*
* The implementation must call libvlc_dialog_dismiss() to really release
* the dialog.
*
* @param p_id id of the dialog
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_cancel
)(
libvlc_dialog_id
*
p_id
,
void
*
p_data
);
/**
* Called when a progress dialog needs to be updated
*
* @param p_id id of the dialog
* @param f_position osition of the progress bar (between 0.0 and 1.0)
* @param psz_text new text of the progress dialog
* @param p_data opaque pointer for the callback
*/
void
(
*
pf_update_progress
)(
libvlc_dialog_id
*
p_id
,
float
f_position
,
const
char
*
psz_text
,
void
*
p_data
);
}
libvlc_dialog_cbs
;
/**
* Register callbacks in order to handle VLC dialogs
*
* @version LibVLC 3.0.0 and later.
*
* @param p_cbs a pointer to callbacks, or NULL to unregister callbacks.
* @param p_data opaque pointer for the callback
*/
LIBVLC_API
void
libvlc_dialog_set_callbacks
(
libvlc_instance_t
*
p_instance
,
const
libvlc_dialog_cbs
*
p_cbs
,
void
*
p_data
);
/**
* Associate an opaque pointer with the dialog id
*
* @version LibVLC 3.0.0 and later.
*/
LIBVLC_API
void
libvlc_dialog_set_context
(
libvlc_dialog_id
*
p_id
,
void
*
p_context
);
/**
* Return the opaque pointer associated with the dialog id
*
* @version LibVLC 3.0.0 and later.
*/
LIBVLC_API
void
*
libvlc_dialog_get_context
(
libvlc_dialog_id
*
p_id
);
/**
* Post a login answer
*
* After this call, p_id won't be valid anymore
*
* @see libvlc_dialog_cbs.pf_display_login
*
* @version LibVLC 3.0.0 and later.
*
* @param p_id id of the dialog
* @param psz_username valid and non empty string
* @param psz_password valid string (can be empty)
* @param b_store if true, store the credentials
* @return 0 on success, or -1 on error
*/
LIBVLC_API
int
libvlc_dialog_post_login
(
libvlc_dialog_id
*
p_id
,
const
char
*
psz_username
,
const
char
*
psz_password
,
bool
b_store
);
/**
* Post a question answer
*
* After this call, p_id won't be valid anymore
*
* @see libvlc_dialog_cbs.pf_display_question
*
* @version LibVLC 3.0.0 and later.
*
* @param p_id id of the dialog
* @param i_action 1 for action1, 2 for action2
* @return 0 on success, or -1 on error
*/
LIBVLC_API
int
libvlc_dialog_post_action
(
libvlc_dialog_id
*
p_id
,
int
i_action
);
/**
* Dismiss a dialog
*
* After this call, p_id won't be valid anymore
*
* @see libvlc_dialog_cbs.pf_cancel
*
* @version LibVLC 3.0.0 and later.
*
* @param p_id id of the dialog
* @return 0 on success, or -1 on error
*/
LIBVLC_API
int
libvlc_dialog_dismiss
(
libvlc_dialog_id
*
p_id
);
/** @} */
# ifdef __cplusplus
}
# endif
#endif
/* LIBVLC_DIALOG_H */
lib/Makefile.am
View file @
68cc74c5
...
@@ -11,6 +11,7 @@ CLEANFILES = $(BUILT_SOURCES) $(pkgconfig_DATA)
...
@@ -11,6 +11,7 @@ CLEANFILES = $(BUILT_SOURCES) $(pkgconfig_DATA)
pkginclude_HEADERS
=
\
pkginclude_HEADERS
=
\
../include/vlc/deprecated.h
\
../include/vlc/deprecated.h
\
../include/vlc/libvlc.h
\
../include/vlc/libvlc.h
\
../include/vlc/libvlc_dialog.h
\
../include/vlc/libvlc_events.h
\
../include/vlc/libvlc_events.h
\
../include/vlc/libvlc_media.h
\
../include/vlc/libvlc_media.h
\
../include/vlc/libvlc_media_discoverer.h
\
../include/vlc/libvlc_media_discoverer.h
\
...
@@ -36,6 +37,7 @@ libvlc_la_SOURCES = \
...
@@ -36,6 +37,7 @@ libvlc_la_SOURCES = \
media_list_internal.h
\
media_list_internal.h
\
media_player_internal.h
\
media_player_internal.h
\
core.c
\
core.c
\
dialog.c
\
error.c
\
error.c
\
log.c
\
log.c
\
playlist.c
\
playlist.c
\
...
...
lib/dialog.c
0 → 100644
View file @
68cc74c5
/*****************************************************************************
* dialog.c: libvlc dialog API
*****************************************************************************
* Copyright © 2016 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc_dialog.h>
#include <vlc_common.h>
#include <vlc_dialog.h>
#include "libvlc_internal.h"
static
libvlc_dialog_question_type
vlc_to_libvlc_dialog_question_type
(
vlc_dialog_question_type
i_type
)
{
switch
(
i_type
)
{
case
VLC_DIALOG_QUESTION_NORMAL
:
return
LIBVLC_DIALOG_QUESTION_NORMAL
;
case
VLC_DIALOG_QUESTION_WARNING
:
return
LIBVLC_DIALOG_QUESTION_WARNING
;
case
VLC_DIALOG_QUESTION_CRITICAL
:
return
LIBVLC_DIALOG_QUESTION_CRITICAL
;
default:
vlc_assert_unreachable
();
}
}
static
void
display_error_cb
(
const
char
*
psz_title
,
const
char
*
psz_text
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
p_instance
->
dialog
.
cbs
.
pf_display_error
(
psz_title
,
psz_text
,
p_instance
->
dialog
.
data
);
}
static
void
display_login_cb
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
const
char
*
psz_default_username
,
bool
b_ask_store
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
p_instance
->
dialog
.
cbs
.
pf_display_login
((
libvlc_dialog_id
*
)
p_id
,
psz_title
,
psz_text
,
psz_default_username
,
b_ask_store
,
p_instance
->
dialog
.
data
);
}
static
void
display_question_cb
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
vlc_dialog_question_type
i_type
,
const
char
*
psz_cancel
,
const
char
*
psz_action1
,
const
char
*
psz_action2
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
const
libvlc_dialog_question_type
i_ltype
=
vlc_to_libvlc_dialog_question_type
(
i_type
);
p_instance
->
dialog
.
cbs
.
pf_display_question
((
libvlc_dialog_id
*
)
p_id
,
psz_title
,
psz_text
,
i_ltype
,
psz_cancel
,
psz_action1
,
psz_action2
,
p_instance
->
dialog
.
data
);
}
static
void
display_progress_cb
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
bool
b_indeterminate
,
float
f_position
,
const
char
*
psz_cancel
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
p_instance
->
dialog
.
cbs
.
pf_display_progress
((
libvlc_dialog_id
*
)
p_id
,
psz_title
,
psz_text
,
b_indeterminate
,
f_position
,
psz_cancel
,
p_instance
->
dialog
.
data
);
}
static
void
cancel_cb
(
vlc_dialog_id
*
p_id
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
p_instance
->
dialog
.
cbs
.
pf_cancel
((
libvlc_dialog_id
*
)
p_id
,
p_instance
->
dialog
.
data
);
}
static
void
update_progress_cb
(
vlc_dialog_id
*
p_id
,
float
f_position
,
const
char
*
psz_text
,
void
*
p_data
)
{
libvlc_instance_t
*
p_instance
=
p_data
;
p_instance
->
dialog
.
cbs
.
pf_update_progress
((
libvlc_dialog_id
*
)
p_id
,
f_position
,
psz_text
,
p_instance
->
dialog
.
data
);
}
void
libvlc_dialog_set_callbacks
(
libvlc_instance_t
*
p_instance
,
const
libvlc_dialog_cbs
*
p_cbs
,
void
*
p_data
)
{
libvlc_int_t
*
p_libvlc
=
p_instance
->
p_libvlc_int
;
vlc_mutex_lock
(
&
p_instance
->
instance_lock
);
if
(
p_cbs
!=
NULL
)
{
const
vlc_dialog_cbs
dialog_cbs
=
{
.
pf_display_error
=
p_cbs
->
pf_display_error
!=
NULL
?
display_error_cb
:
NULL
,
.
pf_display_login
=
p_cbs
->
pf_display_login
?
display_login_cb
:
NULL
,
.
pf_display_question
=
p_cbs
->
pf_display_question
!=
NULL
?
display_question_cb
:
NULL
,
.
pf_display_progress
=
p_cbs
->
pf_display_progress
!=
NULL
?
display_progress_cb
:
NULL
,
.
pf_cancel
=
p_cbs
->
pf_cancel
!=
NULL
?
cancel_cb
:
NULL
,
.
pf_update_progress
=
p_cbs
->
pf_update_progress
!=
NULL
?
update_progress_cb
:
NULL
,
};
p_instance
->
dialog
.
cbs
=
*
p_cbs
;
p_instance
->
dialog
.
data
=
p_data
;
vlc_dialog_provider_set_callbacks
(
p_libvlc
,
&
dialog_cbs
,
p_instance
);
}
else
vlc_dialog_provider_set_callbacks
(
p_libvlc
,
NULL
,
NULL
);
vlc_mutex_unlock
(
&
p_instance
->
instance_lock
);
}
void
libvlc_dialog_set_context
(
libvlc_dialog_id
*
p_id
,
void
*
p_context
)
{
vlc_dialog_id_set_context
((
vlc_dialog_id
*
)
p_id
,
p_context
);
}
void
*
libvlc_dialog_get_context
(
libvlc_dialog_id
*
p_id
)
{
return
vlc_dialog_id_get_context
((
vlc_dialog_id
*
)
p_id
);
}
int
libvlc_dialog_post_login
(
libvlc_dialog_id
*
p_id
,
const
char
*
psz_username
,
const
char
*
psz_password
,
bool
b_store
)
{
int
i_ret
=
vlc_dialog_id_post_login
((
vlc_dialog_id
*
)
p_id
,
psz_username
,
psz_password
,
b_store
);
return
i_ret
==
VLC_SUCCESS
?
0
:
-
1
;
}
int
libvlc_dialog_post_action
(
libvlc_dialog_id
*
p_id
,
int
i_action
)
{
int
i_ret
=
vlc_dialog_id_post_action
((
vlc_dialog_id
*
)
p_id
,
i_action
);
return
i_ret
==
VLC_SUCCESS
?
0
:
-
1
;
}
int
libvlc_dialog_dismiss
(
libvlc_dialog_id
*
p_id
)
{
int
i_ret
=
vlc_dialog_id_dismiss
((
vlc_dialog_id
*
)
p_id
);
return
i_ret
==
VLC_SUCCESS
?
0
:
-
1
;
}
lib/libvlc.sym
View file @
68cc74c5
...
@@ -46,6 +46,12 @@ libvlc_audio_set_callbacks
...
@@ -46,6 +46,12 @@ libvlc_audio_set_callbacks
libvlc_audio_set_volume_callback
libvlc_audio_set_volume_callback
libvlc_chapter_descriptions_release
libvlc_chapter_descriptions_release
libvlc_clock
libvlc_clock
libvlc_dialog_dismiss
libvlc_dialog_get_context
libvlc_dialog_post_action
libvlc_dialog_post_login
libvlc_dialog_set_callbacks
libvlc_dialog_set_context
libvlc_event_attach
libvlc_event_attach
libvlc_event_detach
libvlc_event_detach
libvlc_event_type_name
libvlc_event_type_name
...
...
lib/libvlc_internal.h
View file @
68cc74c5
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc_dialog.h>
#include <vlc/libvlc_media.h>
#include <vlc/libvlc_media.h>
#include <vlc/libvlc_events.h>
#include <vlc/libvlc_events.h>
...
@@ -78,6 +79,11 @@ struct libvlc_instance_t
...
@@ -78,6 +79,11 @@ struct libvlc_instance_t
void
(
*
cb
)
(
void
*
,
int
,
const
libvlc_log_t
*
,
const
char
*
,
va_list
);
void
(
*
cb
)
(
void
*
,
int
,
const
libvlc_log_t
*
,
const
char
*
,
va_list
);
void
*
data
;
void
*
data
;
}
log
;
}
log
;
struct
{
libvlc_dialog_cbs
cbs
;
void
*
data
;
}
dialog
;
};
};
...
...
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