1 /*****************************************************************************
2 * npolibvlc.cpp: official Javascript APIs
3 *****************************************************************************
4 * Copyright (C) 2002-2009 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7 * JP Dinger <jpd@m2x.nl>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
31 #ifdef HAVE_MOZILLA_CONFIG_H
32 # include <mozilla-config.h>
35 #include "vlcplugin.h"
36 #include "npolibvlc.h"
39 ** Local helper macros and function
41 #define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
42 #define RETURN_ON_EXCEPTION(this,ex) \
43 do { if( libvlc_exception_raised(&ex) ) \
45 NPN_SetException(this, libvlc_errmsg()); \
46 libvlc_exception_clear(&ex); \
47 return INVOKERESULT_GENERIC_ERROR; \
51 ** implementation of libvlc root object
54 LibvlcRootNPObject::~LibvlcRootNPObject()
57 ** When the plugin is destroyed, firefox takes it upon itself to
58 ** destroy all 'live' script objects and ignores refcounting.
59 ** Therefore we cannot safely assume that refcounting will control
60 ** lifespan of objects. Hence they are only lazily created on
61 ** request, so that firefox can take ownership, and are not released
62 ** when the plugin is destroyed.
66 if( audioObj ) NPN_ReleaseObject(audioObj);
67 if( inputObj ) NPN_ReleaseObject(inputObj);
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 InstantObj<LibvlcAudioNPObject>( audioObj );
104 OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
105 return INVOKERESULT_NO_ERROR;
107 InstantObj<LibvlcInputNPObject>( inputObj );
108 OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
109 return INVOKERESULT_NO_ERROR;
110 case ID_root_playlist:
111 InstantObj<LibvlcPlaylistNPObject>( playlistObj );
112 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
113 return INVOKERESULT_NO_ERROR;
114 case ID_root_subtitle:
115 InstantObj<LibvlcSubtitleNPObject>( subtitleObj );
116 OBJECT_TO_NPVARIANT(NPN_RetainObject(subtitleObj), result);
117 return INVOKERESULT_NO_ERROR;
119 InstantObj<LibvlcVideoNPObject>( videoObj );
120 OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
121 return INVOKERESULT_NO_ERROR;
122 case ID_root_VersionInfo:
123 return invokeResultString(libvlc_get_version(),result);
128 return INVOKERESULT_GENERIC_ERROR;
131 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =
135 COUNTNAMES(LibvlcRootNPObject,methodCount,methodNames);
137 enum LibvlcRootNPObjectMethodIds
142 RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
143 const NPVariant *args, uint32_t argCount, NPVariant &result)
145 /* is plugin still running */
146 if( isPluginRunning() )
148 libvlc_exception_t ex;
149 libvlc_exception_init(&ex);
153 case ID_root_versionInfo:
155 return INVOKERESULT_NO_SUCH_METHOD;
156 return invokeResultString(libvlc_get_version(),result);
161 return INVOKERESULT_GENERIC_ERROR;
165 ** implementation of libvlc audio object
168 const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
176 COUNTNAMES(LibvlcAudioNPObject,propertyCount,propertyNames);
178 enum LibvlcAudioNPObjectPropertyIds
187 RuntimeNPObject::InvokeResult
188 LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
190 /* is plugin still running */
191 if( isPluginRunning() )
193 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
194 libvlc_exception_t ex;
195 libvlc_exception_init(&ex);
201 bool muted = libvlc_audio_get_mute(p_plugin->getVLC());
202 BOOLEAN_TO_NPVARIANT(muted, result);
203 return INVOKERESULT_NO_ERROR;
205 case ID_audio_volume:
207 int volume = libvlc_audio_get_volume(p_plugin->getVLC());
208 INT32_TO_NPVARIANT(volume, result);
209 return INVOKERESULT_NO_ERROR;
213 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
214 RETURN_ON_EXCEPTION(this,ex);
215 int track = libvlc_audio_get_track(p_md, &ex);
216 RETURN_ON_EXCEPTION(this,ex);
217 INT32_TO_NPVARIANT(track, result);
218 return INVOKERESULT_NO_ERROR;
222 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
223 RETURN_ON_EXCEPTION(this,ex);
224 // get the number of audio track available
225 int i_track = libvlc_audio_get_track_count(p_md, &ex);
226 RETURN_ON_EXCEPTION(this,ex);
228 INT32_TO_NPVARIANT(i_track, result);
229 return INVOKERESULT_NO_ERROR;
231 case ID_audio_channel:
233 int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
234 RETURN_ON_EXCEPTION(this,ex);
235 INT32_TO_NPVARIANT(channel, result);
236 return INVOKERESULT_NO_ERROR;
242 return INVOKERESULT_GENERIC_ERROR;
245 RuntimeNPObject::InvokeResult
246 LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
248 /* is plugin still running */
249 if( isPluginRunning() )
251 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
252 libvlc_exception_t ex;
253 libvlc_exception_init(&ex);
258 if( NPVARIANT_IS_BOOLEAN(value) )
260 libvlc_audio_set_mute(p_plugin->getVLC(),
261 NPVARIANT_TO_BOOLEAN(value));
262 return INVOKERESULT_NO_ERROR;
264 return INVOKERESULT_INVALID_VALUE;
265 case ID_audio_volume:
266 if( isNumberValue(value) )
268 libvlc_audio_set_volume(p_plugin->getVLC(),
269 numberValue(value), &ex);
270 RETURN_ON_EXCEPTION(this,ex);
271 return INVOKERESULT_NO_ERROR;
273 return INVOKERESULT_INVALID_VALUE;
275 if( isNumberValue(value) )
277 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
278 RETURN_ON_EXCEPTION(this,ex);
279 libvlc_audio_set_track(p_md, numberValue(value), &ex);
280 RETURN_ON_EXCEPTION(this,ex);
281 return INVOKERESULT_NO_ERROR;
283 return INVOKERESULT_INVALID_VALUE;
284 case ID_audio_channel:
285 if( isNumberValue(value) )
287 libvlc_audio_set_channel(p_plugin->getVLC(),
288 numberValue(value), &ex);
289 RETURN_ON_EXCEPTION(this,ex);
290 return INVOKERESULT_NO_ERROR;
292 return INVOKERESULT_INVALID_VALUE;
297 return INVOKERESULT_GENERIC_ERROR;
300 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
305 COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
307 enum LibvlcAudioNPObjectMethodIds
310 ID_audio_description,
313 RuntimeNPObject::InvokeResult
314 LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
315 uint32_t argCount, NPVariant &result)
317 /* is plugin still running */
318 if( isPluginRunning() )
320 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
321 libvlc_exception_t ex;
322 libvlc_exception_init(&ex);
326 case ID_audio_togglemute:
329 libvlc_audio_toggle_mute(p_plugin->getVLC());
330 VOID_TO_NPVARIANT(result);
331 return INVOKERESULT_NO_ERROR;
333 return INVOKERESULT_NO_SUCH_METHOD;
334 case ID_audio_description:
339 int i_trackID, i_limit, i;
340 libvlc_track_description_t *p_trackDesc;
342 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
343 RETURN_ON_EXCEPTION(this,ex);
345 /* get tracks description */
346 p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
347 RETURN_ON_EXCEPTION(this,ex);
349 return INVOKERESULT_GENERIC_ERROR;
351 /* get the number of track available */
352 i_limit = libvlc_audio_get_track_count(p_md, &ex);
353 RETURN_ON_EXCEPTION(this,ex);
355 /* check if a number is given by the user
356 * and get the track number */
357 if( isNumberValue(args[0]) )
358 i_trackID = numberValue(args[0]);
360 return INVOKERESULT_INVALID_VALUE;
362 /* if bad number is given return invalid value */
363 if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) )
364 return INVOKERESULT_INVALID_VALUE;
366 /* get the good trackDesc */
367 for( i = 0 ; i < i_trackID ; i++ )
369 p_trackDesc = p_trackDesc->p_next;
371 psz_name = p_trackDesc->psz_name;
373 /* display the name of the track chosen */
374 return invokeResultString( psz_name, result );
376 return INVOKERESULT_NO_SUCH_METHOD;
382 return INVOKERESULT_GENERIC_ERROR;
386 ** implementation of libvlc input object
389 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
399 COUNTNAMES(LibvlcInputNPObject,propertyCount,propertyNames);
401 enum LibvlcInputNPObjectPropertyIds
412 RuntimeNPObject::InvokeResult
413 LibvlcInputNPObject::getProperty(int index, NPVariant &result)
415 /* is plugin still running */
416 if( isPluginRunning() )
418 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
419 libvlc_exception_t ex;
420 libvlc_exception_init(&ex);
422 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
423 if( libvlc_exception_raised(&ex) )
425 if( index != ID_input_state )
427 NPN_SetException(this, libvlc_errmsg());
428 libvlc_exception_clear(&ex);
429 return INVOKERESULT_GENERIC_ERROR;
433 /* for input state, return CLOSED rather than an exception */
434 INT32_TO_NPVARIANT(0, result);
435 libvlc_exception_clear(&ex);
436 return INVOKERESULT_NO_ERROR;
442 case ID_input_length:
444 double val = (double)libvlc_media_player_get_length(p_md, &ex);
445 RETURN_ON_EXCEPTION(this,ex);
446 DOUBLE_TO_NPVARIANT(val, result);
447 return INVOKERESULT_NO_ERROR;
449 case ID_input_position:
451 double val = libvlc_media_player_get_position(p_md, &ex);
452 RETURN_ON_EXCEPTION(this,ex);
453 DOUBLE_TO_NPVARIANT(val, result);
454 return INVOKERESULT_NO_ERROR;
458 double val = (double)libvlc_media_player_get_time(p_md, &ex);
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 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 RETURN_ON_EXCEPTION(this,ex);
474 DOUBLE_TO_NPVARIANT(val, result);
475 return INVOKERESULT_NO_ERROR;
479 double val = libvlc_media_player_get_fps(p_md, &ex);
480 RETURN_ON_EXCEPTION(this,ex);
481 DOUBLE_TO_NPVARIANT(val, result);
482 return INVOKERESULT_NO_ERROR;
484 case ID_input_hasvout:
486 bool val = p_plugin->player_has_vout(&ex);
487 RETURN_ON_EXCEPTION(this,ex);
488 BOOLEAN_TO_NPVARIANT(val, result);
489 return INVOKERESULT_NO_ERROR;
495 return INVOKERESULT_GENERIC_ERROR;
498 RuntimeNPObject::InvokeResult
499 LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
501 /* is plugin still running */
502 if( isPluginRunning() )
504 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
505 libvlc_exception_t ex;
506 libvlc_exception_init(&ex);
508 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
509 RETURN_ON_EXCEPTION(this,ex);
513 case ID_input_position:
515 if( ! NPVARIANT_IS_DOUBLE(value) )
517 return INVOKERESULT_INVALID_VALUE;
520 float val = (float)NPVARIANT_TO_DOUBLE(value);
521 libvlc_media_player_set_position(p_md, val, &ex);
522 RETURN_ON_EXCEPTION(this,ex);
523 return INVOKERESULT_NO_ERROR;
528 if( NPVARIANT_IS_INT32(value) )
529 val = (int64_t)NPVARIANT_TO_INT32(value);
530 else if( NPVARIANT_IS_DOUBLE(value) )
531 val = (int64_t)NPVARIANT_TO_DOUBLE(value);
534 return INVOKERESULT_INVALID_VALUE;
537 libvlc_media_player_set_time(p_md, val, &ex);
538 RETURN_ON_EXCEPTION(this,ex);
539 return INVOKERESULT_NO_ERROR;
544 if( NPVARIANT_IS_INT32(value) )
545 val = (float)NPVARIANT_TO_INT32(value);
546 else if( NPVARIANT_IS_DOUBLE(value) )
547 val = (float)NPVARIANT_TO_DOUBLE(value);
550 return INVOKERESULT_INVALID_VALUE;
553 libvlc_media_player_set_rate(p_md, val, &ex);
554 RETURN_ON_EXCEPTION(this,ex);
555 return INVOKERESULT_NO_ERROR;
561 return INVOKERESULT_GENERIC_ERROR;
564 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
569 COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
571 enum LibvlcInputNPObjectMethodIds
576 RuntimeNPObject::InvokeResult
577 LibvlcInputNPObject::invoke(int index, const NPVariant *args,
578 uint32_t argCount, NPVariant &result)
580 /* is plugin still running */
581 if( isPluginRunning() )
586 return INVOKERESULT_NO_SUCH_METHOD;
591 return INVOKERESULT_GENERIC_ERROR;
595 ** implementation of libvlc playlist items object
598 const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
602 COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
604 enum LibvlcPlaylistItemsNPObjectPropertyIds
606 ID_playlistitems_count,
609 RuntimeNPObject::InvokeResult
610 LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
612 /* is plugin still running */
613 if( isPluginRunning() )
615 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
616 libvlc_exception_t ex;
617 libvlc_exception_init(&ex);
621 case ID_playlistitems_count:
623 int val = p_plugin->playlist_count(&ex);
624 RETURN_ON_EXCEPTION(this,ex);
625 INT32_TO_NPVARIANT(val, result);
626 return INVOKERESULT_NO_ERROR;
632 return INVOKERESULT_GENERIC_ERROR;
635 const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
640 COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
642 enum LibvlcPlaylistItemsNPObjectMethodIds
644 ID_playlistitems_clear,
645 ID_playlistitems_remove,
648 RuntimeNPObject::InvokeResult
649 LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
650 uint32_t argCount, NPVariant &result)
652 /* is plugin still running */
653 if( isPluginRunning() )
655 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
656 libvlc_exception_t ex;
657 libvlc_exception_init(&ex);
661 case ID_playlistitems_clear:
664 p_plugin->playlist_clear(&ex);
665 RETURN_ON_EXCEPTION(this,ex);
666 VOID_TO_NPVARIANT(result);
667 return INVOKERESULT_NO_ERROR;
669 return INVOKERESULT_NO_SUCH_METHOD;
670 case ID_playlistitems_remove:
671 if( (argCount == 1) && isNumberValue(args[0]) )
673 p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
674 RETURN_ON_EXCEPTION(this,ex);
675 VOID_TO_NPVARIANT(result);
676 return INVOKERESULT_NO_ERROR;
678 return INVOKERESULT_NO_SUCH_METHOD;
683 return INVOKERESULT_GENERIC_ERROR;
687 ** implementation of libvlc playlist object
690 LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
692 // Why the isValid()?
693 if( isValid() && playlistItemsObj )
694 NPN_ReleaseObject(playlistItemsObj);
697 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
699 "itemCount", /* deprecated */
703 COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
705 enum LibvlcPlaylistNPObjectPropertyIds
707 ID_playlist_itemcount,
708 ID_playlist_isplaying,
712 RuntimeNPObject::InvokeResult
713 LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
715 /* is plugin still running */
716 if( isPluginRunning() )
718 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
719 libvlc_exception_t ex;
720 libvlc_exception_init(&ex);
724 case ID_playlist_itemcount: /* deprecated */
726 int val = p_plugin->playlist_count(&ex);
727 RETURN_ON_EXCEPTION(this,ex);
728 INT32_TO_NPVARIANT(val, result);
729 return INVOKERESULT_NO_ERROR;
731 case ID_playlist_isplaying:
733 int val = p_plugin->playlist_isplaying(&ex);
734 RETURN_ON_EXCEPTION(this,ex);
735 BOOLEAN_TO_NPVARIANT(val, result);
736 return INVOKERESULT_NO_ERROR;
738 case ID_playlist_items:
740 InstantObj<LibvlcPlaylistItemsNPObject>( playlistItemsObj );
741 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
742 return INVOKERESULT_NO_ERROR;
748 return INVOKERESULT_GENERIC_ERROR;
751 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
760 "clear", /* deprecated */
761 "removeItem", /* deprecated */
763 COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
765 enum LibvlcPlaylistNPObjectMethodIds
769 ID_playlist_playItem,
770 ID_playlist_togglepause,
775 ID_playlist_removeitem
778 RuntimeNPObject::InvokeResult
779 LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
780 uint32_t argCount, NPVariant &result)
782 /* is plugin still running */
783 if( isPluginRunning() )
785 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
786 libvlc_exception_t ex;
787 libvlc_exception_init(&ex);
791 // XXX FIXME this needs squashing into something much smaller
792 case ID_playlist_add:
794 if( (argCount < 1) || (argCount > 3) )
795 return INVOKERESULT_NO_SUCH_METHOD;
796 if( !NPVARIANT_IS_STRING(args[0]) )
797 return INVOKERESULT_NO_SUCH_METHOD;
800 if( NPVARIANT_IS_NULL(args[0]) )
801 return INVOKERESULT_NO_SUCH_METHOD;
803 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
805 return INVOKERESULT_OUT_OF_MEMORY;
807 char *url = p_plugin->getAbsoluteURL(s);
811 // problem with combining url, use argument
816 // grab name if available
819 if( NPVARIANT_IS_NULL(args[1]) )
823 else if( NPVARIANT_IS_STRING(args[1]) )
825 name = stringValue(NPVARIANT_TO_STRING(args[1]));
830 return INVOKERESULT_INVALID_VALUE;
835 char** ppsz_options = NULL;
837 // grab options if available
840 if( NPVARIANT_IS_NULL(args[2]) )
844 else if( NPVARIANT_IS_STRING(args[2]) )
846 parseOptions(NPVARIANT_TO_STRING(args[2]),
847 &i_options, &ppsz_options);
850 else if( NPVARIANT_IS_OBJECT(args[2]) )
852 parseOptions(NPVARIANT_TO_OBJECT(args[2]),
853 &i_options, &ppsz_options);
859 return INVOKERESULT_INVALID_VALUE;
863 int item = p_plugin->playlist_add_extended_untrusted(url, name,
864 i_options, const_cast<const char **>(ppsz_options), &ex);
867 for( int i=0; i< i_options; ++i )
869 free(ppsz_options[i]);
873 RETURN_ON_EXCEPTION(this,ex);
874 INT32_TO_NPVARIANT(item, result);
875 return INVOKERESULT_NO_ERROR;
877 case ID_playlist_play:
880 p_plugin->playlist_play(&ex);
881 RETURN_ON_EXCEPTION(this,ex);
882 VOID_TO_NPVARIANT(result);
883 return INVOKERESULT_NO_ERROR;
885 return INVOKERESULT_NO_SUCH_METHOD;
886 case ID_playlist_playItem:
887 if( (argCount == 1) && isNumberValue(args[0]) )
889 p_plugin->playlist_play_item(numberValue(args[0]),&ex);
890 RETURN_ON_EXCEPTION(this,ex);
891 VOID_TO_NPVARIANT(result);
892 return INVOKERESULT_NO_ERROR;
894 return INVOKERESULT_NO_SUCH_METHOD;
895 case ID_playlist_togglepause:
898 p_plugin->playlist_pause(&ex);
899 RETURN_ON_EXCEPTION(this,ex);
900 VOID_TO_NPVARIANT(result);
901 return INVOKERESULT_NO_ERROR;
903 return INVOKERESULT_NO_SUCH_METHOD;
904 case ID_playlist_stop:
907 p_plugin->playlist_stop(&ex);
908 RETURN_ON_EXCEPTION(this,ex);
909 VOID_TO_NPVARIANT(result);
910 return INVOKERESULT_NO_ERROR;
912 return INVOKERESULT_NO_SUCH_METHOD;
913 case ID_playlist_next:
916 p_plugin->playlist_next(&ex);
917 RETURN_ON_EXCEPTION(this,ex);
918 VOID_TO_NPVARIANT(result);
919 return INVOKERESULT_NO_ERROR;
921 return INVOKERESULT_NO_SUCH_METHOD;
922 case ID_playlist_prev:
925 p_plugin->playlist_prev(&ex);
926 RETURN_ON_EXCEPTION(this,ex);
927 VOID_TO_NPVARIANT(result);
928 return INVOKERESULT_NO_ERROR;
930 return INVOKERESULT_NO_SUCH_METHOD;
931 case ID_playlist_clear: /* deprecated */
934 p_plugin->playlist_clear(&ex);
935 RETURN_ON_EXCEPTION(this,ex);
936 VOID_TO_NPVARIANT(result);
937 return INVOKERESULT_NO_ERROR;
939 return INVOKERESULT_NO_SUCH_METHOD;
940 case ID_playlist_removeitem: /* deprecated */
941 if( (argCount == 1) && isNumberValue(args[0]) )
943 p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
944 RETURN_ON_EXCEPTION(this,ex);
945 VOID_TO_NPVARIANT(result);
946 return INVOKERESULT_NO_ERROR;
948 return INVOKERESULT_NO_SUCH_METHOD;
953 return INVOKERESULT_GENERIC_ERROR;
956 // XXX FIXME The new playlist_add creates a media instance and feeds it
957 // XXX FIXME these options one at a time, so this hunk of code does lots
958 // XXX FIXME of unnecessairy work. Break out something that can do one
959 // XXX FIXME option at a time and doesn't need to realloc().
960 // XXX FIXME Same for the other version of parseOptions.
962 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
963 int *i_options, char*** ppsz_options)
967 char *s = stringValue(nps);
972 char **options = (char **)malloc(capacity*sizeof(char *));
977 char *end = val + nps.utf8length;
980 // skip leading blanks
982 && ((*val == ' ' ) || (*val == '\t')) )
986 // skip till we get a blank character
992 if( ('\'' == c) || ('"' == c) )
994 // skip till end of string
995 while( (val < end) && (*(val++) != c ) );
1001 if( nOptions == capacity )
1004 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1007 /* failed to allocate more memory */
1009 /* return what we got so far */
1010 *i_options = nOptions;
1011 *ppsz_options = options;
1014 options = moreOptions;
1017 options[nOptions++] = strdup(start);
1020 // must be end of string
1023 *i_options = nOptions;
1024 *ppsz_options = options;
1031 // XXX FIXME See comment at the other parseOptions variant.
1032 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options,
1033 char*** ppsz_options)
1035 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
1039 /* we are expecting to have a Javascript Array object */
1040 NPIdentifier propId = NPN_GetStringIdentifier("length");
1041 if( NPN_GetProperty(_instance, obj, propId, &value) )
1043 int count = numberValue(value);
1044 NPN_ReleaseVariantValue(&value);
1049 char **options = (char **)malloc(capacity*sizeof(char *));
1054 while( nOptions < count )
1056 propId = NPN_GetIntIdentifier(nOptions);
1057 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
1058 /* return what we got so far */
1061 if( ! NPVARIANT_IS_STRING(value) )
1063 /* return what we got so far */
1064 NPN_ReleaseVariantValue(&value);
1068 if( nOptions == capacity )
1071 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
1074 /* failed to allocate more memory */
1075 NPN_ReleaseVariantValue(&value);
1076 /* return what we got so far */
1077 *i_options = nOptions;
1078 *ppsz_options = options;
1081 options = moreOptions;
1084 options[nOptions++] = stringValue(value);
1085 NPN_ReleaseVariantValue(&value);
1087 *i_options = nOptions;
1088 *ppsz_options = options;
1095 ** implementation of libvlc subtitle object
1098 const NPUTF8 * const LibvlcSubtitleNPObject::propertyNames[] =
1104 enum LibvlcSubtitleNPObjectPropertyIds
1109 COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
1111 RuntimeNPObject::InvokeResult
1112 LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
1114 /* is plugin still running */
1115 if( isPluginRunning() )
1117 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1118 libvlc_exception_t ex;
1119 libvlc_exception_init(&ex);
1121 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1122 RETURN_ON_EXCEPTION(this,ex);
1126 case ID_subtitle_track:
1128 /* get the current subtitle ID */
1129 int i_spu = libvlc_video_get_spu(p_md, &ex);
1130 RETURN_ON_EXCEPTION(this,ex);
1132 INT32_TO_NPVARIANT(i_spu, result);
1133 return INVOKERESULT_NO_ERROR;
1135 case ID_subtitle_count:
1137 /* get the number of subtitles available */
1138 int i_spu = libvlc_video_get_spu_count(p_md, &ex);
1139 RETURN_ON_EXCEPTION(this,ex);
1141 INT32_TO_NPVARIANT(i_spu, result);
1142 return INVOKERESULT_NO_ERROR;
1146 return INVOKERESULT_GENERIC_ERROR;
1149 RuntimeNPObject::InvokeResult
1150 LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
1152 /* is plugin still running */
1153 if( isPluginRunning() )
1155 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1156 libvlc_exception_t ex;
1157 libvlc_exception_init(&ex);
1159 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1160 RETURN_ON_EXCEPTION(this,ex);
1164 case ID_subtitle_track:
1166 if( isNumberValue(value) )
1168 /* set the new subtitle track to show */
1169 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1170 RETURN_ON_EXCEPTION(this,ex);
1172 return INVOKERESULT_NO_ERROR;
1174 return INVOKERESULT_INVALID_VALUE;
1178 return INVOKERESULT_GENERIC_ERROR;
1181 const NPUTF8 * const LibvlcSubtitleNPObject::methodNames[] =
1185 COUNTNAMES(LibvlcSubtitleNPObject,methodCount,methodNames);
1187 enum LibvlcSubtitleNPObjectMethodIds
1189 ID_subtitle_description
1192 RuntimeNPObject::InvokeResult
1193 LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
1194 uint32_t argCount, NPVariant &result)
1196 /* is plugin still running */
1197 if( isPluginRunning() )
1199 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1200 libvlc_exception_t ex;
1201 libvlc_exception_init(&ex);
1203 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1204 RETURN_ON_EXCEPTION(this,ex);
1208 case ID_subtitle_description:
1213 int i_spuID, i_limit, i;
1214 libvlc_track_description_t *p_spuDesc;
1216 /* get subtitles description */
1217 p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
1218 RETURN_ON_EXCEPTION(this,ex);
1220 return INVOKERESULT_GENERIC_ERROR;
1222 /* get the number of subtitle available */
1223 i_limit = libvlc_video_get_spu_count(p_md, &ex);
1224 RETURN_ON_EXCEPTION(this,ex);
1226 /* check if a number is given by the user
1227 * and get the subtitle number */
1228 if( isNumberValue(args[0]) )
1229 i_spuID = numberValue(args[0]);
1231 return INVOKERESULT_INVALID_VALUE;
1233 /* if bad number is given return invalid value */
1234 if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
1235 return INVOKERESULT_INVALID_VALUE;
1237 /* get the good spuDesc */
1238 for( i = 0 ; i < i_spuID ; i++ )
1240 p_spuDesc = p_spuDesc->p_next;
1242 psz_name = p_spuDesc->psz_name;
1244 /* return the name of the track chosen */
1245 return invokeResultString(psz_name, result);
1247 return INVOKERESULT_NO_SUCH_METHOD;
1250 return INVOKERESULT_NO_SUCH_METHOD;
1253 return INVOKERESULT_GENERIC_ERROR;
1257 ** implementation of libvlc video object
1260 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
1272 enum LibvlcVideoNPObjectPropertyIds
1274 ID_video_fullscreen,
1277 ID_video_aspectratio,
1283 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
1285 RuntimeNPObject::InvokeResult
1286 LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
1288 /* is plugin still running */
1289 if( isPluginRunning() )
1291 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1292 libvlc_exception_t ex;
1293 libvlc_exception_init(&ex);
1295 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1296 RETURN_ON_EXCEPTION(this,ex);
1300 case ID_video_fullscreen:
1302 int val = p_plugin->get_fullscreen(&ex);
1303 RETURN_ON_EXCEPTION(this,ex);
1304 BOOLEAN_TO_NPVARIANT(val, result);
1305 return INVOKERESULT_NO_ERROR;
1307 case ID_video_height:
1309 int val = libvlc_video_get_height(p_md, &ex);
1310 RETURN_ON_EXCEPTION(this,ex);
1311 INT32_TO_NPVARIANT(val, result);
1312 return INVOKERESULT_NO_ERROR;
1314 case ID_video_width:
1316 int val = libvlc_video_get_width(p_md, &ex);
1317 RETURN_ON_EXCEPTION(this,ex);
1318 INT32_TO_NPVARIANT(val, result);
1319 return INVOKERESULT_NO_ERROR;
1321 case ID_video_aspectratio:
1323 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
1324 RETURN_ON_EXCEPTION(this,ex);
1326 return INVOKERESULT_GENERIC_ERROR;
1328 STRINGZ_TO_NPVARIANT(psz_aspect, result);
1329 return INVOKERESULT_NO_ERROR;
1331 case ID_video_subtitle:
1333 int i_spu = libvlc_video_get_spu(p_md, &ex);
1334 RETURN_ON_EXCEPTION(this,ex);
1335 INT32_TO_NPVARIANT(i_spu, result);
1336 return INVOKERESULT_NO_ERROR;
1340 NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
1341 RETURN_ON_EXCEPTION(this,ex);
1343 return INVOKERESULT_GENERIC_ERROR;
1345 STRINGZ_TO_NPVARIANT(psz_geometry, result);
1346 return INVOKERESULT_NO_ERROR;
1348 case ID_video_teletext:
1350 int i_page = libvlc_video_get_teletext(p_md, &ex);
1351 RETURN_ON_EXCEPTION(this,ex);
1352 INT32_TO_NPVARIANT(i_page, result);
1353 return INVOKERESULT_NO_ERROR;
1355 case ID_video_marquee:
1357 InstantObj<LibvlcMarqueeNPObject>( marqueeObj );
1358 OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
1359 return INVOKERESULT_NO_ERROR;
1363 return INVOKERESULT_GENERIC_ERROR;
1366 RuntimeNPObject::InvokeResult
1367 LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
1369 /* is plugin still running */
1370 if( isPluginRunning() )
1372 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1373 libvlc_exception_t ex;
1374 libvlc_exception_init(&ex);
1376 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1377 RETURN_ON_EXCEPTION(this,ex);
1381 case ID_video_fullscreen:
1383 if( ! NPVARIANT_IS_BOOLEAN(value) )
1385 return INVOKERESULT_INVALID_VALUE;
1388 int val = NPVARIANT_TO_BOOLEAN(value);
1389 p_plugin->set_fullscreen(val, &ex);
1390 RETURN_ON_EXCEPTION(this,ex);
1391 return INVOKERESULT_NO_ERROR;
1393 case ID_video_aspectratio:
1395 char *psz_aspect = NULL;
1397 if( ! NPVARIANT_IS_STRING(value) )
1399 return INVOKERESULT_INVALID_VALUE;
1402 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
1405 return INVOKERESULT_GENERIC_ERROR;
1408 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
1410 RETURN_ON_EXCEPTION(this,ex);
1412 return INVOKERESULT_NO_ERROR;
1414 case ID_video_subtitle:
1416 if( isNumberValue(value) )
1418 libvlc_video_set_spu(p_md, numberValue(value), &ex);
1419 RETURN_ON_EXCEPTION(this,ex);
1421 return INVOKERESULT_NO_ERROR;
1423 return INVOKERESULT_INVALID_VALUE;
1427 char *psz_geometry = NULL;
1429 if( ! NPVARIANT_IS_STRING(value) )
1431 return INVOKERESULT_INVALID_VALUE;
1434 psz_geometry = stringValue(NPVARIANT_TO_STRING(value));
1437 return INVOKERESULT_GENERIC_ERROR;
1440 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
1442 RETURN_ON_EXCEPTION(this,ex);
1444 return INVOKERESULT_NO_ERROR;
1446 case ID_video_teletext:
1448 if( isNumberValue(value) )
1450 libvlc_video_set_teletext(p_md, numberValue(value), &ex);
1451 RETURN_ON_EXCEPTION(this,ex);
1453 return INVOKERESULT_NO_ERROR;
1455 return INVOKERESULT_INVALID_VALUE;
1459 return INVOKERESULT_GENERIC_ERROR;
1462 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
1466 "deinterlaceEnable",
1467 "deinterlaceDisable"
1469 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
1471 enum LibvlcVideoNPObjectMethodIds
1473 ID_video_togglefullscreen,
1474 ID_video_toggleteletext,
1475 ID_video_deinterlaceenable,
1476 ID_video_deinterlacedisable
1479 RuntimeNPObject::InvokeResult
1480 LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
1481 uint32_t argCount, NPVariant &result)
1483 /* is plugin still running */
1484 if( isPluginRunning() )
1486 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1487 libvlc_exception_t ex;
1488 libvlc_exception_init(&ex);
1490 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1491 RETURN_ON_EXCEPTION(this,ex);
1495 case ID_video_togglefullscreen:
1499 p_plugin->toggle_fullscreen(&ex);
1500 RETURN_ON_EXCEPTION(this,ex);
1501 VOID_TO_NPVARIANT(result);
1502 return INVOKERESULT_NO_ERROR;
1504 return INVOKERESULT_NO_SUCH_METHOD;
1506 case ID_video_toggleteletext:
1510 libvlc_toggle_teletext(p_md, &ex);
1511 RETURN_ON_EXCEPTION(this,ex);
1512 VOID_TO_NPVARIANT(result);
1513 return INVOKERESULT_NO_ERROR;
1515 return INVOKERESULT_NO_SUCH_METHOD;
1517 case ID_video_deinterlacedisable:
1519 libvlc_video_set_deinterlace(p_md, 0, "", &ex);
1520 RETURN_ON_EXCEPTION(this,ex);
1521 return INVOKERESULT_NO_ERROR;
1523 case ID_video_deinterlaceenable:
1527 if( NPVARIANT_IS_STRING( args[0] ) )
1529 /* get deinterlace mode from the user */
1530 char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1531 /* enable deinterlace filter if possible */
1532 libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
1534 RETURN_ON_EXCEPTION(this,ex);
1535 return INVOKERESULT_NO_ERROR;
1539 return INVOKERESULT_INVALID_VALUE;
1544 return INVOKERESULT_NO_SUCH_METHOD;
1547 return INVOKERESULT_GENERIC_ERROR;
1551 ** implementation of libvlc marquee object
1554 const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
1558 enum LibvlcMarqueeNPObjectPropertyIds
1561 COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
1563 RuntimeNPObject::InvokeResult
1564 LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
1566 /* is plugin still running */
1567 if( isPluginRunning() )
1569 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1570 libvlc_exception_t ex;
1571 libvlc_exception_init(&ex);
1573 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1574 RETURN_ON_EXCEPTION(this,ex);
1580 return INVOKERESULT_GENERIC_ERROR;
1583 RuntimeNPObject::InvokeResult
1584 LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
1586 /* is plugin still running */
1587 if( isPluginRunning() )
1589 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1590 libvlc_exception_t ex;
1591 libvlc_exception_init(&ex);
1593 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1594 RETURN_ON_EXCEPTION(this,ex);
1600 return INVOKERESULT_GENERIC_ERROR;
1603 const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
1617 COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
1619 enum LibvlcMarqueeNPObjectMethodIds
1625 ID_marquee_position,
1634 RuntimeNPObject::InvokeResult
1635 LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
1636 uint32_t argCount, NPVariant &result)
1638 /* is plugin still running */
1639 if( isPluginRunning() )
1641 VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
1642 libvlc_exception_t ex;
1643 libvlc_exception_init(&ex);
1645 libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
1646 RETURN_ON_EXCEPTION(this,ex);
1650 case ID_marquee_enable:
1652 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
1653 RETURN_ON_EXCEPTION(this,ex);
1654 return INVOKERESULT_NO_ERROR;
1656 case ID_marquee_disable:
1658 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
1659 RETURN_ON_EXCEPTION(this,ex);
1660 return INVOKERESULT_NO_ERROR;
1662 case ID_marquee_color:
1666 if( NPVARIANT_IS_INT32( args[0] ) )
1668 int i_color = NPVARIANT_TO_INT32( args[0] );
1669 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, i_color, &ex);
1670 RETURN_ON_EXCEPTION(this,ex);
1671 return INVOKERESULT_NO_ERROR;
1674 return INVOKERESULT_GENERIC_ERROR;
1676 return INVOKERESULT_NO_SUCH_METHOD;
1678 case ID_marquee_opacity:
1682 if( NPVARIANT_IS_INT32( args[0] ) )
1684 int i_opacity = NPVARIANT_TO_INT32( args[0] );
1685 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, i_opacity, &ex);
1686 RETURN_ON_EXCEPTION(this,ex);
1687 return INVOKERESULT_NO_ERROR;
1690 return INVOKERESULT_GENERIC_ERROR;
1692 return INVOKERESULT_NO_SUCH_METHOD;
1694 case ID_marquee_position:
1698 if( NPVARIANT_IS_INT32( args[0] ) )
1700 int i_position = NPVARIANT_TO_INT32( args[0] );
1701 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, i_position, &ex);
1702 RETURN_ON_EXCEPTION(this,ex);
1703 return INVOKERESULT_NO_ERROR;
1706 return INVOKERESULT_GENERIC_ERROR;
1708 return INVOKERESULT_NO_SUCH_METHOD;
1710 case ID_marquee_refresh:
1714 if( NPVARIANT_IS_INT32( args[0] ) )
1716 int i_refresh = NPVARIANT_TO_INT32( args[0] );
1717 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, i_refresh, &ex);
1718 RETURN_ON_EXCEPTION(this,ex);
1719 return INVOKERESULT_NO_ERROR;
1722 return INVOKERESULT_GENERIC_ERROR;
1724 return INVOKERESULT_NO_SUCH_METHOD;
1726 case ID_marquee_size:
1730 if( NPVARIANT_IS_INT32( args[0] ) )
1732 int i_size = NPVARIANT_TO_INT32( args[0] );
1733 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, i_size, &ex);
1734 RETURN_ON_EXCEPTION(this,ex);
1735 return INVOKERESULT_NO_ERROR;
1738 return INVOKERESULT_GENERIC_ERROR;
1740 return INVOKERESULT_NO_SUCH_METHOD;
1742 case ID_marquee_text:
1746 if( NPVARIANT_IS_STRING( args[0] ) )
1748 char *psz_text = stringValue( NPVARIANT_TO_STRING( args[0] ) );
1749 libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
1750 RETURN_ON_EXCEPTION(this,ex);
1752 return INVOKERESULT_NO_ERROR;
1755 return INVOKERESULT_GENERIC_ERROR;
1757 return INVOKERESULT_NO_SUCH_METHOD;
1759 case ID_marquee_timeout:
1763 if( NPVARIANT_IS_INT32( args[0] ) )
1765 int i_timeout = NPVARIANT_TO_INT32( args[0] );
1766 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, i_timeout, &ex);
1767 RETURN_ON_EXCEPTION(this,ex);
1768 return INVOKERESULT_NO_ERROR;
1771 return INVOKERESULT_GENERIC_ERROR;
1773 return INVOKERESULT_NO_SUCH_METHOD;
1779 if( NPVARIANT_IS_INT32( args[0] ) )
1781 int i_x = NPVARIANT_TO_INT32( args[0] );
1782 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, i_x, &ex);
1783 RETURN_ON_EXCEPTION(this,ex);
1784 return INVOKERESULT_NO_ERROR;
1787 return INVOKERESULT_GENERIC_ERROR;
1789 return INVOKERESULT_NO_SUCH_METHOD;
1795 if( NPVARIANT_IS_INT32( args[0] ) )
1797 int i_y = NPVARIANT_TO_INT32( args[0] );
1798 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, i_y, &ex);
1799 RETURN_ON_EXCEPTION(this,ex);
1800 return INVOKERESULT_NO_ERROR;
1803 return INVOKERESULT_GENERIC_ERROR;
1805 return INVOKERESULT_NO_SUCH_METHOD;
1808 return INVOKERESULT_NO_SUCH_METHOD;
1811 return INVOKERESULT_GENERIC_ERROR;