Пример #1
0
mediacontrol_PlaylistSeq *
mediacontrol_playlist_get_list( mediacontrol_Instance *self,
                                mediacontrol_Exception *exception )
{
    mediacontrol_PlaylistSeq *retval = NULL;
    int i_index;
    playlist_t * p_playlist = self->p_playlist;
    int i_playlist_size;

    exception=mediacontrol_exception_init( exception );
    if( !p_playlist )
    {
        RAISE( mediacontrol_PlaylistException, "No playlist" );
        return NULL;
    }

    vlc_mutex_lock( &p_playlist->object_lock );
    i_playlist_size = p_playlist->i_size;

    retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );

    for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )
    {
        retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->input.psz_uri );
    }
    vlc_mutex_unlock( &p_playlist->object_lock );

    return retval;
}
Пример #2
0
char *
mediacontrol_get_mrl( mediacontrol_Instance *self,
                      mediacontrol_Exception *exception )
{
    libvlc_media_t * p_media;
    libvlc_exception_t ex;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );

    if ( ! p_media )
    {
        return strdup( "" );
    }
    else
    {
        char * psz_mrl;

        psz_mrl = libvlc_media_get_mrl( p_media, &ex );
        HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
        return psz_mrl;
    }
}
Пример #3
0
void
mediacontrol_set_rate( mediacontrol_Instance *self,
               const int rate,
               mediacontrol_Exception *exception )
{
    mediacontrol_exception_init( exception );

    libvlc_media_player_set_rate( self->p_media_player, rate * 10 );
}
Пример #4
0
int
mediacontrol_get_rate( mediacontrol_Instance *self,
               mediacontrol_Exception *exception )
{
    int i_ret;

    mediacontrol_exception_init( exception );
    i_ret = libvlc_media_player_get_rate( self->p_media_player );

    return (i_ret >= 0) ? (i_ret / 10) : -1;
}
Пример #5
0
void
mediacontrol_stop( mediacontrol_Instance *self,
                   mediacontrol_Exception *exception )
{
    libvlc_exception_t ex;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );
    libvlc_media_player_stop( self->p_media_player, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
Пример #6
0
void
mediacontrol_sound_set_volume( mediacontrol_Instance *self,
                               const unsigned short volume,
                               mediacontrol_Exception *exception )
{
    /* FIXME: Normalize in [0..100] */
    mediacontrol_exception_init( exception );

    //libvlc_audio_set_volume( self->p_instance, volume );
#warning FIXME: unimplented
}
Пример #7
0
int mediacontrol_set_visual( mediacontrol_Instance *self,
                                    WINDOWHANDLE visual_id,
                                    mediacontrol_Exception *exception )
{
    mediacontrol_exception_init( exception );
#ifdef WIN32
    libvlc_media_player_set_hwnd( self->p_media_player, visual_id );
#else
    libvlc_media_player_set_xwindow( self->p_media_player, visual_id );
#endif
    return true;
}
Пример #8
0
void
mediacontrol_playlist_clear( mediacontrol_Instance *self,
                             mediacontrol_Exception *exception )
{
    exception=mediacontrol_exception_init( exception );
    if( !self->p_playlist )
    {
        RAISE( mediacontrol_PlaylistException, "No playlist" );
    }
    else
        playlist_Clear( self->p_playlist );
}
Пример #9
0
void
mediacontrol_playlist_next_item( mediacontrol_Instance *self,
                                 mediacontrol_Exception *exception )
{
    exception=mediacontrol_exception_init( exception );
    if ( !self->p_playlist )
    {
        RAISE( mediacontrol_InternalException, "No playlist" );
    }
    else
        playlist_Next( self->p_playlist );
}
Пример #10
0
unsigned short
mediacontrol_sound_get_volume( mediacontrol_Instance *self,
                               mediacontrol_Exception *exception )
{
    int i_ret = 0;

    mediacontrol_exception_init( exception );

    //i_ret = libvlc_audio_get_volume( self->p_instance );
#warning FIXME: unimplented
    /* FIXME: Normalize in [0..100] */
    return (unsigned short)i_ret;
}
Пример #11
0
void
mediacontrol_set_fullscreen( mediacontrol_Instance *self,
                 const int b_fullscreen,
                 mediacontrol_Exception *exception )
{
    libvlc_exception_t ex;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    libvlc_set_fullscreen( self->p_media_player, b_fullscreen, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
Пример #12
0
/*
 * Known issues: since moving in the playlist using playlist_Next
 * or playlist_Prev implies starting to play items, the a_position
 * argument will be only honored for the 1st item in the list.
 *
 * XXX:FIXME split moving in the playlist and playing items two
 * different actions or make playlist_<Next|Prev> accept a time
 * value to start to play from.
 */
void
mediacontrol_start( mediacontrol_Instance *self,
                    const mediacontrol_Position * a_position,
                    mediacontrol_Exception *exception )
{
    libvlc_media_t * p_media;
    char * psz_name;
    libvlc_exception_t ex;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    p_media = libvlc_media_player_get_media( self->p_media_player, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );

    if ( ! p_media )
    {
        /* No media was defined. */
        RAISE( mediacontrol_PlaylistException, "No defined media." );
    }
    else
    {
        /* A media was defined. Get its mrl to reuse it, but reset the options
           (because start-time may have been set on the previous invocation */
        psz_name = libvlc_media_get_mrl( p_media, &ex );
        HANDLE_LIBVLC_EXCEPTION_VOID( &ex );

        /* Create a new media */
        p_media = libvlc_media_new( self->p_instance, psz_name, &ex );
        HANDLE_LIBVLC_EXCEPTION_VOID( &ex );

        if( a_position->value )
        {
            char * psz_from;
            libvlc_time_t i_from;

            /* A start position was specified. Add it to media options */
            psz_from = ( char * )malloc( 20 * sizeof( char ) );
            i_from = private_mediacontrol_position2microsecond( self->p_media_player, a_position ) / 1000000;
            snprintf( psz_from, 20, "start-time=%"PRId64, i_from );
            libvlc_media_add_option( p_media, psz_from, &ex );
            HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
        }

        libvlc_media_player_set_media( self->p_media_player, p_media, &ex );
        HANDLE_LIBVLC_EXCEPTION_VOID( &ex );

        libvlc_media_player_play( self->p_media_player, &ex );
        HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
    }
}
Пример #13
0
void
mediacontrol_stop( mediacontrol_Instance *self,
                   const mediacontrol_Position * a_position,
                   mediacontrol_Exception *exception )
{
    /* FIXME: use the a_position parameter */
    exception=mediacontrol_exception_init( exception );
    if( !self->p_playlist )
    {
        RAISE( mediacontrol_PlaylistException, "No playlist" );
    }
    else
        playlist_Stop( self->p_playlist );
}
Пример #14
0
void
mediacontrol_playlist_add_item( mediacontrol_Instance *self,
                                const char * psz_file,
                                mediacontrol_Exception *exception )
{
    exception=mediacontrol_exception_init( exception );
    if( !self->p_playlist )
    {
        RAISE( mediacontrol_InternalException, "No playlist" );
    }
    else
        playlist_Add( self->p_playlist, psz_file, psz_file , PLAYLIST_INSERT,
                      PLAYLIST_END );
}
Пример #15
0
/* Sets the media position */
void
mediacontrol_set_media_position( mediacontrol_Instance *self,
                                 const mediacontrol_Position * a_position,
                                 mediacontrol_Exception *exception )
{
    libvlc_exception_t ex;
    int64_t i_pos;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    i_pos = private_mediacontrol_position2microsecond( self->p_media_player, a_position );
    libvlc_media_player_set_time( self->p_media_player, i_pos / 1000, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
Пример #16
0
int
mediacontrol_get_fullscreen( mediacontrol_Instance *self,
                 mediacontrol_Exception *exception )
{
    libvlc_exception_t ex;
    int i_ret;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    i_ret = libvlc_get_fullscreen( self->p_media_player, &ex );
    HANDLE_LIBVLC_EXCEPTION_ZERO( &ex );

    return i_ret;
}
Пример #17
0
/*
 * Known issues: since moving in the playlist using playlist_Next
 * or playlist_Prev implies starting to play items, the a_position
 * argument will be only honored for the 1st item in the list.
 * 
 * XXX:FIXME split moving in the playlist and playing items two
 * different actions or make playlist_<Next|Prev> accept a time
 * value to start to play from.
 */
void
mediacontrol_start( mediacontrol_Instance *self,
                    const mediacontrol_Position * a_position,
                    mediacontrol_Exception *exception )
{
    playlist_t * p_playlist = self->p_playlist;

    exception = mediacontrol_exception_init( exception );
    if( ! p_playlist )
    {
        RAISE( mediacontrol_PlaylistException, "No available playlist" );
        return;
    }

    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_playlist->i_size )
    {
        int i_index;
        int i_from;
        char *psz_from = NULL;

        psz_from = ( char * )malloc( 20 * sizeof( char ) );
        if( psz_from )
        {
            i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;
            i_index = p_playlist->i_index;
            if( i_index < 0 )
            {
                /* We know that there is at least 1 element, since i_size != 0 */
                i_index = 0;
            }

            /* Set start time */
            snprintf( psz_from, 20, "start-time=%i", i_from );
            playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from );
            free( psz_from );
        }

        vlc_mutex_unlock( &p_playlist->object_lock );
        playlist_Play( p_playlist );
    }
    else
    {
        RAISE( mediacontrol_PlaylistException, "Empty playlist." );
        vlc_mutex_unlock( &p_playlist->object_lock );
    }
}
Пример #18
0
void
mediacontrol_set_mrl( mediacontrol_Instance *self,
                      const char * psz_file,
                      mediacontrol_Exception *exception )
{
    libvlc_media_t * p_media;
    libvlc_exception_t ex;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    p_media = libvlc_media_new( self->p_instance, psz_file, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );

    libvlc_media_player_set_media( self->p_media_player, p_media, &ex );
    HANDLE_LIBVLC_EXCEPTION_VOID( &ex );
}
Пример #19
0
mediacontrol_Instance* mediacontrol_new( int argc, char** argv, mediacontrol_Exception *exception )
{
    mediacontrol_Instance* retval;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) );
    if( !retval )
        RAISE_NULL( mediacontrol_InternalException, "Out of memory" );

    retval->p_instance = libvlc_new( argc, (const char**)argv, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    retval->p_media_player = libvlc_media_player_new( retval->p_instance, &ex );
    HANDLE_LIBVLC_EXCEPTION_NULL( &ex );
    return retval;
}
Пример #20
0
void
mediacontrol_resume( mediacontrol_Instance *self,
                     const mediacontrol_Position * a_position,
                     mediacontrol_Exception *exception )
{
    input_thread_t *p_input = self->p_playlist->p_input;

    /* FIXME: use the a_position parameter */
    exception=mediacontrol_exception_init( exception );
    if( p_input != NULL )
    {
        var_SetInteger( p_input, "state", PAUSE_S );
    }
    else
    {
        RAISE( mediacontrol_InternalException, "No input" );
    }
}
Пример #21
0
/**************************************************************************
 * Playback management
 **************************************************************************/
mediacontrol_Position*
mediacontrol_get_media_position( mediacontrol_Instance *self,
                                 const mediacontrol_PositionOrigin an_origin,
                                 const mediacontrol_PositionKey a_key,
                                 mediacontrol_Exception *exception )
{
    mediacontrol_Position* retval = NULL;
    libvlc_exception_t ex;
    int64_t pos;

    mediacontrol_exception_init( exception );
    libvlc_exception_init( &ex );

    retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
    retval->origin = an_origin;
    retval->key = a_key;

    if(  an_origin != mediacontrol_AbsolutePosition )
    {
        free( retval );
        /* Relative or ModuloPosition make no sense */
        RAISE_NULL( mediacontrol_PositionOriginNotSupported,
                    "Only absolute position is valid." );
    }

    /* We are asked for an AbsolutePosition. */
    pos = libvlc_media_player_get_time( self->p_media_player, &ex );

    if( a_key == mediacontrol_MediaTime )
    {
        retval->value = pos;
    }
    else
    {
        retval->value = private_mediacontrol_unit_convert( self->p_media_player,
                                                           mediacontrol_MediaTime,
                                                           a_key,
                                                           pos );
    }
    return retval;
}
Пример #22
0
/**************************************************************************
 * Playback management
 **************************************************************************/
mediacontrol_Position*
mediacontrol_get_media_position( mediacontrol_Instance *self,
                                 const mediacontrol_PositionOrigin an_origin,
                                 const mediacontrol_PositionKey a_key,
                                 mediacontrol_Exception *exception )
{
    mediacontrol_Position* retval = NULL;
    vlc_value_t val;
    input_thread_t * p_input = self->p_playlist->p_input;

    exception = mediacontrol_exception_init( exception );

    retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) );
    retval->origin = an_origin;
    retval->key = a_key;

    if( ! p_input )
    {
        RAISE( mediacontrol_InternalException, "No input thread." );
        return NULL;
    }

    if(  an_origin != mediacontrol_AbsolutePosition )
    {
        /* Relative or ModuloPosition make no sense */
        RAISE( mediacontrol_PositionOriginNotSupported,
                                        "Only absolute position is valid." );
        return NULL;
    }

    /* We are asked for an AbsolutePosition. */
    val.i_time = 0;
    var_Get( p_input, "time", &val );
    /* FIXME: check val.i_time > 0 */

    retval->value = mediacontrol_unit_convert( p_input,
                                               mediacontrol_MediaTime,
                                               a_key,
                                               val.i_time / 1000 );
    return retval;
}
Пример #23
0
/* Sets the media position */
void
mediacontrol_set_media_position( mediacontrol_Instance *self,
                                 const mediacontrol_Position * a_position,
                                 mediacontrol_Exception *exception )
{
    vlc_value_t val;
    input_thread_t * p_input = self->p_playlist->p_input;

    exception=mediacontrol_exception_init( exception );
    if( ! p_input )
    {
        RAISE( mediacontrol_InternalException, "No input thread." );
    }
    else if( !var_GetBool( p_input, "seekable" ) )
    {
        RAISE( mediacontrol_InvalidPosition, "Stream not seekable" );
    }
    else
    {
        val.i_time = mediacontrol_position2microsecond( p_input, a_position );
        var_Set( p_input, "time", val );
    }
}
Пример #24
0
mediacontrol_RGBPicture *
mediacontrol_snapshot( mediacontrol_Instance *self,
                       const mediacontrol_Position * a_position,
                       mediacontrol_Exception *exception )
{
    (void)a_position;
    vout_thread_t* p_vout;
    input_thread_t *p_input;
    mediacontrol_RGBPicture *p_pic;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    p_input = libvlc_get_input_thread( self->p_media_player );
    if( ! p_input )
    {
        RAISE_NULL( mediacontrol_InternalException, "No input" );
    }

    p_vout = input_GetVout( p_input );
    vlc_object_release( p_input );
    if( ! p_vout )
    {
        RAISE_NULL( mediacontrol_InternalException, "No video output" );
    }

    block_t *p_image;
    video_format_t fmt;

    if( vout_GetSnapshot( p_vout, &p_image, NULL, &fmt, "png", 500*1000 ) )
    {
        vlc_object_release( p_vout );
        RAISE_NULL( mediacontrol_InternalException, "Snapshot exception" );
        return NULL;
    }

    /* */
    char *p_data = malloc( p_image->i_buffer );
    if( p_data )
    {
        memcpy( p_data, p_image->p_buffer, p_image->i_buffer );
        p_pic = private_mediacontrol_createRGBPicture( fmt.i_width,
                                                       fmt.i_height,
                                                       fmt.i_chroma,
                                                       p_image->i_pts,
                                                       p_data,
                                                       p_image->i_buffer );
    }
    else
    {
        p_pic = NULL;
    }
    block_Release( p_image );

    if( !p_pic )
        RAISE_NULL( mediacontrol_InternalException, "Out of memory" );

    vlc_object_release( p_vout );
    return p_pic;
}
Пример #25
0
void
mediacontrol_display_text( mediacontrol_Instance *self,
                           const char * message,
                           const mediacontrol_Position * begin,
                           const mediacontrol_Position * end,
                           mediacontrol_Exception *exception )
{
    vout_thread_t *p_vout = NULL;
    input_thread_t *p_input;
    libvlc_exception_t ex;

    libvlc_exception_init( &ex );
    mediacontrol_exception_init( exception );

    if( !message )
    {
        RAISE_VOID( mediacontrol_InternalException, "Empty text" );
    }

    p_input = libvlc_get_input_thread( self->p_media_player );
    if( ! p_input )
    {
        RAISE_VOID( mediacontrol_InternalException, "No input" );
    }
    p_vout = input_GetVout( p_input );
    /*FIXME: take care of the next fixme that can use p_input */
    vlc_object_release( p_input );

    if( ! p_vout )
    {
        RAISE_VOID( mediacontrol_InternalException, "No video output" );
    }

    if( begin->origin == mediacontrol_RelativePosition &&
        begin->value == 0 &&
        end->origin == mediacontrol_RelativePosition )
    {
        mtime_t i_duration = 0;
        mtime_t i_now = mdate();

        i_duration = 1000 * private_mediacontrol_unit_convert(
                                                              self->p_media_player,
                                                              end->key,
                                                              mediacontrol_MediaTime,
                                                              end->value );

        mediacontrol_showtext( p_vout, DEFAULT_CHAN, message, NULL,
                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
                               i_now, i_now + i_duration );
    }
    else
    {
        mtime_t i_debut, i_fin, i_now;

        /* FIXME */
        /* i_now = input_ClockGetTS( p_input, NULL, 0 ); */
        i_now = mdate();

        i_debut = private_mediacontrol_position2microsecond( self->p_media_player,
                                            ( mediacontrol_Position* ) begin );
        i_debut += i_now;

        i_fin = private_mediacontrol_position2microsecond( self->p_media_player,
                                          ( mediacontrol_Position * ) end );
        i_fin += i_now;

        vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, message, NULL,
                               OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 0, 0,
                               i_debut, i_fin );
    }

    vlc_object_release( p_vout );
}