[Android] LibVLC: Media: add unknown tracks
Thomas Guillem
git at videolan.org
Tue Feb 9 15:13:32 CET 2016
vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Feb 9 15:13:13 2016 +0100| [ca921046e2dab7cdd79f5cc7a7f6c357c8d6e047] | committer: Thomas Guillem
LibVLC: Media: add unknown tracks
Better to have an unknown track than a null one.
> https://code.videolan.org/videolan/vlc-android/commit/ca921046e2dab7cdd79f5cc7a7f6c357c8d6e047
---
libvlc/jni/libvlcjni-media.c | 17 ++++++++++++-----
libvlc/jni/libvlcjni.c | 7 +++++++
libvlc/jni/utils.h | 1 +
libvlc/libvlcjni.sym | 1 +
libvlc/src/org/videolan/libvlc/Media.java | 19 ++++++++++++++++++-
5 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/libvlc/jni/libvlcjni-media.c b/libvlc/jni/libvlcjni-media.c
index b783b64..db85d13 100644
--- a/libvlc/jni/libvlcjni-media.c
+++ b/libvlc/jni/libvlcjni-media.c
@@ -278,9 +278,6 @@ media_track_to_object(JNIEnv *env, libvlc_media_track_t *p_tracks)
jstring jlanguage = NULL;
jstring jdescription = NULL;
- if (!p_tracks || p_tracks->i_type == libvlc_track_unknown)
- return NULL;
-
psz_desc = libvlc_media_get_codec_description(p_tracks->i_type,
p_tracks->i_codec);
if (psz_desc)
@@ -347,6 +344,17 @@ media_track_to_object(JNIEnv *env, libvlc_media_track_t *p_tracks)
jdescription,
jencoding);
}
+ case libvlc_track_unknown:
+ return (*env)->CallStaticObjectMethod(env, fields.Media.clazz,
+ fields.Media.createUnknownTrackFromNativeID,
+ jcodec,
+ joriginalCodec,
+ (jint)p_tracks->i_id,
+ (jint)p_tracks->i_profile,
+ (jint)p_tracks->i_level,
+ (jint)p_tracks->i_bitrate,
+ jlanguage,
+ jdescription);
default:
return NULL;
}
@@ -376,8 +384,7 @@ Java_org_videolan_libvlc_Media_nativeGetTracks(JNIEnv *env, jobject thiz)
{
jobject jtrack = media_track_to_object(env, pp_tracks[i]);
- if (jtrack)
- (*env)->SetObjectArrayElement(env, array, i, jtrack);
+ (*env)->SetObjectArrayElement(env, array, i, jtrack);
}
error:
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 573be89..235a4cb 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -248,6 +248,13 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
"Lorg/videolan/libvlc/Media$Track;");
GET_ID(GetStaticMethodID,
+ fields.Media.createUnknownTrackFromNativeID,
+ fields.Media.clazz,
+ "createUnknownTrackFromNative",
+ "(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;)"
+ "Lorg/videolan/libvlc/Media$Track;");
+
+ GET_ID(GetStaticMethodID,
fields.MediaPlayer.createTitleFromNativeID,
fields.MediaPlayer.clazz,
"createTitleFromNative",
diff --git a/libvlc/jni/utils.h b/libvlc/jni/utils.h
index 66852a0..7a9232f 100644
--- a/libvlc/jni/utils.h
+++ b/libvlc/jni/utils.h
@@ -60,6 +60,7 @@ struct fields {
jmethodID createAudioTrackFromNativeID;
jmethodID createVideoTrackFromNativeID;
jmethodID createSubtitleTrackFromNativeID;
+ jmethodID createUnknownTrackFromNativeID;
} Media;
struct {
struct {
diff --git a/libvlc/libvlcjni.sym b/libvlc/libvlcjni.sym
index 36f57c8..37bf9eb 100644
--- a/libvlc/libvlcjni.sym
+++ b/libvlc/libvlcjni.sym
@@ -11,6 +11,7 @@ Java_org_videolan_libvlc_LibVLC_nativeRelease
Java_org_videolan_libvlc_LibVLC_nativeSetOnHardwareAccelerationError
Java_org_videolan_libvlc_LibVLC_nativeSetUserAgent
Java_org_videolan_libvlc_LibVLC_version
+Java_org_videolan_libvlc_MediaDiscoverer_nativeGetServices
Java_org_videolan_libvlc_MediaDiscoverer_nativeNew
Java_org_videolan_libvlc_MediaDiscoverer_nativeRelease
Java_org_videolan_libvlc_MediaDiscoverer_nativeStart
diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
index 2de7f9d..764945e 100644
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ b/libvlc/src/org/videolan/libvlc/Media.java
@@ -209,7 +209,7 @@ public class Media extends VLCObject<Media.Event> {
}
}
- /* Used from JNI */
+ @SuppressWarnings("unused") /* Used from JNI */
private static Track createVideoTrackFromNative(String codec, String originalCodec, int id, int profile,
int level, int bitrate, String language, String description,
int height, int width, int sarNum, int sarDen, int frameRateNum, int frameRateDen) {
@@ -241,6 +241,23 @@ public class Media extends VLCObject<Media.Event> {
encoding);
}
+ /**
+ * see libvlc_subtitle_track_t
+ */
+ public static class UnknownTrack extends Track {
+ private UnknownTrack(String codec, String originalCodec, int id, int profile,
+ int level, int bitrate, String language, String description) {
+ super(Type.Unknown, codec, originalCodec, id, profile, level, bitrate, language, description);
+ }
+ }
+
+ @SuppressWarnings("unused") /* Used from JNI */
+ private static Track createUnknownTrackFromNative(String codec, String originalCodec, int id, int profile,
+ int level, int bitrate, String language, String description) {
+ return new UnknownTrack(codec, originalCodec, id, profile,
+ level, bitrate, language, description);
+ }
+
private static final int PARSE_STATUS_INIT = 0x00;
private static final int PARSE_STATUS_PARSING = 0x01;
private static final int PARSE_STATUS_PARSED = 0x02;
More information about the Android
mailing list