예제 #1
0
파일: audio.c 프로젝트: FLYKingdom/vlc
/*****************************************************************************
 * libvlc_audio_set_track : Set the current audio track
 *****************************************************************************/
void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track,
                             libvlc_exception_t *p_e )
{
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
    vlc_value_t val_list;
    vlc_value_t newval;
    int i_ret = -1;

    if( !p_input_thread )
        return;

    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
    if( (i_track < 0) || (i_track > val_list.p_list->i_count) )
    {
        libvlc_exception_raise( p_e );
        libvlc_printerr( "Audio track out of range" );
        goto end;
    }

    newval = val_list.p_list->p_values[i_track];
    i_ret = var_Set( p_input_thread, "audio-es", newval );
    if( i_ret < 0 )
    {
        libvlc_exception_raise( p_e );
        libvlc_printerr( "Audio track out of range" ); /* Race... */
    }

end:
    var_FreeList( &val_list, NULL );
    vlc_object_release( p_input_thread );
}
예제 #2
0
libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance )
{
    struct libvlc_log_t *p_log = malloc(sizeof(*p_log));
    if (unlikely(p_log == NULL))
    {
        libvlc_printerr ("Not enough memory");
        return NULL;
    }

    p_log->p_instance = p_instance;
    vlc_spin_init( &p_log->data.lock );
    p_log->data.count = 0;
    p_log->data.verbosity = p_instance->verbosity;
    p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int, handler, &p_log->data);

    if( !p_log->p_messages )
    {
        free( p_log );
        libvlc_printerr ("Not enough memory");
        return NULL;
    }

    libvlc_retain( p_instance );
    return p_log;
}
예제 #3
0
/* internal function, used by audio, video */
libvlc_track_description_t *
        libvlc_get_track_description( libvlc_media_player_t *p_mi,
                                      const char *psz_variable )
{
    input_thread_t *p_input = libvlc_get_input_thread( p_mi );
    libvlc_track_description_t *p_track_description = NULL,
                               *p_actual, *p_previous;

    if( !p_input )
        return NULL;

    vlc_value_t val_list, text_list;
    int i_ret = var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list );
    if( i_ret != VLC_SUCCESS )
        return NULL;

    /* no tracks */
    if( val_list.p_list->i_count <= 0 )
        goto end;

    p_track_description = ( libvlc_track_description_t * )
        malloc( sizeof( libvlc_track_description_t ) );
    if ( !p_track_description )
    {
        libvlc_printerr( "Not enough memory" );
        goto end;
    }
    p_actual = p_track_description;
    p_previous = NULL;
    for( int i = 0; i < val_list.p_list->i_count; i++ )
    {
        if( !p_actual )
        {
            p_actual = ( libvlc_track_description_t * )
                malloc( sizeof( libvlc_track_description_t ) );
            if ( !p_actual )
            {
                libvlc_track_description_list_release( p_track_description );
                libvlc_printerr( "Not enough memory" );
                goto end;
            }
        }
        p_actual->i_id = val_list.p_list->p_values[i].i_int;
        p_actual->psz_name = strdup( text_list.p_list->p_values[i].psz_string );
        p_actual->p_next = NULL;
        if( p_previous )
            p_previous->p_next = p_actual;
        p_previous = p_actual;
        p_actual =  NULL;
    }

end:
    var_FreeList( &val_list, &text_list );
    vlc_object_release( p_input );

    return p_track_description;
}
예제 #4
0
파일: media.c 프로젝트: Aakash-729/vlc
/**************************************************************************
 * Create a new media descriptor object from an input_item
 * (libvlc internal)
 * That's the generic constructor
 **************************************************************************/
