Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
056c9fe3
Commit
056c9fe3
authored
Oct 28, 2006
by
Damien Fouilleul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added log APIs to javascript for mozilla
parent
3a168d9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
582 additions
and
1 deletion
+582
-1
mozilla/control/npolibvlc.cpp
mozilla/control/npolibvlc.cpp
+455
-0
mozilla/control/npolibvlc.h
mozilla/control/npolibvlc.h
+127
-1
No files found.
mozilla/control/npolibvlc.cpp
View file @
056c9fe3
...
...
@@ -43,6 +43,7 @@ LibvlcRootNPObject::LibvlcRootNPObject(NPP instance, const NPClass *aClass) :
{
audioObj
=
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcAudioNPObject
>::
getClass
());
inputObj
=
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcInputNPObject
>::
getClass
());
logObj
=
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcLogNPObject
>::
getClass
());
playlistObj
=
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcPlaylistNPObject
>::
getClass
());
videoObj
=
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcVideoNPObject
>::
getClass
());
}
...
...
@@ -51,6 +52,7 @@ LibvlcRootNPObject::~LibvlcRootNPObject()
{
NPN_ReleaseObject
(
audioObj
);
NPN_ReleaseObject
(
inputObj
);
NPN_ReleaseObject
(
logObj
);
NPN_ReleaseObject
(
playlistObj
);
NPN_ReleaseObject
(
videoObj
);
}
...
...
@@ -494,6 +496,459 @@ const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
const
int
LibvlcInputNPObject
::
methodCount
=
sizeof
(
LibvlcInputNPObject
::
methodNames
)
/
sizeof
(
NPUTF8
*
);
/*
** implementation of libvlc message object
*/
const
NPUTF8
*
const
LibvlcMessageNPObject
::
propertyNames
[]
=
{
"severity"
,
"type"
,
"name"
,
"header"
,
"message"
,
};
const
int
LibvlcMessageNPObject
::
propertyCount
=
sizeof
(
LibvlcMessageNPObject
::
propertyNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcMessageNPObjectPropertyIds
{
ID_severity
,
ID_type
,
ID_name
,
ID_header
,
ID_message
,
};
RuntimeNPObject
::
InvokeResult
LibvlcMessageNPObject
::
getProperty
(
int
index
,
NPVariant
&
result
)
{
switch
(
index
)
{
case
ID_severity
:
{
INT32_TO_NPVARIANT
(
_msg
.
i_severity
,
result
);
return
INVOKERESULT_NO_ERROR
;
}
case
ID_type
:
{
if
(
_msg
.
psz_type
)
{
int
len
=
strlen
(
_msg
.
psz_type
);
NPUTF8
*
retval
=
(
NPUTF8
*
)
NPN_MemAlloc
(
len
);
if
(
retval
)
{
memcpy
(
retval
,
_msg
.
psz_type
,
len
);
STRINGN_TO_NPVARIANT
(
retval
,
len
,
result
);
}
}
else
{
NULL_TO_NPVARIANT
(
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
case
ID_name
:
{
if
(
_msg
.
psz_name
)
{
int
len
=
strlen
(
_msg
.
psz_name
);
NPUTF8
*
retval
=
(
NPUTF8
*
)
NPN_MemAlloc
(
len
);
if
(
retval
)
{
memcpy
(
retval
,
_msg
.
psz_name
,
len
);
STRINGN_TO_NPVARIANT
(
retval
,
len
,
result
);
}
}
else
{
NULL_TO_NPVARIANT
(
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
case
ID_header
:
{
if
(
_msg
.
psz_header
)
{
int
len
=
strlen
(
_msg
.
psz_header
);
NPUTF8
*
retval
=
(
NPUTF8
*
)
NPN_MemAlloc
(
len
);
if
(
retval
)
{
memcpy
(
retval
,
_msg
.
psz_header
,
len
);
STRINGN_TO_NPVARIANT
(
retval
,
len
,
result
);
}
}
else
{
NULL_TO_NPVARIANT
(
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
case
ID_message
:
{
if
(
_msg
.
psz_message
)
{
int
len
=
strlen
(
_msg
.
psz_message
);
NPUTF8
*
retval
=
(
NPUTF8
*
)
NPN_MemAlloc
(
len
);
if
(
retval
)
{
memcpy
(
retval
,
_msg
.
psz_message
,
len
);
STRINGN_TO_NPVARIANT
(
retval
,
len
,
result
);
}
}
else
{
NULL_TO_NPVARIANT
(
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
const
NPUTF8
*
const
LibvlcMessageNPObject
::
methodNames
[]
=
{
/* no methods */
};
const
int
LibvlcMessageNPObject
::
methodCount
=
sizeof
(
LibvlcMessageNPObject
::
methodNames
)
/
sizeof
(
NPUTF8
*
);
/*
** implementation of libvlc message iterator object
*/
void
LibvlcMessageIteratorNPObject
::
setLog
(
LibvlcLogNPObject
*
p_vlclog
)
{
_p_vlclog
=
p_vlclog
;
if
(
p_vlclog
->
_p_log
)
{
_p_iter
=
libvlc_log_get_iterator
(
p_vlclog
->
_p_log
,
NULL
);
}
else
_p_iter
=
NULL
;
};
const
NPUTF8
*
const
LibvlcMessageIteratorNPObject
::
propertyNames
[]
=
{
"hasNext"
,
};
const
int
LibvlcMessageIteratorNPObject
::
propertyCount
=
sizeof
(
LibvlcMessageIteratorNPObject
::
propertyNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcMessageIteratorNPObjectPropertyIds
{
ID_hasNext
,
};
RuntimeNPObject
::
InvokeResult
LibvlcMessageIteratorNPObject
::
getProperty
(
int
index
,
NPVariant
&
result
)
{
switch
(
index
)
{
case
ID_hasNext
:
{
if
(
_p_iter
&&
_p_vlclog
->
_p_log
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
BOOLEAN_TO_NPVARIANT
(
libvlc_log_iterator_has_next
(
_p_iter
,
&
ex
),
result
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
else
{
BOOLEAN_TO_NPVARIANT
(
0
,
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
const
NPUTF8
*
const
LibvlcMessageIteratorNPObject
::
methodNames
[]
=
{
"next"
,
};
const
int
LibvlcMessageIteratorNPObject
::
methodCount
=
sizeof
(
LibvlcMessageIteratorNPObject
::
methodNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcMessageIteratorNPObjectMethodIds
{
ID_messageiterator_next
,
};
RuntimeNPObject
::
InvokeResult
LibvlcMessageIteratorNPObject
::
invoke
(
int
index
,
const
NPVariant
*
args
,
uint32_t
argCount
,
NPVariant
&
result
)
{
if
(
_p_iter
&&
_p_vlclog
->
_p_log
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
switch
(
index
)
{
case
ID_messageiterator_next
:
if
(
argCount
==
0
)
{
struct
libvlc_log_message_t
buffer
;
buffer
.
sizeof_msg
=
sizeof
(
buffer
);
libvlc_log_iterator_next
(
_p_iter
,
&
buffer
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
else
{
LibvlcMessageNPObject
*
message
=
static_cast
<
LibvlcMessageNPObject
*>
(
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcMessageNPObject
>::
getClass
()));
if
(
message
)
{
message
->
setMessage
(
buffer
);
OBJECT_TO_NPVARIANT
(
message
,
result
);
return
INVOKERESULT_NO_ERROR
;
}
return
INVOKERESULT_OUT_OF_MEMORY
;
}
}
default:
return
INVOKERESULT_NO_SUCH_METHOD
;
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
/*
** implementation of libvlc message object
*/
const
NPUTF8
*
const
LibvlcMessagesNPObject
::
propertyNames
[]
=
{
"count"
,
};
const
int
LibvlcMessagesNPObject
::
propertyCount
=
sizeof
(
LibvlcMessagesNPObject
::
propertyNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcMessagesNPObjectPropertyIds
{
ID_count
,
};
RuntimeNPObject
::
InvokeResult
LibvlcMessagesNPObject
::
getProperty
(
int
index
,
NPVariant
&
result
)
{
switch
(
index
)
{
case
ID_count
:
{
libvlc_log_t
*
p_log
=
_p_vlclog
->
_p_log
;
if
(
p_log
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
INT32_TO_NPVARIANT
(
libvlc_log_count
(
p_log
,
&
ex
),
result
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
else
{
INT32_TO_NPVARIANT
(
0
,
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
const
NPUTF8
*
const
LibvlcMessagesNPObject
::
methodNames
[]
=
{
"clear"
,
"iterator"
,
};
const
int
LibvlcMessagesNPObject
::
methodCount
=
sizeof
(
LibvlcMessagesNPObject
::
methodNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcMessagesNPObjectMethodIds
{
ID_messages_clear
,
ID_iterator
,
};
RuntimeNPObject
::
InvokeResult
LibvlcMessagesNPObject
::
invoke
(
int
index
,
const
NPVariant
*
args
,
uint32_t
argCount
,
NPVariant
&
result
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
switch
(
index
)
{
case
ID_messages_clear
:
if
(
argCount
==
0
)
{
libvlc_log_t
*
p_log
=
_p_vlclog
->
_p_log
;
if
(
p_log
)
{
libvlc_log_clear
(
p_log
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
return
INVOKERESULT_NO_ERROR
;
}
return
INVOKERESULT_NO_SUCH_METHOD
;
case
ID_iterator
:
if
(
argCount
==
0
)
{
LibvlcMessageIteratorNPObject
*
iter
=
static_cast
<
LibvlcMessageIteratorNPObject
*>
(
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcMessageIteratorNPObject
>::
getClass
()));
if
(
iter
)
{
iter
->
setLog
(
_p_vlclog
);
OBJECT_TO_NPVARIANT
(
iter
,
result
);
return
INVOKERESULT_NO_ERROR
;
}
return
INVOKERESULT_OUT_OF_MEMORY
;
}
return
INVOKERESULT_NO_SUCH_METHOD
;
default:
return
INVOKERESULT_NO_SUCH_METHOD
;
}
return
INVOKERESULT_GENERIC_ERROR
;
}
/*
** implementation of libvlc message object
*/
const
NPUTF8
*
const
LibvlcLogNPObject
::
propertyNames
[]
=
{
"messages"
,
"verbosity"
,
};
const
int
LibvlcLogNPObject
::
propertyCount
=
sizeof
(
LibvlcLogNPObject
::
propertyNames
)
/
sizeof
(
NPUTF8
*
);
enum
LibvlcLogNPObjectPropertyIds
{
ID_messages
,
ID_verbosity
,
};
RuntimeNPObject
::
InvokeResult
LibvlcLogNPObject
::
getProperty
(
int
index
,
NPVariant
&
result
)
{
VlcPlugin
*
p_plugin
=
reinterpret_cast
<
VlcPlugin
*>
(
_instance
->
pdata
);
if
(
p_plugin
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
switch
(
index
)
{
case
ID_messages
:
{
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
_p_vlcmessages
),
result
);
return
INVOKERESULT_NO_ERROR
;
}
case
ID_verbosity
:
{
if
(
_p_log
)
{
INT32_TO_NPVARIANT
(
libvlc_get_log_verbosity
(
p_plugin
->
getVLC
(),
&
ex
),
result
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
else
{
/* log is not enabled, return -1 */
DOUBLE_TO_NPVARIANT
(
-
1.0
,
result
);
}
return
INVOKERESULT_NO_ERROR
;
}
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
RuntimeNPObject
::
InvokeResult
LibvlcLogNPObject
::
setProperty
(
int
index
,
const
NPVariant
&
value
)
{
VlcPlugin
*
p_plugin
=
reinterpret_cast
<
VlcPlugin
*>
(
_instance
->
pdata
);
if
(
p_plugin
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
switch
(
index
)
{
case
ID_verbosity
:
if
(
isNumberValue
(
value
)
)
{
libvlc_instance_t
*
p_libvlc
=
p_plugin
->
getVLC
();
int
verbosity
=
numberValue
(
value
);
if
(
verbosity
>=
0
)
{
if
(
!
_p_log
)
{
_p_log
=
libvlc_log_open
(
p_libvlc
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
libvlc_set_log_verbosity
(
p_libvlc
,
(
unsigned
)
verbosity
,
&
ex
);
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
else
if
(
_p_log
)
{
/* close log when verbosity is set to -1 */
libvlc_log_close
(
_p_log
,
&
ex
);
_p_log
=
NULL
;
if
(
libvlc_exception_raised
(
&
ex
)
)
{
NPN_SetException
(
this
,
libvlc_exception_get_message
(
&
ex
));
libvlc_exception_clear
(
&
ex
);
return
INVOKERESULT_GENERIC_ERROR
;
}
}
return
INVOKERESULT_NO_ERROR
;
}
return
INVOKERESULT_INVALID_VALUE
;
}
}
return
INVOKERESULT_GENERIC_ERROR
;
}
const
NPUTF8
*
const
LibvlcLogNPObject
::
methodNames
[]
=
{
/* no methods */
};
const
int
LibvlcLogNPObject
::
methodCount
=
sizeof
(
LibvlcLogNPObject
::
methodNames
)
/
sizeof
(
NPUTF8
*
);
/*
** implementation of libvlc playlist object
*/
...
...
mozilla/control/npolibvlc.h
View file @
056c9fe3
...
...
@@ -23,6 +23,7 @@
/*
** defined runtime script objects
*/
#include <vlc/libvlc.h>
#include "nporuntime.h"
...
...
@@ -44,6 +45,7 @@ protected:
NPObject
*
audioObj
;
NPObject
*
inputObj
;
NPObject
*
logObj
;
NPObject
*
playlistObj
;
NPObject
*
videoObj
;
};
...
...
@@ -76,7 +78,7 @@ protected:
LibvlcInputNPObject
(
NPP
instance
,
const
NPClass
*
aClass
)
:
RuntimeNPObject
(
instance
,
aClass
)
{};
virtual
~
LibvlcInputNPObject
()
{};
static
const
int
propertyCount
;
...
...
@@ -89,6 +91,130 @@ protected:
static
const
NPUTF8
*
const
methodNames
[];
};
class
LibvlcMessageNPObject
:
public
RuntimeNPObject
{
public:
void
setMessage
(
struct
libvlc_log_message_t
&
msg
)
{
_msg
=
msg
;
};
protected:
friend
class
RuntimeNPClass
<
LibvlcMessageNPObject
>
;
LibvlcMessageNPObject
(
NPP
instance
,
const
NPClass
*
aClass
)
:
RuntimeNPObject
(
instance
,
aClass
)
{};
virtual
~
LibvlcMessageNPObject
()
{};
static
const
int
propertyCount
;
static
const
NPUTF8
*
const
propertyNames
[];
InvokeResult
getProperty
(
int
index
,
NPVariant
&
result
);
static
const
int
methodCount
;
static
const
NPUTF8
*
const
methodNames
[];
private:
struct
libvlc_log_message_t
_msg
;
};
class
LibvlcLogNPObject
;
class
LibvlcMessageIteratorNPObject
:
public
RuntimeNPObject
{
public:
void
setLog
(
LibvlcLogNPObject
*
p_vlclog
);
protected:
friend
class
RuntimeNPClass
<
LibvlcMessageIteratorNPObject
>
;
LibvlcMessageIteratorNPObject
(
NPP
instance
,
const
NPClass
*
aClass
)
:
RuntimeNPObject
(
instance
,
aClass
)
{};
virtual
~
LibvlcMessageIteratorNPObject
()
{};
static
const
int
propertyCount
;
static
const
NPUTF8
*
const
propertyNames
[];
InvokeResult
getProperty
(
int
index
,
NPVariant
&
result
);
static
const
int
methodCount
;
static
const
NPUTF8
*
const
methodNames
[];
InvokeResult
invoke
(
int
index
,
const
NPVariant
*
args
,
uint32_t
argCount
,
NPVariant
&
result
);
private:
LibvlcLogNPObject
*
_p_vlclog
;
libvlc_log_iterator_t
*
_p_iter
;
};
class
LibvlcMessagesNPObject
:
public
RuntimeNPObject
{
public:
void
setLog
(
LibvlcLogNPObject
*
p_log
)
{
_p_vlclog
=
p_log
;
}
protected:
friend
class
RuntimeNPClass
<
LibvlcMessagesNPObject
>
;
LibvlcMessagesNPObject
(
NPP
instance
,
const
NPClass
*
aClass
)
:
_p_vlclog
(
NULL
),
RuntimeNPObject
(
instance
,
aClass
)
{};
virtual
~
LibvlcMessagesNPObject
()
{};
static
const
int
propertyCount
;
static
const
NPUTF8
*
const
propertyNames
[];
InvokeResult
getProperty
(
int
index
,
NPVariant
&
result
);
static
const
int
methodCount
;
static
const
NPUTF8
*
const
methodNames
[];
InvokeResult
invoke
(
int
index
,
const
NPVariant
*
args
,
uint32_t
argCount
,
NPVariant
&
result
);
private:
LibvlcLogNPObject
*
_p_vlclog
;
};
class
LibvlcLogNPObject
:
public
RuntimeNPObject
{
protected:
friend
class
RuntimeNPClass
<
LibvlcLogNPObject
>
;
friend
class
LibvlcMessagesNPObject
;
friend
class
LibvlcMessageIteratorNPObject
;
libvlc_log_t
*
_p_log
;
LibvlcLogNPObject
(
NPP
instance
,
const
NPClass
*
aClass
)
:
RuntimeNPObject
(
instance
,
aClass
),
_p_log
(
NULL
)
{
_p_vlcmessages
=
static_cast
<
LibvlcMessagesNPObject
*>
(
NPN_CreateObject
(
instance
,
RuntimeNPClass
<
LibvlcMessagesNPObject
>::
getClass
()));
_p_vlcmessages
->
setLog
(
this
);
};
virtual
~
LibvlcLogNPObject
()
{
NPN_ReleaseObject
(
_p_vlcmessages
);
};
static
const
int
propertyCount
;
static
const
NPUTF8
*
const
propertyNames
[];
InvokeResult
getProperty
(
int
index
,
NPVariant
&
result
);
InvokeResult
setProperty
(
int
index
,
const
NPVariant
&
value
);
static
const
int
methodCount
;
static
const
NPUTF8
*
const
methodNames
[];
private:
LibvlcMessagesNPObject
*
_p_vlcmessages
;
};
class
LibvlcPlaylistNPObject
:
public
RuntimeNPObject
{
protected:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment