Commit ca921046 authored by Thomas Guillem's avatar Thomas Guillem

LibVLC: Media: add unknown tracks

Better to have an unknown track than a null one.
parent 2e3ba272
......@@ -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:
......
......@@ -247,6 +247,13 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
"(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)"
"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,
......
......@@ -60,6 +60,7 @@ struct fields {
jmethodID createAudioTrackFromNativeID;
jmethodID createVideoTrackFromNativeID;
jmethodID createSubtitleTrackFromNativeID;
jmethodID createUnknownTrackFromNativeID;
} Media;
struct {
struct {
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment