[vlc-devel] [PATCH 1/2] access: make an access able to request a meta update

Ludovic Fauvet etix at videolan.org
Fri Nov 28 16:20:03 CET 2014


---
 include/vlc_access.h |  5 +++++
 src/input/stream.c   | 32 ++++++++++++++++++++++++++++++++
 src/input/stream.h   |  1 +
 3 files changed, 38 insertions(+)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index e83d53f..f6e44e8 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -107,6 +107,8 @@ struct access_t
     {
         uint64_t     i_pos;     /* idem */
         bool         b_eof;     /* idem */
+        unsigned int i_update;  /* Access sets them on change,
+                                   Stream removes them once take into account*/
     } info;
     access_sys_t *p_sys;
 
@@ -114,6 +116,9 @@ struct access_t
     input_thread_t *p_input;
 };
 
+/* access_t.info.i_update field */
+#define ACCESS_UPDATE_META       0x0040
+
 static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
 {
     if( !p_access ) return VLC_EGENERIC;
diff --git a/src/input/stream.c b/src/input/stream.c
index ba7bcee..2e20d8f 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -745,6 +745,9 @@ static int AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read )
     if( p_sys->block.p_current == NULL )
         return 0;
 
+    /* RFC: probably not the best place to put this. Help would be appreciated */
+    accessUpdateMeta(s);
+
     if( p_data == NULL )
     {
         /* seek within this stream if possible, else use plain old read and discard */
@@ -1062,6 +1065,9 @@ static int AStreamReadStream( stream_t *s, void *p_read, unsigned int i_read )
 {
     stream_sys_t *p_sys = s->p_sys;
 
+    /* RFC: probably not the best place to put this. Help would be appreciated */
+    accessUpdateMeta(s);
+
     if( !p_read )
     {
         const uint64_t i_pos_wanted = p_sys->i_pos + i_read;
@@ -1999,3 +2005,29 @@ int stream_ReadDir( stream_t *s, input_item_node_t *p_node )
 {
     return s->pf_readdir( s, p_node );
 }
+
+/**
+ * Check if the access requested a meta update and send the
+ * new version to the es out.
+ */
+void accessUpdateMeta( stream_t *s )
+{
+    stream_sys_t *p_sys = s->p_sys;
+    access_t *p_access = p_sys->p_access;
+    input_thread_t *p_input = s->p_input;
+
+    if( unlikely( p_access == NULL ) )
+        return;
+
+    if( p_access->info.i_update & ACCESS_UPDATE_META )
+    {
+        vlc_meta_t *p_meta = vlc_meta_New();
+        if( unlikely( p_meta == NULL ) )
+            return;
+
+        access_Control( p_access, ACCESS_GET_META, p_meta );
+        es_out_ControlSetMeta( p_input->p->p_es_out, p_meta );
+        vlc_meta_Delete( p_meta );
+        p_access->info.i_update &= ~ACCESS_UPDATE_META;
+    }
+}
\ No newline at end of file
diff --git a/src/input/stream.h b/src/input/stream.h
index 57c005c..4a1e79f 100644
--- a/src/input/stream.h
+++ b/src/input/stream.h
@@ -40,6 +40,7 @@ struct stream_text_t
 /* */
 stream_t *stream_CommonNew( vlc_object_t * );
 void stream_CommonDelete( stream_t * );
+void accessUpdateMeta( stream_t *s );
 
 /**
  * This function creates a stream_t from a provided access_t.
-- 
2.1.3




More information about the vlc-devel mailing list