]> git.sesse.net Git - vlc/commitdiff
Some initial work for streaming profiles
authorClément Stenac <zorglub@videolan.org>
Fri, 28 Jul 2006 13:28:08 +0000 (13:28 +0000)
committerClément Stenac <zorglub@videolan.org>
Fri, 28 Jul 2006 13:28:08 +0000 (13:28 +0000)
+ some misc test cleanup

14 files changed:
include/vlc_common.h
include/vlc_streaming.h [new file with mode: 0644]
include/vlc_strings.h
include/vlc_symbols.h
src/Makefile.am
src/stream_output/profiles.c [new file with mode: 0644]
test/NativeProfilesTest.py [new file with mode: 0644]
test/native/gc.c
test/native/init.c
test/native/profiles.c [new file with mode: 0644]
test/native/tests.h
test/native/url.c
test/pyunit.h
test/setup.py

index 09f7b31e5d231609e0812b7e0e0fd4cc45b82c91..9615be9a4fc612dfaf0415af484d6f7409de3444 100644 (file)
@@ -334,6 +334,15 @@ typedef struct announce_method_t announce_method_t;
 typedef struct announce_handler_t announce_handler_t;
 typedef struct sap_handler_t sap_handler_t;
 
+typedef struct sout_std_t sout_std_t;
+typedef struct sout_display_t sout_display_t;
+typedef struct sout_duplicate_t sout_duplicate_t;
+typedef struct sout_transcode_t sout_transcode_t;
+typedef struct sout_chain_t sout_chain_t;
+typedef struct streaming_profile_t streaming_profile_t;
+typedef struct sout_module_t sout_module_t;
+typedef struct sout_gui_descr_t sout_gui_descr_t;
+
 /* Decoders */
 typedef struct decoder_t      decoder_t;
 typedef struct decoder_sys_t  decoder_sys_t;
@@ -358,6 +367,8 @@ typedef struct iso639_lang_t iso639_lang_t;
 typedef struct device_t device_t;
 typedef struct device_probe_t device_probe_t;
 typedef struct probe_sys_t probe_sys_t;
+typedef struct localized_string_t localized_string_t;
+typedef struct i18n_string_t i18n_string_t;
 
 /* block */
 typedef struct block_t      block_t;
