Postby AlexJung » 10 Nov 2016 11:11
Hi, I have a problem in capturing screen.
current libvlc_video_take_snapshot source code in git is below:
libvlc_video_take_snapshot(...){
assert( psz_filepath );
vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;
/* FIXME: This is not atomic. All parameters should be passed at once
* (obviously _not_ with var_*()). Also, the libvlc object should not be
* used for the callbacks: that breaks badly if there are concurrent
* media players in the instance. */
var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-width", i_width);
var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-height", i_height );
var_Create( p_vout, "snapshot-path", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-path", psz_filepath );
var_Create( p_vout, "snapshot-format", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-format", "png" );
var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout );
return 0;
}
I call this funtcion and return 0 successfully.
but there was no capture file that I expected place.
I develop in Android OS and code is below;
- in Android test java file
new Thread(new Runnable() {
public void run() {
boolean result = mLibVLC.takeSnapshot(0, "/sdcard/Android/data/com.ebs.android/capture.png", 640, 480);
if(result)
Log.d("EBSSAMPLE", "snapshot success");
}
}).start();
- in Jni function
jboolean Java_org_videolan_libvlc_LibVLC_takeSnapshot(JNIEnv *env, jobject thiz, jint number, jstring jpath, jint width,jint height) {
vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
const char* psz_path;
if (!p_obj)
return;
libvlc_media_player_t *mp = (libvlc_media_player_t *)(p_obj->u.p_mp);
psz_path = jpath ? (*env)->GetStringUTFChars(env, jpath, 0) : NULL;
if(mp && psz_path){
if(libvlc_video_take_snapshot(mp, (int)number, psz_path, (int)width, (int)height) == 0) {
(*env)->ReleaseStringUTFChars(env, jpath, psz_path);
return JNI_TRUE;
}else{
(*env)->ReleaseStringUTFChars(env, jpath, psz_path);
}
}
return JNI_FALSE;
}
Anyone's helps or advices are appreciate that I must check to solve this problem.