[vlc-commits] commit: Add libvlc_media_new_fd ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Nov 6 17:42:39 CET 2010


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov  6 18:40:26 2010 +0200| [628ce6ae32ed3edb3b7a63cb33b45939ea3489d3] | committer: Rémi Denis-Courmont 

Add libvlc_media_new_fd

(cherry picked from commit 8ff2e66fced4218dcd523c65567c8262d88e88b4)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=628ce6ae32ed3edb3b7a63cb33b45939ea3489d3
---

 include/vlc/libvlc_media.h |   29 +++++++++++++++++++++++++++++
 src/control/media.c        |    8 ++++++++
 src/libvlc.sym             |    1 +
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index 67be998..6df3061 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -203,6 +203,35 @@ VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_path(
                                    const char *path );
 
 /**
+ * Create a media for an already open file descriptor.
+ * The file descriptor shall be open for reading (or reading and writing).
+ *
+ * Regular file descriptors, pipe read descriptors and character device
+ * descriptors (including TTYs) are supported on all platforms.
+ * Block device descriptors are supported where available.
+ * Directory descriptors are supported on systems that provide fdopendir().
+ * Sockets are supported on all platforms where they are file descriptors,
+ * i.e. all except Windows.
+ *
+ * \note This library will <b>not</b> automatically close the file descriptor
+ * under any circumstance. Nevertheless, a file descriptor can usually only be
+ * rendered once in a media player. To render it a second time, the file
+ * descriptor should probably be rewound to the beginning with lseek().
+ *
+ * \see libvlc_media_release
+ *
+ * \version LibVLC 1.1.5 and later.
+ *
+ * \param p_instance the instance
+ * \param fd open file descriptor
+ * \return the newly created media or NULL on error
+ */
+VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_fd(
+                                   libvlc_instance_t *p_instance,
+                                   int fd );
+
+
+/**
  * Create a media as an empty node with a given name.
  *
  * \see libvlc_media_release
diff --git a/src/control/media.c b/src/control/media.c
index 0a15c9f..5c5c4c5 100644
--- a/src/control/media.c
+++ b/src/control/media.c
@@ -340,6 +340,14 @@ libvlc_media_t *libvlc_media_new_path( libvlc_instance_t *p_instance,
     return m;
 }
 
+libvlc_media_t *libvlc_media_new_fd( libvlc_instance_t *p_instance, int fd )
+{
+    char mrl[16];
+    snprintf( mrl, sizeof(mrl), "fd://%d", fd );
+
+    return libvlc_media_new_location( p_instance, mrl );
+}
+
 /**************************************************************************
  * Create a new media descriptor object
  **************************************************************************/
diff --git a/src/libvlc.sym b/src/libvlc.sym
index 360398c..560c8c7 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -100,6 +100,7 @@ libvlc_media_list_remove_index
 libvlc_media_list_retain
 libvlc_media_list_set_media
 libvlc_media_list_unlock
+libvlc_media_new_fd
 libvlc_media_new_location
 libvlc_media_new_path
 libvlc_media_new_as_node



More information about the vlc-commits mailing list