Changeset 12c291f038deb29afafc050b67b81df6786fc2b9
- Timestamp:
- 20/05/07 01:11:39 (2 years ago)
- git-parent:
- Files:
-
- bindings/java/VLCExample.java (modified) (2 diffs)
- bindings/java/includes/Audio.h (modified) (1 diff)
- bindings/java/org/videolan/jvlc/Audio.java (modified) (2 diffs)
- bindings/java/src/Makefile.am (modified) (1 diff)
- bindings/java/src/core-jni.cc (modified) (1 diff)
- include/vlc/libvlc.h (modified) (2 diffs)
- include/vlc/libvlc_structures.h (modified) (1 diff)
- src/Makefile.am (modified) (2 diffs)
- src/control/core.c (modified) (1 diff)
- src/control/libvlc_internal.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bindings/java/VLCExample.java
r6a84cf1 r12c291f 2 2 import org.videolan.jvlc.JVLC; 3 3 import org.videolan.jvlc.VLCException; 4 import org.videolan.jvlc.VolumeListener; 4 5 5 6 … … 84 85 85 86 } 87 jvlc.audio.addVolumeListener(new VolumeListener() 88 { 89 public void volumeChanged() { 90 System.out.println("====> From the listener: volume changed"); 91 } 92 }); 93 86 94 System.out.print("Muting..."); 87 95 jvlc.audio.setMute(true); bindings/java/includes/Audio.h
r8b8a684 r12c291f 80 80 (JNIEnv *, jobject, jint); 81 81 82 /* 83 * Class: org_videolan_jvlc_Audio 84 * Method: _install_callback 85 * Signature: ()V 86 */ 87 JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1install_1callback 88 (JNIEnv *, jobject); 89 82 90 #ifdef __cplusplus 83 91 } bindings/java/org/videolan/jvlc/Audio.java
rd959364 r12c291f 1 1 package org.videolan.jvlc; 2 2 3 import java.util.HashMap; 4 import java.util.HashSet; 5 import java.util.Iterator; 6 import java.util.Map; 7 import java.util.Set; 8 3 9 public class Audio implements AudioIntf { 4 10 5 11 private long libvlcInstance; 6 12 7 private native int _getTrack(); 8 private native void _setTrack(int track); 9 private native int _getChannel(); 10 private native void _setChannel(int channel); 11 private native boolean _getMute(); 12 private native void _setMute( boolean value ); 13 private native void _toggleMute(); 14 private native int _getVolume(); 15 private native void _setVolume( int volume ); 16 17 public Audio( long instance ) { 18 this.libvlcInstance = instance; 19 } 20 13 private native int _getTrack(); 14 15 private native void _setTrack(int track); 16 17 private native int _getChannel(); 18 19 private native void _setChannel(int channel); 20 21 private native boolean _getMute(); 22 23 private native void _setMute(boolean value); 24 25 private native void _toggleMute(); 26 27 private native int _getVolume(); 28 29 private native void _setVolume(int volume); 30 31 private native void _install_callback(); 32 33 private static Map objListeners = new HashMap(); 34 35 public Audio(long instance) { 36 this.libvlcInstance = instance; 37 install_callaback(); 38 } 39 40 private void install_callaback() { 41 objListeners.put(this, new HashSet()); 42 _install_callback(); 43 } 44 21 45 public int getTrack() throws VLCException { 22 46 return _getTrack(); 23 47 } 24 48 25 public void setTrack( int track) throws VLCException {49 public void setTrack(int track) throws VLCException { 26 50 _setTrack(track); 27 51 } … … 31 55 } 32 56 33 public void setChannel( int channel) throws VLCException {57 public void setChannel(int channel) throws VLCException { 34 58 _setChannel(channel); 35 } 36 37 public boolean getMute() throws VLCException { 38 return _getMute(); 39 } 59 } 40 60 41 public void setMute( boolean value ) throws VLCException { 42 _setMute( value ); 43 44 } 45 46 public void toggleMute() throws VLCException { 47 _toggleMute(); 48 } 61 public boolean getMute() throws VLCException { 62 return _getMute(); 63 } 49 64 50 public int getVolume() throws VLCException { 51 return _getVolume(); 52 } 65 public void setMute(boolean value) throws VLCException { 66 _setMute(value); 53 67 54 public void setVolume(int volume) throws VLCException { 55 _setVolume( volume ); 56 57 } 58 68 } 69 70 public void toggleMute() throws VLCException { 71 _toggleMute(); 72 } 73 74 public int getVolume() throws VLCException { 75 return _getVolume(); 76 } 77 78 public void setVolume(int volume) throws VLCException { 79 _setVolume(volume); 80 } 81 82 public boolean addVolumeListener(VolumeListener listener) { 83 HashSet listeners = (HashSet) objListeners.get(this); 84 return listeners.add(listener); 85 } 86 87 public boolean removeVolumeListener(VolumeListener listener) { 88 HashSet listeners = (HashSet) objListeners.get(this); 89 return listeners.remove(listener); 90 } 91 92 // this method is invoked natively 93 private static void wakeupListeners() { 94 Set audioObjects = objListeners.keySet(); 95 Iterator audioObjectsIterator = audioObjects.iterator(); 96 97 while (audioObjectsIterator.hasNext()) { 98 Audio audioObject = (Audio) audioObjectsIterator.next(); 99 HashSet listeners = (HashSet) objListeners.get(audioObject); 100 101 Iterator listenerIterator = listeners.iterator(); 102 while (listenerIterator.hasNext()) { 103 VolumeListener listener = (VolumeListener) listenerIterator.next(); 104 listener.volumeChanged(); 105 } 106 } 107 } 108 59 109 public long getInstance() { 60 110 return libvlcInstance; bindings/java/src/Makefile.am
rcab9f4b r12c291f 8 8 utils.h \ 9 9 video-jni.cc \ 10 vlm-jni.cc 10 vlm-jni.cc \ 11 callback-jni.cc 12 11 13 libjvlc_la_CPPFLAGS = `$(VLC_CONFIG) --cflags pic` $(JINCLUDES) 12 14 libjvlc_la_LIBADD = ../../../src/libvlc-control.la $(LIBJINCLUDES) bindings/java/src/core-jni.cc
r52fbb24 r12c291f 71 71 72 72 free( exception ); 73 73 74 74 return res; 75 75 include/vlc/libvlc.h
r3b41ca7 r12c291f 804 804 * \param p_instance the libvlc instance 805 805 * \param i_event_type the desired event mask to which we want to listen 806 * \param pf_callback function the function to call when an_Event occurs 806 * \param f_callback the function to call when i_event_type occurs 807 * \param user_data user provided data to carry with the event 807 808 * \param p_e an initialized exception pointer 808 809 */ 809 /* void libvlc_callback_register_for_eventtype( libvlc_instance_t *p_instance, */ 810 /* libvlc_event_type_t i_event_type, */ 811 /* libvlc_callback_t pf_callback, */ 812 /* libvlc_exception_t *p_e ); */ 810 VLC_PUBLIC_API void libvlc_callback_register_for_event( libvlc_instance_t *p_instance, 811 libvlc_event_type_t i_event_type, 812 libvlc_callback_t f_callback, 813 void *user_data, 814 libvlc_exception_t *p_e ); 813 815 814 816 /** … … 816 818 * \param p_instance the libvlc instance 817 819 * \param i_event_type the desired event mask to which we want to unregister 818 * \param pf_function the function to call when an_Eventoccurs820 * \param f_callback the function to call when i_event_type occurs 819 821 * \param p_e an initialized exception pointer 820 822 */ 821 /* void libvlc_callback_unregister_for_eventtype( libvlc_instance_t *p_instance, */ 822 /* libvlc_event_type_t i_event_type, */ 823 /* libvlc_callback_t pf_function, */ 824 /* libvlc_exception_t *p_e ); */ 825 823 VLC_PUBLIC_API void libvlc_callback_unregister_for_event( libvlc_instance_t *p_instance, 824 libvlc_event_type_t i_event_type, 825 libvlc_callback_t f_callback, 826 libvlc_exception_t *p_e ); 826 827 827 828 /** @} */ include/vlc/libvlc_structures.h
r3c5ed2f r12c291f 155 155 char reserved[8]; /* For future use */ 156 156 } libvlc_event_t; 157 158 typedef void ( *libvlc_callback_t )( struct libvlc_instance_t *, libvlc_event_t * ); 157 158 /** 159 * Callback function notification 160 * \param p_instance the libvlc instance 161 * \param p_event the event triggering the callback 162 * \param p_user_data user provided data 163 */ 164 165 typedef void ( *libvlc_callback_t )( struct libvlc_instance_t *, libvlc_event_t *, void * ); 159 166 160 167 /**@} */ src/Makefile.am
rc43bae3 r12c291f 25 25 ../include/vlc/vlc.h \ 26 26 ../include/vlc/libvlc.h \ 27 ../include/vlc/libvlc_structures.h \ 27 28 ../include/vlc/mediacontrol.h \ 28 29 ../include/vlc/mediacontrol_structures.h \ … … 327 328 control/video.c \ 328 329 control/audio.c \ 330 control/callback.c \ 329 331 control/mediacontrol_internal.h \ 330 332 control/mediacontrol_core.c \ src/control/core.c
r3c5ed2f r12c291f 112 112 while( p_listitem ) 113 113 { 114 struct libvlc_callback_entry_list *p_nextlistitem = p_listitem->next;114 struct libvlc_callback_entry_list_t *p_nextlistitem = p_listitem->next; 115 115 free( p_listitem ); 116 116 p_listitem = p_nextlistitem; src/control/libvlc_internal.h
r3c5ed2f r12c291f 50 50 struct libvlc_callback_entry_t 51 51 { 52 libvlc_callback_t callback; 53 libvlc_event_type_t eventType; 52 libvlc_instance_t *p_instance; 53 libvlc_callback_t f_callback; 54 libvlc_event_type_t i_event_type; 54 55 void *p_user_data; 55 56 }; … … 78 79 }; 79 80 81 82 static inline void add_callback_entry( struct libvlc_callback_entry_t *entry, 83 struct libvlc_callback_entry_list_t **list ) 84 { 85 struct libvlc_callback_entry_list_t *new_listitem; 86 new_listitem = malloc( sizeof( struct libvlc_callback_entry_list_t ) ); 87 new_listitem->elmt = entry; 88 new_listitem->next = *list; 89 new_listitem->prev = NULL; 90 91 if(*list) 92 (*list)->prev = new_listitem; 93 94 *list = new_listitem; 95 } 96 80 97 #define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \ 81 98 return NULL; }
