[vlc-devel] [PATCH] Add methods to libvlc to enable and query recording of current media:

Tony Anecito adanecito at yahoo.com
Sun Jul 29 18:07:25 CEST 2012


Hi Mark,
 
Will we be able to get dowload status (of streaming video) already or will this help?
 
Thanks,
Tony

--- On Sun, 7/29/12, Mark Lee <mark.lee at capricasoftware.co.uk> wrote:


From: Mark Lee <mark.lee at capricasoftware.co.uk>
Subject: [vlc-devel] [PATCH] Add methods to libvlc to enable and query recording of current media:
To: vlc-devel at videolan.org
Date: Sunday, July 29, 2012, 7:30 AM


* libvlc_media_player_can_record
* libvlc_media_player_get_record
* libvlc_media_player_set_record
---
include/vlc/libvlc_media_player.h |   44 +++++++++++++++++++++++++++++++++++++
lib/libvlc.sym                    |    3 +++
lib/media_player.c                |   44 +++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 809ed5f..e6e52ad 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1580,6 +1580,50 @@ LIBVLC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_de

/** @} audio */

+/**
+ * Can the media player record the current media?
+ *
+ * Media must be playing or buffering before it can be recorded.
+ *
+ * \param p_mi media player
+ * \return non-zero if the media player can record, zero if it can not
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API int libvlc_media_player_can_record( libvlc_media_player_t *p_mi );
+
+/**
+ * Set whether or not recording is enabled.
+ *
+ * Media must be buffering or playing before it can be recorded.
+ *
+ * Media will be saved to the appropriate media directory, for example "~/Videos". The
+ * file will not be immediately available in that directory until recording is finished.
+ *
+ * Recording can be started and stopped on-the-fly once the media has started playing,
+ * each time recording is stopped and restarted a new file will be created.
+ *
+ * Recording will be stopped when the media stops playing, and must be explicitly enabled
+ * again to restart recording.
+ *
+ * Features such as next/previous chapter, set time or position and so on are ineffective
+ * when recording is enabled.
+ *
+ * \param p_mi media player
+ * \param i_record start recording if non-zero, stop recording if zero
+ * \return zero on success, -1 on error
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API int libvlc_media_player_set_record( libvlc_media_player_t *p_mi, int i_record );
+
+/**
+ * Get whether or not the media is currently being recorded.
+ *
+ * \param p_mi media player
+ * \return non-zero if recording, zero if not
+ * \version LibVLC 2.1.0 or later
+ */
+LIBVLC_API int libvlc_media_player_get_record( libvlc_media_player_t *p_mi );
+
/** @} media_player */

# ifdef __cplusplus
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 974e04f..059471c 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -116,6 +116,7 @@ libvlc_media_new_from_input_item
libvlc_media_parse
libvlc_media_parse_async
libvlc_media_player_can_pause
+libvlc_media_player_can_record
libvlc_media_player_next_frame
libvlc_media_player_event_manager
libvlc_media_player_get_agl
@@ -129,6 +130,7 @@ libvlc_media_player_get_media
libvlc_media_player_get_nsobject
libvlc_media_player_get_position
libvlc_media_player_get_rate
+libvlc_media_player_get_record
libvlc_media_player_get_state
libvlc_media_player_get_time
libvlc_media_player_get_title
@@ -153,6 +155,7 @@ libvlc_media_player_set_media
libvlc_media_player_set_nsobject
libvlc_media_player_set_position
libvlc_media_player_set_rate
+libvlc_media_player_set_record
libvlc_media_player_set_time
libvlc_media_player_set_title
libvlc_media_player_set_xwindow
diff --git a/lib/media_player.c b/lib/media_player.c
index f30f184..4d93e42 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1408,3 +1408,47 @@ void libvlc_media_player_next_frame( libvlc_media_player_t *p_mi )
         vlc_object_release( p_input_thread );
     }
}
+
+int libvlc_media_player_can_record( libvlc_media_player_t *p_mi )
+{
+    input_thread_t *p_input_thread;
+    bool b_can_record;
+
+    p_input_thread = libvlc_get_input_thread( p_mi );
+    if( !p_input_thread )
+        return 0;
+
+    b_can_record = var_GetBool( p_input_thread, "can-record" );
+
+    vlc_object_release( p_input_thread );
+    return b_can_record;
+}
+
+int libvlc_media_player_set_record( libvlc_media_player_t *p_mi, int i_record )
+{
+    input_thread_t *p_input_thread;
+
+    p_input_thread = libvlc_get_input_thread( p_mi );
+    if( !p_input_thread )
+        return -1;
+
+    var_SetBool( p_input_thread, "record", i_record );
+
+    vlc_object_release( p_input_thread );
+    return 0;
+}
+
+int libvlc_media_player_get_record( libvlc_media_player_t *p_mi )
+{
+    input_thread_t *p_input_thread;
+    bool b_record;
+
+    p_input_thread = libvlc_get_input_thread( p_mi );
+    if( !p_input_thread )
+        return 0;
+
+    b_record = var_GetBool( p_input_thread, "record" );
+
+    vlc_object_release( p_input_thread );
+    return b_record;
+}
-- 
1.7.9.5

_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120729/6e0be92d/attachment.html>


More information about the vlc-devel mailing list