[Android] [PATCH 1/2] Support for multiple player instances. Fix ticket #10831 (https://trac.videolan.org/vlc/ticket/10831).
Paulo Vitor Magacho da Silva
pvmagacho at gmail.com
Wed Jul 23 23:52:37 CEST 2014
Hi,
Thanks for the help. This is the first time I send a significant change to
VLC.
Do you want me to spli these patches ?
Any suggestion of name ?
Thank you
2014-07-23 12:50 GMT-03:00 Jean-Baptiste Kempf <jb at videolan.org>:
> On 23 Jul, Paulo Vitor Magacho da Silva wrote :
> > + setInt(env, item, "Bitrate", p_tracks[i]->i_bitrate);
>
> This should be in a different patch.
>
> > +jobject Java_org_videolan_libvlc_LibVLC_getStats(JNIEnv *env, jobject
> thiz)
> > +{
> > + libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
> > + if (!mp)
> > + return NULL;
> > +
> > + libvlc_media_t *p_mp = libvlc_media_player_get_media(mp);
> > + if (!p_mp)
> > + return NULL;
> > +
> > + libvlc_media_stats_t p_stats;
> > + libvlc_media_get_stats(p_mp, &p_stats);
> > +
> > + jclass mapClass = (*env)->FindClass(env, "java/util/Map");
> > + jclass hashMapClass = (*env)->FindClass(env, "java/util/HashMap");
> > + jmethodID mapPut = (*env)->GetMethodID(env, mapClass, "put",
> "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
> > + /*
> > + * "What are you building? Lay your hand on it. Where is it?"
> > + * We need a concrete map to start
> > + */
> > + jmethodID mapInit = (*env)->GetMethodID(env, hashMapClass,
> "<init>", "()V");
> > + jclass integerCls = (*env)->FindClass(env, "java/lang/Integer");
> > + jmethodID integerConstructor = (*env)->GetMethodID(env, integerCls,
> "<init>", "(I)V");
> > + jclass floatCls = (*env)->FindClass(env, "java/lang/Float");
> > + jmethodID floatConstructor = (*env)->GetMethodID(env, floatCls,
> "<init>", "(F)V");
> > +
> > + LOGE("No media player %f", p_stats.f_demux_bitrate);
> > +
> > + jobject statistics = (*env)->NewObject(env, hashMapClass, mapInit);
> > + jobject value = (*env)->NewObject(env, floatCls, floatConstructor,
> p_stats.f_demux_bitrate);
> > + jstring name = (*env)->NewStringUTF(env, "demuxBitrate");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, floatCls, floatConstructor,
> p_stats.f_input_bitrate);
> > + name = (*env)->NewStringUTF(env, "inputBitrate");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, floatCls, floatConstructor,
> p_stats.f_send_bitrate);
> > + name = (*env)->NewStringUTF(env, "sendBitrate");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_decoded_audio);
> > + name = (*env)->NewStringUTF(env, "decodedAudio");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_decoded_video);
> > + name = (*env)->NewStringUTF(env, "decodedVideo");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_demux_corrupted);
> > + name = (*env)->NewStringUTF(env, "demuxCorrupted");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_demux_discontinuity);
> > + name = (*env)->NewStringUTF(env, "demuxDiscontinuity");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_demux_read_bytes);
> > + name = (*env)->NewStringUTF(env, "demuxReadBytes");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_displayed_pictures);
> > + name = (*env)->NewStringUTF(env, "displayedPictures");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_lost_abuffers);
> > + name = (*env)->NewStringUTF(env, "lostAbuffers");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_lost_pictures);
> > + name = (*env)->NewStringUTF(env, "lostPictures");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_played_abuffers);
> > + name = (*env)->NewStringUTF(env, "playedAbuffers");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_read_bytes);
> > + name = (*env)->NewStringUTF(env, "readBytes");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, value, name);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_sent_bytes);
> > + name = (*env)->NewStringUTF(env, "sentBytes");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + value = (*env)->NewObject(env, integerCls, integerConstructor,
> p_stats.i_sent_packets);
> > + name = (*env)->NewStringUTF(env, "sentPackets");
> > + (*env)->CallObjectMethod(env, statistics, mapPut, name, value);
> > +
> > + // Clean up local references
> > + (*env)->DeleteLocalRef(env, mapClass);
> > + (*env)->DeleteLocalRef(env, hashMapClass);
> > + (*env)->DeleteLocalRef(env, integerCls);
> > + (*env)->DeleteLocalRef(env, floatCls);
> > +
> > + return statistics;
> > +}
>
> And this one in another one.
>
> > diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
> > index 9781d76..fa9b6ad 100644
> > --- a/vlc-android/jni/libvlcjni.c
> > +++ b/vlc-android/jni/libvlcjni.c
> > @@ -137,9 +137,13 @@ static void vlc_event_callback(const libvlc_event_t
> *ev, void *data)
> > jmethodID putString = (*env)->GetMethodID(env, clsBundle,
> "putString", "(Ljava/lang/String;Ljava/lang/String;)V" );
> >
> > if (ev->type == libvlc_MediaPlayerPositionChanged) {
> > - jstring sData = (*env)->NewStringUTF(env, "data");
> > - (*env)->CallVoidMethod(env, bundle, putFloat, sData,
> ev->u.media_player_position_changed.new_position);
> > - (*env)->DeleteLocalRef(env, sData);
> > + jstring sData = (*env)->NewStringUTF(env, "data");
> > + (*env)->CallVoidMethod(env, bundle, putFloat, sData,
> ev->u.media_player_position_changed.new_position);
> > + (*env)->DeleteLocalRef(env, sData);
> > + } else if (ev->type == libvlc_MediaPlayerTimeChanged) {
> > + jstring sData = (*env)->NewStringUTF(env, "data");
> > + (*env)->CallVoidMethod(env, bundle, putInt, sData, (int)
> ev->u.media_player_time_changed.new_time);
> > + (*env)->DeleteLocalRef(env, sData);
>
> This in a different one again.
>
> > + vlc_object *object = (vlc_object *) malloc(sizeof(vlc_object));
>
> malloc MUST be checked.
>
> > + /* Enable statistics */
> > + "--stats",
>
> This should be in the stats patch.
>
> > jlong libVlcInstance = getLong(env, thiz, "mLibVlcInstance");
> > @@ -378,6 +397,7 @@ void Java_org_videolan_libvlc_LibVLC_playMRL(JNIEnv
> *env, jobject thiz, jlong in
> > libvlc_MediaPlayerStopped,
> > libvlc_MediaPlayerVout,
> > libvlc_MediaPlayerPositionChanged,
> > + libvlc_MediaPlayerTimeChanged,
> > libvlc_MediaPlayerEncounteredError
> > };
>
> And that one in the event patch.
>
> > +#include <pthread.h>
> > +
> > +typedef struct vlc_object {
> > + pthread_mutex_t vout_android_lock;
> > + pthread_cond_t vout_android_surf_attached;
> > + void *vout_android_surf;
> > + void *vout_android_gui;
> > + jobject vout_android_java_surf;
> > + jobject vout_android_subtitles_surf;
> > + bool vout_video_player_activity_created;
> > +} vlc_object;
>
> vlc_object is an extremely bad name.
>
> With my kindest regards,
>
> --
> Jean-Baptiste Kempf
> http://www.jbkempf.com/ - +33 672 704 734
> Sent from my Electronic Device
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20140723/6c111acf/attachment-0001.html>
More information about the Android
mailing list