⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 b4s.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
                // Read the element name                if( psz_elname ) free( psz_elname );                psz_elname = xml_ReaderName( p_xml_reader );                if( !psz_elname ) return -1;                                // Read the attributes                while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )                {                    char *psz_name = xml_ReaderName( p_xml_reader );                    char *psz_value = xml_ReaderValue( p_xml_reader );                    if( !psz_name || !psz_value ) return -1;                    if( !strcmp( psz_elname, "entry" ) &&                        !strcmp( psz_name, "Playstring" ) )                    {                        psz_mrl = strdup( psz_value );                    }                    else                    {                        msg_Warn( p_demux, "unexpected attribure %s in element %s",                                  psz_name, psz_elname );                    }                    free( psz_name );                    free( psz_value );                }                break;            }            case XML_READER_TEXT:            {                char *psz_text = xml_ReaderValue( p_xml_reader );                if( IsWhitespace( psz_text ) )                {                    free( psz_text );                    break;                }                if( !strcmp( psz_elname, "Name" ) )                {                    psz_name = strdup( psz_text );                }                else if( !strcmp( psz_elname, "Genre" ) )                {                    psz_genre = strdup( psz_text );                }                else if( !strcmp( psz_elname, "Nowplaying" ) )                {                    psz_now = strdup( psz_text );                }                else if( !strcmp( psz_elname, "Listeners" ) )                {                    psz_listeners = strdup( psz_text );                }                else if( !strcmp( psz_elname, "Bitrate" ) )                {                    psz_bitrate = strdup( psz_text );                }                else if( !strcmp( psz_elname, "" ) )                {                    ;                }                else                {                    msg_Warn( p_demux, "unexpected text in element '%s'",                              psz_elname );                }                free( psz_text );                break;            }            // End element            case XML_READER_ENDELEM:            {                // Read the element name                free( psz_elname );                psz_elname = xml_ReaderName( p_xml_reader );                if( !psz_elname ) return -1;                if( !strcmp( psz_elname, "entry" ) )                {                    p_item = playlist_ItemNew( p_playlist, psz_mrl, psz_name );                    if( psz_now )                    {                        vlc_input_item_AddInfo( &(p_item->input),                                                _("Meta-information"),                                                _( VLC_META_NOW_PLAYING ),                                                "%s",                                                psz_now );                    }                    if( psz_genre )                    {                        vlc_input_item_AddInfo( &p_item->input,                                                _("Meta-information"),                                                _( VLC_META_GENRE ),                                                "%s",                                                psz_genre );                    }                    if( psz_listeners )                    {                        vlc_input_item_AddInfo( &p_item->input,                                                _("Meta-information"),                                                _( "Listeners" ),                                                "%s",                                                psz_listeners );                    }                    if( psz_bitrate )                    {                        vlc_input_item_AddInfo( &p_item->input,                                                _("Meta-information"),                                                _( "Bitrate" ),                                                "%s",                                                psz_bitrate );                    }                    playlist_NodeAddItem( p_playlist, p_item,                                          p_current->pp_parents[0]->i_view,                                          p_current, PLAYLIST_APPEND,                                          PLAYLIST_END );                    /* We need to declare the parents of the node as the                     *                  * same of the parent's ones */                    playlist_CopyParents( p_current, p_item );                                        vlc_input_item_CopyOptions( &p_current->input,                                                &p_item->input );                    if( b_shoutcast )					{						char *psz_genreToken;						char *psz_otherToken;						psz_genreToken = psz_genre;						while ( psz_genreToken && ( psz_otherToken = get_next_token(psz_genreToken )))						{							ShoutcastAdd( p_playlist, p_genre, p_bitrate, p_item,                                      psz_genreToken, psz_bitrate );							psz_genreToken = psz_otherToken;						}					}#define FREE(a) if( a ) free( a ); a = NULL;                    FREE( psz_name );                    FREE( psz_mrl );                    FREE( psz_genre );                    FREE( psz_bitrate );                    FREE( psz_listeners );                    FREE( psz_now );#undef FREE                }                free( psz_elname );                psz_elname = strdup("");                break;            }        }    }    if( i_ret != 0 )    {        msg_Warn( p_demux, "error while parsing data" );    }    if( b_shoutcast )    {        vlc_mutex_lock( &p_playlist->object_lock );        playlist_NodeSort( p_playlist, p_bitrate, SORT_TITLE_NUMERIC, ORDER_NORMAL );        vlc_mutex_unlock( &p_playlist->object_lock );    }    /* Go back and play the playlist */    if( b_play && p_playlist->status.p_item &&        p_playlist->status.p_item->i_children > 0 )    {        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,                          p_playlist->status.i_view,                          p_playlist->status.p_item,                          p_playlist->status.p_item->pp_children[0] );    }        vlc_object_release( p_playlist );    p_sys->p_playlist = NULL;    return VLC_SUCCESS;}static int Control( demux_t *p_demux, int i_query, va_list args ){    return VLC_EGENERIC;}static char *get_next_token(char *cur_string) {        while (*cur_string && !isspace(*cur_string)) cur_string++;        if (!*cur_string) return NULL;        *cur_string++ = '\0';        while (*cur_string && isspace(*cur_string)) cur_string++;        return cur_string;}static int IsWhitespace( char *psz_string ){    while( *psz_string )    {        if( *psz_string != ' ' && *psz_string != '\t' && *psz_string != '\r' &&            *psz_string != '\n' )        {            return VLC_FALSE;        }        psz_string++;    }    return VLC_TRUE;}static void ShoutcastAdd( playlist_t *p_playlist, playlist_item_t* p_genre,                          playlist_item_t *p_bitrate, playlist_item_t *p_item,                          char *psz_genre, char *psz_bitrate ){    playlist_item_t *p_parent;    if( psz_bitrate )    {        playlist_item_t *p_copy = playlist_ItemCopy(p_playlist,p_item);        p_parent = playlist_ChildSearchName( p_bitrate, psz_bitrate );        if( !p_parent )        {            p_parent = playlist_NodeCreate( p_playlist, p_genre->pp_parents[0]->i_view, psz_bitrate,                                            p_bitrate );            playlist_CopyParents( p_bitrate, p_parent );        }        playlist_NodeAddItem( p_playlist, p_copy, p_parent->pp_parents[0]->i_view, p_parent, PLAYLIST_APPEND, PLAYLIST_END  );        playlist_CopyParents( p_parent, p_copy );    }    if( psz_genre )    {        playlist_item_t *p_copy = playlist_ItemCopy(p_playlist,p_item);        p_parent = playlist_ChildSearchName( p_genre, psz_genre );        if( !p_parent )        {            p_parent = playlist_NodeCreate( p_playlist, p_genre->pp_parents[0]->i_view, psz_genre,                                            p_genre );            playlist_CopyParents( p_genre, p_parent );        }        playlist_NodeAddItem( p_playlist, p_copy, p_parent->pp_parents[0]->i_view, p_parent, PLAYLIST_APPEND, PLAYLIST_END );        playlist_CopyParents( p_parent, p_copy );    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -