X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mozilla%2Fcontrol%2Fnpolibvlc.cpp;h=7ff456eae9e5336e3d6f771c007a37d9845d9e98;hb=14d89d29ef0b2a5e49e9078531be82c1eb6d954d;hp=f7d7d8e8e1722709dfff6a67c1f1eb3e9be59f48;hpb=2cb0f8937bdf6e15aafbc5689f7a1272d5fdfb3f;p=vlc diff --git a/mozilla/control/npolibvlc.cpp b/mozilla/control/npolibvlc.cpp index f7d7d8e8e1..7ff456eae9 100755 --- a/mozilla/control/npolibvlc.cpp +++ b/mozilla/control/npolibvlc.cpp @@ -48,11 +48,11 @@ LibvlcRootNPObject::~LibvlcRootNPObject() */ if( isValid() ) { - if( audioObj ) NPN_ReleaseObject(audioObj); - if( inputObj ) NPN_ReleaseObject(inputObj); - if( logObj ) NPN_ReleaseObject(logObj); - if( playlistObj ) NPN_ReleaseObject(playlistObj); - if( videoObj ) NPN_ReleaseObject(videoObj); + if( audioObj ) NPN_ReleaseObject(audioObj); + if( inputObj ) NPN_ReleaseObject(inputObj); + if( logObj ) NPN_ReleaseObject(logObj); + if( playlistObj ) NPN_ReleaseObject(playlistObj); + if( videoObj ) NPN_ReleaseObject(videoObj); } } @@ -86,44 +86,34 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVaria switch( index ) { case ID_root_audio: - // create child object in lazyman fashion to avoid ownership problem with firefox - if( audioObj ) - NPN_RetainObject(audioObj); - else - audioObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(audioObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! audioObj ) + audioObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result); return INVOKERESULT_NO_ERROR; case ID_root_input: - // create child object in lazyman fashion to avoid ownership problem with firefox - if( inputObj ) - NPN_RetainObject(inputObj); - else - inputObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(inputObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! inputObj ) + inputObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result); return INVOKERESULT_NO_ERROR; case ID_root_log: - // create child object in lazyman fashion to avoid ownership problem with firefox - if( logObj ) - NPN_RetainObject(logObj); - else - logObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(logObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! logObj ) + logObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result); return INVOKERESULT_NO_ERROR; case ID_root_playlist: - // create child object in lazyman fashion to avoid ownership problem with firefox - if( playlistObj ) - NPN_RetainObject(playlistObj); - else - playlistObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(playlistObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! playlistObj ) + playlistObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result); return INVOKERESULT_NO_ERROR; case ID_root_video: - // create child object in lazyman fashion to avoid ownership problem with firefox - if( videoObj ) - NPN_RetainObject(videoObj); - else - videoObj = NPN_CreateObject(_instance,RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(videoObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! videoObj ) + videoObj = NPN_CreateObject(_instance,RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result); return INVOKERESULT_NO_ERROR; case ID_root_VersionInfo: { @@ -252,15 +242,15 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari } case ID_audio_track: { - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); libvlc_exception_clear(&ex); return INVOKERESULT_GENERIC_ERROR; } - int track = libvlc_audio_get_track(p_input, &ex); - libvlc_input_free(p_input); + int track = libvlc_audio_get_track(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -331,16 +321,16 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const case ID_audio_track: if( isNumberValue(value) ) { - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); libvlc_exception_clear(&ex); return INVOKERESULT_GENERIC_ERROR; } - libvlc_audio_set_track(p_input, + libvlc_audio_set_track(p_md, numberValue(value), &ex); - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -455,7 +445,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari libvlc_exception_t ex; libvlc_exception_init(&ex); - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { if( index != ID_input_state ) @@ -476,8 +466,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari { case ID_input_length: { - double val = (double)libvlc_input_get_length(p_input, &ex); - libvlc_input_free(p_input); + double val = (double)libvlc_media_instance_get_length(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -489,8 +479,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_position: { - double val = libvlc_input_get_position(p_input, &ex); - libvlc_input_free(p_input); + double val = libvlc_media_instance_get_position(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -502,8 +492,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_time: { - double val = (double)libvlc_input_get_time(p_input, &ex); - libvlc_input_free(p_input); + double val = (double)libvlc_media_instance_get_time(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -515,8 +505,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_state: { - int val = libvlc_input_get_state(p_input, &ex); - libvlc_input_free(p_input); + int val = libvlc_media_instance_get_state(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -528,8 +518,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_rate: { - float val = libvlc_input_get_rate(p_input, &ex); - libvlc_input_free(p_input); + float val = libvlc_media_instance_get_rate(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -541,8 +531,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_fps: { - double val = libvlc_input_get_fps(p_input, &ex); - libvlc_input_free(p_input); + double val = libvlc_media_instance_get_fps(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -554,8 +544,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari } case ID_input_hasvout: { - vlc_bool_t val = libvlc_input_has_vout(p_input, &ex); - libvlc_input_free(p_input); + vlc_bool_t val = libvlc_media_instance_has_vout(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -568,7 +558,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari default: ; } - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); } return INVOKERESULT_GENERIC_ERROR; } @@ -582,7 +572,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const libvlc_exception_t ex; libvlc_exception_init(&ex); - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -596,13 +586,13 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const { if( ! NPVARIANT_IS_DOUBLE(value) ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } float val = (float)NPVARIANT_TO_DOUBLE(value); - libvlc_input_set_position(p_input, val, &ex); - libvlc_input_free(p_input); + libvlc_media_instance_set_position(p_md, val, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -620,12 +610,12 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const val = (vlc_int64_t)NPVARIANT_TO_DOUBLE(value); else { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } - libvlc_input_set_time(p_input, val, &ex); - libvlc_input_free(p_input); + libvlc_media_instance_set_time(p_md, val, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -643,12 +633,12 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const val = (float)NPVARIANT_TO_DOUBLE(value); else { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } - libvlc_input_set_rate(p_input, val, &ex); - libvlc_input_free(p_input); + libvlc_media_instance_set_rate(p_md, val, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -660,7 +650,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const default: ; } - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); } return INVOKERESULT_GENERIC_ERROR; } @@ -1057,7 +1047,7 @@ LibvlcLogNPObject::~LibvlcLogNPObject() { if( isValid() ) { - if( messagesObj ) NPN_ReleaseObject(messagesObj); + if( messagesObj ) NPN_ReleaseObject(messagesObj); } }; @@ -1088,12 +1078,10 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian { case ID_log_messages: { - // create child object in lazyman fashion to avoid ownership problem with firefox - if( messagesObj ) - NPN_RetainObject(messagesObj); - else - messagesObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(messagesObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! messagesObj ) + messagesObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result); return INVOKERESULT_NO_ERROR; } case ID_log_verbosity: @@ -1311,7 +1299,7 @@ LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject() { if( isValid() ) { - if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj); + if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj); } }; @@ -1368,12 +1356,10 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV } case ID_playlist_items: { - // create child object in lazyman fashion to avoid ownership problem with firefox - if( playlistItemsObj ) - NPN_RetainObject(playlistItemsObj); - else - playlistItemsObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); - OBJECT_TO_NPVARIANT(playlistItemsObj, result); + // create child object in lazyman fashion to avoid ownership problem with firefox + if( ! playlistItemsObj ) + playlistItemsObj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); + OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result); return INVOKERESULT_NO_ERROR; } default: @@ -1664,11 +1650,12 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP return INVOKERESULT_GENERIC_ERROR; } -void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options) +void LibvlcPlaylistNPObject::parseOptions(const NPString &nps, int *i_options, char*** ppsz_options) { - if( s.utf8length ) + if( nps.utf8length ) { - char *val = stringValue(s); + char *s = stringValue(nps); + char *val = s; if( val ) { long capacity = 16; @@ -1677,7 +1664,7 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, cha { int nOptions = 0; - char *end = val + s.utf8length; + char *end = val + nps.utf8length; while( val < end ) { // skip leading blanks @@ -1708,11 +1695,11 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, cha if( ! moreOptions ) { /* failed to allocate more memory */ - delete val; + delete s; /* return what we got so far */ *i_options = nOptions; *ppsz_options = options; - break; + return; } options = moreOptions; } @@ -1726,7 +1713,7 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, cha *i_options = nOptions; *ppsz_options = options; } - delete val; + delete s; } } } @@ -1802,7 +1789,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = "width", "aspectRatio", "subtitle", - "crop" + "crop", + "teletext" }; enum LibvlcVideoNPObjectPropertyIds @@ -1812,7 +1800,8 @@ enum LibvlcVideoNPObjectPropertyIds ID_video_width, ID_video_aspectratio, ID_video_subtitle, - ID_video_crop + ID_video_crop, + ID_video_teletext }; const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *); @@ -1826,7 +1815,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari libvlc_exception_t ex; libvlc_exception_init(&ex); - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1838,8 +1827,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari { case ID_video_fullscreen: { - int val = libvlc_get_fullscreen(p_input, &ex); - libvlc_input_free(p_input); + int val = libvlc_get_fullscreen(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1851,8 +1840,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari } case ID_video_height: { - int val = libvlc_video_get_height(p_input, &ex); - libvlc_input_free(p_input); + int val = libvlc_video_get_height(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1864,8 +1853,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari } case ID_video_width: { - int val = libvlc_video_get_width(p_input, &ex); - libvlc_input_free(p_input); + int val = libvlc_video_get_width(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1877,8 +1866,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari } case ID_video_aspectratio: { - NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex); - libvlc_input_free(p_input); + NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1893,8 +1882,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari } case ID_video_subtitle: { - int i_spu = libvlc_video_get_spu(p_input, &ex); - libvlc_input_free(p_input); + int i_spu = libvlc_video_get_spu(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1906,8 +1895,8 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari } case ID_video_crop: { - NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_input, &ex); - libvlc_input_free(p_input); + NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1920,8 +1909,21 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari STRINGZ_TO_NPVARIANT(psz_geometry, result); return INVOKERESULT_NO_ERROR; } + case ID_video_teletext: + { + int i_page = libvlc_video_get_teletext(p_md, &ex); + libvlc_media_instance_release(p_md); + if( libvlc_exception_raised(&ex) ) + { + NPN_SetException(this, libvlc_exception_get_message(&ex)); + libvlc_exception_clear(&ex); + return INVOKERESULT_GENERIC_ERROR; + } + INT32_TO_NPVARIANT(i_page, result); + return INVOKERESULT_NO_ERROR; + } } - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); } return INVOKERESULT_GENERIC_ERROR; } @@ -1935,7 +1937,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const libvlc_exception_t ex; libvlc_exception_init(&ex); - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -1949,13 +1951,13 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const { if( ! NPVARIANT_IS_BOOLEAN(value) ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } int val = NPVARIANT_TO_BOOLEAN(value); - libvlc_set_fullscreen(p_input, val, &ex); - libvlc_input_free(p_input); + libvlc_set_fullscreen(p_md, val, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { @@ -1971,20 +1973,20 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const if( ! NPVARIANT_IS_STRING(value) ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } psz_aspect = stringValue(NPVARIANT_TO_STRING(value)); if( !psz_aspect ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_GENERIC_ERROR; } - libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex); + libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex); delete psz_aspect; - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { @@ -1998,9 +2000,9 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const { if( isNumberValue(value) ) { - libvlc_video_set_spu(p_input, + libvlc_video_set_spu(p_md, numberValue(value), &ex); - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -2009,7 +2011,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const } return INVOKERESULT_NO_ERROR; } - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } case ID_video_crop: @@ -2018,20 +2020,20 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const if( ! NPVARIANT_IS_STRING(value) ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_INVALID_VALUE; } psz_geometry = stringValue(NPVARIANT_TO_STRING(value)); if( !psz_geometry ) { - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); return INVOKERESULT_GENERIC_ERROR; } - libvlc_video_set_crop_geometry(p_input, psz_geometry, &ex); + libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex); delete psz_geometry; - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { @@ -2041,8 +2043,26 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const } return INVOKERESULT_NO_ERROR; } + case ID_video_teletext: + { + if( isNumberValue(value) ) + { + libvlc_video_set_teletext(p_md, + numberValue(value), &ex); + libvlc_media_instance_release(p_md); + if( libvlc_exception_raised(&ex) ) + { + NPN_SetException(this, libvlc_exception_get_message(&ex)); + libvlc_exception_clear(&ex); + return INVOKERESULT_GENERIC_ERROR; + } + return INVOKERESULT_NO_ERROR; + } + libvlc_media_instance_release(p_md); + return INVOKERESULT_INVALID_VALUE; + } } - libvlc_input_free(p_input); + libvlc_media_instance_release(p_md); } return INVOKERESULT_GENERIC_ERROR; } @@ -2050,11 +2070,13 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const const NPUTF8 * const LibvlcVideoNPObject::methodNames[] = { "toggleFullscreen", + "toggleTeletext" }; enum LibvlcVideoNPObjectMethodIds { ID_video_togglefullscreen, + ID_video_toggleteletext }; const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *); @@ -2068,7 +2090,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar libvlc_exception_t ex; libvlc_exception_init(&ex); - libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); + libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_plugin->getVLC(), &ex); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -2081,8 +2103,36 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar case ID_video_togglefullscreen: if( argCount == 0 ) { - libvlc_toggle_fullscreen(p_input, &ex); - libvlc_input_free(p_input); + libvlc_toggle_fullscreen(p_md, &ex); + libvlc_media_instance_release(p_md); + if( libvlc_exception_raised(&ex) ) + { + NPN_SetException(this, libvlc_exception_get_message(&ex)); + libvlc_exception_clear(&ex); + return INVOKERESULT_GENERIC_ERROR; + } + else + { + VOID_TO_NPVARIANT(result); + return INVOKERESULT_NO_ERROR; + } + } + else + { + /* cannot get md, probably not playing */ + if( libvlc_exception_raised(&ex) ) + { + NPN_SetException(this, libvlc_exception_get_message(&ex)); + libvlc_exception_clear(&ex); + } + return INVOKERESULT_GENERIC_ERROR; + } + return INVOKERESULT_NO_SUCH_METHOD; + case ID_video_toggleteletext: + if( argCount == 0 ) + { + libvlc_toggle_teletext(p_md, &ex); + libvlc_media_instance_release(p_md); if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex)); @@ -2097,7 +2147,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar } else { - /* cannot get input, probably not playing */ + /* cannot get md, probably not playing */ if( libvlc_exception_raised(&ex) ) { NPN_SetException(this, libvlc_exception_get_message(&ex));