[vlc-devel] Re: Mozilla Plugin
Sigmund Augdal
sigmunau at stud.ntnu.no
Fri Apr 30 01:34:51 CEST 2004
Seems like vlc_peer.cpp still includes these files:
+#include "vlc_common.h"
+#include <vlc/intf.h>
+
+
+#include <input_ext-plugins.h>
That is in my opinion bad, but I can't see any code in there that needs it.
Is it safe to remove?
Sigmund
On Thu, Apr 29, 2004 at 02:10:56PM +0200, Michael Pron wrote:
>
> Hi,
>
> Here i send you the patches of the work I've done on the mozilla plugin.
> I hope it can help.
> I add some functions in libvlc.c, and in vlcpeer.cpp. Now, you can call via javascript some functions like:
>
> get_length()
> get_position()
> Mute()
> Is_Mute()
> Playlist_status()
> Get_index_of_actual_item_in_playlist()
> Get_Number_of_item_in_playlist()
> Access_item_in_playlist(in PRInt64 item_number)
> prev_in_playlist()
> next_in_playlist()
> add_item_to_playlist(in string item_name)
> slower_video()
> faster_video()
> goto_from_begin(in PRInt64 sec)
> goto_from_current_position(in PRInt64 sec)
>
>
> patch_libvlc : cvs diff -u ./src/libvlc.c
> patch_mozilla : cvs diff -u ./mozilla
> patch_include_vlc : cvs diff -u ./include/vlc
>
> mkl
> ? ./mozilla/.deps
> ? ./mozilla/Makefile
> ? ./mozilla/Makefile.in
> ? ./mozilla/stamp-pic
> ? ./mozilla/vlcintf.h
> ? ./mozilla/vlcintf.xpt
> Index: ./mozilla/vlcintf.idl
> ===================================================================
> RCS file: /var/cvs/videolan/vlc/mozilla/vlcintf.idl,v
> retrieving revision 1.2
> diff -u -r1.2 vlcintf.idl
> --- ./mozilla/vlcintf.idl 30 Sep 2002 11:05:41 -0000 1.2
> +++ ./mozilla/vlcintf.idl 29 Apr 2004 11:52:49 -0000
> @@ -10,5 +10,30 @@
> void stop();
>
> void fullscreen();
> +
> +
> +
> + void goto_from_current_position(in PRInt64 sec);
> + void goto_from_begin(in PRInt64 sec);
> + void faster_video();
> + void slower_video();
> + PRInt64 get_rate();
> + void add_item_to_playlist(in string item_name);
> + void next_in_playlist();
> + void prev_in_playlist();
> + void Access_item_in_playlist(in PRInt64 item_number);
> + PRInt64 Get_Number_of_item_in_playlist();
> + PRInt64 Get_index_of_actual_item_in_playlist();
> + PRInt64 Playlist_status();
> + void Mute();
> + PRInt64 Is_Mute();
> +
> + void Stop_video();
> +
> + PRInt64 get_position();
> + PRInt64 get_length();
> +
> +
> +
> };
>
> Index: ./mozilla/vlcpeer.cpp
> ===================================================================
> RCS file: /var/cvs/videolan/vlc/mozilla/vlcpeer.cpp,v
> retrieving revision 1.9
> diff -u -r1.9 vlcpeer.cpp
> --- ./mozilla/vlcpeer.cpp 23 Oct 2003 17:04:39 -0000 1.9
> +++ ./mozilla/vlcpeer.cpp 29 Apr 2004 11:52:49 -0000
> @@ -49,6 +49,17 @@
> #include "vlcpeer.h"
> #include "vlcplugin.h"
>
> +
> +#include "vlc_common.h"
> +#include <vlc/intf.h>
> +
> +
> +#include <input_ext-plugins.h>
> +
> +
> +
> +
> +
> NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
>
> /*****************************************************************************
> @@ -128,3 +139,186 @@
> return NS_OK;
> }
>
> +NS_IMETHODIMP VlcPeer::Stop_video()
> +{
> + if( p_plugin )
> + {
> + VLC_Stop_video( p_plugin->i_vlc );
> + p_plugin->b_stream = 0;
> + }
> + return NS_OK;
> +}
> +
> +
> +
> +NS_IMETHODIMP VlcPeer::Get_rate( PRInt64 *rate )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + *rate = VLC_Get_rate( p_plugin->i_vlc );
> +
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Goto_from_current_position( PRInt64 seconde )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Goto_from_current_position( p_plugin->i_vlc, seconde );
> + }
> + return NS_OK;
> +}
> +
> +NS_IMETHODIMP VlcPeer::Goto_from_begin( PRInt64 seconde )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Goto_from_begin( p_plugin->i_vlc, seconde );
> + }
> + return NS_OK;
> +}
> +
> +
> +
> +NS_IMETHODIMP VlcPeer::Faster_video()
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Faster_video( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +
> +NS_IMETHODIMP VlcPeer::Slower_video()
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Slower_video( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Add_item_to_playlist( const char *item_name )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Add_item_to_playlist( p_plugin->i_vlc, (char *)item_name );
> + }
> + return NS_OK;
> +}
> +
> +
> +
> +
> +NS_IMETHODIMP VlcPeer::Next_in_playlist()
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Playlist_Next( p_plugin->i_vlc ) ;
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Prev_in_playlist()
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Playlist_Prev( p_plugin->i_vlc ) ;
> + }
> + return NS_OK;
> +}
> +
> +NS_IMETHODIMP VlcPeer::Access_item_in_playlist( PRInt64 item_number )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + VLC_Playlist_Access_to( p_plugin->i_vlc, item_number ) ;
> + }
> + return NS_OK;
> +}
> +
> +NS_IMETHODIMP VlcPeer::Get_Number_of_item_in_playlist( PRInt64 *item_number )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + *item_number = VLC_Playlist_Number_of_item( p_plugin->i_vlc ) ;
> + }
> + return NS_OK;
> +}
> +
> +NS_IMETHODIMP VlcPeer::Get_index_of_actual_item_in_playlist( PRInt64 *item_number )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + *item_number = VLC_Playlist_index_of_actual_item( p_plugin->i_vlc ) ;
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Playlist_status( PRInt64 *status )
> +{
> + if( p_plugin->i_vlc )
> + {
> + *status = VLC_Playlist_status( p_plugin->i_vlc ) ;
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Mute()
> +{
> +
> + if( p_plugin )
> + {
> + VLC_Mute( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Is_Mute( PRInt64 *mute )
> +{
> +
> + if( p_plugin )
> + {
> + *mute = VLC_Is_Mute( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +
> +
> +NS_IMETHODIMP VlcPeer::Get_position( PRInt64 *pos )
> +{
> + if( p_plugin->i_vlc )
> + {
> + *pos = VLC_Get_position( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +NS_IMETHODIMP VlcPeer::Get_length( PRInt64 *length )
> +{
> +
> + if( p_plugin->i_vlc )
> + {
> + *length = VLC_Get_length( p_plugin->i_vlc );
> + }
> + return NS_OK;
> +}
> +
> +
> Index: ./src/libvlc.c
> ===================================================================
> RCS file: /var/cvs/videolan/vlc/src/libvlc.c,v
> retrieving revision 1.121
> diff -u -r1.121 libvlc.c
> --- ./src/libvlc.c 20 Apr 2004 17:58:04 -0000 1.121
> +++ ./src/libvlc.c 29 Apr 2004 11:52:25 -0000
> @@ -1164,6 +1164,432 @@
> return VLC_SUCCESS;
> }
>
> +
> +void VLC_Goto_from_current_position( int i_object, int i_second )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if ( p_vlc )
> + {
> +
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> +
> +
> + if ( p_input )
> + {
> + input_Seek( p_input, i_second, INPUT_SEEK_SECONDS|INPUT_SEEK_CUR );
> + vlc_object_release( p_input );
> + }
> +
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +
> +void VLC_Goto_from_begin( int i_object, int i_second )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> + vlc_value_t value;
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + input_Seek( p_input, i_second, INPUT_SEEK_SECONDS|INPUT_SEEK_SET );
> + vlc_cond_signal( &p_input->stream.stream_wait );
> + vlc_object_release( p_input );
> +
> + }
> + vlc_object_release( p_vlc );
> + }
> +
> +}
> +
> +
> +void VLC_Faster_video( int i_object )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + input_SetStatus( p_input, INPUT_STATUS_FASTER );
> + vlc_object_release( p_input );
> + }
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +
> +void VLC_Slower_video( int i_object )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + input_SetStatus( p_input, INPUT_STATUS_SLOWER );
> + vlc_object_release( p_input );
> + }
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +int VLC_Get_rate( int i_object )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> + stream_position_t p_position;
> + int i_rate=0;
> +
> + vlc_value_t valeur;
> +
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if (p_vlc)
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + input_Tell( p_input, &p_position );
> + i_rate=p_position.i_mux_rate;
> + vlc_object_release( p_input );
> + }
> + vlc_object_release( p_vlc );
> + }
> +
> + return i_rate;
> +}
> +
> +void VLC_Add_item_to_playlist( int i_object, char *item_name )
> +{
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> +
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if( !p_playlist )
> + {
> + p_playlist = playlist_Create( p_vlc );
> + if( !p_playlist )
> + {
> + msg_Err( p_vlc, "playlist initialization failed" );
> + if( p_vlc->p_memcpy_module != NULL )
> + {
> + module_Unneed( p_vlc, p_vlc->p_memcpy_module );
> + }
> + if( i_object ) vlc_object_release( p_vlc );
> + }
> + }
> + else
> + {
> + playlist_Add( p_playlist, item_name, 0, PLAYLIST_APPEND, PLAYLIST_END );
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +void VLC_Playlist_Next( int i_object )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> +
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if (p_playlist)
> + {
> + playlist_Next( p_playlist );
> + vlc_object_release( p_playlist );
> + }
> +
> +
> + vlc_object_release( p_vlc );
> + }
> +
> +}
> +
> +void VLC_Playlist_Prev( int i_object )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if ( p_playlist )
> + {
> + playlist_Prev( p_playlist );
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +void VLC_Playlist_Access_to( int i_object, int i_item_number )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if ( p_playlist )
> + {
> + playlist_Command( p_playlist, PLAYLIST_GOTO, i_item_number );
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +
> +int VLC_Playlist_Number_of_item( int i_object )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> + int i_size=0;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if ( p_playlist )
> + {
> + i_size=p_playlist->i_size;
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> + return ( i_size );
> +}
> +
> +
> +
> +int VLC_Playlist_index_of_actual_item( int i_object )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> + int i_index=0;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
> + if ( p_playlist )
> + {
> + i_index=p_playlist->i_index;
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> + return ( i_index );
> +}
> +
> +
> +int VLC_Playlist_status( int i_object )
> +{
> +
> + playlist_t *p_playlist;
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> + int i_status=-2;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> +
> +
> +
> + if ( p_vlc )
> + {
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
> +
> + if ( p_playlist )
> + {
> + /*if the status is equal to 1 we've had to get the right status : Play or Pause*/
> + if ( p_playlist->i_status==1 )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + if ( p_input->stream.i_new_status == PAUSE_S )
> + i_status=2;
> + else
> + i_status=1;
> + vlc_object_release( p_input );
> + }
> + }
> + else
> + {
> + i_status=0;
> + }
> +
> + vlc_object_release( p_playlist );
> + }
> + vlc_object_release( p_vlc );
> + }
> + return ( i_status );
> +}
> +
> +
> +void VLC_Mute ( int i_object )
> +{
> + vlc_t *p_vlc;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if( p_vlc )
> + {
> + aout_VolumeMute( p_vlc, NULL );
> + vlc_object_release( p_vlc );
> + }
> +}
> +
> +int VLC_Is_Mute ( int i_object )
> +{
> + vlc_t *p_vlc;
> + audio_volume_t i_volume;
> + int i_mute=0;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if ( p_vlc )
> + {
> + i_volume = ( audio_volume_t )config_GetInt( p_vlc, "volume" );
> + if ( i_volume==0 )
> + i_mute=1;
> + vlc_object_release( p_vlc );
> + }
> + return ( i_mute );
> +}
> +
> +int VLC_Stop_video( int i_object )
> +{
> + playlist_t * p_playlist;
> + vlc_t *p_vlc = vlc_current_object( i_object );
> +
> + /* Check that the handle is valid */
> + if( !p_vlc )
> + {
> + return VLC_ENOOBJ;
> + }
> +
> + p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST,
> + FIND_CHILD );
> +
> + /* Send the command STOP to the playlist */
> + if ( p_playlist )
> + {
> + playlist_Command( p_playlist, PLAYLIST_STOP ,0 );
> + vlc_object_release( p_playlist );
> + }
> +
> +
> + if( i_object ) vlc_object_release( p_vlc );
> + return VLC_SUCCESS;
> +}
> +
> +int VLC_Get_position( int i_object )
> +{
> + vlc_t *p_vlc;
> +
> + vlc_value_t value;
> + int i_position=0;
> +
> +
> + input_thread_t *p_input;
> +
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if ( p_vlc )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + var_Get( p_input, "time", &value );
> + i_position = value.i_int;
> +
> + vlc_object_release( p_input );
> + }
> +
> + vlc_object_release( p_vlc );
> + }
> + return( i_position );
> +
> +}
> +
> +int VLC_Get_length( int i_object )
> +{
> + vlc_t *p_vlc;
> + input_thread_t *p_input;
> + int i_length=0;
> + vlc_value_t value;
> +
> + p_vlc = i_object ? vlc_object_get( p_libvlc, i_object ) : p_static_vlc;
> + if ( p_vlc )
> + {
> + p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
> + if ( p_input )
> + {
> + var_Get( p_input, "length", &value );
> + i_length = value.i_int;
> +
> + vlc_object_release( p_input );
> + }
> + vlc_object_release( p_vlc );
> + }
> + return ( i_length );
> +
> +}
> +
> +
> +
> +
> +
> +
> /* following functions are local */
>
> /*****************************************************************************
> Index: ./include/vlc/vlc.h
> ===================================================================
> RCS file: /var/cvs/videolan/vlc/include/vlc/vlc.h,v
> retrieving revision 1.32
> diff -u -r1.32 vlc.h
> --- ./include/vlc/vlc.h 20 Apr 2004 15:05:34 -0000 1.32
> +++ ./include/vlc/vlc.h 29 Apr 2004 11:53:16 -0000
> @@ -236,6 +236,29 @@
> int VLC_ClearPlaylist( int );
> vlc_bool_t VLC_IsPlaying ( int );
>
> +
> +void VLC_Goto_from_current_position( int, int );
> +void VLC_Goto_from_begin( int, int );
> +void VLC_Faster_video( int );
> +void VLC_Slower_video( int );
> +int VLC_Get_rate( int );
> +void VLC_Add_item_to_playlist( int, char* );
> +void VLC_Playlist_Next( int );
> +void VLC_Playlist_Prev( int );
> +void VLC_Playlist_Access_to( int, int );
> +int VLC_Playlist_Number_of_item( int );
> +int VLC_Playlist_index_of_actual_item( int );
> +int VLC_Playlist_status( int );
> +void VLC_Mute ( int );
> +int VLC_Is_Mute (int );
> +int VLC_Stop_video( int );
> +int VLC_Get_position( int );
> +int VLC_Get_length( int );
> +
> +
> +
> +
> +
> # ifdef __cplusplus
> }
> # endif
--
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>
More information about the vlc-devel
mailing list