diff --git a/include/vlc_streaming.h b/include/vlc_streaming.h
new file mode 100644 (file)
index 0000000..0874b1f
--- /dev/null
@@ -0,0 +1,196 @@
+/*****************************************************************************
+ * vlc_streaming.h: Methods and descriptions for Streaming profiles
+ *****************************************************************************
+ * Copyright (C) 2002-2005 the VideoLAN team
+ * $Id: stream_output.h 14151 2006-02-04 00:08:50Z zorglub $
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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_STREAMING_H_
+#define _VLC_STREAMING_H_
+
+#include <vlc/vlc.h>
+
+#ifdef WIN32
+#define VCODECS_NUMBER 13
+#else
+#define VCODECS_NUMBER 12
+#endif
+
+#define ACODECS_NUMBER 9
+
+/// Keep this up to date !
+#define MUXERS_NUMBER 10
+enum
+{
+    MUX_PS,
+    MUX_TS,
+    MUX_MPEG,
+    MUX_OGG,
+    MUX_RAW,
+    MUX_ASF,
+    MUX_AVI,
+    MUX_MP4,
+    MUX_MOV,
+    MUX_WAV,
+};
+
+enum
+{
+    ACCESS_HTTP,
+    ACCESS_UDP,
+    ACCESS_MMS,
+    ACCESS_RTP,
+    ACCESS_FILE
+};
+
+struct codec_desc_t {
+    char *psz_display;
+    char *psz_codec;
+    char *psz_descr;
+    int muxers[MUXERS_NUMBER];
+};
+//extern const struct codec vcodecs_array[];
+//extern const struct codec acodecs_array[];
+
+struct method_desc_t {
+    char *psz_access;
+    char *psz_method;
+    char *psz_descr;
+    char *psz_address;
+    int   muxers[MUXERS_NUMBER];
+};
+//xtern const struct method methods_array[];
+
+struct mux_desc_t {
+    int   id;
+    char *psz_mux;
+    char *psz_encap;
+    char *psz_descr;
+};
+//extern const struct mux_desc_t muxers_array[];
+
+
+/* Standard bitrates arrays */
+//static const char * vbitrates_array[] =
+//{ "3072", "2048", "1024", "768", "512", "384", "256", "192", "128", "96",
+//  "64" };
+
+//static const char *abitrates_array[] =
+//{ "512", "256", "192", "128", "96", "64", "32", "16" } ;
+
+struct sout_transcode_t
+{
+    int i_vb, i_ab, i_channels;
+    float f_scale;
+    vlc_bool_t b_audio, b_video, b_subtitles, b_soverlay;
+    char *psz_vcodec, *psz_acodec, *psz_scodec, *psz_venc, *psz_aenc;
+    char *psz_additional;
+};
+
+struct sout_std_t 
+{
+    char *psz_mux, *psz_access;
+    char *psz_url, *psz_name, *psz_group;
+};
+
+struct sout_display_t 
+{
+};
+
+struct sout_duplicate_t
+{
+    int i_children;
+    sout_chain_t **pp_children;
+    /// Conditions
+};
+
+typedef union
+{
+    sout_transcode_t *p_transcode;
+    sout_std_t       *p_std;
+    sout_duplicate_t *p_duplicate;
+    sout_display_t   *p_display;
+} sout_module_type_t;
+
+
+struct sout_module_t
+{
+    int i_type;
+    sout_module_type_t typed;
+    sout_module_t *p_parent;
+};
+
+enum
+{
+    SOUT_MOD_TRANSCODE,
+    SOUT_MOD_STD,
+    SOUT_MOD_RTP,
+    SOUT_MOD_DUPLICATE,
+    SOUT_MOD_DISPLAY
+};
+
+struct sout_chain_t
+{
+    int i_modules;
+    sout_module_t **pp_modules;
+
+    int i_options;
+    char **ppsz_options;
+};
+
+struct sout_gui_descr_t 
+{
+    /* Access */
+    vlc_bool_t b_local, b_file, b_http, b_mms, b_rtp, b_udp, b_dump;
+    char *psz_file, *psz_http, *psz_mms, *psz_rtp, *psz_udp;
+    int i_http, i_mms, i_rtp, i_udp;
+
+    /* Mux */
+    char *psz_mux;
+
+    /* Transcode */
+    vlc_bool_t b_video, b_audio, b_subtitles, b_soverlay;
+    char *psz_vcodec, *psz_acodec, *psz_scodec;
+    int i_vb, i_ab, i_channels;
+    float f_scale;
+
+    /* Misc */
+    vlc_bool_t b_sap, b_all_es;
+    char *psz_group, *psz_name;
+    int i_ttl;
+};
+
+struct streaming_profile_t 
+{
+    i18n_string_t *p_title;
+    i18n_string_t *p_description;
+    sout_chain_t *p_chain;
+};
+
+static inline sout_chain_t *streaming_ChainNew()
+{
+    DECMALLOC_NULL( p_chain, sout_chain_t );
+    memset( p_chain, 0, sizeof( sout_chain_t ) );
+    p_chain->i_options = 0;
+    return p_chain;
+}
+
+//VLC_XEXPORT( char *, streaming_ChainToPsz, (sout_chain_t * ) );
+
+#endif
index 6faae1b71e8075a3855b4f47b81e4e52687e701a..8c16a21290dd356387ba43adb17be8e6ea4b9515 100644 (file)
 VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) );
 VLC_EXPORT( char *, convert_xml_special_chars, ( const char *psz_content ) );
 
+struct localized_string_t 
+{
+    char *psz_lang;
+    char *psz_text;
+};
+
+struct i18n_string_t
+{
+    int i_langs;
+    localized_string_t **pp_langs;
+};
+
+static inline void i18n_AddLang( i18n_string_t *p_src,
+                                 char *psz_lang, char *psz_text )
+{
+    DECMALLOC_VOID( pl10n, localized_string_t );
+    pl10n->psz_lang = strdup( psz_lang );
+    pl10n->psz_text = strdup( psz_text );
+    INSERT_ELEM( p_src->pp_langs, p_src->i_langs, p_src->i_langs, pl10n );
+};
+
+static inline char *i18n_Get( i18n_string_t *p_src, char *psz_lang )
+{
+    int i;
+    for( i = 0 ; i < p_src->i_langs; i++ )
+    {
+        if( !strcmp( p_src->pp_langs[i]->psz_lang, psz_lang ) )
+            return p_src->pp_langs[i]->psz_text;
+    }
+    return strdup( "" );
+};
+
 /**
  * @}
  */
index 219053bcd9acd921f495bcec28482b843f501fb4..860b07b61589c491c789dbc6cb3d266bd1ae86c4 100644 (file)
@@ -519,6 +519,7 @@ struct module_symbols_t
     void (*__stats_TimersClean_inner) (vlc_object_t *);
     void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
     int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float);
+    void *streaming_ChainToPsz_deprecated;
 };
 # if defined (__PLUGIN__)
 #  define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
