Commit 89471fa0 authored by Clément Stenac's avatar Clément Stenac

Some initial work for streaming profiles

+ some misc test cleanup
parent ebc698a5
...@@ -334,6 +334,15 @@ typedef struct announce_method_t announce_method_t; ...@@ -334,6 +334,15 @@ typedef struct announce_method_t announce_method_t;
typedef struct announce_handler_t announce_handler_t; typedef struct announce_handler_t announce_handler_t;
typedef struct sap_handler_t sap_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 */ /* Decoders */
typedef struct decoder_t decoder_t; typedef struct decoder_t decoder_t;
typedef struct decoder_sys_t decoder_sys_t; typedef struct decoder_sys_t decoder_sys_t;
...@@ -358,6 +367,8 @@ typedef struct iso639_lang_t iso639_lang_t; ...@@ -358,6 +367,8 @@ typedef struct iso639_lang_t iso639_lang_t;
typedef struct device_t device_t; typedef struct device_t device_t;
typedef struct device_probe_t device_probe_t; typedef struct device_probe_t device_probe_t;
typedef struct probe_sys_t probe_sys_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 */ /* block */
typedef struct block_t block_t; typedef struct block_t block_t;
......
/*****************************************************************************
* 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
...@@ -34,6 +34,38 @@ ...@@ -34,6 +34,38 @@
VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) ); VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) );
VLC_EXPORT( char *, convert_xml_special_chars, ( const char *psz_content ) ); 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( "" );
};
/** /**
* @} * @}
*/ */
......
...@@ -519,6 +519,7 @@ struct module_symbols_t ...@@ -519,6 +519,7 @@ struct module_symbols_t
void (*__stats_TimersClean_inner) (vlc_object_t *); void (*__stats_TimersClean_inner) (vlc_object_t *);
void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float); void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float);
int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float); int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float);
void *streaming_ChainToPsz_deprecated;
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -1493,6 +1494,7 @@ struct module_symbols_t ...@@ -1493,6 +1494,7 @@ struct module_symbols_t
(p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \ (p_symbols)->playlist_ItemNewFromInput_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \ (p_symbols)->stats_TimerClean_deprecated = NULL; \
(p_symbols)->stats_TimersClean_deprecated = NULL; \ (p_symbols)->stats_TimersClean_deprecated = NULL; \
(p_symbols)->streaming_ChainToPsz_deprecated = NULL; \
# endif /* __PLUGIN__ */ # endif /* __PLUGIN__ */
#endif /* __VLC_SYMBOLS_H */ #endif /* __VLC_SYMBOLS_H */
...@@ -57,6 +57,7 @@ HEADERS_include = \ ...@@ -57,6 +57,7 @@ HEADERS_include = \
../include/os_specific.h \ ../include/os_specific.h \
../include/snapshot.h \ ../include/snapshot.h \
../include/stream_output.h \ ../include/stream_output.h \
../include/vlc_streaming.h \
../include/variables.h \ ../include/variables.h \
../include/video_output.h \ ../include/video_output.h \
../include/vlc_access.h \ ../include/vlc_access.h \
...@@ -287,6 +288,7 @@ SOURCES_libvlc_common = \ ...@@ -287,6 +288,7 @@ SOURCES_libvlc_common = \
audio_output/intf.c \ audio_output/intf.c \
stream_output/stream_output.c \ stream_output/stream_output.c \
stream_output/announce.c \ stream_output/announce.c \
stream_output/profiles.c \
stream_output/sap.c \ stream_output/sap.c \
osd/osd.c \ osd/osd.c \
osd/osd_parser.c \ osd/osd_parser.c \
......
This diff is collapsed.
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()
#include "../pyunit.h" #include "../pyunit.h"
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc_common.h>
struct mygc struct mygc
{ {
VLC_GC_MEMBERS; VLC_GC_MEMBERS;
...@@ -21,9 +19,8 @@ static PyObject *gc_test( PyObject *self, PyObject *args ) ...@@ -21,9 +19,8 @@ static PyObject *gc_test( PyObject *self, PyObject *args )
{ {
mygc *gc = (mygc *)malloc( sizeof( mygc ) ); mygc *gc = (mygc *)malloc( sizeof( mygc ) );
vlc_gc_init( gc, mygc_destructor ); vlc_gc_init( gc, mygc_destructor, NULL );
gc->i_gc_refcount = 0; ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
vlc_gc_incref( gc ); vlc_gc_incref( gc );
ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" ); ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
vlc_gc_incref( gc ); vlc_gc_incref( gc );
......
...@@ -8,6 +8,9 @@ static PyMethodDef native_libvlc_test_methods[] = { ...@@ -8,6 +8,9 @@ static PyMethodDef native_libvlc_test_methods[] = {
DEF_METHOD( timers_test, "Test timers" ) DEF_METHOD( timers_test, "Test timers" )
DEF_METHOD( i18n_atof_test, "Test i18n_atof" ) DEF_METHOD( i18n_atof_test, "Test i18n_atof" )
DEF_METHOD( url_decode_test, "URL decoding" ) 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 } { NULL, NULL, 0, NULL }
}; };
......
/*****************************************************************************
* 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;
}
...@@ -10,3 +10,7 @@ PyObject *timers_test( PyObject *self, PyObject *args ); ...@@ -10,3 +10,7 @@ PyObject *timers_test( PyObject *self, PyObject *args );
PyObject *url_decode_test( PyObject *self, PyObject *args ); PyObject *url_decode_test( PyObject *self, PyObject *args );
PyObject *i18n_atof_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 );
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include "vlc_url.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; char *res;
...@@ -39,8 +39,9 @@ ...@@ -39,8 +39,9 @@
return Py_None; 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); (void)setvbuf (stdout, NULL, _IONBF, 0);
if( !test_decode ("this_should_not_be_modified_1234", if( !test_decode ("this_should_not_be_modified_1234",
"this_should_not_be_modified_1234") ) return NULL; "this_should_not_be_modified_1234") ) return NULL;
......
...@@ -15,5 +15,4 @@ ...@@ -15,5 +15,4 @@
else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; } else PyErr_SetString( PyExc_AssertionError, "Exception not raised" ); return NULL; }
#define DEF_METHOD( method, desc ) { #method, method, METH_VARARGS, desc}, #define DEF_METHOD( method, desc ) { #method, method, METH_VARARGS, desc},
...@@ -41,7 +41,15 @@ def get_ldflags(): ...@@ -41,7 +41,15 @@ def get_ldflags():
# To compile in a local vlc tree # To compile in a local vlc tree
native_libvlc_test = Extension( 'native_libvlc_test', native_libvlc_test = Extension( 'native_libvlc_test',
sources = ['native/init.c', 'native/url.c', 'native/i18n.c', 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' ], include_dirs = ['../include', '../', '/usr/win32/include' ],
extra_objects = [ '../src/.libs/libvlc.so' ], extra_objects = [ '../src/.libs/libvlc.so' ],
extra_compile_args = get_cflags(), extra_compile_args = get_cflags(),
...@@ -49,3 +57,6 @@ native_libvlc_test = Extension( 'native_libvlc_test', ...@@ -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_libvlc_test' ,version = '1242', ext_modules = [ native_libvlc_test ] )
setup( name = 'native_gc_test' ,version = '1242', ext_modules = [ native_gc_test ] )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment