Changeset 8444ce1225006facbe1b6742f8b864c66a64fe0d

Show
Ignore:
Timestamp:
02/15/06 23:31:49 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1140042709 +0000
git-parent:

[73c29a6a9f11299a8d2ec8c7c6fe16c67c74bba3]

git-author:
Clément Stenac <zorglub@videolan.org> 1140042709 +0000
Message:

More VLM API stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc/libvlc.h

    re0003be r8444ce1  
    348348 
    349349/** 
     350 * Set the output for a media 
     351 * \param p_instance the instance 
     352 * \param psz_name the media to work on 
     353 * \param psz_output the output MRL (the parameter to the "sout" variable) 
     354 * \param p_exception an initialized exception 
     355 */ 
     356void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*, 
     357                            libvlc_exception_t *); 
     358 
     359/** 
     360 * Set a media's input MRL. This will delete all existing inputs and 
     361 * add the specified one. 
     362 * \param p_instance the instance 
     363 * \param psz_name the media to work on 
     364 * \param psz_input the input MRL 
     365 * \param p_exception an initialized exception 
     366 */ 
     367void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*, 
     368                           libvlc_exception_t *); 
     369 
     370 
     371 
     372/** 
     373 * Set output for a media 
     374 * \param p_instance the instance 
     375 * \param psz_name the media to work on 
     376 * \param b_loop the new status 
     377 * \param p_exception an initialized exception 
     378 */ 
     379void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int, 
     380                          libvlc_exception_t *); 
     381 
     382 
     383 
     384 
     385/** 
    350386 * Edit the parameters of a media. This will delete all existing inputs and 
    351387 * add the specified one. 
  • src/control/vlm.c

    rce98868 r8444ce1  
    3939                      libvlc_exception_raise( p_exception, \ 
    4040                                         "Unable to create VLM" ); return; } } 
     41 
     42#define GET_MEDIA { p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );\ 
     43                   if( !p_media ) \ 
     44                   { \ 
     45                        libvlc_exception_raise( p_exception, \ 
     46                                                "Media %s does not exist", \ 
     47                                                psz_name ); return; } } 
    4148 
    4249void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name, 
     
    8390    vlm_media_t *p_media; 
    8491    CHECK_VLM; 
    85  
     92    GET_MEDIA; 
    8693    if( b_enabled != 0 ) b_enabled = 1; 
    87  
    88     p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name ); 
    89     if( !p_media ) 
    90     { 
    91         libvlc_exception_raise( p_exception, "Media %s does not exist", 
    92                                 psz_name ); 
    93         return; 
    94     } 
    9594    p_media->b_enabled = b_enabled; 
    9695} 
     96 
     97void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, char *psz_name, 
     98                          int b_loop, libvlc_exception_t *p_exception ) 
     99{ 
     100    vlm_media_t *p_media; 
     101    CHECK_VLM; 
     102    GET_MEDIA; 
     103    if( b_loop != 0 ) b_loop = 1; 
     104    p_media->b_loop = b_loop; 
     105} 
     106 
     107void libvlc_vlm_set_output( libvlc_instance_t *p_instance, char *psz_name, 
     108                            char *psz_output,  libvlc_exception_t *p_exception ) 
     109{ 
     110    vlm_media_t *p_media; 
     111    int i_ret; 
     112    CHECK_VLM; 
     113    GET_MEDIA; 
     114 
     115    vlc_mutex_lock( &p_instance->p_vlm->lock ); 
     116    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output ); 
     117    if( i_ret ) 
     118    { libvlc_exception_raise( p_exception, "Unable to set output" ); return;} 
     119    vlc_mutex_unlock( &p_instance->p_vlm->lock ); 
     120} 
     121 
     122void libvlc_vlm_set_input( libvlc_instance_t *p_instance, char *psz_name, 
     123                           char *psz_input,  libvlc_exception_t *p_exception ) 
     124{ 
     125    vlm_media_t *p_media; 
     126    int i_ret; 
     127    CHECK_VLM; 
     128    GET_MEDIA; 
     129 
     130    vlc_mutex_lock( &p_instance->p_vlm->lock ); 
     131 
     132    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" ); 
     133    if( i_ret ) 
     134    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;} 
     135    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input ); 
     136    if( i_ret ) 
     137    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;} 
     138 
     139    vlc_mutex_unlock( &p_instance->p_vlm->lock ); 
     140} 
     141 
     142void libvlc_vlm_add_input( libvlc_instance_t *p_instance, char *psz_name, 
     143                           char *psz_input,  libvlc_exception_t *p_exception ) 
     144{ 
     145    vlm_media_t *p_media; 
     146    int i_ret; 
     147    CHECK_VLM; 
     148    GET_MEDIA; 
     149 
     150    vlc_mutex_lock( &p_instance->p_vlm->lock ); 
     151 
     152    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input ); 
     153    if( i_ret ) 
     154    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;} 
     155 
     156    vlc_mutex_unlock( &p_instance->p_vlm->lock ); 
     157} 
     158 
     159 
     160 
    97161 
    98162void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name, 
     
    102166{ 
    103167    vlm_media_t *p_media; 
     168    int i_ret; 
    104169    CHECK_VLM; 
     170    GET_MEDIA; 
    105171    if( b_enabled != 0 ) b_enabled = 1; 
    106172    if( b_loop != 0 ) b_loop = 1; 
    107173 
    108     p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name ); 
    109     if( !p_media ) 
    110     { 
    111         libvlc_exception_raise( p_exception, "Media %s does not exist", 
    112                                 psz_name ); 
    113         return; 
    114     } 
     174    vlc_mutex_lock( &p_instance->p_vlm->lock ); 
     175    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output ); 
     176    if( i_ret ) libvlc_exception_raise( p_exception, "Unable to set output" ); 
    115177    p_media->b_enabled = b_enabled; 
    116178    p_media->b_loop = b_loop; 
     179 
     180    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output ); 
     181    if( i_ret ) 
     182    { libvlc_exception_raise( p_exception, "Unable to set output" ); return;} 
     183    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" ); 
     184    if( i_ret ) 
     185    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;} 
     186    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input ); 
     187    if( i_ret ) 
     188    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;} 
     189 
     190    vlc_mutex_unlock( &p_instance->p_vlm->lock ); 
    117191} 
  • test/native/libvlc.c

    ref273c0 r8444ce1  
    9494    libvlc_instance_t *p_instance; 
    9595    char *argv[] = { "vlc", "--quiet" }; 
     96    char *ppsz_empty[] = {}; 
    9697    libvlc_exception_t exception; 
    9798    libvlc_exception_init( &exception ); 
     
    99100    p_instance = libvlc_new( 2, argv, &exception ); 
    100101    ASSERT_NOEXCEPTION; 
    101     
     102   
     103    /* Test that working on unexisting streams fail */ 
    102104    libvlc_vlm_set_enabled( p_instance, "test", 1, &exception ); 
    103105    ASSERT_EXCEPTION; 
    104106    libvlc_exception_clear( &exception ); 
     107    libvlc_vlm_set_input( p_instance, "test", "input", &exception ); 
     108    ASSERT_EXCEPTION; 
     109    libvlc_exception_clear( &exception ); 
     110    libvlc_vlm_del_media( p_instance, "test", &exception ); 
     111    ASSERT_EXCEPTION; 
     112    libvlc_exception_clear( &exception ); 
     113 
     114    /*******  Broadcast *******/ 
     115    /* Now create a media */ 
     116    libvlc_vlm_add_broadcast( p_instance, "test", "input_test", "output_test", 
     117                              0, ppsz_empty, 1, 1, &exception ); 
     118    ASSERT_NOEXCEPTION; 
     119    libvlc_exception_clear( &exception ); 
     120 
     121    /* Change its parameters */ 
     122    libvlc_vlm_set_enabled( p_instance, "test", 0, &exception ); 
     123    ASSERT_NOEXCEPTION; 
     124    libvlc_exception_clear( &exception ); 
     125    libvlc_vlm_set_output( p_instance, "test", "output_test2", &exception ); 
     126    ASSERT_NOEXCEPTION; 
     127    libvlc_exception_clear( &exception ); 
     128 
     129    /* Check the parameters */ 
     130    fprintf( stderr, "The code for this is not written yet\n"); 
     131 
     132    /* Control it a bit */ 
     133    fprintf( stderr, "The code for this is not written yet\n"); 
     134 
     135    /* Try to delete it */ 
     136    libvlc_vlm_del_media( p_instance, "test", &exception ); 
     137    ASSERT_NOEXCEPTION; 
     138    libvlc_exception_clear( &exception ); 
     139 
     140    libvlc_vlm_del_media( p_instance, "test", &exception ); 
     141    ASSERT_EXCEPTION; 
     142    libvlc_exception_clear( &exception ); 
     143 
     144    /*******  VOD *******/ 
    105145 
    106146    Py_INCREF( Py_None );