@@ -1493,6 +1494,7 @@ struct module_symbols_t
     (p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \
     (p_symbols)->stats_TimerClean_deprecated = NULL; \
     (p_symbols)->stats_TimersClean_deprecated = NULL; \
+    (p_symbols)->streaming_ChainToPsz_deprecated = NULL; \
 
 # endif /* __PLUGIN__ */
 #endif /* __VLC_SYMBOLS_H */
index 98ee7ff0995b6cbfdcf33859a618c65481b091a1..f159fb3fb72a9f23c90a5bb533ff402493098dca 100644 (file)
@@ -57,6 +57,7 @@ HEADERS_include = \
        ../include/os_specific.h \
        ../include/snapshot.h \
        ../include/stream_output.h \
+       ../include/vlc_streaming.h \
        ../include/variables.h \
        ../include/video_output.h \
        ../include/vlc_access.h \
@@ -287,6 +288,7 @@ SOURCES_libvlc_common = \
        audio_output/intf.c \
        stream_output/stream_output.c \
        stream_output/announce.c \
+       stream_output/profiles.c \
        stream_output/sap.c \
        osd/osd.c \
        osd/osd_parser.c \
diff --git a/src/stream_output/profiles.c b/src/stream_output/profiles.c
new file mode 100644 (file)
index 0000000..7b8558c
--- /dev/null
@@ -0,0 +1,444 @@
+/*****************************************************************************
+ * profiles.c: Streaming profiles
+ *****************************************************************************
+ * Copyright (C) 2002-2004 the VideoLAN team
+ * $Id: stream_output.c 15915 2006-06-15 21:22:35Z zorglub $
+ *
+ * Authors: ClÃment Stenac <zorglub@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 <vlc_streaming.h>
+
+#define MAX_CHAIN 32768
+#define CHAIN_APPEND( format, args... ) { \
+    memcpy( psz_temp, psz_output, MAX_CHAIN ); \
+    snprintf( psz_output, MAX_CHAIN - 1, "%s"  format , psz_temp, ## args ); }
+
+#define DUPM p_module->typed.p_duplicate
+#define STDM p_module->typed.p_std
+#define DISM p_module->typed.p_display
+#define TRAM p_module->typed.p_transcode
+
+/**********************************************************************
+ * General chain manipulation
+ **********************************************************************/
+sout_duplicate_t *streaming_ChainAddDup( sout_chain_t *p_chain )
+{
+    DECMALLOC_NULL( p_module, sout_module_t );
+    MALLOC_NULL( DUPM, sout_duplicate_t );
+    p_module->i_type = SOUT_MOD_DUPLICATE;
+    DUPM->i_children = 0;
+    DUPM->pp_children = NULL;
+    INSERT_ELEM( p_chain->pp_modules, p_chain->i_modules, p_chain->i_modules,
+                 p_module );
+    return p_module->typed.p_duplicate;
+}
+
+sout_std_t *streaming_ChainAddStd( sout_chain_t *p_chain, char *psz_access,
+                                   char *psz_mux, char *psz_url )
+{
+    DECMALLOC_NULL( p_module, sout_module_t );
+    MALLOC_NULL( STDM, sout_std_t );
+    p_module->i_type = SOUT_MOD_STD;
+    STDM->psz_mux = strdup( psz_mux );
+    STDM->psz_access = strdup( psz_access );
+    STDM->psz_url = strdup( psz_url );
+    INSERT_ELEM( p_chain->pp_modules, p_chain->i_modules, p_chain->i_modules,
+                 p_module );
+    return STDM;
+}
+
+sout_display_t *streaming_ChainAddDisplay( sout_chain_t *p_chain )
+{
+    DECMALLOC_NULL( p_module, sout_module_t );
+    MALLOC_NULL( DISM, sout_display_t );
+    p_module->i_type = SOUT_MOD_DISPLAY;
+    return DISM;
+}
+
+sout_transcode_t *streaming_ChainAddTranscode( sout_chain_t *p_chain,
+                        char *psz_vcodec, char * psz_acodec, char * psz_scodec,
+                        int i_vb, float f_scale, int i_ab, int i_channels, 
+                        char *psz_additional )
+{
+    DECMALLOC_NULL( p_module, sout_module_t );
+    MALLOC_NULL( TRAM, sout_transcode_t );
+    p_module->i_type = SOUT_MOD_TRANSCODE;
+    if( psz_vcodec )
+    { TRAM->b_video = VLC_TRUE; TRAM->psz_vcodec = strdup( psz_vcodec); }
+    if( psz_acodec )
+    { TRAM->b_audio = VLC_TRUE; TRAM->psz_acodec = strdup( psz_acodec ); }
+    TRAM->psz_scodec = strdup( psz_scodec );
+    TRAM->i_vb = i_vb; TRAM->i_ab = i_ab; TRAM->f_scale = f_scale;
+    TRAM->i_channels = i_channels;
+    TRAM->psz_additional = strdup( psz_additional );
+    return TRAM;
+}
+            
+void streaming_DupAddChild( sout_duplicate_t *p_dup )
+{
+    if( p_dup )
+    {
+        sout_chain_t * p_child = streaming_ChainNew();
+        INSERT_ELEM( p_dup->pp_children, p_dup->i_children,
+                     p_dup->i_children, p_child );
+    }
+}
+
+#define DUP_OR_CHAIN p_dup ? p_dup->pp_children[p_dup->i_children-1] : p_chain
+
+#define ADD_OPT( format, args... ) { \
+    char *psz_opt; asprintf( &psz_opt, format, ##args ); \
+    INSERT_ELEM( p_chain->ppsz_options, p_chain->i_options, p_chain->i_options,\
+                 psz_opt );\
+    free( psz_opt ); }
+
+void streaming_ChainClean( sout_chain_t *p_chain )
+{
+    int i,j;
+    sout_module_t *p_module;
+    if( p_chain->i_modules )
+    {
+        for( i = p_chain->i_modules -1; i >= 0 ; i-- )
+        {
+            p_module = p_chain->pp_modules[i];
+            switch( p_module->i_type )
+            {
+            case SOUT_MOD_DUPLICATE:
+                if( DUPM->i_children == 0 ) break;
+                for( j = DUPM->i_children - 1 ; j >= 0; j-- )
+                {
+                    streaming_ChainClean( DUPM->pp_children[j] );
+                }
+                break;
+            case SOUT_MOD_STD:
+                FREENULL( STDM->psz_url );
+                FREENULL( STDM->psz_name );
+                FREENULL( STDM->psz_group );
+                memset( STDM, 0, sizeof( sout_std_t ) );
+                break;
+            case SOUT_MOD_TRANSCODE:
+                FREENULL( TRAM->psz_vcodec );
+                FREENULL( TRAM->psz_acodec );
+                FREENULL( TRAM->psz_scodec );
+                FREENULL( TRAM->psz_venc );
+                FREENULL( TRAM->psz_aenc );
+                memset( TRAM, 0, sizeof( sout_transcode_t ) ) ;
+                break;
+            }
+            REMOVE_ELEM( p_chain->pp_modules, p_chain->i_modules, i );
+        }
+    }
+}
+
+/**********************************************************************
+ * Interaction with streaming GUI descriptors
+ **********************************************************************/
+#define DO_ENABLE_ACCESS \
+    if( !strcmp( STDM->psz_access, "file" ) )\
+    { \
+        pd->b_file = VLC_TRUE; pd->psz_file = strdup( STDM->psz_url ); \
+    } \
+    else if(  !strcmp( STDM->psz_access, "http" ) )\
+    { \
+        pd->b_http = VLC_TRUE; pd->psz_http = strdup( STDM->psz_url ); \
+    } \
+    else if(  !strcmp( STDM->psz_access, "mms" ) )\
+    { \
+        pd->b_mms = VLC_TRUE; pd->psz_mms = strdup( STDM->psz_url ); \
+    } \
+    else if(  !strcmp( STDM->psz_access, "udp" ) )\
+    { \
+        pd->b_udp = VLC_TRUE; pd->psz_udp = strdup( STDM->psz_url ); \
+    } \
+    else \
+    { \
+        msg_Err( p_this, "unahandled access %s", STDM->psz_access ); \
+    }
+
+
+/**
+ * Try to convert a chain to a gui descriptor. This is only possible for 
+ * "simple" chains. 
+ * \param p_this vlc object
+ * \param p_chain the source streaming chain
+ * \param pd the destination gui descriptor object
+ * \return TRUE if the conversion succeeded, false else
+ */
+vlc_bool_t streaming_ChainToGuiDesc(  vlc_object_t *p_this,
+                                      sout_chain_t *p_chain,
+                                      sout_gui_descr_t *pd )
+{
+    int j, i_last = 0;
+    sout_module_t *p_module;
+    if( p_chain->i_modules == 0 || p_chain->i_modules > 2 ) return VLC_FALSE;
+
+    if( p_chain->pp_modules[0]->i_type == SOUT_MOD_TRANSCODE )
+    {
+        if( p_chain->i_modules == 1 ) return VLC_FALSE;
+        p_module = p_chain->pp_modules[0];
+        i_last++;
+
+        pd->b_video = TRAM->b_video; pd->b_audio = TRAM->b_audio;
+        pd->b_subtitles = TRAM->b_subtitles; pd->b_soverlay = TRAM->b_soverlay;
+        pd->i_vb = TRAM->i_vb; pd->i_ab = TRAM->i_ab;
+        pd->i_channels = TRAM->i_channels; pd->f_scale = TRAM->f_scale;
+        pd->psz_vcodec = strdup( TRAM->psz_vcodec );
+        pd->psz_acodec = strdup( TRAM->psz_acodec );
+        pd->psz_scodec = strdup( TRAM->psz_scodec );
+    }
+    if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DUPLICATE )
+    {
+        p_module = p_chain->pp_modules[i_last];
+        
+        // Nothing allowed after duplicate. Duplicate mustn't be empty
+        if( p_chain->i_modules > i_last +1 || !DUPM->i_children ) 
+            return VLC_FALSE;
+        for( j = 0 ; j<  DUPM->i_children ; j++ )
+        {
+            sout_chain_t *p_child = DUPM->pp_children[j];
+            if( p_child->i_modules != 1 ) return VLC_FALSE;
+            p_module = p_child->pp_modules[0];
+            if( p_module->i_type == SOUT_MOD_STD )
+            {
+                DO_ENABLE_ACCESS
+            }
+            else if( p_module->i_type == SOUT_MOD_DISPLAY )
+                pd->b_local = VLC_TRUE;
+            else if( p_module->i_type == SOUT_MOD_RTP )
+            {
+                msg_Err( p_this, "RTP unhandled" );
+                return VLC_FALSE;
+            }
+        }
+        i_last++;
+    }
+    if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_STD )
+    {
+        p_module = p_chain->pp_modules[i_last];
+        DO_ENABLE_ACCESS;
+    }
+    else if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_DISPLAY )
+    {
+        pd->b_local = VLC_TRUE;
+    }
+    else if( p_chain->pp_modules[i_last]->i_type == SOUT_MOD_RTP )
+    {
+        msg_Err( p_this, "RTP unhandled" );
+        return VLC_FALSE;
+
+    }
+    return VLC_TRUE;
+
+}
+
+#define HANDLE_GUI_URL( type, access ) if( pd->b_##type ) { \
+        streaming_DupAddChild( p_dup ); \
+        if( pd->i_##type > 0 ) \
+        { \
+            char *psz_url; \
+            asprintf( &psz_url, "%s:%i", pd->psz_##type, pd->i_##type ); \
+            streaming_ChainAddStd( DUP_OR_CHAIN, access, pd->psz_mux,\
+                                   psz_url ); \
+            free( psz_url ); \
+        } \
+        else \
+        { \
+            streaming_ChainAddStd( DUP_OR_CHAIN, access, pd->psz_mux,\
+                                   pd->psz_##type );\
+        }\
+    }
+
+void streaming_GuiDescToChain( vlc_object_t *p_obj, sout_chain_t *p_chain,
+                               sout_gui_descr_t *pd )
+{
+    sout_duplicate_t *p_dup = NULL;
+    /* Clean up the chain */
+    streaming_ChainClean( p_chain );
+
+    /* Transcode */
+    if( pd->b_video || pd->b_audio || pd->b_subtitles || pd->b_soverlay )
+    {
+        streaming_ChainAddTranscode( p_chain, pd->psz_vcodec, pd->psz_acodec,
+                                     pd->psz_scodec, pd->i_vb, pd->f_scale,
+                                     pd->i_ab, pd->i_channels, NULL );
+    }
+    /* #std{} */
+    if( pd->b_local + pd->b_file + pd->b_http + pd->b_mms + pd->b_rtp + 
+        pd->b_udp > 1 )
+    {
+        p_dup = streaming_ChainAddDup( p_chain );
+    }
+    if( pd->b_local )
+    {
+        streaming_DupAddChild( p_dup );
+        streaming_ChainAddDisplay(  DUP_OR_CHAIN );
+    }
+    if( pd->b_file )
+    {
+        streaming_DupAddChild( p_dup );
+        streaming_ChainAddStd( DUP_OR_CHAIN, "file", pd->psz_mux,
+                               pd->psz_file );
+    }
+    if( pd->b_udp )
+    {
+        sout_std_t *p_std;
+        streaming_DupAddChild( p_dup );
+        if( pd->i_udp > 0 )
+        {
+            char *psz_url;
+            asprintf( &psz_url, "%s:%i", pd->psz_udp, pd->i_udp );
+            p_std = streaming_ChainAddStd( DUP_OR_CHAIN, "udp",
+                                           pd->psz_mux, psz_url );
+            free( psz_url );
+        }
+        else
+        {
+            p_std = streaming_ChainAddStd( DUP_OR_CHAIN, "udp",
+                                           pd->psz_mux, pd->psz_udp );
+        }
+        if( pd->i_ttl ) ADD_OPT( "ttl=%i", pd->i_ttl );
+        if( pd->b_sap )
+        {
+            pd->b_sap = VLC_TRUE;
+            p_std->psz_name = strdup( pd->psz_name );       
+            p_std->psz_group = pd->psz_group ? strdup( pd->psz_group ) : NULL;
+        }
+    }
+    HANDLE_GUI_URL( http, "http" )
+    HANDLE_GUI_URL( mms, "mms" )
+}
+#undef HANDLE_GUI_URL
+
+/**********************************************************************
+ * Create a sout string from a chain
+ **********************************************************************/
+char * streaming_ChainToPsz( sout_chain_t *p_chain )
+{
+    int i;
+    char psz_output[MAX_CHAIN];
+    char psz_temp[MAX_CHAIN];
+    sprintf( psz_output, "#" );
+    for( i = 0 ; i< p_chain->i_modules; i++ )
+    {
+        sout_module_t *p_module = p_chain->pp_modules[i];
+        switch( p_module->i_type )
+        {
+        case SOUT_MOD_TRANSCODE:
+            CHAIN_APPEND( "transcode{" );
+            if( TRAM->b_video )
+            {
+                CHAIN_APPEND( "vcodec=%s,vb=%i,scale=%f", TRAM->psz_vcodec,
+                                     TRAM->i_vb, TRAM->f_scale );
+                if( TRAM->b_audio || TRAM->b_subtitles || TRAM->b_soverlay )
+                    CHAIN_APPEND( "," );
+            }
+            if( TRAM->b_audio )
+            {
+                CHAIN_APPEND( "acodec=%s,ab=%i,channels=%i", TRAM->psz_acodec,
+                              TRAM->i_ab, TRAM->i_channels );
+                if( TRAM->b_subtitles || TRAM->b_soverlay )
+                    CHAIN_APPEND( "," );
+            }
+            if( TRAM->b_subtitles && TRAM->b_soverlay ) return NULL;
+            if( TRAM->b_subtitles )
+                CHAIN_APPEND( "scodec=%s", TRAM->psz_scodec) ;
+            if( TRAM->b_soverlay )
+                CHAIN_APPEND( "soverlay" );
+            CHAIN_APPEND( "}" );
+            break;
+
+        case SOUT_MOD_DISPLAY:
+            CHAIN_APPEND( "display" )
+            break;
+        case SOUT_MOD_STD:
+            CHAIN_APPEND( "std{access=%s,url=%s,mux=%s}", STDM->psz_access,
+                          STDM->psz_url, STDM->psz_mux );
+        }
+    }
+    return strdup( psz_output );
+}
+
+/**********************************************************************
+ * Handle streaming profiles
+ **********************************************************************/
+
+/**
+ * List the available profiles. Fills the pp_profiles list with preinitialized
+ * values. Only metadata is decoded
+ * \param p_this vlc object
+ * \param pi_profiles number of listed profiles
+ * \param pp_profiles array of profiles
+ */
+void streaming_ProfilesList( vlc_object_t *p_this, int *pi_profiles, 
+                             streaming_profile_t **pp_profiles )
+{
+}
+
+
+//////////// DEPRECATED
+#if 0
+vlc_bool_t streaming_ChainIsGuiSupported( sout_chain_t *p_chain,
+                                          vlc_bool_t b_root )
+{
+    /* First is transcode, std/rtp or duplicate.
+     * If transcode, then std/rtp or duplicate
+     * If duplicate, each subchain is std/rtp only */
+    int j;
+    if( p_chain->i_modules == 0 || p_chain->i_modules > 2 ) return VLC_FALSE;
+
+    if( p_chain->pp_modules[0]->i_type == SOUT_MOD_TRANSCODE && b_root )
+    {
+        if( p_chain->pp_modules[1]->i_type == SOUT_MOD_DUPLICATE )
+        {
+            sout_duplicate_t *p_dup = p_chain->pp_modules[1]->typed.p_duplicate;
+            if( p_dup->i_children == 0 ) return VLC_FALSE;
+            for( j = 0 ; j<  p_dup->i_children ; j++ )
+            {
+                if( !streaming_ChainIsGuiSupported( p_dup->pp_children[j],
+                                                    VLC_FALSE))
+                    return VLC_FALSE;
+            }
+            return VLC_TRUE;
+        }
+    }
+    if( p_chain->pp_modules[0]->i_type == SOUT_MOD_DUPLICATE && b_root )
+    {
+        sout_duplicate_t *p_dup =  p_chain->pp_modules[0]->typed.p_duplicate;
+        if( p_dup->i_children == 0 ) return VLC_FALSE;
+        for( j = 0 ; j<  p_dup->i_children ; j++ )
+        {
+            if( !streaming_ChainIsSupported( p_dup->pp_children[j], VLC_FALSE))
+                return VLC_FALSE;
+        }
+        return VLC_TRUE;
+    }
+    // Now check for supported simple chain
+    if( p_chain->i_modules == 1 || b_root )
+    {
+        return p_chain->pp_modules[0]->i_type == SOUT_MOD_RTP ||
+               p_chain->pp_modules[0]->i_type == SOUT_MOD_STD;
+    }
+    else if( b_root )
+    {
+        return p_chain->pp_modules[0]->i_type == SOUT_MOD_TRANSCODE && 
+               (p_chain->pp_modules[1]->i_type == SOUT_MOD_RTP ||
+                p_chain->pp_modules[1]->i_type == SOUT_MOD_STD );
+    }
+    return VLC_FALSE;
+}
+#endif
diff --git a/test/NativeProfilesTest.py b/test/NativeProfilesTest.py
new file mode 100644 (file)
index 0000000..798942d
--- /dev/null
@@ -0,0 +1,12 @@
+import unittest
+
+import native_libvlc_test
+
+class NativeProfilesTestCase( unittest.TestCase ):
+    def testchains( self ):
+        """[Streaming] Test sout chains handling"""
+        native_libvlc_test.chains_test()
+    def testchains2(self ):
+        """[Streaming] Test sout chain interactions handling"""
+       native_libvlc_test.gui_chains_test()
+       native_libvlc_test.psz_chains_test()
index eaa5ff28206e55405edd433b0cbc712634d088b9..de198de2f4c5daaf79a89a8803ba8e1a4ecabc5d 100644 (file)
@@ -1,8 +1,6 @@
 #include "../pyunit.h"
 #include <vlc/vlc.h>
 
-#include <vlc_common.h>
-
 struct mygc
 {
     VLC_GC_MEMBERS;
@@ -21,9 +19,8 @@ static PyObject *gc_test( PyObject *self, PyObject *args )
 {
      mygc *gc = (mygc *)malloc( sizeof( mygc ) );
 
-     vlc_gc_init( gc, mygc_destructor );
-     gc->i_gc_refcount = 0;
-
+     vlc_gc_init( gc, mygc_destructor, NULL );
+     ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
      vlc_gc_incref( gc );
      ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
      vlc_gc_incref( gc );
index 902e56a77989a1f959113469f7d7158ebc10a3c8..c334c3e7cf3d3b626d05d9b881ad173fb0269505 100644 (file)
@@ -8,6 +8,9 @@ static PyMethodDef native_libvlc_test_methods[] = {
    DEF_METHOD( timers_test, "Test timers" )
    DEF_METHOD( i18n_atof_test, "Test i18n_atof" )
    DEF_METHOD( url_decode_test, "URL decoding" )
+   DEF_METHOD( chains_test, "Test building of chains" )
+   DEF_METHOD( gui_chains_test, "Test interactions between chains and GUI" )
+   DEF_METHOD( psz_chains_test, "Test building of chain strings" )
    { NULL, NULL, 0, NULL }
 };
 
diff --git a/test/native/profiles.c b/test/native/profiles.c
new file mode 100644 (file)
index 0000000..426e94e
--- /dev/null
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ * i18n: Test streaming profiles
+ *****************************************************************************
+ * Copyright (C) 2006 The VideoLAN project
+ * $Id: i18n_atof.c 14675 2006-03-08 12:25:29Z courmisch $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 "../pyunit.h"
+#include <vlc/vlc.h>
+#include <vlc_streaming.h>
+
+#define STDCHAIN1 "#std{access=udp,url=12.42.12.42,mux=ts}"
+//#define GUICHAIN1 
+static void BuildStdChain1( sout_chain_t *p_chain )
+{
+    streaming_ChainAddStd( p_chain, "udp", "ts", "12.42.12.42" ); 
+}
+
+#define TRACHAIN1 "#transcode{vcodec=mpgv,vb=1024,scale=1.0,acodec=mp3,ab=128,channels=2}:std{mux=mp4,access=file,url=/dev/null}"
+static void BuildTranscodeChain1( sout_chain_t *p_chain )
+{
+    streaming_ChainAddTranscode( p_chain, "mpgv", "mp3", NULL, 1024, 1.0,
+                                 128, 2, NULL );
+    streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
+}
+
+static void BuildInvalid1( sout_chain_t *p_chain )
+{
+    streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
+    streaming_ChainAddStd( p_chain, "file", "mp4", "/dev/null" );
+}
+
+PyObject *chains_test( PyObject *self, PyObject *args )
+{
+    sout_chain_t *p_chain = streaming_ChainNew();
+    sout_duplicate_t *p_dup;
+    ASSERT( p_chain->i_modules == 0, "unclean chain" );
+    ASSERT( p_chain->i_options == 0, "unclean chain" );
+    ASSERT( p_chain->pp_modules == NULL, "unclean chain" );
+    ASSERT( p_chain->ppsz_options == NULL, "unclean chain" );
+
+    /* Check duplicate */
+    p_dup = streaming_ChainAddDup( p_chain );
+    ASSERT( p_chain->i_modules == 1, "not 1 module" );
+    ASSERT( p_dup->i_children == 0, "dup has children" );
+    streaming_DupAddChild( p_dup );
+    ASSERT( p_dup->i_children == 1, "not 1 child" );
+    ASSERT( p_dup->pp_children[0]->i_modules == 0, "unclean child chain");
+    streaming_DupAddChild( p_dup );
+    ASSERT( p_dup->i_children == 2, "not 2 children" );
+
+    Py_INCREF( Py_None );
+    return Py_None;
+}
+
+PyObject *gui_chains_test( PyObject *self, PyObject *args )
+{
+    Py_INCREF( Py_None);
+    return Py_None;
+}
+
+PyObject *psz_chains_test( PyObject *self, PyObject *args )
+{
+    sout_chain_t *p_chain = streaming_ChainNew();
+    sout_module_t *p_module;
+    char *psz_output;
+    printf( "\n" );
+
+    BuildStdChain1( p_chain );
+    psz_output = streaming_ChainToPsz( p_chain );
+    printf( "STD1: %s\n", psz_output );
+    ASSERT( !strcmp( psz_output, STDCHAIN1 ), "wrong output for STD1" )
+    ASSERT( p_chain->i_modules == 1, "wrong number of modules" );
+    p_module = p_chain->pp_modules[0];
+    ASSERT( p_module->i_type ==  SOUT_MOD_STD, "wrong type of module" );
+
+
+    Py_INCREF( Py_None);
+    return Py_None;
+}
index 3ff4f2e96e7e29049f22d4aa1323eaca5c9e708c..94b6acb102e625b5cb1a3abd5eb599d6a91980c6 100644 (file)
@@ -10,3 +10,7 @@ PyObject *timers_test( PyObject *self, PyObject *args );
 PyObject *url_decode_test( PyObject *self, PyObject *args );
 
 PyObject *i18n_atof_test( PyObject *self, PyObject *args );
+
+PyObject *chains_test( PyObject *self, PyObject *args );
+PyObject *gui_chains_test( PyObject *self, PyObject *args );
+PyObject *psz_chains_test( PyObject *self, PyObject *args );
index 8fb65fc5f7b12fdbadb18e3f8acb2e1dd7a52735..2abfb0021f67ee9173f911dc2d74495306f35c02 100644 (file)
@@ -23,7 +23,7 @@
 #include <vlc/vlc.h>
 #include "vlc_url.h"
 
- PyObject * test_decode (const char *in, const char *out)
+PyObject * test_decode (const char *in, const char *out)
 {
     char *res;
 
@@ -39,8 +39,9 @@
     return Py_None;
 }
 
- PyObject *url_decode_test( PyObject *self, PyObject *args )
+PyObject *url_decode_test( PyObject *self, PyObject *args )
 {
+    printf( "\n" );
     (void)setvbuf (stdout, NULL, _IONBF, 0);
     if( !test_decode ("this_should_not_be_modified_1234",
                      "this_should_not_be_modified_1234") ) return NULL;
index 2a0809fcd44442de2caa238173d409e4c659635c..c2523d516dbe66e2c63d944a8d2a5fa9bf73647a 100644 (file)
@@ -15,5 +15,4 @@
          else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; }
 
 
-
 #define DEF_METHOD( method, desc ) { #method, method, METH_VARARGS, desc},
index dc43b12754d584a39f61d583b69205ed65835bf4..098b52a0d680050db7544e58e58343ef9634dba8 100644 (file)
@@ -41,7 +41,15 @@ def get_ldflags():
 # To compile in a local vlc tree
 native_libvlc_test = Extension( 'native_libvlc_test',
                 sources = ['native/init.c', 'native/url.c', 'native/i18n.c',
-                          'native/stats.c', 'native/libvlc.c'],
+                           'native/stats.c', 'native/libvlc.c', 'native/profiles.c'],
+                include_dirs = ['../include', '../', '/usr/win32/include' ],
+                extra_objects = [ '../src/.libs/libvlc.so' ],
+                extra_compile_args = get_cflags(),
+                           extra_link_args = [ '-L../..' ]  + get_ldflags(),
+                )
+
+native_gc_test = Extension( 'native_gc_test',
+                sources = ['native/gc.c'],
                 include_dirs = ['../include', '../', '/usr/win32/include' ],
                 extra_objects = [ '../src/.libs/libvlc.so' ],
                 extra_compile_args = get_cflags(),
@@ -49,3 +57,6 @@ native_libvlc_test = Extension( 'native_libvlc_test',
                 )
 
 setup( name = 'native_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
+
+
+setup( name = 'native_gc_test' ,version = '1242', ext_modules = [ native_gc_test ] )