1 /*****************************************************************************
\r
2 * npolibvlc.cpp: official Javascript APIs
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2002-2006 the VideoLAN team
\r
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
\r
21 *****************************************************************************/
\r
30 #ifdef HAVE_MOZILLA_CONFIG_H
\r
31 # include <mozilla-config.h>
\r
34 #include "npolibvlc.h"
\r
35 #include "vlcplugin.h"
\r
38 ** implementation of libvlc root object
\r
41 LibvlcRootNPObject::LibvlcRootNPObject(NPP instance, const NPClass *aClass) :
\r
42 RuntimeNPObject(instance, aClass)
\r
44 audioObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcAudioNPObject>::getClass());
\r
45 inputObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcInputNPObject>::getClass());
\r
46 logObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcLogNPObject>::getClass());
\r
47 playlistObj = NPN_CreateObject(instance, RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
\r
48 videoObj = NPN_CreateObject(instance,RuntimeNPClass<LibvlcVideoNPObject>::getClass());
\r
51 LibvlcRootNPObject::~LibvlcRootNPObject()
\r
53 NPN_ReleaseObject(audioObj);
\r
54 NPN_ReleaseObject(inputObj);
\r
55 NPN_ReleaseObject(logObj);
\r
56 NPN_ReleaseObject(playlistObj);
\r
57 NPN_ReleaseObject(videoObj);
\r
60 const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
\r
69 const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
71 enum LibvlcRootNPObjectPropertyIds
\r
80 RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)
\r
85 OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
\r
86 return INVOKERESULT_NO_ERROR;
\r
88 OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
\r
89 return INVOKERESULT_NO_ERROR;
\r
91 OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
\r
92 return INVOKERESULT_NO_ERROR;
\r
94 OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
\r
95 return INVOKERESULT_NO_ERROR;
\r
96 case ID_VersionInfo:
\r
97 NPUTF8 *versionStr = NULL;
\r
99 versionStr = strdup( VLC_Version() );
\r
101 return INVOKERESULT_GENERIC_ERROR;
\r
103 STRINGZ_TO_NPVARIANT(versionStr, result);
\r
104 return INVOKERESULT_NO_ERROR;
\r
106 return INVOKERESULT_GENERIC_ERROR;
\r
109 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =
\r
114 const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNames)/sizeof(NPUTF8 *);
\r
116 enum LibvlcRootNPObjectMethodIds
\r
121 RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
123 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
126 libvlc_exception_t ex;
\r
127 libvlc_exception_init(&ex);
\r
132 if( argCount == 0 )
\r
134 NPUTF8 *versionStr = NULL;
\r
136 versionStr = strdup( VLC_Version() );
\r
138 return INVOKERESULT_GENERIC_ERROR;
\r
140 STRINGZ_TO_NPVARIANT(versionStr, result);
\r
141 return INVOKERESULT_NO_ERROR;
\r
143 return INVOKERESULT_NO_SUCH_METHOD;
\r
145 return INVOKERESULT_NO_SUCH_METHOD;
\r
148 return INVOKERESULT_GENERIC_ERROR;
\r
152 ** implementation of libvlc audio object
\r
155 const NPUTF8 * const LibvlcAudioNPObject::propertyNames[] =
\r
161 const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
163 enum LibvlcAudioNPObjectPropertyIds
\r
169 RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
\r
171 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
174 libvlc_exception_t ex;
\r
175 libvlc_exception_init(&ex);
\r
181 vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
\r
182 if( libvlc_exception_raised(&ex) )
\r
184 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
185 libvlc_exception_clear(&ex);
\r
186 return INVOKERESULT_GENERIC_ERROR;
\r
188 BOOLEAN_TO_NPVARIANT(muted, result);
\r
189 return INVOKERESULT_NO_ERROR;
\r
193 int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
\r
194 if( libvlc_exception_raised(&ex) )
\r
196 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
197 libvlc_exception_clear(&ex);
\r
198 return INVOKERESULT_GENERIC_ERROR;
\r
200 INT32_TO_NPVARIANT(volume, result);
\r
201 return INVOKERESULT_NO_ERROR;
\r
205 return INVOKERESULT_GENERIC_ERROR;
\r
208 RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
\r
210 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
213 libvlc_exception_t ex;
\r
214 libvlc_exception_init(&ex);
\r
219 if( NPVARIANT_IS_BOOLEAN(value) )
\r
221 libvlc_audio_set_mute(p_plugin->getVLC(),
\r
222 NPVARIANT_TO_BOOLEAN(value), &ex);
\r
223 if( libvlc_exception_raised(&ex) )
\r
225 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
226 libvlc_exception_clear(&ex);
\r
227 return INVOKERESULT_GENERIC_ERROR;
\r
229 return INVOKERESULT_NO_ERROR;
\r
231 return INVOKERESULT_INVALID_VALUE;
\r
233 if( isNumberValue(value) )
\r
235 libvlc_audio_set_volume(p_plugin->getVLC(),
\r
236 numberValue(value), &ex);
\r
237 if( libvlc_exception_raised(&ex) )
\r
239 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
240 libvlc_exception_clear(&ex);
\r
241 return INVOKERESULT_GENERIC_ERROR;
\r
243 return INVOKERESULT_NO_ERROR;
\r
245 return INVOKERESULT_INVALID_VALUE;
\r
248 return INVOKERESULT_GENERIC_ERROR;
\r
251 const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
\r
256 const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodNames)/sizeof(NPUTF8 *);
\r
258 enum LibvlcAudioNPObjectMethodIds
\r
263 RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
265 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
268 libvlc_exception_t ex;
\r
269 libvlc_exception_init(&ex);
\r
273 case ID_togglemute:
\r
274 if( argCount == 0 )
\r
276 libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
\r
277 if( libvlc_exception_raised(&ex) )
\r
279 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
280 libvlc_exception_clear(&ex);
\r
281 return INVOKERESULT_GENERIC_ERROR;
\r
285 VOID_TO_NPVARIANT(result);
\r
286 return INVOKERESULT_NO_ERROR;
\r
289 return INVOKERESULT_NO_SUCH_METHOD;
\r
291 return INVOKERESULT_NO_SUCH_METHOD;
\r
294 return INVOKERESULT_GENERIC_ERROR;
\r
298 ** implementation of libvlc input object
\r
301 const NPUTF8 * const LibvlcInputNPObject::propertyNames[] =
\r
312 const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
314 enum LibvlcInputNPObjectPropertyIds
\r
325 RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)
\r
327 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
330 libvlc_exception_t ex;
\r
331 libvlc_exception_init(&ex);
\r
333 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
\r
334 if( libvlc_exception_raised(&ex) )
\r
336 if( index != ID_state )
\r
338 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
339 libvlc_exception_clear(&ex);
\r
340 return INVOKERESULT_GENERIC_ERROR;
\r
344 /* for input state, return CLOSED rather than an exception */
\r
345 INT32_TO_NPVARIANT(0, result);
\r
346 return INVOKERESULT_NO_ERROR;
\r
354 double val = (double)libvlc_input_get_length(p_input, &ex);
\r
355 libvlc_input_free(p_input);
\r
356 if( libvlc_exception_raised(&ex) )
\r
358 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
359 libvlc_exception_clear(&ex);
\r
360 return INVOKERESULT_GENERIC_ERROR;
\r
362 DOUBLE_TO_NPVARIANT(val, result);
\r
363 return INVOKERESULT_NO_ERROR;
\r
367 double val = libvlc_input_get_position(p_input, &ex);
\r
368 libvlc_input_free(p_input);
\r
369 if( libvlc_exception_raised(&ex) )
\r
371 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
372 libvlc_exception_clear(&ex);
\r
373 return INVOKERESULT_GENERIC_ERROR;
\r
375 DOUBLE_TO_NPVARIANT(val, result);
\r
376 return INVOKERESULT_NO_ERROR;
\r
380 double val = (double)libvlc_input_get_time(p_input, &ex);
\r
381 libvlc_input_free(p_input);
\r
382 if( libvlc_exception_raised(&ex) )
\r
384 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
385 libvlc_exception_clear(&ex);
\r
386 return INVOKERESULT_GENERIC_ERROR;
\r
388 DOUBLE_TO_NPVARIANT(val, result);
\r
389 return INVOKERESULT_NO_ERROR;
\r
393 int val = libvlc_input_get_state(p_input, &ex);
\r
394 libvlc_input_free(p_input);
\r
395 if( libvlc_exception_raised(&ex) )
\r
397 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
398 libvlc_exception_clear(&ex);
\r
399 return INVOKERESULT_GENERIC_ERROR;
\r
401 INT32_TO_NPVARIANT(val, result);
\r
402 return INVOKERESULT_NO_ERROR;
\r
406 float val = libvlc_input_get_rate(p_input, &ex);
\r
407 libvlc_input_free(p_input);
\r
408 if( libvlc_exception_raised(&ex) )
\r
410 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
411 libvlc_exception_clear(&ex);
\r
412 return INVOKERESULT_GENERIC_ERROR;
\r
414 DOUBLE_TO_NPVARIANT(val, result);
\r
415 return INVOKERESULT_NO_ERROR;
\r
419 double val = libvlc_input_get_fps(p_input, &ex);
\r
420 libvlc_input_free(p_input);
\r
421 if( libvlc_exception_raised(&ex) )
\r
423 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
424 libvlc_exception_clear(&ex);
\r
425 return INVOKERESULT_GENERIC_ERROR;
\r
427 DOUBLE_TO_NPVARIANT(val, result);
\r
428 return INVOKERESULT_NO_ERROR;
\r
432 vlc_bool_t val = libvlc_input_has_vout(p_input, &ex);
\r
433 libvlc_input_free(p_input);
\r
434 if( libvlc_exception_raised(&ex) )
\r
436 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
437 libvlc_exception_clear(&ex);
\r
438 return INVOKERESULT_GENERIC_ERROR;
\r
440 BOOLEAN_TO_NPVARIANT(val, result);
\r
441 return INVOKERESULT_NO_ERROR;
\r
444 libvlc_input_free(p_input);
\r
446 return INVOKERESULT_GENERIC_ERROR;
\r
449 RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
\r
451 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
454 libvlc_exception_t ex;
\r
455 libvlc_exception_init(&ex);
\r
457 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
\r
458 if( libvlc_exception_raised(&ex) )
\r
460 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
461 libvlc_exception_clear(&ex);
\r
462 return INVOKERESULT_GENERIC_ERROR;
\r
469 if( ! NPVARIANT_IS_DOUBLE(value) )
\r
471 libvlc_input_free(p_input);
\r
472 return INVOKERESULT_INVALID_VALUE;
\r
475 float val = (float)NPVARIANT_TO_DOUBLE(value);
\r
476 libvlc_input_set_position(p_input, val, &ex);
\r
477 libvlc_input_free(p_input);
\r
478 if( libvlc_exception_raised(&ex) )
\r
480 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
481 libvlc_exception_clear(&ex);
\r
482 return INVOKERESULT_GENERIC_ERROR;
\r
484 return INVOKERESULT_NO_ERROR;
\r
489 if( NPVARIANT_IS_INT32(value) )
\r
490 val = (vlc_int64_t)NPVARIANT_TO_INT32(value);
\r
491 else if( NPVARIANT_IS_DOUBLE(value) )
\r
492 val = (vlc_int64_t)NPVARIANT_TO_DOUBLE(value);
\r
495 libvlc_input_free(p_input);
\r
496 return INVOKERESULT_INVALID_VALUE;
\r
499 libvlc_input_set_time(p_input, val, &ex);
\r
500 libvlc_input_free(p_input);
\r
501 if( libvlc_exception_raised(&ex) )
\r
503 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
504 libvlc_exception_clear(&ex);
\r
505 return INVOKERESULT_GENERIC_ERROR;
\r
507 return INVOKERESULT_NO_ERROR;
\r
512 if( NPVARIANT_IS_INT32(value) )
\r
513 val = (float)NPVARIANT_TO_INT32(value);
\r
514 else if( NPVARIANT_IS_DOUBLE(value) )
\r
515 val = (float)NPVARIANT_TO_DOUBLE(value);
\r
518 libvlc_input_free(p_input);
\r
519 return INVOKERESULT_INVALID_VALUE;
\r
522 libvlc_input_set_rate(p_input, val, &ex);
\r
523 libvlc_input_free(p_input);
\r
524 if( libvlc_exception_raised(&ex) )
\r
526 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
527 libvlc_exception_clear(&ex);
\r
528 return INVOKERESULT_GENERIC_ERROR;
\r
530 return INVOKERESULT_NO_ERROR;
\r
533 libvlc_input_free(p_input);
\r
535 return INVOKERESULT_GENERIC_ERROR;
\r
538 const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
\r
543 const int LibvlcInputNPObject::methodCount = sizeof(LibvlcInputNPObject::methodNames)/sizeof(NPUTF8 *);
\r
546 ** implementation of libvlc message object
\r
549 const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
\r
558 const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
560 enum LibvlcMessageNPObjectPropertyIds
\r
569 RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
\r
575 INT32_TO_NPVARIANT(_msg.i_severity, result);
\r
576 return INVOKERESULT_NO_ERROR;
\r
580 if( _msg.psz_type )
\r
582 int len = strlen(_msg.psz_type);
\r
583 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
\r
586 memcpy(retval, _msg.psz_type, len);
\r
587 STRINGN_TO_NPVARIANT(retval, len, result);
\r
592 NULL_TO_NPVARIANT(result);
\r
594 return INVOKERESULT_NO_ERROR;
\r
598 if( _msg.psz_name )
\r
600 int len = strlen(_msg.psz_name);
\r
601 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
\r
604 memcpy(retval, _msg.psz_name, len);
\r
605 STRINGN_TO_NPVARIANT(retval, len, result);
\r
610 NULL_TO_NPVARIANT(result);
\r
612 return INVOKERESULT_NO_ERROR;
\r
616 if( _msg.psz_header )
\r
618 int len = strlen(_msg.psz_header);
\r
619 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
\r
622 memcpy(retval, _msg.psz_header, len);
\r
623 STRINGN_TO_NPVARIANT(retval, len, result);
\r
628 NULL_TO_NPVARIANT(result);
\r
630 return INVOKERESULT_NO_ERROR;
\r
634 if( _msg.psz_message )
\r
636 int len = strlen(_msg.psz_message);
\r
637 NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
\r
640 memcpy(retval, _msg.psz_message, len);
\r
641 STRINGN_TO_NPVARIANT(retval, len, result);
\r
646 NULL_TO_NPVARIANT(result);
\r
648 return INVOKERESULT_NO_ERROR;
\r
651 return INVOKERESULT_GENERIC_ERROR;
\r
654 const NPUTF8 * const LibvlcMessageNPObject::methodNames[] =
\r
659 const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::methodNames)/sizeof(NPUTF8 *);
\r
662 ** implementation of libvlc message iterator object
\r
665 void LibvlcMessageIteratorNPObject::setLog(LibvlcLogNPObject* p_vlclog)
\r
667 _p_vlclog = p_vlclog;
\r
668 if( p_vlclog->_p_log )
\r
670 _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
\r
676 const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
\r
681 const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIteratorNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
683 enum LibvlcMessageIteratorNPObjectPropertyIds
\r
688 RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
\r
694 if( _p_iter && _p_vlclog->_p_log )
\r
696 libvlc_exception_t ex;
\r
697 libvlc_exception_init(&ex);
\r
699 BOOLEAN_TO_NPVARIANT(libvlc_log_iterator_has_next(_p_iter, &ex), result);
\r
700 if( libvlc_exception_raised(&ex) )
\r
702 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
703 libvlc_exception_clear(&ex);
\r
704 return INVOKERESULT_GENERIC_ERROR;
\r
709 BOOLEAN_TO_NPVARIANT(0, result);
\r
711 return INVOKERESULT_NO_ERROR;
\r
714 return INVOKERESULT_GENERIC_ERROR;
\r
717 const NPUTF8 * const LibvlcMessageIteratorNPObject::methodNames[] =
\r
722 const int LibvlcMessageIteratorNPObject::methodCount = sizeof(LibvlcMessageIteratorNPObject::methodNames)/sizeof(NPUTF8 *);
\r
724 enum LibvlcMessageIteratorNPObjectMethodIds
\r
726 ID_messageiterator_next,
\r
729 RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
731 if( _p_iter && _p_vlclog->_p_log )
\r
733 libvlc_exception_t ex;
\r
734 libvlc_exception_init(&ex);
\r
738 case ID_messageiterator_next:
\r
739 if( argCount == 0 )
\r
741 struct libvlc_log_message_t buffer;
\r
743 buffer.sizeof_msg = sizeof(buffer);
\r
745 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
\r
746 if( libvlc_exception_raised(&ex) )
\r
748 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
749 libvlc_exception_clear(&ex);
\r
750 return INVOKERESULT_GENERIC_ERROR;
\r
754 LibvlcMessageNPObject* message =
\r
755 static_cast<LibvlcMessageNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageNPObject>::getClass()));
\r
758 message->setMessage(buffer);
\r
759 OBJECT_TO_NPVARIANT(message, result);
\r
760 return INVOKERESULT_NO_ERROR;
\r
762 return INVOKERESULT_OUT_OF_MEMORY;
\r
766 return INVOKERESULT_NO_SUCH_METHOD;
\r
769 return INVOKERESULT_GENERIC_ERROR;
\r
773 ** implementation of libvlc message object
\r
776 const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
\r
781 const int LibvlcMessagesNPObject::propertyCount = sizeof(LibvlcMessagesNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
783 enum LibvlcMessagesNPObjectPropertyIds
\r
788 RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
\r
794 libvlc_log_t *p_log = _p_vlclog->_p_log;
\r
797 libvlc_exception_t ex;
\r
798 libvlc_exception_init(&ex);
\r
800 INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
\r
801 if( libvlc_exception_raised(&ex) )
\r
803 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
804 libvlc_exception_clear(&ex);
\r
805 return INVOKERESULT_GENERIC_ERROR;
\r
810 INT32_TO_NPVARIANT(0, result);
\r
812 return INVOKERESULT_NO_ERROR;
\r
815 return INVOKERESULT_GENERIC_ERROR;
\r
818 const NPUTF8 * const LibvlcMessagesNPObject::methodNames[] =
\r
824 const int LibvlcMessagesNPObject::methodCount = sizeof(LibvlcMessagesNPObject::methodNames)/sizeof(NPUTF8 *);
\r
826 enum LibvlcMessagesNPObjectMethodIds
\r
832 RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
834 libvlc_exception_t ex;
\r
835 libvlc_exception_init(&ex);
\r
839 case ID_messages_clear:
\r
840 if( argCount == 0 )
\r
842 libvlc_log_t *p_log = _p_vlclog->_p_log;
\r
845 libvlc_log_clear(p_log, &ex);
\r
846 if( libvlc_exception_raised(&ex) )
\r
848 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
849 libvlc_exception_clear(&ex);
\r
850 return INVOKERESULT_GENERIC_ERROR;
\r
853 return INVOKERESULT_NO_ERROR;
\r
855 return INVOKERESULT_NO_SUCH_METHOD;
\r
858 if( argCount == 0 )
\r
860 LibvlcMessageIteratorNPObject* iter =
\r
861 static_cast<LibvlcMessageIteratorNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageIteratorNPObject>::getClass()));
\r
864 iter->setLog(_p_vlclog);
\r
865 OBJECT_TO_NPVARIANT(iter, result);
\r
866 return INVOKERESULT_NO_ERROR;
\r
868 return INVOKERESULT_OUT_OF_MEMORY;
\r
870 return INVOKERESULT_NO_SUCH_METHOD;
\r
873 return INVOKERESULT_NO_SUCH_METHOD;
\r
875 return INVOKERESULT_GENERIC_ERROR;
\r
879 ** implementation of libvlc message object
\r
882 const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
\r
888 const int LibvlcLogNPObject::propertyCount = sizeof(LibvlcLogNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
890 enum LibvlcLogNPObjectPropertyIds
\r
896 RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVariant &result)
\r
898 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
901 libvlc_exception_t ex;
\r
902 libvlc_exception_init(&ex);
\r
908 OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcmessages), result);
\r
909 return INVOKERESULT_NO_ERROR;
\r
915 INT32_TO_NPVARIANT(libvlc_get_log_verbosity(p_plugin->getVLC(),
\r
917 if( libvlc_exception_raised(&ex) )
\r
919 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
920 libvlc_exception_clear(&ex);
\r
921 return INVOKERESULT_GENERIC_ERROR;
\r
926 /* log is not enabled, return -1 */
\r
927 DOUBLE_TO_NPVARIANT(-1.0, result);
\r
929 return INVOKERESULT_NO_ERROR;
\r
933 return INVOKERESULT_GENERIC_ERROR;
\r
936 RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NPVariant &value)
\r
938 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
941 libvlc_exception_t ex;
\r
942 libvlc_exception_init(&ex);
\r
947 if( isNumberValue(value) )
\r
949 libvlc_instance_t* p_libvlc = p_plugin->getVLC();
\r
950 int verbosity = numberValue(value);
\r
951 if( verbosity >= 0 )
\r
955 _p_log = libvlc_log_open(p_libvlc, &ex);
\r
956 if( libvlc_exception_raised(&ex) )
\r
958 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
959 libvlc_exception_clear(&ex);
\r
960 return INVOKERESULT_GENERIC_ERROR;
\r
963 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
\r
964 if( libvlc_exception_raised(&ex) )
\r
966 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
967 libvlc_exception_clear(&ex);
\r
968 return INVOKERESULT_GENERIC_ERROR;
\r
973 /* close log when verbosity is set to -1 */
\r
974 libvlc_log_close(_p_log, &ex);
\r
976 if( libvlc_exception_raised(&ex) )
\r
978 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
979 libvlc_exception_clear(&ex);
\r
980 return INVOKERESULT_GENERIC_ERROR;
\r
983 return INVOKERESULT_NO_ERROR;
\r
985 return INVOKERESULT_INVALID_VALUE;
\r
988 return INVOKERESULT_GENERIC_ERROR;
\r
991 const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
\r
996 const int LibvlcLogNPObject::methodCount = sizeof(LibvlcLogNPObject::methodNames)/sizeof(NPUTF8 *);
\r
999 ** implementation of libvlc playlist object
\r
1003 const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
\r
1009 const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
1011 enum LibvlcPlaylistNPObjectPropertyIds
\r
1017 RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
\r
1019 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
1022 libvlc_exception_t ex;
\r
1023 libvlc_exception_init(&ex);
\r
1027 case ID_itemcount:
\r
1029 int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
\r
1030 if( libvlc_exception_raised(&ex) )
\r
1032 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1033 libvlc_exception_clear(&ex);
\r
1034 return INVOKERESULT_GENERIC_ERROR;
\r
1036 INT32_TO_NPVARIANT(val, result);
\r
1037 return INVOKERESULT_NO_ERROR;
\r
1039 case ID_isplaying:
\r
1041 int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
\r
1042 if( libvlc_exception_raised(&ex) )
\r
1044 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1045 libvlc_exception_clear(&ex);
\r
1046 return INVOKERESULT_GENERIC_ERROR;
\r
1048 BOOLEAN_TO_NPVARIANT(val, result);
\r
1049 return INVOKERESULT_NO_ERROR;
\r
1053 return INVOKERESULT_GENERIC_ERROR;
\r
1056 const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
\r
1069 const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);
\r
1071 enum LibvlcPlaylistNPObjectMethodIds
\r
1084 RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
1086 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
1089 libvlc_exception_t ex;
\r
1090 libvlc_exception_init(&ex);
\r
1096 if( (argCount < 1) || (argCount > 3) )
\r
1097 return INVOKERESULT_NO_SUCH_METHOD;
\r
1102 if( NPVARIANT_IS_STRING(args[0]) )
\r
1104 char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
\r
1107 url = p_plugin->getAbsoluteURL(s);
\r
1110 // what happened ?
\r
1111 return INVOKERESULT_GENERIC_ERROR;
\r
1114 return INVOKERESULT_OUT_OF_MEMORY;
\r
1117 return INVOKERESULT_NO_SUCH_METHOD;
\r
1119 char *name = NULL;
\r
1121 // grab name if available
\r
1122 if( argCount > 1 )
\r
1124 if( NPVARIANT_IS_NULL(args[1]) )
\r
1128 else if( NPVARIANT_IS_STRING(args[1]) )
\r
1130 name = stringValue(NPVARIANT_TO_STRING(args[0]));
\r
1133 return INVOKERESULT_NO_SUCH_METHOD;
\r
1136 int i_options = 0;
\r
1137 char** ppsz_options = NULL;
\r
1139 // grab options if available
\r
1140 if( argCount > 2 )
\r
1142 if( NPVARIANT_IS_NULL(args[2]) )
\r
1146 else if( NPVARIANT_IS_STRING(args[2]) )
\r
1148 parseOptions(NPVARIANT_TO_STRING(args[2]), &i_options, &ppsz_options);
\r
1151 else if( NPVARIANT_IS_OBJECT(args[2]) )
\r
1153 parseOptions(NPVARIANT_TO_OBJECT(args[2]), &i_options, &ppsz_options);
\r
1157 int item = libvlc_playlist_add_extended(p_plugin->getVLC(),
\r
1161 const_cast<const char **>(ppsz_options),
\r
1165 for( int i=0; i< i_options; ++i )
\r
1167 if( ppsz_options[i] )
\r
1168 free(ppsz_options[i]);
\r
1170 if( ppsz_options )
\r
1171 free(ppsz_options);
\r
1172 if( libvlc_exception_raised(&ex) )
\r
1174 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1175 libvlc_exception_clear(&ex);
\r
1176 return INVOKERESULT_GENERIC_ERROR;
\r
1180 INT32_TO_NPVARIANT(item, result);
\r
1181 return INVOKERESULT_NO_ERROR;
\r
1185 if( argCount == 0 )
\r
1187 libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
\r
1188 if( libvlc_exception_raised(&ex) )
\r
1190 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1191 libvlc_exception_clear(&ex);
\r
1192 return INVOKERESULT_GENERIC_ERROR;
\r
1196 VOID_TO_NPVARIANT(result);
\r
1197 return INVOKERESULT_NO_ERROR;
\r
1200 return INVOKERESULT_NO_SUCH_METHOD;
\r
1202 if( (argCount == 1) && isNumberValue(args[0]) )
\r
1204 libvlc_playlist_play(p_plugin->getVLC(), numberValue(args[0]), 0, NULL, &ex);
\r
1205 if( libvlc_exception_raised(&ex) )
\r
1207 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1208 libvlc_exception_clear(&ex);
\r
1209 return INVOKERESULT_GENERIC_ERROR;
\r
1213 VOID_TO_NPVARIANT(result);
\r
1214 return INVOKERESULT_NO_ERROR;
\r
1217 return INVOKERESULT_NO_SUCH_METHOD;
\r
1218 case ID_togglepause:
\r
1219 if( argCount == 0 )
\r
1221 libvlc_playlist_pause(p_plugin->getVLC(), &ex);
\r
1222 if( libvlc_exception_raised(&ex) )
\r
1224 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1225 libvlc_exception_clear(&ex);
\r
1226 return INVOKERESULT_GENERIC_ERROR;
\r
1230 VOID_TO_NPVARIANT(result);
\r
1231 return INVOKERESULT_NO_ERROR;
\r
1234 return INVOKERESULT_NO_SUCH_METHOD;
\r
1236 if( argCount == 0 )
\r
1238 libvlc_playlist_stop(p_plugin->getVLC(), &ex);
\r
1239 if( libvlc_exception_raised(&ex) )
\r
1241 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1242 libvlc_exception_clear(&ex);
\r
1243 return INVOKERESULT_GENERIC_ERROR;
\r
1247 VOID_TO_NPVARIANT(result);
\r
1248 return INVOKERESULT_NO_ERROR;
\r
1251 return INVOKERESULT_NO_SUCH_METHOD;
\r
1253 if( argCount == 0 )
\r
1255 libvlc_playlist_next(p_plugin->getVLC(), &ex);
\r
1256 if( libvlc_exception_raised(&ex) )
\r
1258 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1259 libvlc_exception_clear(&ex);
\r
1260 return INVOKERESULT_GENERIC_ERROR;
\r
1264 VOID_TO_NPVARIANT(result);
\r
1265 return INVOKERESULT_NO_ERROR;
\r
1268 return INVOKERESULT_NO_SUCH_METHOD;
\r
1270 if( argCount == 0 )
\r
1272 libvlc_playlist_prev(p_plugin->getVLC(), &ex);
\r
1273 if( libvlc_exception_raised(&ex) )
\r
1275 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1276 libvlc_exception_clear(&ex);
\r
1277 return INVOKERESULT_GENERIC_ERROR;
\r
1281 VOID_TO_NPVARIANT(result);
\r
1282 return INVOKERESULT_NO_ERROR;
\r
1285 return INVOKERESULT_NO_SUCH_METHOD;
\r
1287 if( argCount == 0 )
\r
1289 libvlc_playlist_clear(p_plugin->getVLC(), &ex);
\r
1290 if( libvlc_exception_raised(&ex) )
\r
1292 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1293 libvlc_exception_clear(&ex);
\r
1294 return INVOKERESULT_GENERIC_ERROR;
\r
1298 VOID_TO_NPVARIANT(result);
\r
1299 return INVOKERESULT_NO_ERROR;
\r
1302 return INVOKERESULT_NO_SUCH_METHOD;
\r
1303 case ID_removeitem:
\r
1304 if( (argCount == 1) && isNumberValue(args[0]) )
\r
1306 libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);
\r
1307 if( libvlc_exception_raised(&ex) )
\r
1309 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1310 libvlc_exception_clear(&ex);
\r
1311 return INVOKERESULT_GENERIC_ERROR;
\r
1315 VOID_TO_NPVARIANT(result);
\r
1316 return INVOKERESULT_NO_ERROR;
\r
1319 return INVOKERESULT_NO_SUCH_METHOD;
\r
1321 return INVOKERESULT_NO_SUCH_METHOD;
\r
1324 return INVOKERESULT_GENERIC_ERROR;
\r
1327 void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options)
\r
1329 if( s.utf8length )
\r
1331 char *val = stringValue(s);
\r
1334 long capacity = 16;
\r
1335 char **options = (char **)malloc(capacity*sizeof(char *));
\r
1340 char *end = val + s.utf8length;
\r
1341 while( val < end )
\r
1343 // skip leading blanks
\r
1344 while( (val < end)
\r
1345 && ((*val == ' ' ) || (*val == '\t')) )
\r
1348 char *start = val;
\r
1349 // skip till we get a blank character
\r
1350 while( (val < end)
\r
1352 && (*val != '\t') )
\r
1354 char c = *(val++);
\r
1355 if( ('\'' == c) || ('"' == c) )
\r
1357 // skip till end of string
\r
1358 while( (val < end) && (*(val++) != c ) );
\r
1364 if( nOptions == capacity )
\r
1367 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
\r
1368 if( ! moreOptions )
\r
1370 /* failed to allocate more memory */
\r
1372 /* return what we got so far */
\r
1373 *i_options = nOptions;
\r
1374 *ppsz_options = options;
\r
1377 options = moreOptions;
\r
1380 options[nOptions++] = strdup(start);
\r
1383 // must be end of string
\r
1386 *i_options = nOptions;
\r
1387 *ppsz_options = options;
\r
1394 void LibvlcPlaylistNPObject::parseOptions(NPObject *obj, int *i_options, char*** ppsz_options)
\r
1396 /* WARNING: Safari does not implement NPN_HasProperty/NPN_HasMethod */
\r
1400 /* we are expecting to have a Javascript Array object */
\r
1401 NPIdentifier propId = NPN_GetStringIdentifier("length");
\r
1402 if( NPN_GetProperty(_instance, obj, propId, &value) )
\r
1404 int count = numberValue(value);
\r
1405 NPN_ReleaseVariantValue(&value);
\r
1409 long capacity = 16;
\r
1410 char **options = (char **)malloc(capacity*sizeof(char *));
\r
1415 while( nOptions < count )
\r
1417 propId = NPN_GetIntIdentifier(nOptions);
\r
1418 if( ! NPN_GetProperty(_instance, obj, propId, &value) )
\r
1419 /* return what we got so far */
\r
1422 if( ! NPVARIANT_IS_STRING(value) )
\r
1424 /* return what we got so far */
\r
1425 NPN_ReleaseVariantValue(&value);
\r
1429 if( nOptions == capacity )
\r
1432 char **moreOptions = (char **)realloc(options, capacity*sizeof(char*));
\r
1433 if( ! moreOptions )
\r
1435 /* failed to allocate more memory */
\r
1436 NPN_ReleaseVariantValue(&value);
\r
1437 /* return what we got so far */
\r
1438 *i_options = nOptions;
\r
1439 *ppsz_options = options;
\r
1442 options = moreOptions;
\r
1445 options[nOptions++] = stringValue(value);
\r
1447 *i_options = nOptions;
\r
1448 *ppsz_options = options;
\r
1455 ** implementation of libvlc video object
\r
1458 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
\r
1466 enum LibvlcVideoNPObjectPropertyIds
\r
1474 const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
\r
1476 RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
\r
1478 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
1481 libvlc_exception_t ex;
\r
1482 libvlc_exception_init(&ex);
\r
1484 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
\r
1485 if( libvlc_exception_raised(&ex) )
\r
1487 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1488 libvlc_exception_clear(&ex);
\r
1489 return INVOKERESULT_GENERIC_ERROR;
\r
1494 case ID_fullscreen:
\r
1496 int val = libvlc_get_fullscreen(p_input, &ex);
\r
1497 libvlc_input_free(p_input);
\r
1498 if( libvlc_exception_raised(&ex) )
\r
1500 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1501 libvlc_exception_clear(&ex);
\r
1502 return INVOKERESULT_GENERIC_ERROR;
\r
1504 BOOLEAN_TO_NPVARIANT(val, result);
\r
1505 return INVOKERESULT_NO_ERROR;
\r
1509 int val = libvlc_video_get_height(p_input, &ex);
\r
1510 libvlc_input_free(p_input);
\r
1511 if( libvlc_exception_raised(&ex) )
\r
1513 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1514 libvlc_exception_clear(&ex);
\r
1515 return INVOKERESULT_GENERIC_ERROR;
\r
1517 INT32_TO_NPVARIANT(val, result);
\r
1518 return INVOKERESULT_NO_ERROR;
\r
1522 int val = libvlc_video_get_width(p_input, &ex);
\r
1523 libvlc_input_free(p_input);
\r
1524 if( libvlc_exception_raised(&ex) )
\r
1526 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1527 libvlc_exception_clear(&ex);
\r
1528 return INVOKERESULT_GENERIC_ERROR;
\r
1530 INT32_TO_NPVARIANT(val, result);
\r
1531 return INVOKERESULT_NO_ERROR;
\r
1533 case ID_aspectratio:
\r
1535 NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
\r
1536 libvlc_input_free(p_input);
\r
1537 if( libvlc_exception_raised(&ex) )
\r
1539 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1540 libvlc_exception_clear(&ex);
\r
1541 return INVOKERESULT_GENERIC_ERROR;
\r
1544 return INVOKERESULT_GENERIC_ERROR;
\r
1546 STRINGZ_TO_NPVARIANT(psz_aspect, result);
\r
1547 return INVOKERESULT_NO_ERROR;
\r
1550 libvlc_input_free(p_input);
\r
1552 return INVOKERESULT_GENERIC_ERROR;
\r
1555 RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
\r
1557 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
1560 libvlc_exception_t ex;
\r
1561 libvlc_exception_init(&ex);
\r
1563 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
\r
1564 if( libvlc_exception_raised(&ex) )
\r
1566 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1567 libvlc_exception_clear(&ex);
\r
1568 return INVOKERESULT_GENERIC_ERROR;
\r
1573 case ID_fullscreen:
\r
1575 if( ! NPVARIANT_IS_BOOLEAN(value) )
\r
1577 libvlc_input_free(p_input);
\r
1578 return INVOKERESULT_INVALID_VALUE;
\r
1581 int val = NPVARIANT_TO_BOOLEAN(value);
\r
1582 libvlc_set_fullscreen(p_input, val, &ex);
\r
1583 libvlc_input_free(p_input);
\r
1584 if( libvlc_exception_raised(&ex) )
\r
1586 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1587 libvlc_exception_clear(&ex);
\r
1588 return INVOKERESULT_GENERIC_ERROR;
\r
1590 return INVOKERESULT_NO_ERROR;
\r
1592 case ID_aspectratio:
\r
1594 char *psz_aspect = NULL;
\r
1596 if( ! NPVARIANT_IS_STRING(value) )
\r
1598 libvlc_input_free(p_input);
\r
1599 return INVOKERESULT_INVALID_VALUE;
\r
1602 psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
\r
1604 return INVOKERESULT_GENERIC_ERROR;
\r
1606 libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
\r
1608 free(psz_aspect );
\r
1610 libvlc_input_free(p_input);
\r
1611 if( libvlc_exception_raised(&ex) )
\r
1613 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1614 libvlc_exception_clear(&ex);
\r
1615 return INVOKERESULT_GENERIC_ERROR;
\r
1617 return INVOKERESULT_NO_ERROR;
\r
1620 libvlc_input_free(p_input);
\r
1622 return INVOKERESULT_GENERIC_ERROR;
\r
1625 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
\r
1627 "toggleFullscreen",
\r
1630 enum LibvlcVideoNPObjectMethodIds
\r
1632 ID_togglefullscreen,
\r
1635 const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *);
\r
1637 RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
\r
1639 VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
\r
1642 libvlc_exception_t ex;
\r
1643 libvlc_exception_init(&ex);
\r
1645 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
\r
1646 if( libvlc_exception_raised(&ex) )
\r
1648 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1649 libvlc_exception_clear(&ex);
\r
1650 return INVOKERESULT_GENERIC_ERROR;
\r
1655 case ID_togglefullscreen:
\r
1656 if( argCount == 0 )
\r
1658 libvlc_toggle_fullscreen(p_input, &ex);
\r
1659 libvlc_input_free(p_input);
\r
1660 if( libvlc_exception_raised(&ex) )
\r
1662 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1663 libvlc_exception_clear(&ex);
\r
1664 return INVOKERESULT_GENERIC_ERROR;
\r
1668 VOID_TO_NPVARIANT(result);
\r
1669 return INVOKERESULT_NO_ERROR;
\r
1674 /* cannot get input, probably not playing */
\r
1675 if( libvlc_exception_raised(&ex) )
\r
1677 NPN_SetException(this, libvlc_exception_get_message(&ex));
\r
1678 libvlc_exception_clear(&ex);
\r
1680 return INVOKERESULT_GENERIC_ERROR;
\r
1682 return INVOKERESULT_NO_SUCH_METHOD;
\r
1684 return INVOKERESULT_NO_SUCH_METHOD;
\r
1687 return INVOKERESULT_GENERIC_ERROR;
\r