[vlc-devel] [RFC PATCH 10/10] libvlc: media_player: add hwaccel get/set
Thomas Guillem
thomas at gllm.fr
Thu Apr 21 11:53:44 CEST 2016
---
include/vlc/libvlc_media_player.h | 45 +++++++++++++++++++++++++++++++++++++++
lib/libvlc.sym | 2 ++
lib/media_player.c | 36 +++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 73562b8..6101e33 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -996,6 +996,51 @@ LIBVLC_API void libvlc_track_description_list_release( libvlc_track_description_
LIBVLC_DEPRECATED LIBVLC_API
void libvlc_track_description_release( libvlc_track_description_t *p_track_description );
+/**
+ * Enum to specify audio or video hardware decoder.
+ *
+ * @see libvlc_media_player_set_hwaccel_enabled()
+ * @see libvlc_media_player_is_hwaccel_enabled()
+ */
+enum libvlc_hw_type
+{
+ libvlc_hw_video_dec,
+ libvlc_hw_audio_dec,
+};
+
+/**
+ * Enable or disable hardware accelerated decoding for audio or video
+ *
+ * @version LibVLC 3.0.0 and later
+ *
+ * The enabled state will be updated for the next media being opened. Hardware
+ * accelerated decoding can fail for a lot of reason (unsupported codec, VLC
+ * plugin not built, no hardware support for a specific OS). In case of
+ * failure, VLC will fallback to software decoding silently even if hwaccel is
+ * enabled.
+ *
+ * @note hardware accelerated decoding is enabled by default for audio and
+ * video
+ * @see libvlc_media_player_is_hwaccel_enabled()
+ * @see libvlc_hw_type
+ */
+LIBVLC_API void
+libvlc_media_player_set_hwaccel_enabled( libvlc_media_player_t *p_mi,
+ enum libvlc_hw_type type,
+ bool b_enabled );
+
+/**
+ * Return true if hardware accelerated decoding is enabled for audio or video
+ *
+ * @version LibVLC 3.0.0 and later
+ *
+ * @see libvlc_media_player_set_hwaccel_enabled()
+ * @see libvlc_hw_type
+ */
+LIBVLC_API bool
+libvlc_media_player_is_hwaccel_enabled( libvlc_media_player_t *p_mi,
+ enum libvlc_hw_type type );
+
/** \defgroup libvlc_video LibVLC video controls
* @{
*/
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index c134fef..d324144 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -199,6 +199,8 @@ libvlc_media_player_stop
libvlc_media_player_will_play
libvlc_media_player_navigate
libvlc_media_player_set_video_title_display
+libvlc_media_player_set_hwaccel_enabled
+libvlc_media_player_is_hwaccel_enabled
libvlc_media_release
libvlc_media_retain
libvlc_media_save_meta
diff --git a/lib/media_player.c b/lib/media_player.c
index 4761fee..e5905a7 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -585,6 +585,8 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "vmem-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "vmem-pitch", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_Create (mp, "avcodec-hw", VLC_VAR_STRING);
+ var_Create (mp, "codec-video-hw", VLC_VAR_BOOL );
+ var_Create (mp, "codec-audio-hw", VLC_VAR_BOOL );
var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
#if defined (_WIN32) || defined (__OS2__)
var_Create (mp, "drawable-hwnd", VLC_VAR_INTEGER);
@@ -1901,3 +1903,37 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
return 0;
}
+
+void
+libvlc_media_player_set_hwaccel_enabled( libvlc_media_player_t *p_mi,
+ enum libvlc_hw_type type,
+ bool b_enabled )
+{
+ switch( type )
+ {
+ case libvlc_hw_video_dec:
+ var_SetBool( p_mi, "codec-video-hw", b_enabled );
+ break;
+ case libvlc_hw_audio_dec:
+ var_SetBool( p_mi, "codec-audio-hw", b_enabled );
+ break;
+ default:
+ vlc_assert_unreachable();
+ }
+}
+
+bool
+libvlc_media_player_is_hwaccel_enabled( libvlc_media_player_t *p_mi,
+ enum libvlc_hw_type type )
+{
+ switch( type )
+ {
+ case libvlc_hw_video_dec:
+ return var_GetBool( p_mi, "codec-video-hw" );
+ case libvlc_hw_audio_dec:
+ return var_GetBool( p_mi, "codec-audio-hw" );
+ default:
+ vlc_assert_unreachable();
+ return false;
+ }
+}
--
2.8.0.rc3
More information about the vlc-devel
mailing list