libvlc_media_t * libvlc_media_new_from_input_item(
                                   libvlc_instance_t *p_instance,
                                   input_item_t *p_input_item )
{
    libvlc_media_t * p_md;

    if (!p_input_item)
    {
        libvlc_printerr( "No input item given" );
        return NULL;
    }

    p_md = calloc( 1, sizeof(libvlc_media_t) );
    if( !p_md )
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_md->p_libvlc_instance = p_instance;
    p_md->p_input_item      = p_input_item;
    p_md->i_refcount        = 1;

    vlc_cond_init(&p_md->parsed_cond);
    vlc_mutex_init(&p_md->parsed_lock);
    vlc_mutex_init(&p_md->subitems_lock);

    p_md->state = libvlc_NothingSpecial;

    /* A media descriptor can be a playlist. When you open a playlist
     * It can give a bunch of item to read. */
    p_md->p_subitems        = NULL;

    p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance );
    if( unlikely(p_md->p_event_manager == NULL) )
    {
        free(p_md);
        return NULL;
    }

    libvlc_event_manager_t *em = p_md->p_event_manager;
    libvlc_event_manager_register_event_type(em, libvlc_MediaMetaChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemAdded);
    libvlc_event_manager_register_event_type(em, libvlc_MediaFreed);
    libvlc_event_manager_register_event_type(em, libvlc_MediaDurationChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaStateChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaParsedChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemTreeAdded);

    vlc_gc_incref( p_md->p_input_item );

    install_input_item_observer( p_md );

    return p_md;
}
예제 #5
0
파일: vlm.c 프로젝트: FLYKingdom/vlc
const char* libvlc_vlm_show_media( libvlc_instance_t *p_instance,
                                   const char *psz_name,
                                   libvlc_exception_t *p_exception )
{
    char *psz_message = NULL;
    vlm_message_t *answer = NULL;
    char *psz_response = NULL;
    const char *psz_fmt = NULL;
    const char *psz_delimiter = NULL;
    int i_list;
    vlm_t *p_vlm = NULL;

    VLM_RET(p_vlm, NULL);

    assert( psz_name );

    if( asprintf( &psz_message, "show %s", psz_name ) == -1 )
    {
        libvlc_exception_raise( p_exception );
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    vlm_ExecuteCommand( p_vlm, psz_message, &answer );
    if( answer->psz_value )
    {
        libvlc_exception_raise( p_exception );
        libvlc_printerr( "Unable to call show %s: %s",
                         psz_name, answer->psz_value );
    }
    else if ( answer->child )
    {   /* in case everything was requested  */
        if ( strcmp( psz_name, "" ) == 0 )
        {
            psz_fmt = "{\n\t%s\n}\n";
            psz_delimiter = "\n\t";
            i_list = 0;
        }
        else
        {
            psz_fmt = "%s\n";
            psz_delimiter = "\n";
            i_list = 1;
        }
        if( asprintf( &psz_response, psz_fmt,
                      recurse_answer( answer, psz_delimiter, i_list ) ) == -1 )
        {
            libvlc_exception_raise( p_exception );
            libvlc_printerr( "Out of memory" );
        }
    }
    free( psz_message );
    return( psz_response );
}
예제 #6
0
/**************************************************************************
 * Tell media player to start playing.
 **************************************************************************/
int libvlc_media_player_play( libvlc_media_player_t *p_mi )
{
    lock_input( p_mi );

    input_thread_t *p_input_thread = p_mi->input.p_thread;
    if( p_input_thread )
    {
        /* A thread already exists, send it a play message */
        input_Control( p_input_thread, INPUT_SET_STATE, PLAYING_S );
        unlock_input( p_mi );
        return 0;
    }

    /* Ignore previous exception */
    lock(p_mi);

    if( !p_mi->p_md )
    {
        unlock(p_mi);
        unlock_input( p_mi );
        libvlc_printerr( "No associated media descriptor" );
        return -1;
    }

    p_input_thread = input_Create( p_mi, p_mi->p_md->p_input_item, NULL,
                                   p_mi->input.p_resource );
    unlock(p_mi);
    if( !p_input_thread )
    {
        unlock_input(p_mi);
        libvlc_printerr( "Not enough memory" );
        return -1;
    }

    var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
    var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
    var_AddCallback( p_input_thread, "program-scrambled", input_scrambled_changed, p_mi );
    var_AddCallback( p_input_thread, "intf-event", input_event_changed, p_mi );

    if( input_Start( p_input_thread ) )
    {
        unlock_input(p_mi);
        var_DelCallback( p_input_thread, "intf-event", input_event_changed, p_mi );
        var_DelCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
        var_DelCallback( p_input_thread, "program-scrambled", input_scrambled_changed, p_mi );
        var_DelCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
        vlc_object_release( p_input_thread );
        libvlc_printerr( "Input initialization failure" );
        return -1;
    }
    p_mi->input.p_thread = p_input_thread;
    unlock_input(p_mi);
    return 0;
}
예제 #7
0
int libvlc_add_intf( libvlc_instance_t *p_instance, const char *name )
{
    if( libvlc_InternalAddIntf( p_instance->p_libvlc_int, name ))
    {
        if( name != NULL )
            libvlc_printerr("interface \"%s\" initialization failed", name );
        else
            libvlc_printerr("default interface initialization failed");
        return -1;
    }
    return 0;
}
예제 #8
0
파일: media.c 프로젝트: anonymous31173/vlc
/**************************************************************************
 * Create a new media descriptor object
 **************************************************************************/
libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance,
                                           const char * psz_name )
{
    input_item_t * p_input_item;
    libvlc_media_t * p_md;
    libvlc_media_list_t * p_subitems;

    p_input_item = input_item_New( "vlc://nop", psz_name );

    if (!p_input_item)
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );

    p_subitems = media_get_subitems( p_md, true );
    if( p_subitems == NULL) {
        libvlc_media_release( p_md );
        return NULL;
    }

    return p_md;
}
예제 #9
0
파일: vlm.c 프로젝트: FLYKingdom/vlc
static int libvlc_vlm_init( libvlc_instance_t *p_instance,
                            libvlc_exception_t *p_exception )
{
    if( !p_instance->libvlc_vlm.p_event_manager )
    {
        p_instance->libvlc_vlm.p_event_manager =
            libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm,
                                      p_instance, p_exception );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaAdded, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaRemoved, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaChanged, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStarted, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStopped, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusInit, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusOpening, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusPlaying, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusPause, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusEnd, NULL );
        libvlc_event_manager_register_event_type(
            p_instance->libvlc_vlm.p_event_manager,
            libvlc_VlmMediaInstanceStatusError, NULL );
    }

    if( !p_instance->libvlc_vlm.p_vlm )
    {
        p_instance->libvlc_vlm.p_vlm = vlm_New( p_instance->p_libvlc_int );
        if( !p_instance->libvlc_vlm.p_vlm )
        {
            libvlc_exception_raise( p_exception );
            libvlc_printerr( "VLM not supported or out of memory" );
            return VLC_EGENERIC;
        }
        var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm,
                         "intf-event", VlmEvent,
                         p_instance->libvlc_vlm.p_event_manager );
        p_instance->libvlc_vlm.pf_release = libvlc_vlm_release_internal;
    }

    return VLC_SUCCESS;
}
예제 #10
0
파일: vlm.c 프로젝트: IAPark/vlc
static int libvlc_vlm_init( libvlc_instance_t *p_instance )
{
    if( !p_instance->vlm )
    {
        p_instance->vlm = malloc( sizeof(*p_instance->vlm) );
        if( p_instance->vlm == NULL )
            return VLC_ENOMEM;
        p_instance->vlm->p_vlm = NULL;
        libvlc_event_manager_init( &p_instance->vlm->event_manager,
                                   p_instance->vlm );
    }

    if( !p_instance->vlm->p_vlm )
    {
        p_instance->vlm->p_vlm = vlm_New( p_instance->p_libvlc_int );
        if( !p_instance->vlm->p_vlm )
        {
            libvlc_printerr( "VLM not supported or out of memory" );
            return VLC_EGENERIC;
        }
        var_AddCallback( (vlc_object_t *)p_instance->vlm->p_vlm,
                         "intf-event", VlmEvent,
                         &p_instance->vlm->event_manager );
        libvlc_retain( p_instance );
    }

    return VLC_SUCCESS;
}
예제 #11
0
/**************************************************************************
 *       load (Public)
 *
 * It doesn't yet load the playlists
 **************************************************************************/
