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( _instance->pdata )
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( _instance->pdata )
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( _instance->pdata )
237 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
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( _instance->pdata )
288 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
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,
319 numberValue(value), &ex);
320 libvlc_media_player_release(p_md);
321 RETURN_ON_EXCEPTION(this,ex);
322 return INVOKERESULT_NO_ERROR;
324 return INVOKERESULT_INVALID_VALUE;
325 case ID_audio_channel:
326 if( isNumberValue(value) )
328 libvlc_audio_set_channel(p_plugin->getVLC(),
329 numberValue(value), &ex);
330 RETURN_ON_EXCEPTION(this,ex);
331 return INVOKERESULT_NO_ERROR;
333 return INVOKERESULT_INVALID_VALUE;
338 return INVOKERESULT_GENERIC_ERROR;
341 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
345 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
347 enum LibvlcAudioNPObjectMethodIds
352 RuntimeNPObject::InvokeResult
353 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
354 uint32_t argCount, NPVariant &result)
356 /* is plugin still running */
357 if( _instance->pdata )
359 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
360 libvlc_exception_t ex;
361 libvlc_exception_init(&ex);
365 case ID_audio_togglemute:
368 libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
369 RETURN_ON_EXCEPTION(this,ex);
370 VOID_TO_NPVARIANT(result);
371 return INVOKERESULT_NO_ERROR;
373 return INVOKERESULT_NO_SUCH_METHOD;
378 return INVOKERESULT_GENERIC_ERROR;
382 ** implementation of libvlc input object
385 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
395 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
397 enum LibvlcInputNPObjectPropertyIds
408 RuntimeNPObject::InvokeResult
409 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
411 /* is plugin still running */
412 if( _instance->pdata )
414 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
415 libvlc_exception_t ex;
416 libvlc_exception_init(&ex);
418 libvlc_media_player_t *p_md =
419 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
420 if( libvlc_exception_raised(&ex) )
422 if( index != ID_input_state )
424 NPN_SetException(this, libvlc_exception_get_message(&ex));
425 libvlc_exception_clear(&ex);
426 return INVOKERESULT_GENERIC_ERROR;
430 /* for input state, return CLOSED rather than an exception */
431 INT32_TO_NPVARIANT(0, result);
432 libvlc_exception_clear(&ex);
433 return INVOKERESULT_NO_ERROR;
439 case ID_input_length:
441 double val = (double)libvlc_media_player_get_length(p_md, &ex);
442 libvlc_media_player_release(p_md);
443 RETURN_ON_EXCEPTION(this,ex);
444 DOUBLE_TO_NPVARIANT(val, result);
445 return INVOKERESULT_NO_ERROR;
447 case ID_input_position:
449 double val = libvlc_media_player_get_position(p_md, &ex);
450 libvlc_media_player_release(p_md);
451 RETURN_ON_EXCEPTION(this,ex);
452 DOUBLE_TO_NPVARIANT(val, result);
453 return INVOKERESULT_NO_ERROR;
457 double val = (double)libvlc_media_player_get_time(p_md, &ex);
458 libvlc_media_player_release(p_md);
459 RETURN_ON_EXCEPTION(this,ex);
460 DOUBLE_TO_NPVARIANT(val, result);
461 return INVOKERESULT_NO_ERROR;
465 int val = libvlc_media_player_get_state(p_md, &ex);
466 libvlc_media_player_release(p_md);
467 RETURN_ON_EXCEPTION(this,ex);
468 INT32_TO_NPVARIANT(val, result);
469 return INVOKERESULT_NO_ERROR;
473 float val = libvlc_media_player_get_rate(p_md, &ex);
474 libvlc_media_player_release(p_md);
475 RETURN_ON_EXCEPTION(this,ex);
476 DOUBLE_TO_NPVARIANT(val, result);
477 return INVOKERESULT_NO_ERROR;
481 double val = libvlc_media_player_get_fps(p_md, &ex);
482 libvlc_media_player_release(p_md);
483 RETURN_ON_EXCEPTION(this,ex);
484 DOUBLE_TO_NPVARIANT(val, result);
485 return INVOKERESULT_NO_ERROR;
487 case ID_input_hasvout:
489 bool val = libvlc_media_player_has_vout(p_md, &ex);
490 libvlc_media_player_release(p_md);
491 RETURN_ON_EXCEPTION(this,ex);
492 BOOLEAN_TO_NPVARIANT(val, result);
493 return INVOKERESULT_NO_ERROR;
498 libvlc_media_player_release(p_md);
500 return INVOKERESULT_GENERIC_ERROR;
503 RuntimeNPObject::InvokeResult
504 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
506 /* is plugin still running */
507 if( _instance->pdata )
509 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
510 libvlc_exception_t ex;
511 libvlc_exception_init(&ex);
513 libvlc_media_player_t *p_md =
514 libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
515 RETURN_ON_EXCEPTION(this,ex);
519 case ID_input_position:
521 if( ! NPVARIANT_IS_DOUBLE(value) )
523 libvlc_media_player_release(p_md);
524 return INVOKERESULT_INVALID_VALUE;
527 float val = (float)NPVARIANT_TO_DOUBLE(value);
528 libvlc_media_player_set_position(p_md, val, &ex);
529 libvlc_media_player_release(p_md);
530 RETURN_ON_EXCEPTION(this,ex);
531 return INVOKERESULT_NO_ERROR;
536 if( NPVARIANT_IS_INT32(value) )
537 val = (int64_t)NPVARIANT_TO_INT32(value);
538 else if( NPVARIANT_IS_DOUBLE(value) )
539 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
542 libvlc_media_player_release(p_md);
543 return INVOKERESULT_INVALID_VALUE;
546 libvlc_media_player_set_time(p_md, val, &ex);
547 libvlc_media_player_release(p_md);
548 RETURN_ON_EXCEPTION(this,ex);
549 return INVOKERESULT_NO_ERROR;
554 if( NPVARIANT_IS_INT32(value) )
555 val = (float)NPVARIANT_TO_INT32(value);
556 else if( NPVARIANT_IS_DOUBLE(value) )
557 val = (float)NPVARIANT_TO_DOUBLE(value);
560 libvlc_media_player_release(p_md);
561 return INVOKERESULT_INVALID_VALUE;
564 libvlc_media_player_set_rate(p_md, val, &ex);
565 libvlc_media_player_release(p_md);
566 RETURN_ON_EXCEPTION(this,ex);
567 return INVOKERESULT_NO_ERROR;
572 libvlc_media_player_release(p_md);
574 return INVOKERESULT_GENERIC_ERROR;
577 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
582 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
585 ** implementation of libvlc message object
588 const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
596 COUNTNAMES(LibvlcMessageNPObject,propertyCount,propertyNames);
598 enum LibvlcMessageNPObjectPropertyIds
607 RuntimeNPObject::InvokeResult
608 LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
610 /* is plugin still running */
611 if( _instance->pdata )
615 case ID_message_severity:
617 INT32_TO_NPVARIANT(_msg.i_severity, result);
618 return INVOKERESULT_NO_ERROR;
620 case ID_message_type:
624 int len = strlen(_msg.psz_type);
625 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
628 memcpy(retval, _msg.psz_type, len);
629 STRINGN_TO_NPVARIANT(retval, len, result);
634 NULL_TO_NPVARIANT(result);
636 return INVOKERESULT_NO_ERROR;
638 case ID_message_name:
642 int len = strlen(_msg.psz_name);
643 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
646 memcpy(retval, _msg.psz_name, len);
647 STRINGN_TO_NPVARIANT(retval, len, result);
652 NULL_TO_NPVARIANT(result);
654 return INVOKERESULT_NO_ERROR;
656 case ID_message_header:
658 if( _msg.psz_header )
660 int len = strlen(_msg.psz_header);
661 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
664 memcpy(retval, _msg.psz_header, len);
665 STRINGN_TO_NPVARIANT(retval, len, result);
670 NULL_TO_NPVARIANT(result);
672 return INVOKERESULT_NO_ERROR;
674 case ID_message_message:
676 if( _msg.psz_message )
678 int len = strlen(_msg.psz_message);
679 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
682 memcpy(retval, _msg.psz_message, len);
683 STRINGN_TO_NPVARIANT(retval, len, result);
688 NULL_TO_NPVARIANT(result);
690 return INVOKERESULT_NO_ERROR;
696 return INVOKERESULT_GENERIC_ERROR;
699 const NPUTF8 * const LibvlcMessageNPObject::methodNames[] =
703 COUNTNAMES(LibvlcMessageNPObject,methodCount,methodNames);
706 ** implementation of libvlc message iterator object
709 LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance,
710 const NPClass *aClass) :
711 RuntimeNPObject(instance, aClass),
714 /* is plugin still running */
715 if( instance->pdata )
717 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
718 libvlc_log_t *p_log = p_plugin->getLog();
721 _p_iter = libvlc_log_get_iterator(p_log, NULL);
726 LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
729 libvlc_log_iterator_free(_p_iter, NULL);
732 const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
736 COUNTNAMES(LibvlcMessageIteratorNPObject,propertyCount,propertyNames);
738 enum LibvlcMessageIteratorNPObjectPropertyIds
740 ID_messageiterator_hasNext,
743 RuntimeNPObject::InvokeResult
744 LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
746 /* is plugin still running */
747 if( _instance->pdata )
749 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
752 case ID_messageiterator_hasNext:
754 if( _p_iter && p_plugin->getLog() )
756 libvlc_exception_t ex;
757 libvlc_exception_init(&ex);
759 BOOLEAN_TO_NPVARIANT(
760 libvlc_log_iterator_has_next(_p_iter, &ex), result );
761 RETURN_ON_EXCEPTION(this,ex);
765 BOOLEAN_TO_NPVARIANT(0, result);
767 return INVOKERESULT_NO_ERROR;
773 return INVOKERESULT_GENERIC_ERROR;
776 const NPUTF8 * const LibvlcMessageIteratorNPObject::methodNames[] =
780 COUNTNAMES(LibvlcMessageIteratorNPObject,methodCount,methodNames);
782 enum LibvlcMessageIteratorNPObjectMethodIds
784 ID_messageiterator_next,
787 RuntimeNPObject::InvokeResult
788 LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args,
789 uint32_t argCount, NPVariant &result)
791 /* is plugin still running */
792 if( _instance->pdata )
794 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
795 libvlc_exception_t ex;
796 libvlc_exception_init(&ex);
800 case ID_messageiterator_next:
803 if( _p_iter && p_plugin->getLog() )
805 struct libvlc_log_message_t buffer;
807 buffer.sizeof_msg = sizeof(buffer);
809 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
810 RETURN_ON_EXCEPTION(this,ex);
812 LibvlcMessageNPObject* message =
813 static_cast<LibvlcMessageNPObject*>(
814 NPN_CreateObject(_instance, RuntimeNPClass<
815 LibvlcMessageNPObject>::getClass()));
818 message->setMessage(buffer);
819 OBJECT_TO_NPVARIANT(message, result);
820 return INVOKERESULT_NO_ERROR;
822 return INVOKERESULT_OUT_OF_MEMORY;
824 return INVOKERESULT_GENERIC_ERROR;
826 return INVOKERESULT_NO_SUCH_METHOD;
831 return INVOKERESULT_GENERIC_ERROR;
835 ** implementation of libvlc message object
838 const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
842 COUNTNAMES(LibvlcMessagesNPObject,propertyCount,propertyNames);
844 enum LibvlcMessagesNPObjectPropertyIds
849 RuntimeNPObject::InvokeResult
850 LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
852 /* is plugin still running */
853 if( _instance->pdata )
855 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
858 case ID_messages_count:
860 libvlc_log_t *p_log = p_plugin->getLog();
863 libvlc_exception_t ex;
864 libvlc_exception_init(&ex);
866 INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
867 RETURN_ON_EXCEPTION(this,ex);
871 INT32_TO_NPVARIANT(0, result);
873 return INVOKERESULT_NO_ERROR;
879 return INVOKERESULT_GENERIC_ERROR;
882 const NPUTF8 * const LibvlcMessagesNPObject::methodNames[] =
887 COUNTNAMES(LibvlcMessagesNPObject,methodCount,methodNames);
889 enum LibvlcMessagesNPObjectMethodIds
892 ID_messages_iterator,
895 RuntimeNPObject::InvokeResult
896 LibvlcMessagesNPObject::invoke(int index, const NPVariant *args,
897 uint32_t argCount, NPVariant &result)
899 /* is plugin still running */
900 if( _instance->pdata )
902 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
903 libvlc_exception_t ex;
904 libvlc_exception_init(&ex);
908 case ID_messages_clear:
911 libvlc_log_t *p_log = p_plugin->getLog();
914 libvlc_log_clear(p_log, &ex);
915 RETURN_ON_EXCEPTION(this,ex);
917 return INVOKERESULT_NO_ERROR;
919 return INVOKERESULT_NO_SUCH_METHOD;
921 case ID_messages_iterator:
924 LibvlcMessageIteratorNPObject* iter =
925 static_cast<LibvlcMessageIteratorNPObject*>(
926 NPN_CreateObject(_instance, RuntimeNPClass<
927 LibvlcMessageIteratorNPObject>::getClass()));
930 OBJECT_TO_NPVARIANT(iter, result);
931 return INVOKERESULT_NO_ERROR;
933 return INVOKERESULT_OUT_OF_MEMORY;
935 return INVOKERESULT_NO_SUCH_METHOD;
941 return INVOKERESULT_GENERIC_ERROR;
946 ** implementation of libvlc message object
950 LibvlcLogNPObject::~LibvlcLogNPObject()
954 if( messagesObj ) NPN_ReleaseObject(messagesObj);
958 const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
963 COUNTNAMES(LibvlcLogNPObject,propertyCount,propertyNames);
965 enum LibvlcLogNPObjectPropertyIds
971 RuntimeNPObject::InvokeResult
972 LibvlcLogNPObject::getProperty(int index, NPVariant &result)
974 /* is plugin still running */
975 if( _instance->pdata )
977 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
978 libvlc_exception_t ex;
979 libvlc_exception_init(&ex);
983 case ID_log_messages:
985 // create child object in lazyman fashion to avoid
986 // ownership problem with firefox
988 messagesObj = NPN_CreateObject(_instance,
989 RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
990 OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result);
991 return INVOKERESULT_NO_ERROR;
993 case ID_log_verbosity:
995 if( p_plugin->getLog() )
997 INT32_TO_NPVARIANT( libvlc_get_log_verbosity(
998 p_plugin->getVLC(), &ex), result);
999 RETURN_ON_EXCEPTION(this,ex);
1003 /* log is not enabled, return -1 */
1004 DOUBLE_TO_NPVARIANT(-1.0, result);
1006 return INVOKERESULT_NO_ERROR;
1012 return INVOKERESULT_GENERIC_ERROR;
1015 RuntimeNPObject::InvokeResult
1016 LibvlcLogNPObject::setProperty(int index, const NPVariant &value)
1018 /* is plugin still running */
1019 if( _instance->pdata )
1021 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1022 libvlc_exception_t ex;
1023 libvlc_exception_init(&ex);
1027 case ID_log_verbosity:
1028 if( isNumberValue(value) )
1030 libvlc_instance_t* p_libvlc = p_plugin->getVLC();
1031 libvlc_log_t *p_log = p_plugin->getLog();
1032 int verbosity = numberValue(value);
1033 if( verbosity >= 0 )
1037 p_log = libvlc_log_open(p_libvlc, &ex);
1038 RETURN_ON_EXCEPTION(this,ex);
1039 p_plugin->setLog(p_log);
1041 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
1042 RETURN_ON_EXCEPTION(this,ex);
1046 /* close log when verbosity is set to -1 */
1047 p_plugin->setLog(NULL);
1048 libvlc_log_close(p_log, &ex);
1049 RETURN_ON_EXCEPTION(this,ex);
1051 return INVOKERESULT_NO_ERROR;
1053 return INVOKERESULT_INVALID_VALUE;
1058 return INVOKERESULT_GENERIC_ERROR;
1061 const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
1065 COUNTNAMES(LibvlcLogNPObject,methodCount,methodNames);
1068 ** implementation of libvlc playlist items object
1071 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
1075 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
1077 enum LibvlcPlaylistItemsNPObjectPropertyIds
1079 ID_playlistitems_count,
1082 RuntimeNPObject::InvokeResult
1083 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
1085 /* is plugin still running */
1086 if( _instance->pdata )
1088 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1089 libvlc_exception_t ex;
1090 libvlc_exception_init(&ex);
1094 case ID_playlistitems_count:
1096 libvlc_playlist_lock(p_plugin->getVLC());
1097 int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
1098 libvlc_playlist_unlock(p_plugin->getVLC());
1099 RETURN_ON_EXCEPTION(this,ex);
1100 INT32_TO_NPVARIANT(val, result);
1101 return INVOKERESULT_NO_ERROR;
1107 return INVOKERESULT_GENERIC_ERROR;
1110 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
1115 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
1117 enum LibvlcPlaylistItemsNPObjectMethodIds
1119 ID_playlistitems_clear,
1120 ID_playlistitems_remove,
1123 RuntimeNPObject::InvokeResult
1124 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
1125 uint32_t argCount, NPVariant &result)
1127 /* is plugin still running */
1128 if( _instance->pdata )
1130 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1131 libvlc_exception_t ex;
1132 libvlc_exception_init(&ex);
1136 case ID_playlistitems_clear:
1139 libvlc_playlist_clear(p_plugin->getVLC(), &ex);
1140 RETURN_ON_EXCEPTION(this,ex);
1141 VOID_TO_NPVARIANT(result);
1142 return INVOKERESULT_NO_ERROR;
1144 return INVOKERESULT_NO_SUCH_METHOD;
1145 case ID_playlistitems_remove:
1146 if( (argCount == 1) && isNumberValue(args[0]) )
1148 libvlc_playlist_delete_item(p_plugin->getVLC(),
1149 numberValue(args[0]), &ex);
1150 RETURN_ON_EXCEPTION(this,ex);
1151 VOID_TO_NPVARIANT(result);
1152 return INVOKERESULT_NO_ERROR;
1154 return INVOKERESULT_NO_SUCH_METHOD;
1159 return INVOKERESULT_GENERIC_ERROR;
1163 ** implementation of libvlc playlist object
1167 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
1171 if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj);
1175 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
1177 "itemCount", /* deprecated */
1181 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
1183 enum LibvlcPlaylistNPObjectPropertyIds
1185 ID_playlist_itemcount,
1186 ID_playlist_isplaying,
1190 RuntimeNPObject::InvokeResult
1191 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
1193 /* is plugin still running */
1194 if( _instance->pdata )
1196 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1197 libvlc_exception_t ex;
1198 libvlc_exception_init(&ex);
1202 case ID_playlist_itemcount: /* deprecated */
1204 libvlc_playlist_lock(p_plugin->getVLC());
1205 int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
1206 libvlc_playlist_unlock(p_plugin->getVLC());
1207 RETURN_ON_EXCEPTION(this,ex);
1208 INT32_TO_NPVARIANT(val, result);
1209 return INVOKERESULT_NO_ERROR;
1211 case ID_playlist_isplaying:
1213 libvlc_playlist_lock(p_plugin->getVLC());
1214 int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
1215 libvlc_playlist_unlock(p_plugin->getVLC());
1216 RETURN_ON_EXCEPTION(this,ex);
1217 BOOLEAN_TO_NPVARIANT(val, result);
1218 return INVOKERESULT_NO_ERROR;
1220 case ID_playlist_items:
1222 // create child object in lazyman fashion to avoid
1223 // ownership problem with firefox
1224 if( ! playlistItemsObj )
1226 NPN_CreateObject(_instance, RuntimeNPClass<
1227 LibvlcPlaylistItemsNPObject>::getClass());
1228 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
1229 return INVOKERESULT_NO_ERROR;
1235 return INVOKERESULT_GENERIC_ERROR;
1238 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
1247 "clear", /* deprecated */
1248 "removeItem", /* deprecated */
1250 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
1252 enum LibvlcPlaylistNPObjectMethodIds
1256 ID_playlist_playItem,
1257 ID_playlist_togglepause,
1262 ID_playlist_removeitem
1265 RuntimeNPObject::InvokeResult
1266 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
1267 uint32_t argCount, NPVariant &result)
1269 /* is plugin still running */
1270 if( _instance->pdata )
1272 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1273 libvlc_exception_t ex;
1274 libvlc_exception_init(&ex);
1278 case ID_playlist_add:
1280 if( (argCount < 1) || (argCount > 3) )
1281 return INVOKERESULT_NO_SUCH_METHOD;
1286 if( NPVARIANT_IS_STRING(args[0]) )
1288 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
1291 url = p_plugin->getAbsoluteURL(s);
1295 // problem with combining url, use argument
1299 return INVOKERESULT_OUT_OF_MEMORY;
1302 return INVOKERESULT_NO_SUCH_METHOD;
1306 // grab name if available
1309 if( NPVARIANT_IS_NULL(args[1]) )
1313 else if( NPVARIANT_IS_STRING(args[1]) )
1315 name = stringValue(NPVARIANT_TO_STRING(args[1]));
1320 return INVOKERESULT_INVALID_VALUE;
1325 char** ppsz_options = NULL;
1327 // grab options if available
1330 if( NPVARIANT_IS_NULL(args[2]) )
1334 else if( NPVARIANT_IS_STRING(args[2]) )
1336 parseOptions(NPVARIANT_TO_STRING(args[2]),
1337 &i_options, &ppsz_options);
1340 else if( NPVARIANT_IS_OBJECT(args[2]) )
1342 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
1343 &i_options, &ppsz_options);
1349 return INVOKERESULT_INVALID_VALUE;
1353 int item = libvlc_playlist_add_extended_untrusted(
1354 p_plugin->getVLC(), url, name, i_options,
1355 const_cast<const char **>(ppsz_options), &ex);
1358 for( int i=0; i< i_options; ++i )
1360 free(ppsz_options[i]);
1364 RETURN_ON_EXCEPTION(this,ex);
1365 INT32_TO_NPVARIANT(item, result);
1366 return INVOKERESULT_NO_ERROR;
1368 case ID_playlist_play:
1371 libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
1372 RETURN_ON_EXCEPTION(this,ex);
1373 VOID_TO_NPVARIANT(result);
1374 return INVOKERESULT_NO_ERROR;
1376 return INVOKERESULT_NO_SUCH_METHOD;
1377 case ID_playlist_playItem:
1378 if( (argCount == 1) && isNumberValue(args[0]) )
1380 libvlc_playlist_play(p_plugin->getVLC(),
1381 numberValue(args[0]), 0, NULL, &ex);
1382 RETURN_ON_EXCEPTION(this,ex);
1383 VOID_TO_NPVARIANT(result);
1384 return INVOKERESULT_NO_ERROR;
1386 return INVOKERESULT_NO_SUCH_METHOD;
1387 case ID_playlist_togglepause:
1390 libvlc_playlist_pause(p_plugin->getVLC(), &ex);
1391 RETURN_ON_EXCEPTION(this,ex);
1392 VOID_TO_NPVARIANT(result);
1393 return INVOKERESULT_NO_ERROR;
1395 return INVOKERESULT_NO_SUCH_METHOD;
1396 case ID_playlist_stop:
1399 libvlc_playlist_stop(p_plugin->getVLC(), &ex);
1400 RETURN_ON_EXCEPTION(this,ex);
1401 VOID_TO_NPVARIANT(result);
1402 return INVOKERESULT_NO_ERROR;
1404 return INVOKERESULT_NO_SUCH_METHOD;
1405 case ID_playlist_next:
1408 libvlc_playlist_next(p_plugin->getVLC(), &ex);
1409 RETURN_ON_EXCEPTION(this,ex);
1410 VOID_TO_NPVARIANT(result);
1411 return INVOKERESULT_NO_ERROR;
1413 return INVOKERESULT_NO_SUCH_METHOD;
1414 case ID_playlist_prev:
1417 libvlc_playlist_prev(p_plugin->getVLC(), &ex);
1418 RETURN_ON_EXCEPTION(this,ex);
1419 VOID_TO_NPVARIANT(result);
1420 return INVOKERESULT_NO_ERROR;
1422 return INVOKERESULT_NO_SUCH_METHOD;
1423 case ID_playlist_clear: /* deprecated */
1426 libvlc_playlist_clear(p_plugin->getVLC(), &ex);
1427 RETURN_ON_EXCEPTION(this,ex);
1428 VOID_TO_NPVARIANT(result);
1429 return INVOKERESULT_NO_ERROR;
1431 return INVOKERESULT_NO_SUCH_METHOD;
1432 case ID_playlist_removeitem: /* deprecated */
1433 if( (argCount == 1) && isNumberValue(args[0]) )
1435 libvlc_playlist_delete_item(p_plugin->getVLC(),
1436 numberValue(args[0]), &ex);
1437 RETURN_ON_EXCEPTION(this,ex);
1438 VOID_TO_NPVARIANT(result);
1439 return INVOKERESULT_NO_ERROR;
1441 return INVOKERESULT_NO_SUCH_METHOD;
1446 return INVOKERESULT_GENERIC_ERROR;
1449 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
1450 int *i_options, char*** ppsz_options)
1452 if( nps.utf8length )
1454 char *s = stringValue(nps);
1459 char **options = (char **)malloc(capacity*sizeof(char *));
1464 char *end = val + nps.utf8length;
1467 // skip leading blanks
1469 && ((*val == ' ' ) || (*val == '\t')) )
1473 // skip till we get a blank character
1479 if( ('\'' == c) || ('"' == c) )
1481 // skip till end of string
1482 while( (val < end) && (*(val++) != c ) );
1488 if( nOptions == capacity )
1491 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1494 /* failed to allocate more memory */
1496 /* return what we got so far */
1497 *i_options = nOptions;
1498 *ppsz_options = options;
1501 options = moreOptions;
1504 options[nOptions++] = strdup(start);
1507 // must be end of string
1510 *i_options = nOptions;
1511 *ppsz_options = options;
1518 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1519 char*** ppsz_options)
1521 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1525 /* we are expecting to have a Javascript Array object */
1526 NPIdentifier propId = NPN_GetStringIdentifier("length");
1527 if( NPN_GetProperty(_instance, obj, propId, &value) )
1529 int count = numberValue(value);
1530 NPN_ReleaseVariantValue(&value);
1535 char **options = (char **)malloc(capacity*sizeof(char *));
1540 while( nOptions < count )
1542 propId = NPN_GetIntIdentifier(nOptions);
1543 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1544 /* return what we got so far */
1547 if( ! NPVARIANT_IS_STRING(value) )
1549 /* return what we got so far */
1550 NPN_ReleaseVariantValue(&value);
1554 if( nOptions == capacity )
1557 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1560 /* failed to allocate more memory */
1561 NPN_ReleaseVariantValue(&value);
1562 /* return what we got so far */
1563 *i_options = nOptions;
1564 *ppsz_options = options;
1567 options = moreOptions;
1570 options[nOptions++] = stringValue(value);
1572 *i_options = nOptions;
1573 *ppsz_options = options;
1580 ** implementation of libvlc video object
1583 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1594 enum LibvlcVideoNPObjectPropertyIds
1596 ID_video_fullscreen,
1599 ID_video_aspectratio,
1604 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1606 RuntimeNPObject::InvokeResult
1607 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1609 /* is plugin still running */
1610 if( _instance->pdata )
1612 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1613 libvlc_exception_t ex;
1614 libvlc_exception_init(&ex);
1616 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1617 RETURN_ON_EXCEPTION(this,ex);
1621 case ID_video_fullscreen:
1623 int val = libvlc_get_fullscreen(p_md, &ex);
1624 libvlc_media_player_release(p_md);
1625 RETURN_ON_EXCEPTION(this,ex);
1626 BOOLEAN_TO_NPVARIANT(val, result);
1627 return INVOKERESULT_NO_ERROR;
1629 case ID_video_height:
1631 int val = libvlc_video_get_height(p_md, &ex);
1632 libvlc_media_player_release(p_md);
1633 RETURN_ON_EXCEPTION(this,ex);
1634 INT32_TO_NPVARIANT(val, result);
1635 return INVOKERESULT_NO_ERROR;
1637 case ID_video_width:
1639 int val = libvlc_video_get_width(p_md, &ex);
1640 libvlc_media_player_release(p_md);
1641 RETURN_ON_EXCEPTION(this,ex);
1642 INT32_TO_NPVARIANT(val, result);
1643 return INVOKERESULT_NO_ERROR;
1645 case ID_video_aspectratio:
1647 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1648 libvlc_media_player_release(p_md);
1649 RETURN_ON_EXCEPTION(this,ex);
1651 return INVOKERESULT_GENERIC_ERROR;
1653 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1654 return INVOKERESULT_NO_ERROR;
1656 case ID_video_subtitle:
1658 int i_spu = libvlc_video_get_spu(p_md, &ex);
1659 libvlc_media_player_release(p_md);
1660 RETURN_ON_EXCEPTION(this,ex);
1661 INT32_TO_NPVARIANT(i_spu, result);
1662 return INVOKERESULT_NO_ERROR;
1666 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1667 libvlc_media_player_release(p_md);
1668 RETURN_ON_EXCEPTION(this,ex);
1670 return INVOKERESULT_GENERIC_ERROR;
1672 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1673 return INVOKERESULT_NO_ERROR;
1675 case ID_video_teletext:
1677 int i_page = libvlc_video_get_teletext(p_md, &ex);
1678 libvlc_media_player_release(p_md);
1679 RETURN_ON_EXCEPTION(this,ex);
1680 INT32_TO_NPVARIANT(i_page, result);
1681 return INVOKERESULT_NO_ERROR;
1684 libvlc_media_player_release(p_md);
1686 return INVOKERESULT_GENERIC_ERROR;
1689 RuntimeNPObject::InvokeResult
1690 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1692 /* is plugin still running */
1693 if( _instance->pdata )
1695 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1696 libvlc_exception_t ex;
1697 libvlc_exception_init(&ex);
1699 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1700 RETURN_ON_EXCEPTION(this,ex);
1704 case ID_video_fullscreen:
1706 if( ! NPVARIANT_IS_BOOLEAN(value) )
1708 libvlc_media_player_release(p_md);
1709 return INVOKERESULT_INVALID_VALUE;
1712 int val = NPVARIANT_TO_BOOLEAN(value);
1713 libvlc_set_fullscreen(p_md, val, &ex);
1714 libvlc_media_player_release(p_md);
1716 RETURN_ON_EXCEPTION(this,ex);
1717 return INVOKERESULT_NO_ERROR;
1719 case ID_video_aspectratio:
1721 char *psz_aspect = NULL;
1723 if( ! NPVARIANT_IS_STRING(value) )
1725 libvlc_media_player_release(p_md);
1726 return INVOKERESULT_INVALID_VALUE;
1729 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1732 libvlc_media_player_release(p_md);
1733 return INVOKERESULT_GENERIC_ERROR;
1736 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1738 libvlc_media_player_release(p_md);
1739 RETURN_ON_EXCEPTION(this,ex);
1741 return INVOKERESULT_NO_ERROR;
1743 case ID_video_subtitle:
1745 if( isNumberValue(value) )
1747 libvlc_video_set_spu(p_md,
1748 numberValue(value), &ex);
1749 libvlc_media_player_release(p_md);
1750 RETURN_ON_EXCEPTION(this,ex);
1752 return INVOKERESULT_NO_ERROR;
1754 libvlc_media_player_release(p_md);
1755 return INVOKERESULT_INVALID_VALUE;
1759 char *psz_geometry = NULL;
1761 if( ! NPVARIANT_IS_STRING(value) )
1763 libvlc_media_player_release(p_md);
1764 return INVOKERESULT_INVALID_VALUE;
1767 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1770 libvlc_media_player_release(p_md);
1771 return INVOKERESULT_GENERIC_ERROR;
1774 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1776 libvlc_media_player_release(p_md);
1777 RETURN_ON_EXCEPTION(this,ex);
1779 return INVOKERESULT_NO_ERROR;
1781 case ID_video_teletext:
1783 if( isNumberValue(value) )
1785 libvlc_video_set_teletext(p_md,
1786 numberValue(value), &ex);
1787 libvlc_media_player_release(p_md);
1788 RETURN_ON_EXCEPTION(this,ex);
1790 return INVOKERESULT_NO_ERROR;
1792 libvlc_media_player_release(p_md);
1793 return INVOKERESULT_INVALID_VALUE;
1796 libvlc_media_player_release(p_md);
1798 return INVOKERESULT_GENERIC_ERROR;
1801 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1806 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1808 enum LibvlcVideoNPObjectMethodIds
1810 ID_video_togglefullscreen,
1811 ID_video_toggleteletext
1814 RuntimeNPObject::InvokeResult
1815 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1816 uint32_t argCount, NPVariant &result)
1818 /* is plugin still running */
1819 if( _instance->pdata )
1821 VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(_instance->pdata);
1822 libvlc_exception_t ex;
1823 libvlc_exception_init(&ex);
1825 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
1826 RETURN_ON_EXCEPTION(this,ex);
1830 case ID_video_togglefullscreen:
1833 libvlc_toggle_fullscreen(p_md, &ex);
1834 libvlc_media_player_release(p_md);
1835 RETURN_ON_EXCEPTION(this,ex);
1836 VOID_TO_NPVARIANT(result);
1837 return INVOKERESULT_NO_ERROR;
1839 return INVOKERESULT_NO_SUCH_METHOD;
1840 case ID_video_toggleteletext:
1843 libvlc_toggle_teletext(p_md, &ex);
1844 libvlc_media_player_release(p_md);
1845 RETURN_ON_EXCEPTION(this,ex);
1846 VOID_TO_NPVARIANT(result);
1847 return INVOKERESULT_NO_ERROR;
1849 return INVOKERESULT_NO_SUCH_METHOD;
1851 return INVOKERESULT_NO_SUCH_METHOD;
1854 return INVOKERESULT_GENERIC_ERROR;