1 /*****************************************************************************
2 * npolibvlc.cpp: official Javascript APIs
3 *****************************************************************************
4 * Copyright (C) 2002-2006 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
30 #ifdef HAVE_MOZILLA_CONFIG_H
31 # include <mozilla-config.h>
34 #include "vlcplugin.h"
35 #include "npolibvlc.h"
38 ** Local helper macros and function
40 #define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
41 #define RETURN_ON_EXCEPTION(this,ex) \
42 do { if( libvlc_exception_raised(&ex) ) \
44 NPN_SetException(this, libvlc_exception_get_message(&ex)); \
45 libvlc_exception_clear(&ex); \
46 return INVOKERESULT_GENERIC_ERROR; \
50 ** implementation of libvlc root object
53 LibvlcRootNPObject::~LibvlcRootNPObject()
56 ** When the plugin is destroyed, firefox takes it upon itself to
57 ** destroy all 'live' script objects and ignores refcounting.
58 ** Therefore we cannot safely assume that refcounting will control
59 ** lifespan of objects. Hence they are only lazily created on
60 ** request, so that firefox can take ownership, and are not released
61 ** when the plugin is destroyed.
65 if( audioObj ) NPN_ReleaseObject(audioObj);
66 if( inputObj ) NPN_ReleaseObject(inputObj);
67 if( logObj ) NPN_ReleaseObject(logObj);
68 if( playlistObj ) NPN_ReleaseObject(playlistObj);
69 if( videoObj ) NPN_ReleaseObject(videoObj);
73 const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
82 COUNTNAMES(LibvlcRootNPObject,propertyCount,propertyNames);
84 enum LibvlcRootNPObjectPropertyIds
94 RuntimeNPObject::InvokeResult
95 LibvlcRootNPObject::getProperty(int index, NPVariant &result)
97 /* is plugin still running */
98 if( isPluginRunning() )
103 // create child object in lazyman fashion to avoid
104 // ownership problem with firefox
106 audioObj = NPN_CreateObject(_instance,
107 RuntimeNPClass<LibvlcAudioNPObject>::getClass());
108 OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
109 return INVOKERESULT_NO_ERROR;
111 // create child object in lazyman fashion to avoid
112 // ownership problem with firefox
114 inputObj = NPN_CreateObject(_instance,
115 RuntimeNPClass<LibvlcInputNPObject>::getClass());
116 OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
117 return INVOKERESULT_NO_ERROR;
119 // create child object in lazyman fashion to avoid
120 // ownership problem with firefox
122 logObj = NPN_CreateObject(_instance,
123 RuntimeNPClass<LibvlcLogNPObject>::getClass());
124 OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
125 return INVOKERESULT_NO_ERROR;
126 case ID_root_playlist:
127 // create child object in lazyman fashion to avoid
128 // ownership problem with firefox
130 playlistObj = NPN_CreateObject(_instance,
131 RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
132 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
133 return INVOKERESULT_NO_ERROR;
135 // create child object in lazyman fashion to avoid
136 // ownership problem with firefox
138 videoObj = NPN_CreateObject(_instance,
139 RuntimeNPClass<LibvlcVideoNPObject>::getClass());
140 OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
141 return INVOKERESULT_NO_ERROR;
142 case ID_root_VersionInfo:
144 int len = strlen(libvlc_get_version());
145 NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
148 memcpy(retval, libvlc_get_version(), len);
149 STRINGN_TO_NPVARIANT(retval, len, result);
153 NULL_TO_NPVARIANT(result);
155 return INVOKERESULT_NO_ERROR;
161 return INVOKERESULT_GENERIC_ERROR;
164 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =
168 COUNTNAMES(LibvlcRootNPObject,methodCount,methodNames);
170 enum LibvlcRootNPObjectMethodIds
175 RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
176 const NPVariant *args, uint32_t argCount, NPVariant &result)
178 /* is plugin still running */
179 if( isPluginRunning() )
181 libvlc_exception_t ex;
182 libvlc_exception_init(&ex);
186 case ID_root_versionInfo:
189 int len = strlen(libvlc_get_version());
190 NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
193 memcpy(retval, libvlc_get_version(), len);
194 STRINGN_TO_NPVARIANT(retval, len, result);
198 NULL_TO_NPVARIANT(result);
200 return INVOKERESULT_NO_ERROR;
202 return INVOKERESULT_NO_SUCH_METHOD;
207 return INVOKERESULT_GENERIC_ERROR;
211 ** implementation of libvlc audio object
214 const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
221 COUNTNAMES(LibvlcAudioNPObject,propertyCount,propertyNames);
223 enum LibvlcAudioNPObjectPropertyIds
231 RuntimeNPObject::InvokeResult
232 LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
234 /* is plugin still running */
235 if( isPluginRunning() )
237 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
238 libvlc_exception_t ex;
239 libvlc_exception_init(&ex);
245 bool muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
246 RETURN_ON_EXCEPTION(this,ex);
247 BOOLEAN_TO_NPVARIANT(muted, result);
248 return INVOKERESULT_NO_ERROR;
250 case ID_audio_volume:
252 int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
253 RETURN_ON_EXCEPTION(this,ex);
254 INT32_TO_NPVARIANT(volume, result);
255 return INVOKERESULT_NO_ERROR;
259 libvlc_media_player_t *p_md =
260 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
261 RETURN_ON_EXCEPTION(this,ex);
262 int track = libvlc_audio_get_track(p_md, &ex);
263 libvlc_media_player_release(p_md);
264 RETURN_ON_EXCEPTION(this,ex);
265 INT32_TO_NPVARIANT(track, result);
266 return INVOKERESULT_NO_ERROR;
268 case ID_audio_channel:
270 int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
271 RETURN_ON_EXCEPTION(this,ex);
272 INT32_TO_NPVARIANT(channel, result);
273 return INVOKERESULT_NO_ERROR;
279 return INVOKERESULT_GENERIC_ERROR;
282 RuntimeNPObject::InvokeResult
283 LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
285 /* is plugin still running */
286 if( isPluginRunning() )
288 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
289 libvlc_exception_t ex;
290 libvlc_exception_init(&ex);
295 if( NPVARIANT_IS_BOOLEAN(value) )
297 libvlc_audio_set_mute(p_plugin->getVLC(),
298 NPVARIANT_TO_BOOLEAN(value), &ex);
299 RETURN_ON_EXCEPTION(this,ex);
300 return INVOKERESULT_NO_ERROR;
302 return INVOKERESULT_INVALID_VALUE;
303 case ID_audio_volume:
304 if( isNumberValue(value) )
306 libvlc_audio_set_volume(p_plugin->getVLC(),
307 numberValue(value), &ex);
308 RETURN_ON_EXCEPTION(this,ex);
309 return INVOKERESULT_NO_ERROR;
311 return INVOKERESULT_INVALID_VALUE;
313 if( isNumberValue(value) )
315 libvlc_media_player_t *p_md =
316 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
317 RETURN_ON_EXCEPTION(this,ex);
318 libvlc_audio_set_track(p_md, numberValue(value), &ex);
319 libvlc_media_player_release(p_md);
320 RETURN_ON_EXCEPTION(this,ex);
321 return INVOKERESULT_NO_ERROR;
323 return INVOKERESULT_INVALID_VALUE;
324 case ID_audio_channel:
325 if( isNumberValue(value) )
327 libvlc_audio_set_channel(p_plugin->getVLC(),
328 numberValue(value), &ex);
329 RETURN_ON_EXCEPTION(this,ex);
330 return INVOKERESULT_NO_ERROR;
332 return INVOKERESULT_INVALID_VALUE;
337 return INVOKERESULT_GENERIC_ERROR;
340 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
344 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
346 enum LibvlcAudioNPObjectMethodIds
351 RuntimeNPObject::InvokeResult
352 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
353 uint32_t argCount, NPVariant &result)
355 /* is plugin still running */
356 if( isPluginRunning() )
358 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
359 libvlc_exception_t ex;
360 libvlc_exception_init(&ex);
364 case ID_audio_togglemute:
367 libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
368 RETURN_ON_EXCEPTION(this,ex);
369 VOID_TO_NPVARIANT(result);
370 return INVOKERESULT_NO_ERROR;
372 return INVOKERESULT_NO_SUCH_METHOD;
377 return INVOKERESULT_GENERIC_ERROR;
381 ** implementation of libvlc input object
384 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
394 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
396 enum LibvlcInputNPObjectPropertyIds
407 RuntimeNPObject::InvokeResult
408 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
410 /* is plugin still running */
411 if( isPluginRunning() )
413 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
414 libvlc_exception_t ex;
415 libvlc_exception_init(&ex);
417 libvlc_media_player_t *p_md =
418 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
419 if( libvlc_exception_raised(&ex) )
421 if( index != ID_input_state )
423 NPN_SetException(this, libvlc_exception_get_message(&ex));
424 libvlc_exception_clear(&ex);
425 return INVOKERESULT_GENERIC_ERROR;
429 /* for input state, return CLOSED rather than an exception */
430 INT32_TO_NPVARIANT(0, result);
431 libvlc_exception_clear(&ex);
432 return INVOKERESULT_NO_ERROR;
438 case ID_input_length:
440 double val = (double)libvlc_media_player_get_length(p_md, &ex);
441 libvlc_media_player_release(p_md);
442 RETURN_ON_EXCEPTION(this,ex);
443 DOUBLE_TO_NPVARIANT(val, result);
444 return INVOKERESULT_NO_ERROR;
446 case ID_input_position:
448 double val = libvlc_media_player_get_position(p_md, &ex);
449 libvlc_media_player_release(p_md);
450 RETURN_ON_EXCEPTION(this,ex);
451 DOUBLE_TO_NPVARIANT(val, result);
452 return INVOKERESULT_NO_ERROR;
456 double val = (double)libvlc_media_player_get_time(p_md, &ex);
457 libvlc_media_player_release(p_md);
458 RETURN_ON_EXCEPTION(this,ex);
459 DOUBLE_TO_NPVARIANT(val, result);
460 return INVOKERESULT_NO_ERROR;
464 int val = libvlc_media_player_get_state(p_md, &ex);
465 libvlc_media_player_release(p_md);
466 RETURN_ON_EXCEPTION(this,ex);
467 INT32_TO_NPVARIANT(val, result);
468 return INVOKERESULT_NO_ERROR;
472 float val = libvlc_media_player_get_rate(p_md, &ex);
473 libvlc_media_player_release(p_md);
474 RETURN_ON_EXCEPTION(this,ex);
475 DOUBLE_TO_NPVARIANT(val, result);
476 return INVOKERESULT_NO_ERROR;
480 double val = libvlc_media_player_get_fps(p_md, &ex);
481 libvlc_media_player_release(p_md);
482 RETURN_ON_EXCEPTION(this,ex);
483 DOUBLE_TO_NPVARIANT(val, result);
484 return INVOKERESULT_NO_ERROR;
486 case ID_input_hasvout:
488 bool val = libvlc_media_player_has_vout(p_md, &ex);
489 libvlc_media_player_release(p_md);
490 RETURN_ON_EXCEPTION(this,ex);
491 BOOLEAN_TO_NPVARIANT(val, result);
492 return INVOKERESULT_NO_ERROR;
497 libvlc_media_player_release(p_md);
499 return INVOKERESULT_GENERIC_ERROR;
502 RuntimeNPObject::InvokeResult
503 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
505 /* is plugin still running */
506 if( isPluginRunning() )
508 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
509 libvlc_exception_t ex;
510 libvlc_exception_init(&ex);
512 libvlc_media_player_t *p_md =
513 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
514 RETURN_ON_EXCEPTION(this,ex);
518 case ID_input_position:
520 if( ! NPVARIANT_IS_DOUBLE(value) )
522 libvlc_media_player_release(p_md);
523 return INVOKERESULT_INVALID_VALUE;
526 float val = (float)NPVARIANT_TO_DOUBLE(value);
527 libvlc_media_player_set_position(p_md, val, &ex);
528 libvlc_media_player_release(p_md);
529 RETURN_ON_EXCEPTION(this,ex);
530 return INVOKERESULT_NO_ERROR;
535 if( NPVARIANT_IS_INT32(value) )
536 val = (int64_t)NPVARIANT_TO_INT32(value);
537 else if( NPVARIANT_IS_DOUBLE(value) )
538 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
541 libvlc_media_player_release(p_md);
542 return INVOKERESULT_INVALID_VALUE;
545 libvlc_media_player_set_time(p_md, val, &ex);
546 libvlc_media_player_release(p_md);
547 RETURN_ON_EXCEPTION(this,ex);
548 return INVOKERESULT_NO_ERROR;
553 if( NPVARIANT_IS_INT32(value) )
554 val = (float)NPVARIANT_TO_INT32(value);
555 else if( NPVARIANT_IS_DOUBLE(value) )
556 val = (float)NPVARIANT_TO_DOUBLE(value);
559 libvlc_media_player_release(p_md);
560 return INVOKERESULT_INVALID_VALUE;
563 libvlc_media_player_set_rate(p_md, val, &ex);
564 libvlc_media_player_release(p_md);
565 RETURN_ON_EXCEPTION(this,ex);
566 return INVOKERESULT_NO_ERROR;
571 libvlc_media_player_release(p_md);
573 return INVOKERESULT_GENERIC_ERROR;
576 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
581 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
584 ** implementation of libvlc message object
587 const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
595 COUNTNAMES(LibvlcMessageNPObject,propertyCount,propertyNames);
597 enum LibvlcMessageNPObjectPropertyIds
606 RuntimeNPObject::InvokeResult
607 LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
609 /* is plugin still running */
610 if( isPluginRunning() )
614 case ID_message_severity:
616 INT32_TO_NPVARIANT(_msg.i_severity, result);
617 return INVOKERESULT_NO_ERROR;
619 case ID_message_type:
623 int len = strlen(_msg.psz_type);
624 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
627 memcpy(retval, _msg.psz_type, len);
628 STRINGN_TO_NPVARIANT(retval, len, result);
633 NULL_TO_NPVARIANT(result);
635 return INVOKERESULT_NO_ERROR;
637 case ID_message_name:
641 int len = strlen(_msg.psz_name);
642 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
645 memcpy(retval, _msg.psz_name, len);
646 STRINGN_TO_NPVARIANT(retval, len, result);
651 NULL_TO_NPVARIANT(result);
653 return INVOKERESULT_NO_ERROR;
655 case ID_message_header:
657 if( _msg.psz_header )
659 int len = strlen(_msg.psz_header);
660 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
663 memcpy(retval, _msg.psz_header, len);
664 STRINGN_TO_NPVARIANT(retval, len, result);
669 NULL_TO_NPVARIANT(result);
671 return INVOKERESULT_NO_ERROR;
673 case ID_message_message:
675 if( _msg.psz_message )
677 int len = strlen(_msg.psz_message);
678 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
681 memcpy(retval, _msg.psz_message, len);
682 STRINGN_TO_NPVARIANT(retval, len, result);
687 NULL_TO_NPVARIANT(result);
689 return INVOKERESULT_NO_ERROR;
695 return INVOKERESULT_GENERIC_ERROR;
698 const NPUTF8 * const LibvlcMessageNPObject::methodNames[] =
702 COUNTNAMES(LibvlcMessageNPObject,methodCount,methodNames);
705 ** implementation of libvlc message iterator object
708 LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance,
709 const NPClass *aClass) :
710 RuntimeNPObject(instance, aClass),
713 // XXX FIXME use _instance or instance in this method?
715 /* is plugin still running */
716 if( instance->pdata )
718 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
719 libvlc_log_t *p_log = p_plugin->getLog();
722 _p_iter = libvlc_log_get_iterator(p_log, NULL);
727 LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
730 libvlc_log_iterator_free(_p_iter, NULL);
733 const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
737 COUNTNAMES(LibvlcMessageIteratorNPObject,propertyCount,propertyNames);
739 enum LibvlcMessageIteratorNPObjectPropertyIds
741 ID_messageiterator_hasNext,
744 RuntimeNPObject::InvokeResult
745 LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
747 /* is plugin still running */
748 if( isPluginRunning() )
750 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
753 case ID_messageiterator_hasNext:
755 if( _p_iter && p_plugin->getLog() )
757 libvlc_exception_t ex;
758 libvlc_exception_init(&ex);
760 BOOLEAN_TO_NPVARIANT(
761 libvlc_log_iterator_has_next(_p_iter, &ex), result );
762 RETURN_ON_EXCEPTION(this,ex);
766 BOOLEAN_TO_NPVARIANT(0, result);
768 return INVOKERESULT_NO_ERROR;
774 return INVOKERESULT_GENERIC_ERROR;
777 const NPUTF8 * const LibvlcMessageIteratorNPObject::methodNames[] =
781 COUNTNAMES(LibvlcMessageIteratorNPObject,methodCount,methodNames);
783 enum LibvlcMessageIteratorNPObjectMethodIds
785 ID_messageiterator_next,
788 RuntimeNPObject::InvokeResult
789 LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args,
790 uint32_t argCount, NPVariant &result)
792 /* is plugin still running */
793 if( isPluginRunning() )
795 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
796 libvlc_exception_t ex;
797 libvlc_exception_init(&ex);
801 case ID_messageiterator_next:
804 if( _p_iter && p_plugin->getLog() )
806 struct libvlc_log_message_t buffer;
808 buffer.sizeof_msg = sizeof(buffer);
810 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
811 RETURN_ON_EXCEPTION(this,ex);
813 LibvlcMessageNPObject* message =
814 static_cast<LibvlcMessageNPObject*>(
815 NPN_CreateObject(_instance, RuntimeNPClass<
816 LibvlcMessageNPObject>::getClass()));
819 message->setMessage(buffer);
820 OBJECT_TO_NPVARIANT(message, result);
821 return INVOKERESULT_NO_ERROR;
823 return INVOKERESULT_OUT_OF_MEMORY;
825 return INVOKERESULT_GENERIC_ERROR;
827 return INVOKERESULT_NO_SUCH_METHOD;
832 return INVOKERESULT_GENERIC_ERROR;
836 ** implementation of libvlc message object
839 const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
843 COUNTNAMES(LibvlcMessagesNPObject,propertyCount,propertyNames);
845 enum LibvlcMessagesNPObjectPropertyIds
850 RuntimeNPObject::InvokeResult
851 LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
853 /* is plugin still running */
854 if( isPluginRunning() )
856 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
859 case ID_messages_count:
861 libvlc_log_t *p_log = p_plugin->getLog();
864 libvlc_exception_t ex;
865 libvlc_exception_init(&ex);
867 INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
868 RETURN_ON_EXCEPTION(this,ex);
872 INT32_TO_NPVARIANT(0, result);
874 return INVOKERESULT_NO_ERROR;
880 return INVOKERESULT_GENERIC_ERROR;
883 const NPUTF8 * const LibvlcMessagesNPObject::methodNames[] =
888 COUNTNAMES(LibvlcMessagesNPObject,methodCount,methodNames);
890 enum LibvlcMessagesNPObjectMethodIds
893 ID_messages_iterator,
896 RuntimeNPObject::InvokeResult
897 LibvlcMessagesNPObject::invoke(int index, const NPVariant *args,
898 uint32_t argCount, NPVariant &result)
900 /* is plugin still running */
901 if( isPluginRunning() )
903 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
904 libvlc_exception_t ex;
905 libvlc_exception_init(&ex);
909 case ID_messages_clear:
912 libvlc_log_t *p_log = p_plugin->getLog();
915 libvlc_log_clear(p_log, &ex);
916 RETURN_ON_EXCEPTION(this,ex);
918 return INVOKERESULT_NO_ERROR;
920 return INVOKERESULT_NO_SUCH_METHOD;
922 case ID_messages_iterator:
925 LibvlcMessageIteratorNPObject* iter =
926 static_cast<LibvlcMessageIteratorNPObject*>(
927 NPN_CreateObject(_instance, RuntimeNPClass<
928 LibvlcMessageIteratorNPObject>::getClass()));
931 OBJECT_TO_NPVARIANT(iter, result);
932 return INVOKERESULT_NO_ERROR;
934 return INVOKERESULT_OUT_OF_MEMORY;
936 return INVOKERESULT_NO_SUCH_METHOD;
942 return INVOKERESULT_GENERIC_ERROR;
947 ** implementation of libvlc message object
951 LibvlcLogNPObject::~LibvlcLogNPObject()
955 if( messagesObj ) NPN_ReleaseObject(messagesObj);
959 const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
964 COUNTNAMES(LibvlcLogNPObject,propertyCount,propertyNames);
966 enum LibvlcLogNPObjectPropertyIds
972 RuntimeNPObject::InvokeResult
973 LibvlcLogNPObject::getProperty(int index, NPVariant &result)
975 /* is plugin still running */
976 if( isPluginRunning() )
978 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
979 libvlc_exception_t ex;
980 libvlc_exception_init(&ex);
984 case ID_log_messages:
986 // create child object in lazyman fashion to avoid
987 // ownership problem with firefox
989 messagesObj = NPN_CreateObject(_instance,
990 RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
991 OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result);
992 return INVOKERESULT_NO_ERROR;
994 case ID_log_verbosity:
996 if( p_plugin->getLog() )
998 INT32_TO_NPVARIANT( libvlc_get_log_verbosity(
999 p_plugin->getVLC(), &ex), result);
1000 RETURN_ON_EXCEPTION(this,ex);
1004 /* log is not enabled, return -1 */
1005 DOUBLE_TO_NPVARIANT(-1.0, result);
1007 return INVOKERESULT_NO_ERROR;
1013 return INVOKERESULT_GENERIC_ERROR;
1016 RuntimeNPObject::InvokeResult
1017 LibvlcLogNPObject::setProperty(int index, const NPVariant &value)
1019 /* is plugin still running */
1020 if( isPluginRunning() )
1022 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1023 libvlc_exception_t ex;
1024 libvlc_exception_init(&ex);
1028 case ID_log_verbosity:
1029 if( isNumberValue(value) )
1031 libvlc_instance_t* p_libvlc = p_plugin->getVLC();
1032 libvlc_log_t *p_log = p_plugin->getLog();
1033 int verbosity = numberValue(value);
1034 if( verbosity >= 0 )
1038 p_log = libvlc_log_open(p_libvlc, &ex);
1039 RETURN_ON_EXCEPTION(this,ex);
1040 p_plugin->setLog(p_log);
1042 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
1043 RETURN_ON_EXCEPTION(this,ex);
1047 /* close log when verbosity is set to -1 */
1048 p_plugin->setLog(NULL);
1049 libvlc_log_close(p_log, &ex);
1050 RETURN_ON_EXCEPTION(this,ex);
1052 return INVOKERESULT_NO_ERROR;
1054 return INVOKERESULT_INVALID_VALUE;
1059 return INVOKERESULT_GENERIC_ERROR;
1062 const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
1066 COUNTNAMES(LibvlcLogNPObject,methodCount,methodNames);
1069 ** implementation of libvlc playlist items object
1072 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
1076 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
1078 enum LibvlcPlaylistItemsNPObjectPropertyIds
1080 ID_playlistitems_count,
1083 RuntimeNPObject::InvokeResult
1084 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
1086 /* is plugin still running */
1087 if( isPluginRunning() )
1089 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1090 libvlc_exception_t ex;
1091 libvlc_exception_init(&ex);
1095 case ID_playlistitems_count:
1097 libvlc_playlist_lock(p_plugin->getVLC());
1098 int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
1099 libvlc_playlist_unlock(p_plugin->getVLC());
1100 RETURN_ON_EXCEPTION(this,ex);
1101 INT32_TO_NPVARIANT(val, result);
1102 return INVOKERESULT_NO_ERROR;
1108 return INVOKERESULT_GENERIC_ERROR;
1111 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
1116 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
1118 enum LibvlcPlaylistItemsNPObjectMethodIds
1120 ID_playlistitems_clear,
1121 ID_playlistitems_remove,
1124 RuntimeNPObject::InvokeResult
1125 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
1126 uint32_t argCount, NPVariant &result)
1128 /* is plugin still running */
1129 if( isPluginRunning() )
1131 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1132 libvlc_exception_t ex;
1133 libvlc_exception_init(&ex);
1137 case ID_playlistitems_clear:
1140 libvlc_playlist_clear(p_plugin->getVLC(), &ex);
1141 RETURN_ON_EXCEPTION(this,ex);
1142 VOID_TO_NPVARIANT(result);
1143 return INVOKERESULT_NO_ERROR;
1145 return INVOKERESULT_NO_SUCH_METHOD;
1146 case ID_playlistitems_remove:
1147 if( (argCount == 1) && isNumberValue(args[0]) )
1149 libvlc_playlist_delete_item(p_plugin->getVLC(),
1150 numberValue(args[0]), &ex);
1151 RETURN_ON_EXCEPTION(this,ex);
1152 VOID_TO_NPVARIANT(result);
1153 return INVOKERESULT_NO_ERROR;
1155 return INVOKERESULT_NO_SUCH_METHOD;
1160 return INVOKERESULT_GENERIC_ERROR;
1164 ** implementation of libvlc playlist object
1168 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
1172 if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj);
1176 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
1178 "itemCount", /* deprecated */
1182 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
1184 enum LibvlcPlaylistNPObjectPropertyIds
1186 ID_playlist_itemcount,
1187 ID_playlist_isplaying,
1191 RuntimeNPObject::InvokeResult
1192 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
1194 /* is plugin still running */
1195 if( isPluginRunning() )
1197 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1198 libvlc_exception_t ex;
1199 libvlc_exception_init(&ex);
1203 case ID_playlist_itemcount: /* deprecated */
1205 libvlc_playlist_lock(p_plugin->getVLC());
1206 int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
1207 libvlc_playlist_unlock(p_plugin->getVLC());
1208 RETURN_ON_EXCEPTION(this,ex);
1209 INT32_TO_NPVARIANT(val, result);
1210 return INVOKERESULT_NO_ERROR;
1212 case ID_playlist_isplaying:
1214 libvlc_playlist_lock(p_plugin->getVLC());
1215 int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
1216 libvlc_playlist_unlock(p_plugin->getVLC());
1217 RETURN_ON_EXCEPTION(this,ex);
1218 BOOLEAN_TO_NPVARIANT(val, result);
1219 return INVOKERESULT_NO_ERROR;
1221 case ID_playlist_items:
1223 // create child object in lazyman fashion to avoid
1224 // ownership problem with firefox
1225 if( ! playlistItemsObj )
1227 NPN_CreateObject(_instance, RuntimeNPClass<
1228 LibvlcPlaylistItemsNPObject>::getClass());
1229 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
1230 return INVOKERESULT_NO_ERROR;
1236 return INVOKERESULT_GENERIC_ERROR;
1239 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
1248 "clear", /* deprecated */
1249 "removeItem", /* deprecated */
1251 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
1253 enum LibvlcPlaylistNPObjectMethodIds
1257 ID_playlist_playItem,
1258 ID_playlist_togglepause,
1263 ID_playlist_removeitem
1266 RuntimeNPObject::InvokeResult
1267 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
1268 uint32_t argCount, NPVariant &result)
1270 /* is plugin still running */
1271 if( isPluginRunning() )
1273 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1274 libvlc_exception_t ex;
1275 libvlc_exception_init(&ex);
1279 case ID_playlist_add:
1281 if( (argCount < 1) || (argCount > 3) )
1282 return INVOKERESULT_NO_SUCH_METHOD;
1287 if( NPVARIANT_IS_STRING(args[0]) )
1289 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
1292 url = p_plugin->getAbsoluteURL(s);
1296 // problem with combining url, use argument
1300 return INVOKERESULT_OUT_OF_MEMORY;
1303 return INVOKERESULT_NO_SUCH_METHOD;
1307 // grab name if available
1310 if( NPVARIANT_IS_NULL(args[1]) )
1314 else if( NPVARIANT_IS_STRING(args[1]) )
1316 name = stringValue(NPVARIANT_TO_STRING(args[1]));
1321 return INVOKERESULT_INVALID_VALUE;
1326 char** ppsz_options = NULL;
1328 // grab options if available
1331 if( NPVARIANT_IS_NULL(args[2]) )
1335 else if( NPVARIANT_IS_STRING(args[2]) )
1337 parseOptions(NPVARIANT_TO_STRING(args[2]),
1338 &i_options, &ppsz_options);
1341 else if( NPVARIANT_IS_OBJECT(args[2]) )
1343 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
1344 &i_options, &ppsz_options);
1350 return INVOKERESULT_INVALID_VALUE;
1354 int item = libvlc_playlist_add_extended_untrusted(
1355 p_plugin->getVLC(), url, name, i_options,
1356 const_cast<const char **>(ppsz_options), &ex);
1359 for( int i=0; i< i_options; ++i )
1361 free(ppsz_options[i]);
1365 RETURN_ON_EXCEPTION(this,ex);
1366 INT32_TO_NPVARIANT(item, result);
1367 return INVOKERESULT_NO_ERROR;
1369 case ID_playlist_play:
1372 libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
1373 RETURN_ON_EXCEPTION(this,ex);
1374 VOID_TO_NPVARIANT(result);
1375 return INVOKERESULT_NO_ERROR;
1377 return INVOKERESULT_NO_SUCH_METHOD;
1378 case ID_playlist_playItem:
1379 if( (argCount == 1) && isNumberValue(args[0]) )
1381 libvlc_playlist_play(p_plugin->getVLC(),
1382 numberValue(args[0]), 0, NULL, &ex);
1383 RETURN_ON_EXCEPTION(this,ex);
1384 VOID_TO_NPVARIANT(result);
1385 return INVOKERESULT_NO_ERROR;
1387 return INVOKERESULT_NO_SUCH_METHOD;
1388 case ID_playlist_togglepause:
1391 libvlc_playlist_pause(p_plugin->getVLC(), &ex);
1392 RETURN_ON_EXCEPTION(this,ex);
1393 VOID_TO_NPVARIANT(result);
1394 return INVOKERESULT_NO_ERROR;
1396 return INVOKERESULT_NO_SUCH_METHOD;
1397 case ID_playlist_stop:
1400 libvlc_playlist_stop(p_plugin->getVLC(), &ex);
1401 RETURN_ON_EXCEPTION(this,ex);
1402 VOID_TO_NPVARIANT(result);
1403 return INVOKERESULT_NO_ERROR;
1405 return INVOKERESULT_NO_SUCH_METHOD;
1406 case ID_playlist_next:
1409 libvlc_playlist_next(p_plugin->getVLC(), &ex);
1410 RETURN_ON_EXCEPTION(this,ex);
1411 VOID_TO_NPVARIANT(result);
1412 return INVOKERESULT_NO_ERROR;
1414 return INVOKERESULT_NO_SUCH_METHOD;
1415 case ID_playlist_prev:
1418 libvlc_playlist_prev(p_plugin->getVLC(), &ex);
1419 RETURN_ON_EXCEPTION(this,ex);
1420 VOID_TO_NPVARIANT(result);
1421 return INVOKERESULT_NO_ERROR;
1423 return INVOKERESULT_NO_SUCH_METHOD;
1424 case ID_playlist_clear: /* deprecated */
1427 libvlc_playlist_clear(p_plugin->getVLC(), &ex);
1428 RETURN_ON_EXCEPTION(this,ex);
1429 VOID_TO_NPVARIANT(result);
1430 return INVOKERESULT_NO_ERROR;
1432 return INVOKERESULT_NO_SUCH_METHOD;
1433 case ID_playlist_removeitem: /* deprecated */
1434 if( (argCount == 1) && isNumberValue(args[0]) )
1436 libvlc_playlist_delete_item(p_plugin->getVLC(),
1437 numberValue(args[0]), &ex);
1438 RETURN_ON_EXCEPTION(this,ex);
1439 VOID_TO_NPVARIANT(result);
1440 return INVOKERESULT_NO_ERROR;
1442 return INVOKERESULT_NO_SUCH_METHOD;
1447 return INVOKERESULT_GENERIC_ERROR;
1450 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
1451 int *i_options, char*** ppsz_options)
1453 if( nps.utf8length )
1455 char *s = stringValue(nps);
1460 char **options = (char **)malloc(capacity*sizeof(char *));
1465 char *end = val + nps.utf8length;
1468 // skip leading blanks
1470 && ((*val == ' ' ) || (*val == '\t')) )
1474 // skip till we get a blank character
1480 if( ('\'' == c) || ('"' == c) )
1482 // skip till end of string
1483 while( (val < end) && (*(val++) != c ) );
1489 if( nOptions == capacity )
1492 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1495 /* failed to allocate more memory */
1497 /* return what we got so far */
1498 *i_options = nOptions;
1499 *ppsz_options = options;
1502 options = moreOptions;
1505 options[nOptions++] = strdup(start);
1508 // must be end of string
1511 *i_options = nOptions;
1512 *ppsz_options = options;
1519 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1520 char*** ppsz_options)
1522 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1526 /* we are expecting to have a Javascript Array object */
1527 NPIdentifier propId = NPN_GetStringIdentifier("length");
1528 if( NPN_GetProperty(_instance, obj, propId, &value) )
1530 int count = numberValue(value);
1531 NPN_ReleaseVariantValue(&value);
1536 char **options = (char **)malloc(capacity*sizeof(char *));
1541 while( nOptions < count )
1543 propId = NPN_GetIntIdentifier(nOptions);
1544 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1545 /* return what we got so far */
1548 if( ! NPVARIANT_IS_STRING(value) )
1550 /* return what we got so far */
1551 NPN_ReleaseVariantValue(&value);
1555 if( nOptions == capacity )
1558 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1561 /* failed to allocate more memory */
1562 NPN_ReleaseVariantValue(&value);
1563 /* return what we got so far */
1564 *i_options = nOptions;
1565 *ppsz_options = options;
1568 options = moreOptions;
1571 options[nOptions++] = stringValue(value);
1573 *i_options = nOptions;
1574 *ppsz_options = options;
1581 ** implementation of libvlc video object
1584 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1595 enum LibvlcVideoNPObjectPropertyIds
1597 ID_video_fullscreen,
1600 ID_video_aspectratio,
1605 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1607 RuntimeNPObject::InvokeResult
1608 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1610 /* is plugin still running */
1611 if( isPluginRunning() )
1613 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1614 libvlc_exception_t ex;
1615 libvlc_exception_init(&ex);
1617 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1618 RETURN_ON_EXCEPTION(this,ex);
1622 case ID_video_fullscreen:
1624 int val = libvlc_get_fullscreen(p_md, &ex);
1625 libvlc_media_player_release(p_md);
1626 RETURN_ON_EXCEPTION(this,ex);
1627 BOOLEAN_TO_NPVARIANT(val, result);
1628 return INVOKERESULT_NO_ERROR;
1630 case ID_video_height:
1632 int val = libvlc_video_get_height(p_md, &ex);
1633 libvlc_media_player_release(p_md);
1634 RETURN_ON_EXCEPTION(this,ex);
1635 INT32_TO_NPVARIANT(val, result);
1636 return INVOKERESULT_NO_ERROR;
1638 case ID_video_width:
1640 int val = libvlc_video_get_width(p_md, &ex);
1641 libvlc_media_player_release(p_md);
1642 RETURN_ON_EXCEPTION(this,ex);
1643 INT32_TO_NPVARIANT(val, result);
1644 return INVOKERESULT_NO_ERROR;
1646 case ID_video_aspectratio:
1648 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1649 libvlc_media_player_release(p_md);
1650 RETURN_ON_EXCEPTION(this,ex);
1652 return INVOKERESULT_GENERIC_ERROR;
1654 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1655 return INVOKERESULT_NO_ERROR;
1657 case ID_video_subtitle:
1659 int i_spu = libvlc_video_get_spu(p_md, &ex);
1660 libvlc_media_player_release(p_md);
1661 RETURN_ON_EXCEPTION(this,ex);
1662 INT32_TO_NPVARIANT(i_spu, result);
1663 return INVOKERESULT_NO_ERROR;
1667 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1668 libvlc_media_player_release(p_md);
1669 RETURN_ON_EXCEPTION(this,ex);
1671 return INVOKERESULT_GENERIC_ERROR;
1673 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1674 return INVOKERESULT_NO_ERROR;
1676 case ID_video_teletext:
1678 int i_page = libvlc_video_get_teletext(p_md, &ex);
1679 libvlc_media_player_release(p_md);
1680 RETURN_ON_EXCEPTION(this,ex);
1681 INT32_TO_NPVARIANT(i_page, result);
1682 return INVOKERESULT_NO_ERROR;
1685 libvlc_media_player_release(p_md);
1687 return INVOKERESULT_GENERIC_ERROR;
1690 RuntimeNPObject::InvokeResult
1691 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1693 /* is plugin still running */
1694 if( isPluginRunning() )
1696 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1697 libvlc_exception_t ex;
1698 libvlc_exception_init(&ex);
1700 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1701 RETURN_ON_EXCEPTION(this,ex);
1705 case ID_video_fullscreen:
1707 if( ! NPVARIANT_IS_BOOLEAN(value) )
1709 libvlc_media_player_release(p_md);
1710 return INVOKERESULT_INVALID_VALUE;
1713 int val = NPVARIANT_TO_BOOLEAN(value);
1714 libvlc_set_fullscreen(p_md, val, &ex);
1715 libvlc_media_player_release(p_md);
1717 RETURN_ON_EXCEPTION(this,ex);
1718 return INVOKERESULT_NO_ERROR;
1720 case ID_video_aspectratio:
1722 char *psz_aspect = NULL;
1724 if( ! NPVARIANT_IS_STRING(value) )
1726 libvlc_media_player_release(p_md);
1727 return INVOKERESULT_INVALID_VALUE;
1730 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1733 libvlc_media_player_release(p_md);
1734 return INVOKERESULT_GENERIC_ERROR;
1737 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1739 libvlc_media_player_release(p_md);
1740 RETURN_ON_EXCEPTION(this,ex);
1742 return INVOKERESULT_NO_ERROR;
1744 case ID_video_subtitle:
1746 if( isNumberValue(value) )
1748 libvlc_video_set_spu(p_md,
1749 numberValue(value), &ex);
1750 libvlc_media_player_release(p_md);
1751 RETURN_ON_EXCEPTION(this,ex);
1753 return INVOKERESULT_NO_ERROR;
1755 libvlc_media_player_release(p_md);
1756 return INVOKERESULT_INVALID_VALUE;
1760 char *psz_geometry = NULL;
1762 if( ! NPVARIANT_IS_STRING(value) )
1764 libvlc_media_player_release(p_md);
1765 return INVOKERESULT_INVALID_VALUE;
1768 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1771 libvlc_media_player_release(p_md);
1772 return INVOKERESULT_GENERIC_ERROR;
1775 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1777 libvlc_media_player_release(p_md);
1778 RETURN_ON_EXCEPTION(this,ex);
1780 return INVOKERESULT_NO_ERROR;
1782 case ID_video_teletext:
1784 if( isNumberValue(value) )
1786 libvlc_video_set_teletext(p_md,
1787 numberValue(value), &ex);
1788 libvlc_media_player_release(p_md);
1789 RETURN_ON_EXCEPTION(this,ex);
1791 return INVOKERESULT_NO_ERROR;
1793 libvlc_media_player_release(p_md);
1794 return INVOKERESULT_INVALID_VALUE;
1797 libvlc_media_player_release(p_md);
1799 return INVOKERESULT_GENERIC_ERROR;
1802 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1807 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1809 enum LibvlcVideoNPObjectMethodIds
1811 ID_video_togglefullscreen,
1812 ID_video_toggleteletext
1815 RuntimeNPObject::InvokeResult
1816 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1817 uint32_t argCount, NPVariant &result)
1819 /* is plugin still running */
1820 if( isPluginRunning() )
1822 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1823 libvlc_exception_t ex;
1824 libvlc_exception_init(&ex);
1826 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1827 RETURN_ON_EXCEPTION(this,ex);
1831 case ID_video_togglefullscreen:
1834 libvlc_toggle_fullscreen(p_md, &ex);
1835 libvlc_media_player_release(p_md);
1836 RETURN_ON_EXCEPTION(this,ex);
1837 VOID_TO_NPVARIANT(result);
1838 return INVOKERESULT_NO_ERROR;
1840 return INVOKERESULT_NO_SUCH_METHOD;
1841 case ID_video_toggleteletext:
1844 libvlc_toggle_teletext(p_md, &ex);
1845 libvlc_media_player_release(p_md);
1846 RETURN_ON_EXCEPTION(this,ex);
1847 VOID_TO_NPVARIANT(result);
1848 return INVOKERESULT_NO_ERROR;
1850 return INVOKERESULT_NO_SUCH_METHOD;
1852 return INVOKERESULT_NO_SUCH_METHOD;
1855 return INVOKERESULT_GENERIC_ERROR;