int libvlc_media_library_load( libvlc_media_library_t * p_mlib )
{
    char *psz_datadir = config_GetUserDir( VLC_DATA_DIR );
    char * psz_uri;

    if( psz_datadir == NULL
            || asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp",
                         psz_datadir ) == -1 )
        psz_uri = NULL;
    free( psz_datadir );

    if( psz_uri == NULL )
    {
        libvlc_printerr( "Not enough memory" );
        return -1;
    }

    if( p_mlib->p_mlist )
        libvlc_media_list_release( p_mlib->p_mlist );

    p_mlib->p_mlist = libvlc_media_list_new( p_mlib->p_libvlc_instance );

    int ret = libvlc_media_list_add_file_content( p_mlib->p_mlist, psz_uri );
    free( psz_uri );
    return ret;
}
예제 #12
0
파일: vlm.c 프로젝트: Aakash-729/vlc
int libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name,
                        const char *psz_input, int i_options,
                        const char * const *ppsz_options, int b_enabled,
                        const char *psz_mux )
{
    vlm_t *p_vlm;
    vlm_media_t m;
    int n;

    VLM_RET(p_vlm, -1);

    vlm_media_Init( &m );
    m.psz_name = strdup( psz_name );
    m.b_enabled = b_enabled;
    m.b_vod = true;
    m.vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL;
    if( psz_input )
        TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
    for( n = 0; n < i_options; n++ )
        TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );

    n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
    vlm_media_Clean( &m );
    if( n )
    {
        libvlc_printerr( "Media %s creation failed", psz_name );
        return -1;
    }
    return 0;
}
예제 #13
0
파일: media_list.c 프로젝트: Aakash-729/vlc
/**************************************************************************
 *       add_file_content (Public)
 **************************************************************************/
