Changeset 25368dcd565835166b736d19615bb66324696b0b
- Timestamp:
- 14/12/05 19:10:27
(3 years ago)
- Author:
- Clément Stenac <zorglub@videolan.org>
- git-committer:
- Clément Stenac <zorglub@videolan.org> 1134583827 +0000
- git-parent:
[eff1f159b6044e12f46aa11fdde69957e811c3d2]
- git-author:
- Clément Stenac <zorglub@videolan.org> 1134583827 +0000
- Message:
Use input_Read in shoutcast and display a progress dialog
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd93b664 |
r25368dc |
|
| 29 | 29 | #include <vlc/vlc.h> |
|---|
| 30 | 30 | #include <vlc/intf.h> |
|---|
| | 31 | #include <vlc_interaction.h> |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | #include <vlc/input.h> |
|---|
| … | … | |
| 86 | 87 | /* playlist node */ |
|---|
| 87 | 88 | playlist_item_t *p_node; |
|---|
| 88 | | input_thread_t *p_input; |
|---|
| 89 | | |
|---|
| | 89 | playlist_item_t *p_item; |
|---|
| | 90 | int i_limit; |
|---|
| | 91 | vlc_bool_t b_dialog; |
|---|
| 90 | 92 | }; |
|---|
| 91 | 93 | |
|---|
| … | … | |
| 111 | 113 | playlist_item_t *p_item; |
|---|
| 112 | 114 | |
|---|
| 113 | | int i_limit; |
|---|
| 114 | 115 | char *psz_shoutcast_url; |
|---|
| 115 | 116 | char *psz_shoutcast_title; |
|---|
| … | … | |
| 127 | 128 | } |
|---|
| 128 | 129 | |
|---|
| 129 | | i_limit = config_GetInt( p_this->p_libvlc, "shoutcast-limit" ); |
|---|
| | 130 | p_sys->i_limit = config_GetInt( p_this->p_libvlc, "shoutcast-limit" ); |
|---|
| 130 | 131 | #define SHOUTCAST_BASE_URL "http/shout-b4s://www.shoutcast.com/sbin/xmllister.phtml?service=vlc&no_compress=1&limit=" |
|---|
| 131 | 132 | psz_shoutcast_url = (char *)malloc( strlen( SHOUTCAST_BASE_URL ) + 20 ); |
|---|
| 132 | 133 | psz_shoutcast_title = (char *)malloc( 6 + 20 ); |
|---|
| 133 | 134 | |
|---|
| 134 | | sprintf( psz_shoutcast_url, SHOUTCAST_BASE_URL "%d", i_limit ); |
|---|
| 135 | | sprintf( psz_shoutcast_title, "Top %d", i_limit ); |
|---|
| | 135 | sprintf( psz_shoutcast_url, SHOUTCAST_BASE_URL "%d", p_sys->i_limit ); |
|---|
| | 136 | sprintf( psz_shoutcast_title, "Top %d", p_sys->i_limit ); |
|---|
| 136 | 137 | |
|---|
| 137 | 138 | p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY ); |
|---|
| … | … | |
| 150 | 151 | * parent's ones */ |
|---|
| 151 | 152 | playlist_CopyParents( p_sys->p_node, p_item ); |
|---|
| 152 | | |
|---|
| 153 | | |
|---|
| 154 | | p_sys->p_input = input_CreateThread( p_playlist, &p_item->input ); |
|---|
| 155 | | |
|---|
| | 153 | |
|---|
| | 154 | p_sys->p_item = p_item; |
|---|
| 156 | 155 | p_sys->p_node->i_flags |= PLAYLIST_RO_FLAG; |
|---|
| 157 | 156 | val.b_bool = VLC_TRUE; |
|---|
| … | … | |
| 172 | 171 | playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_sd, |
|---|
| 173 | 172 | VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); |
|---|
| 174 | | if( p_sd->p_sys->p_input ) |
|---|
| 175 | | { |
|---|
| 176 | | input_StopThread( p_sd->p_sys->p_input ); |
|---|
| 177 | | input_DestroyThread( p_sd->p_sys->p_input ); |
|---|
| 178 | | vlc_object_detach( p_sd->p_sys->p_input ); |
|---|
| 179 | | vlc_object_destroy( p_sd->p_sys->p_input ); |
|---|
| 180 | | p_sd->p_sys->p_input = NULL; |
|---|
| 181 | | } |
|---|
| 182 | 173 | if( p_playlist ) |
|---|
| 183 | 174 | { |
|---|
| … | … | |
| 193 | 184 | static void Run( services_discovery_t *p_sd ) |
|---|
| 194 | 185 | { |
|---|
| | 186 | services_discovery_sys_t *p_sys = p_sd->p_sys; |
|---|
| | 187 | int i_id = input_Read( p_sd, &p_sys->p_item->input, VLC_FALSE ); |
|---|
| | 188 | int i_dialog_id; |
|---|
| | 189 | |
|---|
| | 190 | i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , "Connecting...", 0.0 ); |
|---|
| | 191 | |
|---|
| | 192 | p_sys->b_dialog = VLC_TRUE; |
|---|
| 195 | 193 | while( !p_sd->b_die ) |
|---|
| 196 | 194 | { |
|---|
| 197 | | if( p_sd->p_sys->p_input && |
|---|
| 198 | | ( p_sd->p_sys->p_input->b_eof || p_sd->p_sys->p_input->b_error ) ) |
|---|
| | 195 | input_thread_t *p_input = (input_thread_t *)vlc_object_get( p_sd, |
|---|
| | 196 | i_id ); |
|---|
| | 197 | |
|---|
| | 198 | /* The Shoutcast server does not return a content-length so we |
|---|
| | 199 | * can't know where we are. Use the number of inserted items |
|---|
| | 200 | * as a hint */ |
|---|
| | 201 | if( p_input != NULL ) |
|---|
| 199 | 202 | { |
|---|
| 200 | | input_StopThread( p_sd->p_sys->p_input ); |
|---|
| 201 | | input_DestroyThread( p_sd->p_sys->p_input ); |
|---|
| 202 | | vlc_object_detach( p_sd->p_sys->p_input ); |
|---|
| 203 | | vlc_object_destroy( p_sd->p_sys->p_input ); |
|---|
| 204 | | p_sd->p_sys->p_input = NULL; |
|---|
| | 203 | int i_state = var_GetInteger( p_input, "state" ); |
|---|
| | 204 | if( i_state == PLAYING_S ) |
|---|
| | 205 | { |
|---|
| | 206 | float f_pos = (float)(p_sys->p_item->i_children)* 100.0 / |
|---|
| | 207 | (float)(p_sys->i_limit); |
|---|
| | 208 | intf_UserProgressUpdate( p_sd, i_dialog_id, "Downloading", |
|---|
| | 209 | f_pos ); |
|---|
| | 210 | } |
|---|
| | 211 | vlc_object_release( p_input ); |
|---|
| | 212 | } |
|---|
| | 213 | else if( p_sys->b_dialog ) |
|---|
| | 214 | { |
|---|
| | 215 | p_sys->b_dialog = VLC_FALSE; |
|---|
| | 216 | intf_UserHide( p_sd, i_dialog_id ); |
|---|
| 205 | 217 | } |
|---|
| 206 | 218 | msleep( 100000 ); |
|---|