Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
12c291f0
Commit
12c291f0
authored
May 19, 2007
by
Filippo Carone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial callback support in libvlc + example on how to use in the java bindings
parent
6baab07e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
154 additions
and
59 deletions
+154
-59
bindings/java/VLCExample.java
bindings/java/VLCExample.java
+8
-0
bindings/java/includes/Audio.h
bindings/java/includes/Audio.h
+8
-0
bindings/java/org/videolan/jvlc/Audio.java
bindings/java/org/videolan/jvlc/Audio.java
+91
-41
bindings/java/src/Makefile.am
bindings/java/src/Makefile.am
+3
-1
bindings/java/src/core-jni.cc
bindings/java/src/core-jni.cc
+1
-1
include/vlc/libvlc.h
include/vlc/libvlc.h
+12
-11
include/vlc/libvlc_structures.h
include/vlc/libvlc_structures.h
+9
-2
src/Makefile.am
src/Makefile.am
+2
-0
src/control/core.c
src/control/core.c
+1
-1
src/control/libvlc_internal.h
src/control/libvlc_internal.h
+19
-2
No files found.
bindings/java/VLCExample.java
View file @
12c291f0
import
org.videolan.jvlc.AudioIntf
;
import
org.videolan.jvlc.JVLC
;
import
org.videolan.jvlc.VLCException
;
import
org.videolan.jvlc.VolumeListener
;
public
class
VLCExample
...
...
@@ -83,6 +84,13 @@ public class VLCExample
jvlc
.
video
.
setSize
(
300
,
300
);
}
jvlc
.
audio
.
addVolumeListener
(
new
VolumeListener
()
{
public
void
volumeChanged
()
{
System
.
out
.
println
(
"====> From the listener: volume changed"
);
}
});
System
.
out
.
print
(
"Muting..."
);
jvlc
.
audio
.
setMute
(
true
);
Thread
.
sleep
(
3000
);
...
...
bindings/java/includes/Audio.h
View file @
12c291f0
...
...
@@ -79,6 +79,14 @@ JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getVolume
JNIEXPORT
void
JNICALL
Java_org_videolan_jvlc_Audio__1setVolume
(
JNIEnv
*
,
jobject
,
jint
);
/*
* Class: org_videolan_jvlc_Audio
* Method: _install_callback
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_org_videolan_jvlc_Audio__1install_1callback
(
JNIEnv
*
,
jobject
);
#ifdef __cplusplus
}
#endif
...
...
bindings/java/org/videolan/jvlc/Audio.java
View file @
12c291f0
package
org.videolan.jvlc
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
public
class
Audio
implements
AudioIntf
{
private
long
libvlcInstance
;
private
native
int
_getTrack
();
private
native
void
_setTrack
(
int
track
);
private
native
int
_getChannel
();
private
native
void
_setChannel
(
int
channel
);
private
native
boolean
_getMute
();
private
native
void
_setMute
(
boolean
value
);
private
native
void
_toggleMute
();
private
native
int
_getVolume
();
private
native
void
_setVolume
(
int
volume
);
public
Audio
(
long
instance
)
{
this
.
libvlcInstance
=
instance
;
}
private
native
int
_getTrack
();
private
native
void
_setTrack
(
int
track
);
private
native
int
_getChannel
();
private
native
void
_setChannel
(
int
channel
);
private
native
boolean
_getMute
();
private
native
void
_setMute
(
boolean
value
);
private
native
void
_toggleMute
();
private
native
int
_getVolume
();
private
native
void
_setVolume
(
int
volume
);
private
native
void
_install_callback
();
private
static
Map
objListeners
=
new
HashMap
();
public
Audio
(
long
instance
)
{
this
.
libvlcInstance
=
instance
;
install_callaback
();
}
private
void
install_callaback
()
{
objListeners
.
put
(
this
,
new
HashSet
());
_install_callback
();
}
public
int
getTrack
()
throws
VLCException
{
return
_getTrack
();
}
public
void
setTrack
(
int
track
)
throws
VLCException
{
public
void
setTrack
(
int
track
)
throws
VLCException
{
_setTrack
(
track
);
}
...
...
@@ -30,32 +54,58 @@ public class Audio implements AudioIntf {
return
_getChannel
();
}
public
void
setChannel
(
int
channel
)
throws
VLCException
{
public
void
setChannel
(
int
channel
)
throws
VLCException
{
_setChannel
(
channel
);
}
public
boolean
getMute
()
throws
VLCException
{
return
_getMute
();
}
public
void
setMute
(
boolean
value
)
throws
VLCException
{
_setMute
(
value
);
}
public
void
toggleMute
()
throws
VLCException
{
_toggleMute
();
}
public
int
getVolume
()
throws
VLCException
{
return
_getVolume
();
}
public
void
setVolume
(
int
volume
)
throws
VLCException
{
_setVolume
(
volume
);
}
}
public
boolean
getMute
()
throws
VLCException
{
return
_getMute
();
}
public
void
setMute
(
boolean
value
)
throws
VLCException
{
_setMute
(
value
);
}
public
void
toggleMute
()
throws
VLCException
{
_toggleMute
();
}
public
int
getVolume
()
throws
VLCException
{
return
_getVolume
();
}
public
void
setVolume
(
int
volume
)
throws
VLCException
{
_setVolume
(
volume
);
}
public
boolean
addVolumeListener
(
VolumeListener
listener
)
{
HashSet
listeners
=
(
HashSet
)
objListeners
.
get
(
this
);
return
listeners
.
add
(
listener
);
}
public
boolean
removeVolumeListener
(
VolumeListener
listener
)
{
HashSet
listeners
=
(
HashSet
)
objListeners
.
get
(
this
);
return
listeners
.
remove
(
listener
);
}
// this method is invoked natively
private
static
void
wakeupListeners
()
{
Set
audioObjects
=
objListeners
.
keySet
();
Iterator
audioObjectsIterator
=
audioObjects
.
iterator
();
while
(
audioObjectsIterator
.
hasNext
())
{
Audio
audioObject
=
(
Audio
)
audioObjectsIterator
.
next
();
HashSet
listeners
=
(
HashSet
)
objListeners
.
get
(
audioObject
);
Iterator
listenerIterator
=
listeners
.
iterator
();
while
(
listenerIterator
.
hasNext
())
{
VolumeListener
listener
=
(
VolumeListener
)
listenerIterator
.
next
();
listener
.
volumeChanged
();
}
}
}
public
long
getInstance
()
{
return
libvlcInstance
;
}
...
...
bindings/java/src/Makefile.am
View file @
12c291f0
...
...
@@ -7,7 +7,9 @@ libjvlc_la_SOURCES = \
utils.cc
\
utils.h
\
video-jni.cc
\
vlm-jni.cc
vlm-jni.cc
\
callback-jni.cc
libjvlc_la_CPPFLAGS
=
`
$(VLC_CONFIG)
--cflags
pic
`
$(JINCLUDES)
libjvlc_la_LIBADD
=
../../../src/libvlc-control.la
$(LIBJINCLUDES)
...
...
bindings/java/src/core-jni.cc
View file @
12c291f0
...
...
@@ -70,7 +70,7 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance (JNIEnv *env,
res
=
(
long
)
libvlc_new
(
argc
,
(
char
**
)
argv
,
exception
);
free
(
exception
);
return
res
;
}
...
...
include/vlc/libvlc.h
View file @
12c291f0
...
...
@@ -803,26 +803,27 @@ VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterat
* Register for a callback notification
* \param p_instance the libvlc instance
* \param i_event_type the desired event mask to which we want to listen
* \param pf_callback function the function to call when an_Event occurs
* \param f_callback the function to call when i_event_type occurs
* \param user_data user provided data to carry with the event
* \param p_e an initialized exception pointer
*/
/* void libvlc_callback_register_for_eventtype( libvlc_instance_t *p_instance, */
/* libvlc_event_type_t i_event_type, */
/* libvlc_callback_t pf_callback, */
/* libvlc_exception_t *p_e ); */
VLC_PUBLIC_API
void
libvlc_callback_register_for_event
(
libvlc_instance_t
*
p_instance
,
libvlc_event_type_t
i_event_type
,
libvlc_callback_t
f_callback
,
void
*
user_data
,
libvlc_exception_t
*
p_e
);
/**
* Unregister a callback notification
* \param p_instance the libvlc instance
* \param i_event_type the desired event mask to which we want to unregister
* \param
pf_function the function to call when an_Event
occurs
* \param
f_callback the function to call when i_event_type
occurs
* \param p_e an initialized exception pointer
*/
/* void libvlc_callback_unregister_for_eventtype( libvlc_instance_t *p_instance, */
/* libvlc_event_type_t i_event_type, */
/* libvlc_callback_t pf_function, */
/* libvlc_exception_t *p_e ); */
VLC_PUBLIC_API
void
libvlc_callback_unregister_for_event
(
libvlc_instance_t
*
p_instance
,
libvlc_event_type_t
i_event_type
,
libvlc_callback_t
f_callback
,
libvlc_exception_t
*
p_e
);
/** @} */
...
...
include/vlc/libvlc_structures.h
View file @
12c291f0
...
...
@@ -154,8 +154,15 @@ typedef struct
libvlc_event_type_t
type
;
char
reserved
[
8
];
/* For future use */
}
libvlc_event_t
;
typedef
void
(
*
libvlc_callback_t
)(
struct
libvlc_instance_t
*
,
libvlc_event_t
*
);
/**
* Callback function notification
* \param p_instance the libvlc instance
* \param p_event the event triggering the callback
* \param p_user_data user provided data
*/
typedef
void
(
*
libvlc_callback_t
)(
struct
libvlc_instance_t
*
,
libvlc_event_t
*
,
void
*
);
/**@} */
...
...
src/Makefile.am
View file @
12c291f0
...
...
@@ -24,6 +24,7 @@ pkgincludedir = $(includedir)/vlc
dist_pkginclude_HEADERS
=
\
../include/vlc/vlc.h
\
../include/vlc/libvlc.h
\
../include/vlc/libvlc_structures.h
\
../include/vlc/mediacontrol.h
\
../include/vlc/mediacontrol_structures.h
\
$(NULL)
...
...
@@ -326,6 +327,7 @@ SOURCES_libvlc_control = \
control/input.c
\
control/video.c
\
control/audio.c
\
control/callback.c
\
control/mediacontrol_internal.h
\
control/mediacontrol_core.c
\
control/mediacontrol_util.c
\
...
...
src/control/core.c
View file @
12c291f0
...
...
@@ -111,7 +111,7 @@ void libvlc_destroy( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
while
(
p_listitem
)
{
struct
libvlc_callback_entry_list
*
p_nextlistitem
=
p_listitem
->
next
;
struct
libvlc_callback_entry_list
_t
*
p_nextlistitem
=
p_listitem
->
next
;
free
(
p_listitem
);
p_listitem
=
p_nextlistitem
;
}
...
...
src/control/libvlc_internal.h
View file @
12c291f0
...
...
@@ -49,8 +49,9 @@ VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char *, vlc_boo
struct
libvlc_callback_entry_t
{
libvlc_callback_t
callback
;
libvlc_event_type_t
eventType
;
libvlc_instance_t
*
p_instance
;
libvlc_callback_t
f_callback
;
libvlc_event_type_t
i_event_type
;
void
*
p_user_data
;
};
...
...
@@ -77,6 +78,22 @@ struct libvlc_input_t
struct
libvlc_instance_t
*
p_instance
;
///< Parent instance
};
static
inline
void
add_callback_entry
(
struct
libvlc_callback_entry_t
*
entry
,
struct
libvlc_callback_entry_list_t
**
list
)
{
struct
libvlc_callback_entry_list_t
*
new_listitem
;
new_listitem
=
malloc
(
sizeof
(
struct
libvlc_callback_entry_list_t
)
);
new_listitem
->
elmt
=
entry
;
new_listitem
->
next
=
*
list
;
new_listitem
->
prev
=
NULL
;
if
(
*
list
)
(
*
list
)
->
prev
=
new_listitem
;
*
list
=
new_listitem
;
}
#define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
return NULL; }
#define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
...
...
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