int
libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
                                    const char * psz_uri )
{
    input_item_t * p_input_item;
    libvlc_media_t * p_md;

    p_input_item = input_item_NewExt( psz_uri,
                                         _("Media Library"), 0, NULL, 0, -1 );

    if( !p_input_item )
    {
        libvlc_printerr( "Not enough memory" );
        return -1;
    }

    p_md = libvlc_media_new_from_input_item( p_mlist->p_libvlc_instance,
                                             p_input_item );
    if( !p_md )
    {
        vlc_gc_decref( p_input_item );
        return -1;
    }

    if( libvlc_media_list_add_media( p_mlist, p_md ) )
    {
#warning Missing error handling!
        /* printerr and leaks */
        return -1;
    }

    input_Read( p_mlist->p_libvlc_instance->p_libvlc_int, p_input_item );
    return 0;
}
예제 #14
0
파일: audio.c 프로젝트: FLYKingdom/vlc
/*****************************************************************************
 * libvlc_audio_get_track : Get the current audio track
 *****************************************************************************/
int libvlc_audio_get_track( libvlc_media_player_t *p_mi,
                            libvlc_exception_t *p_e )
{
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
    vlc_value_t val_list;
    vlc_value_t val;
    int i_track = -1;
    int i_ret = -1;
    int i;

    if( !p_input_thread )
        return -1;

    i_ret = var_Get( p_input_thread, "audio-es", &val );
    if( i_ret < 0 )
    {
        vlc_object_release( p_input_thread );
        libvlc_exception_raise( p_e );
        libvlc_printerr( "Audio track information not found" );
        return i_ret;
    }

    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
    for( i = 0; i < val_list.p_list->i_count; i++ )
    {
        if( val_list.p_list->p_values[i].i_int == val.i_int )
        {
            i_track = i;
            break;
        }
    }
    var_FreeList( &val_list, NULL );
    vlc_object_release( p_input_thread );
    return i_track;
}
예제 #15
0
/**************************************************************************
 *       new (Public)
 **************************************************************************/
libvlc_media_discoverer_t *
libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name )
{
    /* podcast SD is a hack and only works with custom playlist callbacks. */
    if( !strncasecmp( psz_name, "podcast", 7 ) )
        return NULL;

    libvlc_media_discoverer_t *p_mdis;

    p_mdis = malloc(sizeof(*p_mdis) + strlen(psz_name) + 1);
    if( unlikely(p_mdis == NULL) )
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_mdis->p_libvlc_instance = p_inst;
    p_mdis->p_mlist = libvlc_media_list_new( p_inst );
    p_mdis->p_mlist->b_read_only = true;
    p_mdis->p_sd = NULL;

    vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 );
    libvlc_event_manager_init( &p_mdis->event_manager, p_mdis );

    libvlc_retain( p_inst );
    strcpy( p_mdis->name, psz_name );
    return p_mdis;
}
예제 #16
0
파일: vlm.c 프로젝트: FLYKingdom/vlc
void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance,
                               const char *psz_name,
                               const char *psz_input,
                               const char *psz_output, int i_options,
                               const char * const *ppsz_options,
                               int b_enabled, int b_loop,
                               libvlc_exception_t *p_exception )
{
    vlm_t *p_vlm;
    vlm_media_t m;
    int n;

    VLM(p_vlm);

    vlm_media_Init( &m );
    m.psz_name = strdup( psz_name );
    m.b_enabled = b_enabled;
    m.b_vod = false;
    m.broadcast.b_loop = b_loop;
    if( psz_input )
        TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
    if( psz_output )
        m.psz_output = strdup( psz_output );
    for( n = 0; n < i_options; n++ )
        TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );

    n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
    vlm_media_Clean( &m );
    if( n )
    {
        libvlc_exception_raise( p_exception );
        libvlc_printerr( "Media %s creation failed", psz_name );
    }
}
/**************************************************************************
 *       flat_media_list_view_item_at_index  (private)
 * (called by flat_media_list_view_item_at_index)
 **************************************************************************/
static libvlc_media_t *
hierarch_node_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv,
                                        int index,
                                        libvlc_exception_t * p_e )
{
    /* FIXME: we may want to cache that */
    libvlc_media_t * p_md;
    libvlc_media_list_t * p_submlist;
    trace("%d\n", index);
    int i, current_index, count = libvlc_media_list_count( p_mlv->p_mlist, p_e );
    current_index = -1;
    for( i = 0; i < count; i++ )
    {
        p_md = libvlc_media_list_item_at_index( p_mlv->p_mlist, i, p_e );
        if( !p_md ) continue;
        p_submlist = libvlc_media_subitems( p_md );
        if( !p_submlist ) continue;
        libvlc_media_list_release( p_submlist );
        current_index++;
        if( current_index == index )
            return p_md;
        libvlc_media_release( p_md );
    }

    libvlc_exception_raise( p_e );
    libvlc_printerr( "Index out of bound in Media List View" );
    return NULL;
}
예제 #18
0
/**************************************************************************
 *       new (Public)
 **************************************************************************/
libvlc_media_library_t *
libvlc_media_library_new( libvlc_instance_t * p_inst )
{
    libvlc_media_library_t * p_mlib;

    p_mlib = malloc(sizeof(libvlc_media_library_t));

    if( !p_mlib )
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_mlib->p_libvlc_instance = p_inst;
    p_mlib->i_refcount = 1;
    p_mlib->p_mlist = NULL;

    p_mlib->p_event_manager = libvlc_event_manager_new( p_mlib, p_inst );
    if( unlikely(p_mlib->p_event_manager == NULL) )
    {
        free(p_mlib);
        return NULL;
    }

    return p_mlib;
}
예제 #19
0
파일: audio.c 프로젝트: 0xheart0/vlc
/*****************************************************************************
 * libvlc_audio_set_track : Set the current audio track
 *****************************************************************************/
int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
{
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
    vlc_value_t val_list;
    int i_ret = -1;

    if( !p_input_thread )
        return -1;

    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
    for( int i = 0; i < val_list.p_list->i_count; i++ )
    {
        if( i_track == val_list.p_list->p_values[i].i_int )
        {
            if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
                break;
            i_ret = 0;
            goto end;
        }
    }
    libvlc_printerr( "Track identifier not found" );
end:
    var_FreeList( &val_list, NULL );
    vlc_object_release( p_input_thread );
    return i_ret;
}
예제 #20
0
파일: vlm.c 프로젝트: Geal/vlc
static int libvlc_vlm_init( libvlc_instance_t *p_instance )
{
    if( !p_instance->libvlc_vlm.p_event_manager )
    {
        p_instance->libvlc_vlm.p_event_manager =
            libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm );
        if( unlikely(p_instance->libvlc_vlm.p_event_manager == NULL) )
            return VLC_ENOMEM;
    }

    if( !p_instance->libvlc_vlm.p_vlm )
    {
        p_instance->libvlc_vlm.p_vlm = vlm_New( p_instance->p_libvlc_int );
        if( !p_instance->libvlc_vlm.p_vlm )
        {
            libvlc_printerr( "VLM not supported or out of memory" );
            return VLC_EGENERIC;
        }
        var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm,
                         "intf-event", VlmEvent,
                         p_instance->libvlc_vlm.p_event_manager );
        p_instance->libvlc_vlm.pf_release = libvlc_vlm_release_internal;
        libvlc_retain( p_instance );
    }

    return VLC_SUCCESS;
}
예제 #21
0
파일: media_list.c 프로젝트: Geal/vlc
/**************************************************************************
 *       libvlc_media_list_new (Public)
 *
 * Init an object.
 **************************************************************************/
libvlc_media_list_t *
libvlc_media_list_new( libvlc_instance_t * p_inst )
{
    libvlc_media_list_t * p_mlist;

    p_mlist = malloc(sizeof(libvlc_media_list_t));
    if( unlikely(p_mlist == NULL) )
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_mlist->p_libvlc_instance = p_inst;
    p_mlist->p_event_manager = libvlc_event_manager_new( p_mlist );
    if( unlikely(p_mlist->p_event_manager == NULL) )
    {
        free(p_mlist);
        return NULL;
    }

    p_mlist->b_read_only = false;

    vlc_mutex_init( &p_mlist->object_lock );
    vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?

    vlc_array_init( &p_mlist->items );
    assert( p_mlist->items.i_count == 0 );
    p_mlist->i_refcount = 1;
    p_mlist->p_md = NULL;
    p_mlist->p_internal_md = NULL;

    libvlc_retain( p_inst );
    return p_mlist;
}
예제 #22
0
파일: vlm.c 프로젝트: Aakash-729/vlc
static vlm_media_instance_t *
libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
                               const char *psz_name, int i_minstance_idx )
{
    vlm_t *p_vlm;
    vlm_media_instance_t **pp_minstance;
    vlm_media_instance_t *p_minstance;
    int i_minstance;
    int64_t id;

    VLM_RET(p_vlm, NULL);

    if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
        vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance,
                     &i_minstance ) )
    {
        libvlc_printerr( "%s: media instances not found", psz_name );
        return NULL;
    }
    p_minstance = NULL;
    if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
    {
        p_minstance = pp_minstance[i_minstance_idx];
        TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
    }
    while( i_minstance > 0 )
        vlm_media_instance_Delete( pp_minstance[--i_minstance] );
    TAB_CLEAN( i_minstance, pp_minstance );
    return p_minstance;
}
예제 #23
0
/**************************************************************************
 *         new (Public)
 **************************************************************************/
