[Android] LibVLC: access LibVLC instance from VLCObjects
Thomas Guillem
git at videolan.org
Wed Mar 8 15:07:21 CET 2017
vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 7 16:18:10 2017 +0100| [1d138efba9fe48ffe06e6280ba3e65479ceb791e] | committer: Thomas Guillem
LibVLC: access LibVLC instance from VLCObjects
> https://code.videolan.org/videolan/vlc-android/commit/1d138efba9fe48ffe06e6280ba3e65479ceb791e
---
libvlc/src/org/videolan/libvlc/Media.java | 4 ++++
libvlc/src/org/videolan/libvlc/MediaDiscoverer.java | 1 +
libvlc/src/org/videolan/libvlc/MediaList.java | 3 +++
libvlc/src/org/videolan/libvlc/MediaPlayer.java | 2 ++
libvlc/src/org/videolan/libvlc/VLCObject.java | 13 +++++++++++++
5 files changed, 23 insertions(+)
diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
index 393c8c8..4a332a0 100644
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ b/libvlc/src/org/videolan/libvlc/Media.java
@@ -425,6 +425,7 @@ public class Media extends VLCObject<Media.Event> {
* @param path an absolute local path
*/
public Media(LibVLC libVLC, String path) {
+ super(libVLC);
nativeNewFromPath(libVLC, path);
mUri = VLCUtil.UriFromMrl(nativeGetMrl());
}
@@ -436,6 +437,7 @@ public class Media extends VLCObject<Media.Event> {
* @param uri a valid RFC 2396 Uri
*/
public Media(LibVLC libVLC, Uri uri) {
+ super(libVLC);
nativeNewFromLocation(libVLC, VLCUtil.locationFromUri(uri));
mUri = uri;
}
@@ -447,6 +449,7 @@ public class Media extends VLCObject<Media.Event> {
* @param fd file descriptor object
*/
public Media(LibVLC libVLC, FileDescriptor fd) {
+ super(libVLC);
nativeNewFromFd(libVLC, fd);
mUri = VLCUtil.UriFromMrl(nativeGetMrl());
}
@@ -457,6 +460,7 @@ public class Media extends VLCObject<Media.Event> {
* @param index index of the Media from the MediaList
*/
protected Media(MediaList ml, int index) {
+ super(ml);
if (ml == null || ml.isReleased())
throw new IllegalArgumentException("MediaList is null or released");
if (!ml.isLocked())
diff --git a/libvlc/src/org/videolan/libvlc/MediaDiscoverer.java b/libvlc/src/org/videolan/libvlc/MediaDiscoverer.java
index e18557a..3b14cbb 100644
--- a/libvlc/src/org/videolan/libvlc/MediaDiscoverer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaDiscoverer.java
@@ -76,6 +76,7 @@ public class MediaDiscoverer extends VLCObject<MediaDiscoverer.Event> {
* @param name Name of the vlc service discovery ("dsm", "upnp", "bonjour"...).
*/
public MediaDiscoverer(LibVLC libVLC, String name) {
+ super(libVLC);
nativeNew(libVLC, name);
}
diff --git a/libvlc/src/org/videolan/libvlc/MediaList.java b/libvlc/src/org/videolan/libvlc/MediaList.java
index 4786354..1c4263b 100644
--- a/libvlc/src/org/videolan/libvlc/MediaList.java
+++ b/libvlc/src/org/videolan/libvlc/MediaList.java
@@ -69,6 +69,7 @@ public class MediaList extends VLCObject<MediaList.Event> {
* @param libVLC a valid libVLC
*/
public MediaList(LibVLC libVLC) {
+ super(libVLC);
nativeNewFromLibVlc(libVLC);
init();
}
@@ -78,6 +79,7 @@ public class MediaList extends VLCObject<MediaList.Event> {
* @param md Should not be released
*/
protected MediaList(MediaDiscoverer md) {
+ super(md);
nativeNewFromMediaDiscoverer(md);
init();
}
@@ -87,6 +89,7 @@ public class MediaList extends VLCObject<MediaList.Event> {
* @param m Should not be released
*/
protected MediaList(Media m) {
+ super(m);
nativeNewFromMedia(m);
init();
}
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 90943ce..efec9fb 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -376,6 +376,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
* @param libVLC a valid libVLC
*/
public MediaPlayer(LibVLC libVLC) {
+ super(libVLC);
nativeNewFromLibVlc(libVLC, mWindow);
}
@@ -385,6 +386,7 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
* @param media a valid Media object
*/
public MediaPlayer(Media media) {
+ super(media);
if (media == null || media.isReleased())
throw new IllegalArgumentException("Media is null or released");
mMedia = media;
diff --git a/libvlc/src/org/videolan/libvlc/VLCObject.java b/libvlc/src/org/videolan/libvlc/VLCObject.java
index 65b8520..7d11b8e 100644
--- a/libvlc/src/org/videolan/libvlc/VLCObject.java
+++ b/libvlc/src/org/videolan/libvlc/VLCObject.java
@@ -29,8 +29,21 @@ import java.lang.ref.WeakReference;
abstract class VLCObject<T extends VLCEvent> {
private VLCEvent.Listener<T> mEventListener = null;
private Handler mHandler = null;
+ final LibVLC mLibVLC;
private int mNativeRefCount = 1;
+ protected VLCObject(LibVLC libvlc) {
+ mLibVLC = libvlc;
+ }
+
+ protected VLCObject(VLCObject parent) {
+ mLibVLC = parent.mLibVLC;
+ }
+
+ protected VLCObject() {
+ mLibVLC = null;
+ }
+
/**
* Returns true if native object is released
*/
More information about the Android
mailing list