Example #1
0
/*****************************************************************************
 * ReadMetaData : Read meta data when parsed by vlc
 *****************************************************************************/
static void ReadMetaData(intf_thread_t *p_this, input_thread_t *p_input)
{
    intf_sys_t *p_sys = p_this->p_sys;

    assert(p_input != NULL);

    input_item_t *p_item = input_GetItem(p_input);
    if (p_item == NULL)
        return;

#define ALLOC_ITEM_META(a, b) do { \
        char *psz_meta = input_item_Get##b(p_item); \
        if (psz_meta && *psz_meta) \
            a = encode_URI_component(psz_meta); \
        free(psz_meta); \
    } while (0)

    vlc_mutex_lock(&p_sys->lock);

    p_sys->b_meta_read = true;

    ALLOC_ITEM_META(p_sys->p_current_song.psz_a, Artist);
    if (!p_sys->p_current_song.psz_a)
    {
        msg_Dbg(p_this, "No artist..");
        DeleteSong(&p_sys->p_current_song);
        goto end;
    }

    ALLOC_ITEM_META(p_sys->p_current_song.psz_t, Title);
    if (!p_sys->p_current_song.psz_t)
    {
        msg_Dbg(p_this, "No track name..");
        DeleteSong(&p_sys->p_current_song);
        goto end;
    }

    /* Now we have read the mandatory meta data, so we can submit that info */
    p_sys->b_submit = true;

    ALLOC_ITEM_META(p_sys->p_current_song.psz_b, Album);
    if (!p_sys->p_current_song.psz_b)
        p_sys->p_current_song.psz_b = calloc(1, 1);

    ALLOC_ITEM_META(p_sys->p_current_song.psz_m, TrackID);
    if (!p_sys->p_current_song.psz_m)
        p_sys->p_current_song.psz_m = calloc(1, 1);

    p_sys->p_current_song.i_l = input_item_GetDuration(p_item) / 1000000;

    ALLOC_ITEM_META(p_sys->p_current_song.psz_n, TrackNum);
    if (!p_sys->p_current_song.psz_n)
        p_sys->p_current_song.psz_n = calloc(1, 1);
#undef ALLOC_ITEM_META

    msg_Dbg(p_this, "Meta data registered");

end:
    vlc_mutex_unlock(&p_sys->lock);
}
Example #2
0
void InputManager::requestArtUpdate( input_item_t *p_item )
{
    bool b_current_item = false;
    if ( !p_item && hasInput() )
    {   /* default to current item */
        p_item = input_GetItem( p_input );
        b_current_item = true;
    }

    if ( p_item )
    {
        /* check if it has already been enqueued */
        if ( p_item->p_meta )
        {
            int status = vlc_meta_GetStatus( p_item->p_meta );
            if ( status & ( ITEM_ART_NOTFOUND|ITEM_ART_FETCHED ) )
                return;
        }
        playlist_AskForArtEnqueue( pl_Get(p_intf), p_item );
        /* No input will signal the cover art to update,
             * let's do it ourself */
        if ( b_current_item )
            UpdateArt();
        else
            emit artChanged( p_item );
    }
}
Example #3
0
static int
MarshalMetadata( intf_thread_t *p_intf, DBusMessageIter *container )
{
    DBusMessageIter a;
    input_thread_t *p_input = pl_CurrentInput( p_intf );
    input_item_t   *p_item  = NULL;

    if( p_input != NULL )
    {
        p_item = input_GetItem( p_input );

        if( p_item )
        {
            int result = GetInputMeta( p_item, container );

            if (result != VLC_SUCCESS)
            {
                vlc_object_release( (vlc_object_t*) p_input );
                return result;
            }
        }

        vlc_object_release( (vlc_object_t*) p_input );
    }

    if (!p_item)
    {
        // avoid breaking the type marshalling
        if( !dbus_message_iter_open_container( container, DBUS_TYPE_ARRAY, "{sv}", &a ) ||
              !dbus_message_iter_close_container( container, &a ) )
            return VLC_ENOMEM;
    }

    return VLC_SUCCESS;
}
Example #4
0
/* Define the Input used.
   Add the callbacks on input
   p_input is held once here */