libvlc_media_list_player_t *
libvlc_media_list_player_new(libvlc_instance_t * p_instance)
{
    libvlc_media_list_player_t * p_mlp;
    p_mlp = calloc( 1, sizeof(libvlc_media_list_player_t) );
    if (unlikely(p_mlp == NULL))
    {
        libvlc_printerr("Not enough memory");
        return NULL;
    }

    p_mlp->p_event_manager = libvlc_event_manager_new(p_mlp, p_instance);
    if (unlikely(p_mlp->p_event_manager == NULL))
    {
        free (p_mlp);
        return NULL;
    }

    libvlc_retain(p_instance);
    p_mlp->p_libvlc_instance = p_instance;
    p_mlp->i_refcount = 1;
    vlc_mutex_init(&p_mlp->object_lock);
    vlc_mutex_init(&p_mlp->mp_callback_lock);
    libvlc_event_manager_register_event_type(p_mlp->p_event_manager, libvlc_MediaListPlayerNextItemSet);
    p_mlp->e_playback_mode = libvlc_playback_mode_default;

    return p_mlp;
}
예제 #24
0
파일: media_list.c 프로젝트: Geal/vlc
/**************************************************************************
 *       libvlc_media_list_index_of_item (Public)
 *
 * Lock should be held when entering.
 * Warning: this function returns the first matching item.
 **************************************************************************/
int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
                                     libvlc_media_t * p_searched_md )
{
    int idx = vlc_array_index_of_item( &p_mlist->items, p_searched_md );
    if( idx == -1 )
        libvlc_printerr( "Media not found" );

    return idx;
}
예제 #25
0
파일: audio.c 프로젝트: 0xheart0/vlc
/*
 * Remember to release the returned audio_output_t since it is locked at
 * the end of this function.
 */
static audio_output_t *GetAOut( libvlc_media_player_t *mp )
{
    assert( mp != NULL );

    audio_output_t *p_aout = input_resource_HoldAout( mp->input.p_resource );
    if( p_aout == NULL )
        libvlc_printerr( "No active audio output" );
    return p_aout;
}
예제 #26
0
/*****************************************************************************
 * libvlc_audio_output_set_device_type : Set the audio device type
 *****************************************************************************/
void libvlc_audio_output_set_device_type( libvlc_media_player_t *mp,
                                          int device_type )
{
    aout_instance_t *p_aout = GetAOut( mp );
    if( !p_aout )
        return;
    if( var_SetInteger( p_aout, "audio-device", device_type ) < 0 )
        libvlc_printerr( "Error setting audio device" );
    vlc_object_release( p_aout );
}
예제 #27
0
파일: media_list.c 프로젝트: Aakash-729/vlc
/**************************************************************************
 *       static mlist_is_writable (private)
 **************************************************************************/
static inline
bool mlist_is_writable( libvlc_media_list_t *p_mlist )
{
    if( !p_mlist||p_mlist->b_read_only )
    {
        /* We are read-only from user side */
        libvlc_printerr( "Attempt to write a read-only media list" );
        return false;
    }
    return true;
}
예제 #28
0
파일: core.c 프로젝트: FLYKingdom/vlc
int libvlc_add_intf( libvlc_instance_t *p_i, const char *name,
                      libvlc_exception_t *p_e )
{
    if( libvlc_InternalAddIntf( p_i->p_libvlc_int, name ) )
    {
        libvlc_printerr("Interface initialization failed");
        libvlc_exception_raise( p_e );
        return -1;
    }
    return 0;
}
예제 #29
0
파일: audio.c 프로젝트: JobsSteve/Task
/*****************************************************************************
 * libvlc_audio_set_volume : Set the current volume
 *****************************************************************************/
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
{
    volume = (volume * AOUT_VOLUME_DEFAULT + 50) / 100;
    if (volume < 0 || volume > AOUT_VOLUME_MAX)
    {
        libvlc_printerr( "Volume out of range" );
        return -1;
    }
    aout_VolumeSet (mp, volume);
    return 0;
}
예제 #30
0
/*****************************************************************************
 * libvlc_audio_set_volume : Set the current volume
 *****************************************************************************/
int libvlc_audio_set_volume( libvlc_media_player_t *mp, int i_volume )
{
    if( i_volume < 0 || i_volume > 200 )
    {
        libvlc_printerr( "Volume out of range" );
        return -1;
    }

    i_volume = (i_volume * AOUT_VOLUME_MAX + 100) / 200;
    aout_VolumeSet( mp, i_volume );
    return 0;
}