]> git.sesse.net Git - vlc/commitdiff
Add libvlc_media_new_fd
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 6 Nov 2010 16:40:26 +0000 (18:40 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 6 Nov 2010 16:40:26 +0000 (18:40 +0200)
include/vlc/libvlc_media.h
src/control/media.c
src/libvlc.sym

index e0e77055714545ce3afde91d52c0c86511147941..ccdaeaedab70cb76e67be25004d4af9113157716 100644 (file)
@@ -202,6 +202,35 @@ VLC_PUBLIC_API libvlc_media_t *libvlc_media_new_path(
                                    libvlc_instance_t *p_instance,
                                    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.
  *
index 46c6740ebe1356e57076532a8d99b0a77580e1a8..ce7714939c58d31dd7dc52f5573b2d0e8da6f8b1 100644 (file)
@@ -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
  **************************************************************************/
index 4c5be10e7ce1e6e1710f4c29cbc67e922cb65eb5..1a401d159d78fd4d69dfafa1a9fe4d96634fa315 100644 (file)
@@ -101,6 +101,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