void InputManager::setInput( input_thread_t *_p_input )
{
    delInput();
    p_input = _p_input;
    if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) )
    {
        msg_Dbg( p_intf, "IM: Setting an input" );
        vlc_object_hold( p_input );
        addCallbacks();
        UpdateStatus();
        UpdateName();
        UpdateArt();
        UpdateTeletext();
        UpdateNavigation();
        UpdateVout();

        p_item = input_GetItem( p_input );
        emit rateChanged( var_GetFloat( p_input, "rate" ) );
    }
    else
    {
        p_input = NULL;
        p_item = NULL;
        assert( !p_input_vbi );
        emit rateChanged( var_InheritFloat( p_intf, "rate" ) );
    }
}
Example #5
0
/*****************************************************************************
 * StateChange: callback on input "state"
 *****************************************************************************/
static int StateChange( intf_thread_t *p_intf )
{
    intf_sys_t          *p_sys      = p_intf->p_sys;
    playlist_t          *p_playlist = p_sys->p_playlist;
    input_thread_t      *p_input;
    input_item_t        *p_item;

    if( p_intf->p_sys->b_dead )
        return VLC_SUCCESS;

    UpdateCaps( p_intf );

    if( !p_sys->b_meta_read && p_sys->i_playing_state == 0)
    {
        p_input = playlist_CurrentInput( p_playlist );
        if( p_input )
        {
            p_item = input_GetItem( p_input );
            if( p_item )
            {
                p_sys->b_meta_read = true;
                TrackChangeEmit( p_intf, p_item );
            }
            vlc_object_release( p_input );
        }
    }

    StatusChangeEmit( p_intf );

    return VLC_SUCCESS;
}
Example #6
0
void InputManager::requestArtUpdate( input_item_t *p_item, bool b_forced )
{
    bool b_current_item = false;
    if ( !p_item && hasInput() )
    {   /* default to current item */
        p_item = input_GetItem( p_input );
        b_current_item = true;
    }

    if ( p_item )
    {
        /* check if it has already been enqueued */
        if ( p_item->p_meta && !b_forced )
        {
            int status = vlc_meta_GetStatus( p_item->p_meta );
            if ( status & ( ITEM_ART_NOTFOUND|ITEM_ART_FETCHED ) )
                return;
        }
        libvlc_ArtRequest( p_intf->obj.libvlc, p_item,
                           (b_forced) ? META_REQUEST_OPTION_SCOPE_ANY
                                      : META_REQUEST_OPTION_NONE );
        /* No input will signal the cover art to update,
             * let's do it ourself */
        if ( b_current_item )
            UpdateArt();
        else
            emit artChanged( p_item );
    }
}
Example #7
0
File: demux.c Project: rlugojr/vlc
static int Demux( demux_t *p_demux )
{
    lua_State *L = p_demux->p_sys->L;
    char *psz_filename = p_demux->p_sys->psz_filename;

    input_item_t *p_current_input = input_GetItem( p_demux->p_input );

    luaL_register_namespace( L, "vlc", p_reg_parse );

    lua_getglobal( L, "parse" );

    if( !lua_isfunction( L, -1 ) )
    {
        msg_Warn( p_demux, "Error while running script %s, "
                  "function parse() not found", psz_filename );
        return VLC_EGENERIC;
    }

    if( lua_pcall( L, 0, 1, 0 ) )
    {
        msg_Warn( p_demux, "Error while running script %s, "
                  "function parse(): %s", psz_filename,
                  lua_tostring( L, lua_gettop( L ) ) );
        return VLC_EGENERIC;
    }

    if( lua_gettop( L ) )
        vlclua_playlist_add_internal( p_demux, L, NULL, p_current_input, 0 );
    else
        msg_Err( p_demux, "Script went completely foobar" );

    return -1; /* Needed for correct operation of go back */
}
Example #8
0
input_item_t * GetCurrentItem(demux_t *p_demux)
{
    input_thread_t *p_input_thread = demux_GetParentInput( p_demux );
    input_item_t *p_current_input = input_GetItem( p_input_thread );
    vlc_gc_incref(p_current_input);
    vlc_object_release(p_input_thread);
    return p_current_input;
}
Example #9
0
/* ****************************************************************************/
static void ReadMetaData(intf_thread_t *p_this)
{
    input_thread_t      *p_input;
    input_item_t        *p_item;

    intf_sys_t          *p_sys = p_this->p_sys;

    p_input = playlist_CurrentInput(pl_Get(p_this));

    if (!p_input)
        return;

    p_item = input_GetItem(p_input);
    if (!p_item)
    {
        vlc_object_release(p_input);
        return;
    }

#define ALLOC_ITEM_META(a, b) do { \
         char *psz_meta = input_item_Get##b(p_item); \
         if (psz_meta && *psz_meta) \
             a = encode_URI_component(psz_meta); \
         free(psz_meta); \
     } while (0)

    vlc_mutex_lock(&p_sys->lock);

    p_sys->b_meta_read = true;

    ALLOC_ITEM_META(p_sys->p_current_item.psz_n, Name);
    if (!p_sys->p_current_item.psz_n)
    {
        msg_Dbg(p_this, "No name..");
        DeleteItem(&p_sys->p_current_item);
        goto end;
    }

    ALLOC_ITEM_META(p_sys->p_current_item.psz_u, URI);
    if (!p_sys->p_current_item.psz_u)
    {
        msg_Dbg(p_this, "No URI..");
        DeleteItem(&p_sys->p_current_item);
        goto end;
    }

    /* Now we have read the mandatory meta data, so we can submit that info */
    p_sys->b_submit = true;

    /* Duration in seconds */
    p_sys->p_current_item.i_l = input_item_GetDuration(p_item) / 1000000;

#undef ALLOC_ITEM_META

end:
    vlc_mutex_unlock(&p_sys->lock);
    vlc_object_release(p_input);
}
Example #10
0
void InputManager::UpdateName()
{
    /* Update text, name and nowplaying */
    QString text;

    /* Try to get the Title, then the Name */
    char *psz_name = input_item_GetTitleFbName( input_GetItem( p_input ) );

    /* Try to get the nowplaying */
    char *psz_nowplaying =
        input_item_GetNowPlaying( input_GetItem( p_input ) );
    if( !EMPTY_STR( psz_nowplaying ) )
    {
        text.sprintf( "%s - %s", psz_nowplaying, psz_name );
    }
    else  /* Do it ourself */
    {
        char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );

        if( !EMPTY_STR( psz_artist ) )
            text.sprintf( "%s - %s", psz_artist, psz_name );
        else
            text.sprintf( "%s", psz_name );

        free( psz_artist );
    }
    /* Free everything */
    free( psz_name );
    free( psz_nowplaying );

    /* If we have Nothing */
    if( text.isEmpty() )
    {
        psz_name = input_item_GetURI( input_GetItem( p_input ) );
        text.sprintf( "%s", psz_name );
        text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 );
        free( psz_name );
    }

    if( oldName != text )
    {
        emit nameChanged( text );
        oldName = text;
    }
}
Example #11
0
/* Define the Input used.
   Add the callbacks on input
   p_input is held once here */
