[vlc-devel] [PATCH 04/10] Adds a new browsing facility whose job is to browse/expand items like folders, playlist or item from APIs.

Julien 'Lta' BALLET elthariel at gmail.com
Mon May 26 11:41:44 CEST 2014


From: Julien 'Lta' BALLET <contact at lta.io>

This subsystem consists of two parts:
  - A new type of module: 'browse' modules. With a very simple API,
    they receive an input_item to browse (and optionnaly a stream)
    and an input_item_node to fill as a result.
  - A browser_thread system carrying most of its code from
    input_thread while being much much simpler. The goal here was to
    avoid making the input system more complex (it's already enough !)
    Many idiosyncrasies has been carried over as well for consistency.
---
 include/vlc_browsing.h         | 138 ++++++++++++++++
 include/vlc_common.h           |   1 +
 src/Makefile.am                |   5 +
 src/browser/browse.c           | 106 +++++++++++++
 src/browser/browser.c          | 348 +++++++++++++++++++++++++++++++++++++++++
 src/browser/browser_internal.h |  48 ++++++
 src/browser/event.c            |  55 +++++++
 src/browser/event.h            |  36 +++++
 8 files changed, 737 insertions(+)
 create mode 100644 include/vlc_browsing.h
 create mode 100644 src/browser/browse.c
 create mode 100644 src/browser/browser.c
 create mode 100644 src/browser/browser_internal.h
 create mode 100644 src/browser/event.c
 create mode 100644 src/browser/event.h

diff --git a/include/vlc_browsing.h b/include/vlc_browsing.h
new file mode 100644
index 0000000..7fd6531
--- /dev/null
+++ b/include/vlc_browsing.h
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * vlc_browsing.h: Browsing modules/functions
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact at lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_BROWSING_H
+#define VLC_BROWSING_H 1
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_input_item.h>
+
+/**
+ * \file
+ * This file defines modules types, functions for browsing items in vlc
+ */
+
+/**
+ * \defgroup browser Browser
+ * @{
+ */
+
+/**
+ * Browser state
+ *
+ * This enum is used by the variable "state"
+ */
+typedef enum browser_state_e
+{
+    BROWSER_INIT_S = 0,
+    BROWSER_OPENING_S,
+    BROWSER_BROWSING_S,
+    BROWSER_END_S,
+    BROWSER_ERROR_S
+} brower_state_e;
+
+/**
+ * Browsing events
+ *
+ * You can catch browsing event by adding a callback on "intf-event" variable.
+ * This variable is an integer that will hold a browsing_event_type_e value.
+ */
+typedef enum browswer_event_type_e
+{
+    /* "state" has changed */
+    BROWSER_EVENT_STATE,
+    /* b_dead is true */
+    BROWSER_EVENT_DEAD,
+    /* a *user* abort has been requested */
+    BROWSER_EVENT_ABORT
+} browser_event_type_e;
+
+typedef struct browse_t browse_t;
+typedef struct browse_sys_t browse_sys_t;
+
+/**
+ * Browse module structure.
+ */
+struct browse_t {
+    VLC_COMMON_MEMBERS
+
+    /* Module properties */
+    module_t            *p_module;
+
+    /* input stream */
+    stream_t            *p_stream;  /**< NULL if access_browser */
+    /* Output node */
+    input_item_node_t   *p_node;    /**< Output node, also used to get input_item */
+
+    char                *psz_location; /** The location to browse */
+
+    /* set by browser */
+    int                 (*pf_browse)( browse_t * );
+
+    browse_sys_t        *p_sys;     /**< Custom private data */
+
+    browser_thread_t    *p_browser; /**< Owning browser_thread_t */
+};
+
+/**
+ * This defines private core storage for a browser thread.
+ */
+typedef struct browser_thread_private_t browser_thread_private_t;
+
+struct browser_thread_t {
+    VLC_COMMON_MEMBERS
+
+    bool b_error;
+    bool b_eof;
+    bool b_dead;
+
+    /* All 'other' data of browser_thread is PRIVATE. You can't access it
+     * outside of src/browser */
+    browser_thread_private_t    *p;
+};
+
+VLC_API browse_t *browse_New( vlc_object_t *p_obj, browser_thread_t *p_browser,
+                              const char *psz_access, const char *psz_browse,
+                              const char *psz_location, stream_t *p_stream );
+#define browse_New(a,b,c,d,e,f) browse_New(VLC_OBJECT(a),b,c,d,e,f)
+VLC_API void browse_Delete( browse_t *p_browse );
+
+/* XXX: Implement me */
+/* VLC_API int browse_browse( browse_t *p_browse ); */
+
+VLC_API browser_thread_t *browser_Create( vlc_object_t *p_parent,
+                                          input_item_t *p_item );
+#define browser_Create(a,b) browser_Create(VLC_OBJECT(a),b)
+
+VLC_API int browser_Start( browser_thread_t * );
+VLC_API void browser_Stop( browser_thread_t *, bool b_abort );
+VLC_API void browser_Close( browser_thread_t * );
+VLC_API void browser_Join( browser_thread_t *p_browser );
+VLC_API void browser_Release( browser_thread_t *p_browser );
+
+/**
+ * @}
+ */
+
+#endif
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 8b4b923..38ce2a6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -220,6 +220,7 @@ typedef struct playlist_t playlist_t;
 typedef struct playlist_item_t playlist_item_t;
 typedef struct services_discovery_t services_discovery_t;
 typedef struct services_discovery_sys_t services_discovery_sys_t;
+typedef struct browser_thread_t browser_thread_t;
 typedef struct playlist_add_t playlist_add_t;
 
 /* Modules */
diff --git a/src/Makefile.am b/src/Makefile.am
index 24af7c3..0834445 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -77,6 +77,7 @@ pluginsinclude_HEADERS = \
 	../include/vlc_probe.h \
 	../include/vlc_rand.h \
 	../include/vlc_services_discovery.h \
+	../include/vlc_browsing.h \
 	../include/vlc_fingerprinter.h \
 	../include/vlc_sout.h \
 	../include/vlc_spu.h \
@@ -354,6 +355,10 @@ SOURCES_libvlc_common = \
 	playlist/item.c \
 	playlist/search.c \
 	playlist/services_discovery.c \
+	browser/browser_internal.h \
+	browser/browser.c \
+	browser/browse.c \
+	browser/event.c \
 	input/item.c \
 	input/access.c \
 	input/clock.c \
diff --git a/src/browser/browse.c b/src/browser/browse.c
new file mode 100644
index 0000000..87f60c3
--- /dev/null
+++ b/src/browser/browse.c
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * browse.c: input_item browse module
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact '#' lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+
+#include <vlc_browsing.h>
+#include <vlc_modules.h>
+#include <vlc_url.h>
+#include "libvlc.h"
+
+#include "browser_internal.h"
+
+/**
+ * Try to find an access_browser, or a browser and initialize it for the
+ * give browser_thread object
+ *
+ * @param p_obj The parent of the browse module.
+ * @param p_browser The browser thread object this browse module will be
+ * run into.
+ * @param psz_access The access part of the MRL (file, ftp, ...)
+ * @param psz_browse The browse par of the MRL.
+ * @param psz_location The location part of the MRL
+ * @param p_stream NULL if you try to load an access_browser or the access
+ * stream that'll be use to read the resource you want to browse
+ *
+ * @return A browse_t object or NULL.
+ */
+#undef browse_New
+browse_t *browse_New( vlc_object_t *p_obj, browser_thread_t *p_browser,
+                      const char *psz_access, const char *psz_browse,
+                      const char *psz_location, stream_t *p_stream )
+{
+    assert( p_browser != NULL );
+
+    browse_t *p_browse = vlc_custom_create( p_obj, sizeof (*p_browse),
+                                            "browse" );
+    if( p_browse == NULL )
+        return NULL;
+
+    p_browse->p_module  = NULL;
+    p_browse->p_stream  = p_stream;
+    p_browse->p_node    = p_browser->p->p_node;
+    p_browse->p_browser = p_browser;
+    p_browse->pf_browse = NULL;
+
+    p_browse->psz_location = decode_URI_duplicate( psz_location );
+
+    if( p_stream != NULL )
+    {
+        p_browse->p_module = module_need( p_browse, "browser",
+                                          psz_browse, true );
+    }
+    else
+    {
+        p_browse->p_module = module_need( p_browse, "access_browser",
+                                          psz_access, true );
+    }
+
+    if( p_browse->p_module == NULL )
+        goto error;
+
+    return p_browse;
+
+    error:
+    vlc_object_release( p_browse );
+    return NULL;
+
+}
+
+/**
+ * Deletes the browse_t object, unloading the module and releasing resources.
+ *
+ * @param p_browse The browse object to delete.
+ */
+VLC_API void browse_Delete( browse_t *p_browse )
+{
+    module_unneed( p_browse, p_browse->p_module );
+
+    free( p_browse->psz_location );
+
+    vlc_object_release( p_browse );
+}
diff --git a/src/browser/browser.c b/src/browser/browser.c
new file mode 100644
index 0000000..e4ba57c
--- /dev/null
+++ b/src/browser/browser.c
@@ -0,0 +1,348 @@
+/*****************************************************************************
+ * browsing.c: input_item browsing
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact '#' lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+#include <time.h>
+
+#include <vlc_common.h>
+#include <vlc_url.h>
+#include "event.h"
+#include "browser_internal.h"
+
+/* Only for input_SplitMRL.*/
+#include "../input/input_internal.h"
+
+static void Destructor( browser_thread_t * p_browser );
+static void *Run( void * );
+static int  Init( browser_thread_t *p_browser );
+static int  MainLoop( browser_thread_t *p_browser );
+static void End( browser_thread_t *p_browser );
+
+static void browser_ChangeState( browser_thread_t *p_browser, int i_state );
+
+
+/**
+ * Create a browser thread object for an input_item_t
+ *
+ * @param p_parent The parent of this object (e.g. playlist)
+ * @param p_item The item to browse
+ *
+ * @return NULL in case of error
+ */
+#undef browser_Create
+browser_thread_t *browser_Create( vlc_object_t *p_parent, input_item_t * p_item )
+{
+    browser_thread_t *p_browser;
+    vlc_value_t val;
+
+    assert(p_item != NULL);
+
+    if( !input_item_IsBrowsable( p_item ) )
+        msg_Warn( p_parent, "tryin to browse a non-browsable item");
+
+    /* Allocate descriptor */
+    p_browser = vlc_custom_create( p_parent, sizeof( *p_browser ), "browser" );
+    if( p_browser == NULL )
+        return NULL;
+
+    /* Allocate private data */
+    p_browser->p = calloc( 1, sizeof( browser_thread_private_t ) );
+    if( p_browser->p == NULL )
+        goto error;
+
+    /* Creating the output input_item_node */
+    p_browser->p->p_node = input_item_node_Create( p_item );
+    if ( p_browser->p->p_node == NULL )
+        goto error;
+
+    /* Parse input options, copied from input/input.c */
+    vlc_mutex_lock( &p_item->lock );
+    assert( (int)p_item->optflagc == p_item->i_options );
+    for( int i = 0; i < p_item->i_options; i++ )
+        var_OptionParse( VLC_OBJECT(p_browser), p_item->ppsz_options[i],
+                         !!(p_item->optflagv[i] & VLC_INPUT_OPTION_TRUSTED) );
+    vlc_mutex_unlock( &p_item->lock );
+
+    /* Init public fields */
+    p_browser->b_error  = false;
+    p_browser->b_eof    = false;
+    p_browser->b_dead   = false;
+
+    /* Init private fields */
+    p_browser->p->p_stream      = NULL;
+    p_browser->p->p_browse      = NULL;
+    p_browser->p->i_state       = BROWSER_INIT_S;
+    p_browser->p->b_abort       = false;
+    p_browser->p->b_is_running  = false;
+
+    /* Special 'intf-event' variable used to send event */
+    var_Create( p_browser, "intf-event", VLC_VAR_INTEGER );
+    /* State */
+    var_Create( p_browser, "state", VLC_VAR_INTEGER );
+    val.i_int = p_browser->p->i_state;
+    var_Change( p_browser, "state", VLC_VAR_SETVALUE, &val, NULL );
+
+    /* Set the destructor when we are sure we are initialized */
+    vlc_object_set_destructor( p_browser, (vlc_destructor_t)Destructor );
+
+    return p_browser;
+
+    error:
+    if( p_browser->p != NULL )
+        free( p_browser->p );
+    vlc_object_release( p_browser );
+
+    return NULL;
+}
+
+
+/**
+ * Starts the give browser_thread, actually spawning the thread
+ *
+ * @param p_browser The browser_thread object to start
+ * @return VLC_SUCCESS or VLC_EGENERIC
+ */
+int browser_Start( browser_thread_t *p_browser )
+{
+    msg_Dbg( p_browser, "starting browser thread");
+
+    /* Create thread and wait for its readiness. */
+    p_browser->p->b_is_running = !vlc_clone( &p_browser->p->thread,
+                                             Run, p_browser,
+                                             VLC_THREAD_PRIORITY_INPUT );
+    if( !p_browser->p->b_is_running )
+    {
+        browser_ChangeState( p_browser, BROWSER_ERROR_S );
+        msg_Err( p_browser, "cannot create browser thread" );
+        return VLC_EGENERIC;
+    }
+    return VLC_SUCCESS;
+}
+
+/**
+ * Stops the browser thread and kill all child objects
+ *
+ * @param p_browser The browser thread to stop
+ * @param b_abort Should we abort and send the abort event ?
+ */
+void browser_Stop( browser_thread_t *p_browser, bool b_abort )
+{
+    /* XXX: This call is deprecated, what should i use instead ? */
+    ObjectKillChildrens( VLC_OBJECT(p_browser) );
+
+    p_browser->p->b_abort |= b_abort;
+}
+
+/**
+ * Convenience function, join and release the browser thread.
+ *
+ * @param p_browser Browser thread object.
+ */
+void browser_Close( browser_thread_t *p_browser )
+{
+    browser_Join( p_browser );
+    browser_Release( p_browser );
+}
+
+void browser_Join( browser_thread_t *p_browser )
+{
+    if( p_browser->p->b_is_running )
+        vlc_join( p_browser->p->thread, NULL );
+}
+
+/**
+ * Release the browser thread, decrementing the ref counter. When it'll
+ * reach 0, browser_thread object will be freed
+ */
+void browser_Release( browser_thread_t *p_browser )
+{
+    vlc_object_release( p_browser );
+}
+
+static int  Init( browser_thread_t *p_browser )
+{
+    const char *psz_access, *psz_browse, *psz_path, *psz_anchor = NULL;
+    input_item_t *p_input = p_browser->p->p_node->p_item;
+    browse_t *p_browse;
+    stream_t *p_stream;
+    char *psz_mrl, *psz_dup;
+
+
+    psz_mrl = p_input->psz_uri;
+    assert( psz_mrl != NULL );
+    psz_dup = decode_URI( strdup( psz_mrl ) );
+
+    if( psz_mrl == NULL )
+        return VLC_ENOMEM;
+
+    /* Split uri */
+    input_SplitMRL( &psz_access, &psz_browse, &psz_path, &psz_anchor, psz_dup );
+    msg_Dbg( p_browser, "`%s' gives access `%s' browser `%s' path `%s'",
+             psz_mrl, psz_access, psz_browse, psz_path );
+
+    /* Let's try to find an access_browser first */
+    p_browse = browse_New( p_browser, p_browser, psz_access,
+                           psz_browse, psz_path, NULL );
+    if( p_browse == NULL )
+    {
+        /* No access_browser found, let's look for an access */
+        p_stream = stream_UrlNew( p_browser, p_input->psz_uri );
+
+        if( p_stream != NULL )
+        {
+            p_browse = browse_New( p_browser, p_browser, psz_access,
+                                   psz_browse, psz_path, p_stream );
+
+            if( p_browse == NULL )
+                goto error;
+            else
+                p_browser->p->p_stream = p_stream;
+        }
+        else
+            msg_Err( p_browser, "Unable to find an access for uri %s, access = %s",
+                     p_input->psz_uri, psz_access );
+    }
+
+    free(psz_dup);
+    if( p_browse == NULL )
+        /* Still no browser found, failure */
+        goto error;
+
+    p_browser->p->p_browse = p_browse;
+    browser_ChangeState( p_browser, BROWSER_BROWSING_S );
+
+    return VLC_SUCCESS;
+
+    error:
+    if( p_stream )
+        stream_Delete( p_stream );
+    browser_ChangeState( p_browser, BROWSER_ERROR_S );
+
+    return VLC_EGENERIC;
+}
+
+static int  MainLoop( browser_thread_t *p_browser )
+{
+    browse_t *p_browse = p_browser->p->p_browse;
+
+    /* If init went well and we weren't interrupted, let's browse */
+    if (vlc_object_alive( p_browser ) && !p_browser->b_error)
+    {
+        if( p_browse->pf_browse( p_browse ) )
+            browser_ChangeState( p_browser, BROWSER_ERROR_S );
+    }
+
+    input_item_t *p_item = p_browser->p->p_node->p_item;
+    input_item_SetBrowsed( p_item, true );
+
+    return VLC_SUCCESS;
+}
+
+static void End( browser_thread_t *p_browser )
+{
+    /* No error... cool. Let's post our browsed node back to the playlist */
+    if( !p_browser->b_error )
+    {
+        input_item_node_PostAndDelete( p_browser->p->p_node );
+        p_browser->p->p_node = NULL;
+        browser_ChangeState( p_browser, BROWSER_END_S );
+    }
+
+    if( p_browser->p->p_browse != NULL )
+        browse_Delete( p_browser->p->p_browse );
+    if( p_browser->p->p_node != NULL )
+        input_item_node_Delete( p_browser->p->p_node );
+    if( p_browser->p->p_stream != NULL )
+        stream_Delete( p_browser->p->p_stream );
+}
+
+static void *Run( void *obj )
+{
+    browser_thread_t *p_browser = (browser_thread_t *)obj;
+    const int canc = vlc_savecancel();
+
+    if( Init( p_browser ) )
+        goto exit;
+
+    MainLoop( p_browser );
+
+    /* Clean up */
+    End( p_browser );
+
+exit:
+    p_browser->p->b_is_running = false;
+
+    /* Tell we're dead */
+    /* Why locking on atomic R/W ? */
+    /* vlc_mutex_lock( &p_browser->p->lock_control ); */
+    const bool b_abort = p_browser->p->b_abort;
+    /* vlc_mutex_unlock( &p_browser->p->lock_control ); */
+
+    if( b_abort )
+        browser_SendEventAbort( p_browser );
+    browser_SendEventDead( p_browser );
+
+    vlc_restorecancel( canc );
+    return NULL;
+
+}
+
+static void browser_ChangeState( browser_thread_t *p_browser, int i_state )
+{
+    const bool b_changed = p_browser->p->i_state != i_state;
+    const char *msg;
+
+
+    p_browser->p->i_state = i_state;
+    if( i_state == BROWSER_BROWSING_S )
+    {
+        msg = "'browsing'";
+    }
+    if( i_state == BROWSER_ERROR_S )
+    {
+        msg = "'error'";
+        p_browser->b_error = true;
+    }
+    else if( i_state == BROWSER_END_S )
+    {
+        msg = "'end'";
+        p_browser->b_eof = true;
+    }
+
+    if( b_changed )
+    {
+        msg_Dbg( p_browser, "changed state to %s", msg );
+        browser_SendEventState( p_browser, i_state );
+    }
+}
+
+static void Destructor( browser_thread_t * p_browser )
+{
+    msg_Err( p_browser, "Destructor ()" );
+
+    free(p_browser->p);
+}
diff --git a/src/browser/browser_internal.h b/src/browser/browser_internal.h
new file mode 100644
index 0000000..d913969
--- /dev/null
+++ b/src/browser/browser_internal.h
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * browser_internal.h: Internal browsing thread structures
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact at lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef LIBVLC_BROWSER_INTERNAL_H
+#define LIBVLC_BROWSER_INTERNAL_H 1
+
+#include <vlc_input_item.h>
+#include <vlc_browsing.h>
+#include <vlc_stream.h>
+
+struct browser_thread_private_t
+{
+    input_item_node_t   *p_node;    /*< The output node. The input item to be
+                                        browsed is inside the node. */
+
+    stream_t            *p_stream;  /*< The input stream if required */
+    browse_t            *p_browse;  /*< The actual browser module */
+
+    int                 i_state;
+
+    bool                b_abort;
+    bool                b_is_running;
+    vlc_thread_t        thread;
+};
+
+//#define browser_priv(x) ( (browser_thread_private_t *) x->private)
+
+#endif
diff --git a/src/browser/event.c b/src/browser/event.c
new file mode 100644
index 0000000..89cf1e1
--- /dev/null
+++ b/src/browser/event.c
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * event.c: Events for browser/
+ *****************************************************************************
+ * Copyright (C) 1998-2004 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact at lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "event.h"
+#include <vlc_browsing.h>
+
+static void Trigger( browser_thread_t *p_browser, int i_type);
+
+void browser_SendEventDead( browser_thread_t *p_browser )
+{
+    p_browser->b_dead = true;
+
+    Trigger( p_browser,  BROWSER_EVENT_DEAD );
+}
+
+void browser_SendEventAbort( browser_thread_t *p_browser )
+{
+    Trigger( p_browser,  BROWSER_EVENT_ABORT );
+}
+
+void browser_SendEventState( browser_thread_t *p_browser, int i_state )
+{
+    vlc_value_t val;
+
+    val.i_int = i_state;
+    var_Change( p_browser, "state", VLC_VAR_SETVALUE, &val, NULL );
+
+    Trigger( p_browser,  BROWSER_EVENT_STATE );
+}
+
+static void Trigger( browser_thread_t *p_browser, int i_type)
+{
+    /* msg_Dbg( p_browser, "Trigger(%d)", i_type); */
+    var_SetInteger( p_browser, "intf-event", i_type );
+}
diff --git a/src/browser/event.h b/src/browser/event.h
new file mode 100644
index 0000000..c5f9b00
--- /dev/null
+++ b/src/browser/event.h
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * event.h: Events for browser/
+ *****************************************************************************
+ * Copyright (C) 2014 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Julien 'Lta' BALLET <contact at lta.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef LIBVLC_BROWSER_EVENT_H
+#define LIBVLC_BROWSER_EVENT_H 1
+
+#include <vlc_browsing.h>
+
+/*****************************************************************************
+ * Event for browser.c
+ *****************************************************************************/
+void browser_SendEventDead( browser_thread_t *p_browser );
+void browser_SendEventAbort( browser_thread_t *p_browser );
+void browser_SendEventState( browser_thread_t *p_browser, int i_state );
+
+#endif
-- 
1.9.3




More information about the vlc-devel mailing list