Changeset 68aa3ca3202b0f2c7e3b10db9dbe46b436b17bbd
- Timestamp:
- 01/08/06 17:32:33 (3 years ago)
- git-parent:
- Files:
-
- Makefile.am (modified) (5 diffs)
- bindings/python/setup.py (modified) (1 diff)
- bindings/python/vlcglue.h (modified) (1 diff)
- include/libvlc_internal.h (added)
- include/mediacontrol_internal.h (added)
- include/vlc/control.h (deleted)
- include/vlc/control_structures.h (deleted)
- include/vlc/libvlc.h (added)
- include/vlc/mediacontrol.h (added)
- include/vlc/mediacontrol_structures.h (added)
- include/vlc/vlc.h (modified) (2 diffs)
- include/vlc_common.h (modified) (1 diff)
- include/vlc_control.h (deleted)
- src/control/audio_video.c (deleted)
- src/control/core.c (modified) (2 diffs)
- src/control/init.c (deleted)
- src/control/input.c (added)
- src/control/mediacontrol_audio_video.c (added)
- src/control/mediacontrol_core.c (added)
- src/control/mediacontrol_init.c (added)
- src/control/mediacontrol_plugin.c (added)
- src/control/mediacontrol_util.c (added)
- src/control/playlist.c (added)
- src/control/plugin.c (deleted)
- src/control/util.c (deleted)
- src/misc/stats.c (modified) (2 diffs)
- test/libvlc_sample.c (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Makefile.am
ra078354 r68aa3ca 64 64 dist_pkginclude_HEADERS = \ 65 65 include/vlc/vlc.h \ 66 include/vlc/libvlc.h \ 66 67 include/vlc/aout.h \ 67 68 include/vlc/vout.h \ … … 70 71 include/vlc/input.h \ 71 72 include/vlc/intf.h \ 72 include/vlc/ control.h \73 include/vlc/ control_structures.h \73 include/vlc/mediacontrol.h \ 74 include/vlc/mediacontrol_structures.h \ 74 75 $(NULL) 75 76 … … 106 107 include/vlc_common.h \ 107 108 include/vlc_config.h \ 108 include/vlc_control.h \109 109 include/vlc_cpu.h \ 110 110 include/vlc_demux.h \ … … 138 138 include/vout_synchro.h \ 139 139 include/win32_specific.h \ 140 include/libvlc_internal.h \ 141 include/mediacontrol_internal.h 140 142 $(NULL) 141 143 … … 472 474 src/extras/libc.c \ 473 475 src/control/core.c \ 474 src/control/util.c \ 475 src/control/audio_video.c \ 476 src/control/playlist.c \ 477 src/control/input.c \ 478 src/control/mediacontrol_core.c \ 479 src/control/mediacontrol_util.c \ 480 src/control/mediacontrol_audio_video.c \ 476 481 $(NULL) 477 482 478 483 # These should be distributed, but not compiled 479 EXTRA_DIST += src/control/ init.c src/control/plugin.c484 EXTRA_DIST += src/control/mediacontrol_init.c src/control/mediacontrol_plugin.c 480 485 481 486 SOURCES_libvlc = \ bindings/python/setup.py
rab75c69 r68aa3ca 49 49 vlclocal = Extension('vlc', 50 50 sources = ['vlcglue.c', 51 '../../src/control/ init.c'],51 '../../src/control/mediacontrol_init.c'], 52 52 include_dirs = ['../../include', '../../', '/usr/win32/include' ], 53 53 extra_objects = [ '../../lib/libvlc_pic.a' ], bindings/python/vlcglue.h
r1fb54fc r68aa3ca 30 30 #include <stdio.h> 31 31 #include <vlc/vlc.h> 32 #include <vlc/ control_structures.h>33 #include <vlc/ control.h>32 #include <vlc/mediacontrol_structures.h> 33 #include <vlc/mediacontrol.h> 34 34 35 35 #define SELF ((MediaControl*)self) include/vlc/vlc.h
r89518a7 r68aa3ca 1 1 /***************************************************************************** 2 * vlc.h: global header for vlc2 * vlc.h: global header for libvlc (old-style) 3 3 ***************************************************************************** 4 4 * Copyright (C) 1998-2004 the VideoLAN team … … 26 26 27 27 /** 28 * \defgroup libvlc Libvlc28 * \defgroup libvlc_old Libvlc Old 29 29 * This is libvlc, the base library of the VLC program. 30 * This is the legacy API. Please consider using the new libvlc API 30 31 * 31 32 * @{ include/vlc_common.h
ra078354 r68aa3ca 420 420 typedef struct counter_sample_t counter_sample_t; 421 421 typedef struct stats_handler_t stats_handler_t; 422 typedef struct input_stats_t input_stats_t; 422 423 423 424 src/control/core.c
r0984909 r68aa3ca 1 1 /***************************************************************************** 2 * core.c: Core functions : init, playlist, stream management2 * core.c: Core libvlc new API functions : initialization, exceptions handling 3 3 ***************************************************************************** 4 4 * Copyright (C) 2005 the VideoLAN team 5 5 * $Id$ 6 6 * 7 * Authors: Olivier Aubert <olivier.aubert@liris.univ-lyon1.fr>7 * Authors: Cl�nt Stenac <zorglub@videolan.org> 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify … … 22 22 *****************************************************************************/ 23 23 24 #include < vlc_control.h>25 #include <vlc/ control.h>24 #include <libvlc_internal.h> 25 #include <vlc/libvlc.h> 26 26 27 27 #include <vlc/intf.h> 28 #include <vlc/vout.h>29 #include <vlc/aout.h>30 #include <vlc_demux.h>31 32 #include <vlc_osd.h>33 34 #define HAS_SNAPSHOT 135 36 #ifdef HAS_SNAPSHOT37 #include <snapshot.h>38 #endif39 40 #include <stdlib.h> /* malloc(), free() */41 #include <string.h>42 43 #include <errno.h> /* ENOMEM */44 #include <stdio.h>45 #include <ctype.h>46 47 #ifdef HAVE_UNISTD_H48 # include <unistd.h>49 #endif50 #ifdef HAVE_SYS_TIME_H51 # include <sys/time.h>52 #endif53 #ifdef HAVE_SYS_TYPES_H54 # include <sys/types.h>55 #endif56 57 #define RAISE( c, m ) exception->code = c; \58 exception->message = strdup(m);59 28 60 29 vlc_t * vlc_current_object( int ); 61 30 62 mediacontrol_Instance* mediacontrol_new_from_object( int vlc_object_id, 63 mediacontrol_Exception *exception ) 31 /************************************************************************* 32 * Exceptions handling 33 *************************************************************************/ 34 inline void libvlc_exception_init( libvlc_exception_t *p_exception ) 64 35 { 65 mediacontrol_Instance* retval;66 vlc_object_t *p_vlc;67 vlc_object_t *p_object; 36 p_exception->b_raised = 0; 37 p_exception->psz_message = NULL; 38 } 68 39 69 p_object = ( vlc_object_t* )vlc_current_object( vlc_object_id ); 70 if( ! p_object ) 40 inline int libvlc_exception_raised( libvlc_exception_t *p_exception ) 41 { 42 return p_exception->b_raised; 43 } 44 45 inline char* libvlc_exception_get_message( libvlc_exception_t *p_exception ) 46 { 47 if( p_exception->b_raised == 1 && p_exception->psz_message ) 71 48 { 72 RAISE( mediacontrol_InternalException, "Unable to find vlc object" ); 49 return p_exception->psz_message; 50 } 51 return NULL; 52 } 53 54 inline void libvlc_exception_raise( libvlc_exception_t *p_exception, 55 char *psz_message ) 56 { 57 if( p_exception == NULL ) return; 58 p_exception->b_raised = 1; 59 p_exception->psz_message = strdup( psz_message ); 60 } 61 62 63 libvlc_instance_t * libvlc_new( int argc, char **argv, 64 libvlc_exception_t *p_exception ) 65 { 66 int i_vlc_id; 67 libvlc_instance_t *p_new; 68 vlc_t *p_vlc; 69 70 i_vlc_id = VLC_Create(); 71 p_vlc = (vlc_t* ) vlc_current_object( i_vlc_id ); 72 73 if( !p_vlc ) 74 { 75 libvlc_exception_raise( p_exception, "VLC initialization failed" ); 76 return NULL; 77 } 78 p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) ); 79 80 /** \todo Look for interface settings. If we don't have any, add -I dummy */ 81 /* Because we probably don't want a GUI by default */ 82 83 if( !p_new ) 84 { 85 libvlc_exception_raise( p_exception, "Out of memory" ); 73 86 return NULL; 74 87 } 75 88 76 p_vlc = vlc_object_find( p_object, VLC_OBJECT_ROOT, FIND_PARENT ); 77 if( ! p_vlc ) 89 VLC_Init( i_vlc_id, argc, argv ); 90 91 p_new->p_vlc = p_vlc; 92 p_new->p_playlist = (playlist_t *)vlc_object_find( p_new->p_vlc, 93 VLC_OBJECT_PLAYLIST, FIND_CHILD ); 94 95 if( !p_new->p_playlist ) 78 96 { 79 RAISE( mediacontrol_InternalException, "Unable to initialize VLC" );97 libvlc_exception_raise( p_exception, "Playlist creation failed" ); 80 98 return NULL; 81 99 } 82 retval = ( mediacontrol_Instance* )malloc( sizeof( mediacontrol_Instance ) ); 83 retval->p_vlc = p_vlc; 84 retval->vlc_object_id = p_vlc->i_object_id; 100 p_new->i_vlc_id = i_vlc_id; 85 101 86 /* We can keep references on these, which should not change. Is it true ? */ 87 retval->p_playlist = vlc_object_find( p_vlc, 88 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); 89 retval->p_intf = vlc_object_find( p_vlc, VLC_OBJECT_INTF, FIND_ANYWHERE ); 90 91 if( ! retval->p_playlist || ! retval->p_intf ) 92 { 93 RAISE( mediacontrol_InternalException, "No available interface" ); 94 return NULL; 95 } 96 return retval; 97 }; 98 99 100 /************************************************************************** 101 * Playback management 102 **************************************************************************/ 103 mediacontrol_Position* 104 mediacontrol_get_media_position( mediacontrol_Instance *self, 105 const mediacontrol_PositionOrigin an_origin, 106 const mediacontrol_PositionKey a_key, 107 mediacontrol_Exception *exception ) 108 { 109 mediacontrol_Position* retval; 110 vlc_value_t val; 111 input_thread_t * p_input = self->p_playlist->p_input; 112 113 exception = mediacontrol_exception_init( exception ); 114 115 retval = ( mediacontrol_Position* )malloc( sizeof( mediacontrol_Position ) ); 116 retval->origin = an_origin; 117 retval->key = a_key; 118 119 if( ! p_input ) 120 { 121 RAISE( mediacontrol_InternalException, "No input thread." ); 122 return NULL; 123 } 124 125 if( an_origin != mediacontrol_AbsolutePosition ) 126 { 127 /* Relative or ModuloPosition make no sense */ 128 RAISE( mediacontrol_PositionOriginNotSupported, "Only absolute position is valid." ); 129 return NULL; 130 } 131 132 /* We are asked for an AbsolutePosition. */ 133 val.i_time = 0; 134 var_Get( p_input, "time", &val ); 135 /* FIXME: check val.i_time > 0 */ 136 137 retval->value = mediacontrol_unit_convert( p_input, 138 mediacontrol_MediaTime, 139 a_key, 140 val.i_time / 1000 ); 141 return retval; 102 return p_new; 142 103 } 143 104 144 /* Sets the media position */ 145 void 146 mediacontrol_set_media_position( mediacontrol_Instance *self, 147 const mediacontrol_Position * a_position, 148 mediacontrol_Exception *exception ) 105 void libvlc_destroy( libvlc_instance_t *p_instance ) 149 106 { 150 vlc_value_t val; 151 input_thread_t * p_input = self->p_playlist->p_input; 152 153 exception=mediacontrol_exception_init( exception ); 154 if( ! p_input ) 155 { 156 RAISE( mediacontrol_InternalException, "No input thread." ); 157 return; 158 } 159 160 if( !var_GetBool( p_input, "seekable" ) ) 161 { 162 RAISE( mediacontrol_InvalidPosition, "Stream not seekable" ); 163 return; 164 } 165 166 val.i_time = mediacontrol_position2microsecond( p_input, a_position ); 167 var_Set( p_input, "time", val ); 168 return; 107 if( p_instance->p_playlist ) 108 vlc_object_release( p_instance->p_playlist ); 109 vlc_object_release( p_instance->p_vlc ); 110 VLC_CleanUp( p_instance->i_vlc_id ); 111 VLC_Destroy( p_instance->i_vlc_id ); 169 112 } 170 171 /* Starts playing a stream */172 /*173 * Known issues: since moving in the playlist using playlist_Next174 * or playlist_Prev implies starting to play items, the a_position175 * argument will be only honored for the 1st item in the list.176 *177 * XXX:FIXME split moving in the playlist and playing items two178 * different actions or make playlist_<Next|Prev> accept a time179 * value to start to play from.180 */181 void182 mediacontrol_start( mediacontrol_Instance *self,183 const mediacontrol_Position * a_position,184 mediacontrol_Exception *exception )185 {186 playlist_t * p_playlist = self->p_playlist;187 188 exception = mediacontrol_exception_init( exception );189 if( ! p_playlist )190 {191 RAISE( mediacontrol_PlaylistException, "No available playlist" );192 return;193 }194 195 vlc_mutex_lock( &p_playlist->object_lock );196 if( p_playlist->i_size )197 {198 int i_index;199 int i_from;200 char * psz_from = ( char * )malloc( 20 * sizeof( char ) );201 202 i_from = mediacontrol_position2microsecond( p_playlist->p_input, a_position ) / 1000000;203 204 i_index = p_playlist->i_index;205 if( i_index < 0 )206 {207 /* We know that there is at least 1 element, since i_size != 0 */208 i_index = 0;209 }210 211 /* Set start time */212 snprintf( psz_from, 20, "start-time=%i", i_from );213 playlist_ItemAddOption( p_playlist->pp_items[i_index], psz_from );214 free( psz_from );215 216 vlc_mutex_unlock( &p_playlist->object_lock );217 218 playlist_Play( p_playlist );219 }220 else221 {222 RAISE( mediacontrol_PlaylistException, "Empty playlist." );223 vlc_mutex_unlock( &p_playlist->object_lock );224 }225 226 return;227 }228 229 void230 mediacontrol_pause( mediacontrol_Instance *self,231 const mediacontrol_Position * a_position,232 mediacontrol_Exception *exception )233 {234 input_thread_t *p_input = self->p_playlist->p_input;235 236 /* FIXME: use the a_position parameter */237 exception=mediacontrol_exception_init( exception );238 if( p_input != NULL )239 {240 var_SetInteger( p_input, "state", PAUSE_S );241 }242 else243 {244 RAISE( mediacontrol_InternalException, "No input" );245 }246 247 return;248 }249 250 void251 mediacontrol_resume( mediacontrol_Instance *self,252 const mediacontrol_Position * a_position,253 mediacontrol_Exception *exception )254 {255 input_thread_t *p_input = self->p_playlist->p_input;256 257 /* FIXME: use the a_position parameter */258 exception=mediacontrol_exception_init( exception );259 if( p_input != NULL )260 {261 var_SetInteger( p_input, "state", PAUSE_S );262 }263 else264 {265 RAISE( mediacontrol_InternalException, "No input" );266 }267 }268 269 void270 mediacontrol_stop( mediacontrol_Instance *self,271 const mediacontrol_Position * a_position,272 mediacontrol_Exception *exception )273 {274 /* FIXME: use the a_position parameter */275 exception=mediacontrol_exception_init( exception );276 if( !self->p_playlist )277 {278 RAISE( mediacontrol_PlaylistException, "No playlist" );279 return;280 }281 282 playlist_Stop( self->p_playlist );283 }284 285 /**************************************************************************286 * Playlist management287 **************************************************************************/288 289 void290 mediacontrol_playlist_add_item( mediacontrol_Instance *self,291 const char * psz_file,292 mediacontrol_Exception *exception )293 {294 exception=mediacontrol_exception_init( exception );295 if( !self->p_playlist )296 {297 RAISE( mediacontrol_InternalException, "No playlist" );298 return;299 }300 301 playlist_Add( self->p_playlist, psz_file, psz_file , PLAYLIST_INSERT,302 PLAYLIST_END );303 }304 305 void306 mediacontrol_playlist_next_item( mediacontrol_Instance *self,307 mediacontrol_Exception *exception )308 {309 exception=mediacontrol_exception_init( exception );310 if ( !self->p_playlist )311 {312 RAISE( mediacontrol_InternalException, "No playlist" );313 return;314 }315 316 playlist_Next( self->p_playlist );317 318 return;319 }320 321 void322 mediacontrol_playlist_clear( mediacontrol_Instance *self,323 mediacontrol_Exception *exception )324 {325 exception=mediacontrol_exception_init( exception );326 if( !self->p_playlist )327 {328 RAISE( mediacontrol_PlaylistException, "No playlist" );329 return;330 }331 332 playlist_Clear( self->p_playlist );333 334 return;335 }336 337 mediacontrol_PlaylistSeq *338 mediacontrol_playlist_get_list( mediacontrol_Instance *self,339 mediacontrol_Exception *exception )340 {341 mediacontrol_PlaylistSeq *retval;342 int i_index;343 playlist_t * p_playlist = self->p_playlist;344 int i_playlist_size;345 346 exception=mediacontrol_exception_init( exception );347 if( !p_playlist )348 {349 RAISE( mediacontrol_PlaylistException, "No playlist" );350 return NULL;351 }352 353 vlc_mutex_lock( &p_playlist->object_lock );354 i_playlist_size = p_playlist->i_size;355 356 retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size );357 358 for( i_index = 0 ; i_index < i_playlist_size ; i_index++ )359 {360 retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->input.psz_uri );361 }362 vlc_mutex_unlock( &p_playlist->object_lock );363 364 return retval;365 }366 367 /***************************************************************************368 * Status feedback369 ***************************************************************************/370 371 mediacontrol_StreamInformation *372 mediacontrol_get_stream_information( mediacontrol_Instance *self,373 mediacontrol_PositionKey a_key,374 mediacontrol_Exception *exception )375 {376 mediacontrol_StreamInformation *retval;377 input_thread_t *p_input = self->p_playlist->p_input;378 vlc_value_t val;379 380 retval = ( mediacontrol_StreamInformation* )malloc( sizeof( mediacontrol_StreamInformation ) );381 if( ! retval )382 {383 RAISE( mediacontrol_InternalException, "Out of memory" );384 return NULL;385 }386 387 if( ! p_input )388 {389 /* No p_input defined */390 retval->streamstatus = mediacontrol_UndefinedStatus;391 retval->url = strdup( "None" );392 retval->position = 0;393 retval->length = 0;394 }395 else396 {397 switch( var_GetInteger( p_input, "state" ) )398 {399 case PLAYING_S :400 retval->streamstatus = mediacontrol_PlayingStatus;401 break;402 case PAUSE_S :403 retval->streamstatus = mediacontrol_PauseStatus;404 break;405 case INIT_S :406 retval->streamstatus = mediacontrol_InitStatus;407 break;408 case END_S :409 retval->streamstatus = mediacontrol_EndStatus;410 break;411 default :412 retval->streamstatus = mediacontrol_UndefinedStatus;413 break;414 }415 416 retval->url = strdup( p_input->input.p_item->psz_uri );417 418 /* TIME and LENGTH are in microseconds. We want them in ms */419 var_Get( p_input, "time", &val);420 retval->position = val.i_time / 1000;421 422 var_Get( p_input, "length", &val);423 retval->length = val.i_time / 1000;424 425 retval->position = mediacontrol_unit_convert( p_input,426 mediacontrol_MediaTime, a_key,427 retval->position );428 retval->length = mediacontrol_unit_convert( p_input,429 mediacontrol_MediaTime, a_key,430 retval->length );431 }432 return retval;433 }src/misc/stats.c
r03b059c r68aa3ca 97 97 case STATS_LAST: 98 98 case STATS_MIN: 99 case STATS_ LAST:99 case STATS_MAX: 100 100 if( p_counter->i_samples > 1) 101 101 { … … 250 250 int i; 251 251 /* read_packets and read_bytes are common to all streams */ 252 p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );253 p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );254 255 } 252 //p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" ); 253 // p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" ); 254 255 }