void InputManager::setInput( input_thread_t *_p_input )
{
    delInput();
    p_input = _p_input;
    if( p_input != NULL )
    {
        msg_Dbg( p_intf, "IM: Setting an input" );
        vlc_object_hold( p_input );
        addCallbacks();

        UpdateStatus();
        UpdateName();
        UpdateArt();
        UpdateTeletext();
        UpdateNavigation();
        UpdateVout();

        p_item = input_GetItem( p_input );
        emit rateChanged( var_GetFloat( p_input, "rate" ) );

        /* Get Saved Time */
        if( p_item->i_type == ITEM_TYPE_FILE )
        {
            char *uri = input_item_GetURI( p_item );

            int i_time = RecentsMRL::getInstance( p_intf )->time( qfu(uri) );
            if( i_time > 0 && qfu( uri ) != lastURI &&
                    !var_GetFloat( p_input, "run-time" ) &&
                    !var_GetFloat( p_input, "start-time" ) &&
                    !var_GetFloat( p_input, "stop-time" ) )
            {
                emit resumePlayback( (int64_t)i_time * 1000 );
            }
            playlist_Lock( THEPL );
            // Add root items only
            playlist_item_t* p_node = playlist_CurrentPlayingItem( THEPL );
            if ( p_node != NULL && p_node->p_parent != NULL && p_node->p_parent->i_id == THEPL->p_playing->i_id )
            {
                // Save the latest URI to avoid asking to restore the
                // position on the same input file.
                lastURI = qfu( uri );
                RecentsMRL::getInstance( p_intf )->addRecent( lastURI );
            }
            playlist_Unlock( THEPL );
            free( uri );
        }
    }
    else
    {
        p_item = NULL;
        lastURI.clear();
        assert( !p_input_vbi );
        emit rateChanged( var_InheritFloat( p_intf, "rate" ) );
    }
}
Example #12
0
void InputManager::UpdateArt()
{
    QString url = decodeArtURL( input_GetItem( p_input ) );

    /* the art hasn't changed, no need to update */
    if(artUrl == url)
        return;

    /* Update Art meta */
    artUrl = url;
    emit artChanged( artUrl );
}
Example #13
0
void InputManager::requestArtUpdate()
{
    if( hasInput() )
    {
        playlist_AskForArtEnqueue( pl_Get(p_intf), input_GetItem( p_input ) );
    }
    else
    {
        /* No input will signal the cover art to update,
         * let's do it ourself */
        UpdateArt();
    }
}
Example #14
0
File: mvar.c Project: cobr123/qtVlc
mvar_t *mvar_InfoSetNew( char *name, input_thread_t *p_input )
{
    mvar_t *s = mvar_New( name, "set" );
    int i, j;

    if( p_input == NULL || p_input->p == NULL /* workarround assert in input_GetItem */ )
    {
        return s;
    }

    vlc_mutex_lock( &input_GetItem(p_input)->lock );
    for ( i = 0; i < input_GetItem(p_input)->i_categories; i++ )
    {
        info_category_t *p_category = input_GetItem(p_input)->pp_categories[i];

        mvar_t *cat  = mvar_New( name, "set" );
        mvar_t *iset = mvar_New( "info", "set" );

        mvar_AppendNewVar( cat, "name", p_category->psz_name );
        mvar_AppendVar( cat, iset );

        for ( j = 0; j < p_category->i_infos; j++ )
        {
            info_t *p_info = p_category->pp_infos[j];
            mvar_t *info = mvar_New( "info", "" );

            /* msg_Dbg( p_input, "adding info name=%s value=%s",
                     psz_name, psz_value ); */
            mvar_AppendNewVar( info, "name",  p_info->psz_name );
            mvar_AppendNewVar( info, "value", p_info->psz_value );
            mvar_AppendVar( iset, info );
        }
        mvar_AppendVar( s, cat );
    }
    vlc_mutex_unlock( &input_GetItem(p_input)->lock );

    return s;
}
/*****************************************************************************
 * ItemChange: Playlist item change callback
 *****************************************************************************/
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    input_thread_t      *p_input;
    intf_thread_t       *p_intf     = ( intf_thread_t* ) p_data;
    intf_sys_t          *p_sys      = p_intf->p_sys;
    input_item_t        *p_item;

    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var );
    VLC_UNUSED( oldval ); VLC_UNUSED( newval );

    p_sys->b_state_cb       = false;
    p_sys->b_meta_read      = false;
    p_sys->b_submit         = false;

    p_input = playlist_CurrentInput( pl_Get( p_intf ) );

    if( !p_input || p_input->b_dead )
        return VLC_SUCCESS;

    p_item = input_GetItem( p_input );
    if( !p_item )
    {
        vlc_object_release( p_input );
        return VLC_SUCCESS;
    }

    if( var_CountChoices( p_input, "video-es" ) )
    {
        msg_Dbg( p_this, "Not an audio-only input, not submitting");
        vlc_object_release( p_input );
        return VLC_SUCCESS;
    }

    p_sys->time_total_pauses = 0;
    time( &p_sys->p_current_song.date );        /* to be sent to last.fm */
    p_sys->p_current_song.i_start = mdate();    /* only used locally */

    var_AddCallback( p_input, "intf-event", PlayingChange, p_intf );
    p_sys->b_state_cb = true;

    if( input_item_IsPreparsed( p_item ) )
        ReadMetaData( p_intf );
    /* if the input item was not preparsed, we'll do it in PlayingChange()
     * callback, when "state" == PLAYING_S */

    vlc_object_release( p_input );
    return VLC_SUCCESS;
}
Example #16
0
/**
 * @brief Return the index of currently playing item
 */
QModelIndex MLModel::currentIndex() const
{
    input_thread_t *p_input_thread = THEMIM->getInput();
    if( !p_input_thread ) return QModelIndex();

    input_item_t* p_iitem = input_GetItem( p_input_thread );
    int i = 0;
    foreach( MLItem* item, items )
    {
        if ( item->inputItem() == p_iitem )
            return index( i, 0 );
        i++;
    }
    return QModelIndex();
}
Example #17
0
static char *TitleGet( vlc_object_t *p_this )
{
    input_thread_t *p_input = playlist_CurrentInput( pl_Get( p_this ) );
    if( !p_input )
        return NULL;

    char *psz_title = input_item_GetTitle( input_GetItem( p_input ) );
    if( EMPTY_STR( psz_title ) )
    {
        free( psz_title );

        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
        const char *psz = strrchr( psz_uri, '/' );
        if( psz )
        {
            psz_title = strdup( psz + 1 );
            free( psz_uri );
        }
        else
            psz_title = psz_uri;
    }
    vlc_object_release( p_input );
    return psz_title;
}
/**
 * @brief Return the index of currently playing item
 */
QModelIndex MLModel::currentIndex() const
{
    input_thread_t *p_input_thread = THEMIM->getInput();
    if( !p_input_thread ) return QModelIndex();

    /*TODO: O(n) not good */
    input_item_t* p_iitem = input_GetItem( p_input_thread );
    foreach( MLItem* item, items )
    {
        if( !QString::compare( item->getUri().toString(),
                    QString::fromAscii( p_iitem->psz_uri ) ) )
            return index( items.indexOf( item ), 0 );
    }
    return QModelIndex();
}
Example #19
0
static int vlclua_input_item_get_current( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    input_item_t *p_item = p_input ? input_GetItem( p_input ) : NULL;
    if( !p_item )
    {
        lua_pushnil( L );
        if( p_input ) vlc_object_release( p_input );
        return 1;
    }

    vlclua_input_item_get( L, p_item );

    if( p_input ) vlc_object_release( p_input );
    return 1;
}
Example #20
0
static int Demux( demux_t *p_demux )
{
    input_item_t *p_input = input_GetItem( p_demux->p_input );
    input_item_node_t *p_node = input_item_node_Create( p_input );

    if( vlc_stream_ReadDir( p_demux->s, p_node ) )
    {
        msg_Warn( p_demux, "unable to read directory" );
        input_item_node_Delete( p_node );
        return VLC_EGENERIC;
    }

    if (es_out_Control(p_demux->out, ES_OUT_POST_SUBNODE, p_node))
        input_item_node_Delete(p_node);

    return VLC_SUCCESS;
}
Example #21
0
static int vlclua_playlist_current( lua_State *L )
{
    playlist_t *p_playlist = vlclua_get_playlist_internal( L );
    input_thread_t *p_input = playlist_CurrentInput( p_playlist );
    int id = -1;

    if( p_input )
    {
        input_item_t *p_item = input_GetItem( p_input );
        if( p_item )
            id = p_item->i_id;
        vlc_object_release( p_input );
    }

#warning Indexing input items by ID is unsafe,
    lua_pushinteger( L, id );
    return 1;
}
Example #22
0
void InputManager::UpdateName()
{
    assert( p_input );

    /* Update text, name and nowplaying */
    QString name;

    /* Try to get the nowplaying */
    char *format = var_InheritString( p_intf, "input-title-format" );
    char *formatted = NULL;
    if (format != NULL)
    {
        formatted = str_format_meta( p_input, format );
        free( format );
        if( formatted != NULL )
        {
            name = qfu(formatted);
            free( formatted );
        }
    }

    /* If we have Nothing */
    if( name.simplified().isEmpty() )
    {
        char *uri = input_item_GetURI( input_GetItem( p_input ) );
        char *file = uri ? strrchr( uri, '/' ) : NULL;
        if( file != NULL )
        {
            decode_URI( ++file );
            name = qfu(file);
        }
        else
            name = qfu(uri);
        free( uri );
    }

    name = name.trimmed();

    if( oldName != name )
    {
        emit nameChanged( name );
        oldName = name;
    }
}
Example #23
0
/*****************************************************************************
 * TrackChange: callback on playlist "item-current"
 *****************************************************************************/
