]> git.sesse.net Git - vlc/commitdiff
mozilla: activex: add cache filling level to event MediaPlayerBuffering
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Tue, 18 May 2010 14:21:37 +0000 (16:21 +0200)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Tue, 7 Sep 2010 08:26:37 +0000 (10:26 +0200)
Add cache filling level to the MediaPlayerBuffering event.

include/vlc/libvlc_events.h
projects/activex/axvlc.idl
projects/activex/axvlc.tlb
projects/activex/plugin.cpp
projects/activex/plugin.h
projects/mozilla/vlcplugin.cpp
src/control/media_list.c
src/control/media_player.c

index 8aa41d820cb6ffd86ed6ba84b603664749d3ed03..8046b5f708632403f309219fa34c106b8e9a00a7 100644 (file)
@@ -139,6 +139,10 @@ typedef struct libvlc_event_t
 
         /* media instance */
         struct
+        {
+            float new_cache;
+        } media_player_buffering;
+        struct
         {
             float new_position;
         } media_player_position_changed;
index de7562ddf213759bc211977cdc1bb3a5951e10e5..85ef7731a167ee10b713b84aa452da0a2321e8a3 100644 (file)
@@ -206,7 +206,7 @@ library AXVLC
             [id(DISPID_MediaPlayerOpeningEvent), helpstring("Opening media")]\r
             void MediaPlayerOpening();\r
             [id(DISPID_MediaPlayerBufferingEvent), helpstring("Buffering media")]\r
-            void MediaPlayerBuffering();\r
+            void MediaPlayerBuffering([in] long cache);\r
             [id(DISPID_MediaPlayerPlayingEvent), helpstring("Media is playing")]\r
             void MediaPlayerPlaying();\r
             [id(DISPID_MediaPlayerPausedEvent), helpstring("Media is paused")]\r
index a65b13ef28bbc73237fa71344794e21dcd199ab4..ac0a11879fb814698b12ff5b25f7fb0f8fced5e5 100644 (file)
Binary files a/projects/activex/axvlc.tlb and b/projects/activex/axvlc.tlb differ
index 1627e5e3d2c6c0ab9f6b99270600e11b3a512e6c..52c19652bd4d58a45dd559026d11c3ab0f313bd0 100644 (file)
@@ -1021,10 +1021,17 @@ void VLCPlugin::fireOnMediaPlayerOpeningEvent()
     vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerOpeningEvent, &dispparamsNoArgs);
 };
 
-void VLCPlugin::fireOnMediaPlayerBufferingEvent()
+void VLCPlugin::fireOnMediaPlayerBufferingEvent(long cache)
 {
-    DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
-    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBufferingEvent, &dispparamsNoArgs);
+    DISPPARAMS params;
+    params.cArgs = 1;
+    params.rgvarg = (VARIANTARG *) CoTaskMemAlloc(sizeof(VARIANTARG) * params.cArgs) ;
+    memset(params.rgvarg, 0, sizeof(VARIANTARG) * params.cArgs);
+    params.rgvarg[0].vt = VT_I4;
+    params.rgvarg[0].lVal = cache;
+    params.rgdispidNamedArgs = NULL;
+    params.cNamedArgs = 0;
+    vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBufferingEvent, &params);
 };
 
 void VLCPlugin::fireOnMediaPlayerPlayingEvent()
@@ -1081,7 +1088,7 @@ static void handle_input_state_event(const libvlc_event_t* event, void *param)
             plugin->fireOnMediaPlayerOpeningEvent();
             break;
         case libvlc_MediaPlayerBuffering:
-            plugin->fireOnMediaPlayerBufferingEvent();
+            plugin->fireOnMediaPlayerBufferingEvent(event->u.media_player_buffering.new_cache);
             break;
         case libvlc_MediaPlayerPlaying:
             plugin->fireOnMediaPlayerPlayingEvent();
index 412bdcedf3cc077434dcb115583c2624c5483888..7db813ac19301572755d4003bad64248b0f58d0b 100644 (file)
@@ -241,7 +241,7 @@ public:
     // async events;
     void fireOnMediaPlayerNothingSpecialEvent();
     void fireOnMediaPlayerOpeningEvent();
-    void fireOnMediaPlayerBufferingEvent();
+    void fireOnMediaPlayerBufferingEvent(long cache);
     void fireOnMediaPlayerPlayingEvent();
     void fireOnMediaPlayerPausedEvent();
     void fireOnMediaPlayerForwardEvent();
index 320b19005c92ca3e2d1c912c21f07f7abc6e2a7b..2fabfc049959edb76109911db9c7d90bb1d5aee1 100644 (file)
@@ -112,7 +112,7 @@ static vlcplugin_event_t vlcevents[] = {
     { "MediaPlayerMediaChanged", libvlc_MediaPlayerMediaChanged, handle_input_event },
     { "MediaPlayerNothingSpecial", libvlc_MediaPlayerNothingSpecial, handle_input_event },
     { "MediaPlayerOpening", libvlc_MediaPlayerOpening, handle_input_event },
-    { "MediaPlayerBuffering", libvlc_MediaPlayerBuffering, handle_input_event },
+    { "MediaPlayerBuffering", libvlc_MediaPlayerBuffering, handle_changed_event },
     { "MediaPlayerPlaying", libvlc_MediaPlayerPlaying, handle_input_event },
     { "MediaPlayerPaused", libvlc_MediaPlayerPaused, handle_input_event },
     { "MediaPlayerStopped", libvlc_MediaPlayerStopped, handle_input_event },
@@ -135,7 +135,6 @@ static void handle_input_event(const libvlc_event_t* event, void *param)
     {
         case libvlc_MediaPlayerNothingSpecial:
         case libvlc_MediaPlayerOpening:
-        case libvlc_MediaPlayerBuffering:
         case libvlc_MediaPlayerPlaying:
         case libvlc_MediaPlayerPaused:
         case libvlc_MediaPlayerStopped:
@@ -158,6 +157,9 @@ static void handle_changed_event(const libvlc_event_t* event, void *param)
     VlcPlugin *plugin = (VlcPlugin*)param;
     switch( event->type )
     {
+        case libvlc_MediaPlayerBuffering:
+            DOUBLE_TO_NPVARIANT(event->u.media_player_buffering.new_cache, npparam[0]);
+            break;
         case libvlc_MediaPlayerTimeChanged:
             DOUBLE_TO_NPVARIANT(event->u.media_player_time_changed.new_time, npparam[0]);
             break;
@@ -207,7 +209,6 @@ void EventObj::deliver(NPP browser)
                 NPVariant result;
                 NPVariant *params = iter->params();
                 uint32_t   count  = iter->count();
-                assert( params );
 
                 NPObject *listener = j->listener();
                 assert( listener );
@@ -225,7 +226,7 @@ void EventObj::deliver(NPP browser)
                         NPN_MemFree( (void*)NPVARIANT_TO_OBJECT(params[n]) );
                     }
                 }
-                NPN_MemFree( params );
+                if (params) NPN_MemFree( params );
             }
         }
     }
index 8dc7e0c6ae6a585cb7d24d265e1d1888f4556d26..08271247a3ceca66c8f9a946777741ae7bcbf5a6 100644 (file)
@@ -183,6 +183,7 @@ libvlc_media_list_new( libvlc_instance_t * p_inst )
     vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?
 
     vlc_array_init( &p_mlist->items );
+    assert( p_mlist->items.i_count == 0 );
     p_mlist->i_refcount = 1;
     p_mlist->p_md = NULL;
 
index 4b71ec885d79f5179dc68dc3ed209232bf49dfd9..328a7e40cf2534da066223cb502fc53767742146 100644 (file)
@@ -299,9 +299,15 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
            from_mtime(var_GetTime( p_input, "length" ));
         libvlc_event_send( p_mi->p_event_manager, &event );
     }
+    else if( newval.i_int == INPUT_EVENT_CACHE )
+    {
+        event.type = libvlc_MediaPlayerBuffering;
+        event.u.media_player_buffering.new_cache = (int)(100 *
+            var_GetFloat( p_input, "cache" ));
+        libvlc_event_send( p_mi->p_event_manager, &event );
+    }
 
     return VLC_SUCCESS;
-
 }
 
 /**************************************************************************