static int TrackChange( intf_thread_t *p_intf )
{
    intf_sys_t          *p_sys      = p_intf->p_sys;
    playlist_t          *p_playlist = p_sys->p_playlist;
    input_thread_t      *p_input    = NULL;
    input_item_t        *p_item     = NULL;

    if( p_intf->p_sys->b_dead )
        return VLC_SUCCESS;

    if( p_sys->p_input )
    {
        var_DelCallback( p_sys->p_input, "intf-event", AllCallback, p_intf );
        var_DelCallback( p_sys->p_input, "can-pause", AllCallback, p_intf );
        var_DelCallback( p_sys->p_input, "can-seek", AllCallback, p_intf );
        vlc_object_release( p_sys->p_input );
        p_sys->p_input = NULL;
    }

    p_sys->b_meta_read = false;

    p_input = playlist_CurrentInput( p_playlist );
    if( !p_input )
    {
        return VLC_SUCCESS;
    }

    p_item = input_GetItem( p_input );
    if( !p_item )
    {
        vlc_object_release( p_input );
        return VLC_EGENERIC;
    }

    if( input_item_IsPreparsed( p_item ) )
        p_sys->b_meta_read = true;

    p_sys->p_input = p_input;
    var_AddCallback( p_input, "intf-event", AllCallback, p_intf );
    var_AddCallback( p_input, "can-pause", AllCallback, p_intf );
    var_AddCallback( p_input, "can-seek", AllCallback, p_intf );

    return VLC_SUCCESS;
}
static void DisplayVoutTitle( input_resource_t *p_resource,
                              vout_thread_t *p_vout )
{
    if( p_resource->p_input == NULL )
        return;

    /* TODO display the title only one time for the same input ? */

    input_item_t *p_item = input_GetItem( p_resource->p_input );

    char *psz_nowplaying = input_item_GetNowPlaying( p_item );
    if( psz_nowplaying && *psz_nowplaying )
    {
        vout_DisplayTitle( p_vout, psz_nowplaying );
    }
    else
    {
        char *psz_artist = input_item_GetArtist( p_item );
        char *psz_name = input_item_GetTitle( p_item );

        if( !psz_name || *psz_name == '\0' )
        {
            free( psz_name );
            psz_name = input_item_GetName( p_item );
        }
        if( psz_artist && *psz_artist )
        {
            char *psz_string;
            if( asprintf( &psz_string, "%s - %s", psz_name, psz_artist ) != -1 )
            {
                vout_DisplayTitle( p_vout, psz_string );
                free( psz_string );
            }
        }
        else if( psz_name )
        {
            vout_DisplayTitle( p_vout, psz_name );
        }
        free( psz_name );
        free( psz_artist );
    }
    free( psz_nowplaying );
}
Example #25
0
/*****************************************************************************
 * ItemChange: Playlist item change callback
 *****************************************************************************/
static int ItemChange(vlc_object_t *p_this, const char *psz_var,
                       vlc_value_t oldval, vlc_value_t newval, void *p_data)
{
    input_thread_t      *p_input;
    intf_thread_t       *p_intf     = (intf_thread_t*) p_data;
    intf_sys_t          *p_sys      = p_intf->p_sys;
    input_item_t        *p_item;

    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
    VLC_UNUSED(oldval); VLC_UNUSED(newval);

    p_sys->b_state_cb       = false;
    p_sys->b_meta_read      = false;
    p_sys->b_submit         = false;

    p_input = playlist_CurrentInput(pl_Get(p_intf));

    if (!p_input || p_input->b_dead)
        return VLC_SUCCESS;

    p_item = input_GetItem(p_input);
    if (!p_item)
    {
        vlc_object_release(p_input);
        return VLC_SUCCESS;
    }

    p_sys->time_total_pauses = 0;
    time(&p_sys->p_current_item.date);        /* to be sent to upstream */
    p_sys->p_current_item.i_start = mdate();  /* used to calculate run
                                               * time as fallback       */

    var_AddCallback(p_input, "intf-event", PlayingChange, p_intf);
    p_sys->b_state_cb = true;

    if (input_item_IsPreparsed(p_item))
        ReadMetaData(p_intf);

    vlc_object_release(p_input);
    return VLC_SUCCESS;
}
Example #26
0
void ActionsManager::record()
{
    input_thread_t *p_input = THEMIM->getInput();
    if( p_input )
    {
        /* This method won't work fine if the stream can't be cut anywhere */
        var_ToggleBool( p_input, "record" );
#if 0
        else
        {
            /* 'record' access-filter is not loaded, we open Save dialog */
            input_item_t *p_item = input_GetItem( p_input );
            if( !p_item )
                return;

            char *psz = input_item_GetURI( p_item );
            if( psz )
                THEDP->streamingDialog( NULL, qfu(psz), true );
        }
#endif
    }
Example #27
0
void EpgDialog::updateInfos()
{
    timer->stop();
    input_item_t *p_input_item = NULL;
    playlist_t *p_playlist = THEPL;
    input_thread_t *p_input_thread = playlist_CurrentInput( p_playlist ); /* w/hold */
    if( p_input_thread )
    {
        PL_LOCK; /* as input_GetItem still unfixed */
        p_input_item = input_GetItem( p_input_thread );
        if ( p_input_item ) vlc_gc_incref( p_input_item );
        PL_UNLOCK;
        vlc_object_release( p_input_thread );
        if ( p_input_item )
        {
            epg->updateEPG( p_input_item );
            vlc_gc_decref( p_input_item );
            if ( isVisible() ) timer->start();
        }
    }
}
Example #28
0
void CmdUpdateItem::execute()
{
    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
    if( pPlaylist == NULL )
        return;

    input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
    if( !p_input )
        return;

    // Get playlist item information
    input_item_t *pItem = input_GetItem( p_input );

    char *pszName = input_item_GetName( pItem );
    char *pszUri = input_item_GetURI( pItem );

    string name = pszName;
    // XXX: This should be done in VLC core, not here...
    // Remove path information if any
    OSFactory *pFactory = OSFactory::instance( getIntf() );
    string::size_type pos = name.rfind( pFactory->getDirSeparator() );
    if( pos != string::npos )
    {
        name = name.substr( pos + 1, name.size() - pos + 1 );
    }
    UString srcName( getIntf(), name.c_str() );
    UString srcURI( getIntf(), pszUri );

    free( pszName );
    free( pszUri );

    // Create commands to update the stream variables
    CmdSetText *pCmd1 = new CmdSetText( getIntf(), m_rStreamName, srcName );
    CmdSetText *pCmd2 = new CmdSetText( getIntf(), m_rStreamURI, srcURI );
    // Push the commands in the asynchronous command queue
    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
    pQueue->push( CmdGenericPtr( pCmd1 ), false );
    pQueue->push( CmdGenericPtr( pCmd2 ), false );
    vlc_object_release( p_input );
}
Example #29
0
/*****************************************************************************
 * TrackChange: callback on playlist "item-current"
 *****************************************************************************/
static int TrackChange( intf_thread_t *p_intf )
{
    intf_sys_t          *p_sys      = p_intf->p_sys;
    playlist_t          *p_playlist;
    input_thread_t      *p_input    = NULL;
    input_item_t        *p_item     = NULL;

    if( p_intf->p_sys->b_dead )
        return VLC_SUCCESS;

    p_sys->b_meta_read = false;

    p_playlist = pl_Hold( p_intf );
    p_input = playlist_CurrentInput( p_playlist );
    if( !p_input )
    {
        pl_Release( p_intf );
        return VLC_SUCCESS;
    }

    pl_Release( p_intf );

    p_item = input_GetItem( p_input );
    if( !p_item )
    {
        vlc_object_release( p_input );
        return VLC_EGENERIC;
    }

    if( input_item_IsPreparsed( p_item ) )
    {
        p_sys->b_meta_read = true;
        TrackChangeSignal( p_sys->p_conn, p_item );
    }

    var_AddCallback( p_input, "state", AllCallback, p_intf );

    vlc_object_release( p_input );
    return VLC_SUCCESS;
}
Example #30
0
/* Define the Input used.
   Add the callbacks on input
   p_input is held once here */
void InputManager::setInput( input_thread_t *_p_input )
{
    delInput();
    p_input = _p_input;
    if( p_input != NULL )
    {
        msg_Dbg( p_intf, "IM: Setting an input" );
        vlc_object_hold( p_input );
        addCallbacks();

        UpdateStatus();
        UpdateName();
        UpdateArt();
        UpdateTeletext();
        UpdateNavigation();
        UpdateVout();

        p_item = input_GetItem( p_input );
        emit rateChanged( var_GetFloat( p_input, "rate" ) );

        /* Get Saved Time */
        if( p_item->i_type == ITEM_TYPE_FILE )
        {
            int i_time = RecentsMRL::getInstance( p_intf )->time( p_item->psz_uri );
            if( i_time > 0 &&
                    !var_GetFloat( p_input, "run-time" ) &&
                    !var_GetFloat( p_input, "start-time" ) &&
                    !var_GetFloat( p_input, "stop-time" ) )
            {
                emit resumePlayback( (int64_t)i_time * 1000 );
            }
        }
    }
    else
    {
        p_item = NULL;
        assert( !p_input_vbi );
        emit rateChanged( var_InheritFloat( p_intf, "rate" ) );
    }
}