From falcon.sheep at gmail.com Sat Feb 24 17:17:27 2018 From: falcon.sheep at gmail.com (Abu Abdullah) Date: Sat, 24 Feb 2018 21:17:27 +0400 Subject: Unable to retrieve the video-sink Message-ID: Hi, I'm modifying tutorial-3 to get snapshot (bitmap) while the streaming is on. the problem is with getting the video_sink, it always gives me null. the same thing for pipeline. any hints is appreciated. the code is the following: ************************** static jobject gst_native_snapshot (JNIEnv* env, jobject thiz) { CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id); if (!data) return NULL; GST_DEBUG ("gst_native_snapshot 2"); //gst_element_set_state (data->pipeline, GST_STATE_READY); //if (!data->pipeline) return NULL; GST_DEBUG ("gst_native_snapshot 3"); //data->video_sink = gst_bin_get_by_interface(GST_BIN(data->pipeline), GST_TYPE_VIDEO_OVERLAY); //data->video_sink = gst_bin_get_by_name(GST_BIN(data->pipeline), "mysink"); GST_DEBUG ("gst_native_snapshot 4"); if (data->video_sink) { GstSample *sample = gst_base_sink_get_last_sample(GST_BASE_SINK(GST_VIDEO_OVERLAY(data->video_sink ))); GstBuffer *buffer = gst_sample_get_buffer(sample); GST_DEBUG("gst_native_snapshot 6"); GstCaps *caps = gst_sample_get_caps(sample); GST_DEBUG ("snapshot caps %" GST_PTR_FORMAT, caps); GstMapInfo map; gst_buffer_map(buffer, &map, GST_MAP_READ); GstVideoInfo info; gst_video_info_from_caps(&info, caps); GST_DEBUG("format name is %s", GST_VIDEO_INFO_NAME(&info)); // get static method id of createBitmap(int width, int height, Bitmap.Config config) jclass java_bitmap_class = (*env)->FindClass(env, "android/graphics/Bitmap"); jmethodID mid = (*env)->GetStaticMethodID(env, java_bitmap_class, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); // enum for Bitmap.Config jclass bcfg_class = (*env)->FindClass(env, "android/graphics/Bitmap$Config"); jobject java_bitmap_config = (*env)->CallStaticObjectMethod(env, bcfg_class, (*env)->GetStaticMethodID(env,bcfg_clas, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;"),(*env)->NewStringUTF(env,"RGB_565")); jobject objectbitmap = (*env)->CallStaticObjectMethod(env, java_bitmap_class, mid, GST_VIDEO_INFO_WIDTH(&info), GST_VIDEO_INFO_HEIGHT(&info), java_bitmap_config); void *pixels = NULL; int ret = AndroidBitmap_lockPixels(env, objectbitmap, &pixels); memcpy(pixels, map.data, map.size); AndroidBitmap_unlockPixels(env, objectbitmap); return objectbitmap; } else { GST_DEBUG("Could not retrieve video sink"); return NULL; } }

Virus-free. www.avast.com
From falcon.sheep at gmail.com Sun Feb 25 03:45:27 2018 From: falcon.sheep at gmail.com (Abu Abdullah) Date: Sun, 25 Feb 2018 07:45:27 +0400 Subject: Unable to retrieve the video-sink Message-ID: Hi, I'm modifying tutorial-3 to get snapshot (bitmap) while the streaming is on. the problem is with getting the video_sink, it always gives me null. the same thing for pipeline. any hints is appreciated. the code is the following: ************************** static jobject gst_native_snapshot (JNIEnv* env, jobject thiz) { CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id); if (!data) return NULL; GST_DEBUG ("gst_native_snapshot 2"); //gst_element_set_state (data->pipeline, GST_STATE_READY); //if (!data->pipeline) return NULL; GST_DEBUG ("gst_native_snapshot 3"); //data->video_sink = gst_bin_get_by_interface(GST_BIN(data->pipeline), GST_TYPE_VIDEO_OVERLAY); //data->video_sink = gst_bin_get_by_name(GST_BIN(data->pipeline), "mysink"); GST_DEBUG ("gst_native_snapshot 4"); if (data->video_sink) { GstSample *sample = gst_base_sink_get_last_sample(GST_BASE_SINK(GST_VIDEO_OVERLAY(data->video_sink ))); GstBuffer *buffer = gst_sample_get_buffer(sample); GST_DEBUG("gst_native_snapshot 6"); GstCaps *caps = gst_sample_get_caps(sample); GST_DEBUG ("snapshot caps %" GST_PTR_FORMAT, caps); GstMapInfo map; gst_buffer_map(buffer, &map, GST_MAP_READ); GstVideoInfo info; gst_video_info_from_caps(&info, caps); GST_DEBUG("format name is %s", GST_VIDEO_INFO_NAME(&info)); // get static method id of createBitmap(int width, int height, Bitmap.Config config) jclass java_bitmap_class = (*env)->FindClass(env, "android/graphics/Bitmap"); jmethodID mid = (*env)->GetStaticMethodID(env, java_bitmap_class, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); // enum for Bitmap.Config jclass bcfg_class = (*env)->FindClass(env, "android/graphics/Bitmap$Config"); jobject java_bitmap_config = (*env)->CallStaticObjectMethod(env, bcfg_class, (*env)->GetStaticMethodID(env,bcfg_clas, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;"),(*env)->NewStringUTF(env,"RGB_565")); jobject objectbitmap = (*env)->CallStaticObjectMethod(env, java_bitmap_class, mid, GST_VIDEO_INFO_WIDTH(&info), GST_VIDEO_INFO_HEIGHT(&info), java_bitmap_config); void *pixels = NULL; int ret = AndroidBitmap_lockPixels(env, objectbitmap, &pixels); memcpy(pixels, map.data, map.size); AndroidBitmap_unlockPixels(env, objectbitmap); return objectbitmap; } else { GST_DEBUG("Could not retrieve video sink"); return NULL; } } From falcon.sheep at gmail.com Wed Feb 28 17:42:48 2018 From: falcon.sheep at gmail.com (Abu Abdullah) Date: Wed, 28 Feb 2018 21:42:48 +0400 Subject: Unable to retrieve the video-sink In-Reply-To: References: Message-ID: after many trials, I'm still getting errors in the sort of: E/GLib: gst_base_sink_get_last_sample: assertion 'GST_IS_BASE_SINK (sink)' failed sender pipeline is: gst-launch-1.0 fdsrc ! h264parse ! rtph264pay pt=96 config-interval=10 ! multiudpsink clients=192.168.1.21:5009 receiver pipeline is: udpsrc port=5009 ! application/x-rtp,payload=96 ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink name=mysink sync=false

Virus-free. www.avast.com
On Sun, Feb 25, 2018 at 7:45 AM, Abu Abdullah wrote: > Hi, > > I'm modifying tutorial-3 to get snapshot (bitmap) while the streaming > is on. the problem is with getting the video_sink, it always gives me > null. the same thing for pipeline. any hints is appreciated. > > the code is the following: > ************************** > static jobject gst_native_snapshot (JNIEnv* env, jobject thiz) { > CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id); > if (!data) return NULL; > > GST_DEBUG ("gst_native_snapshot 2"); > > //gst_element_set_state (data->pipeline, GST_STATE_READY); > > //if (!data->pipeline) return NULL; > > GST_DEBUG ("gst_native_snapshot 3"); > > //data->video_sink = > gst_bin_get_by_interface(GST_BIN(data->pipeline), > GST_TYPE_VIDEO_OVERLAY); > //data->video_sink = gst_bin_get_by_name(GST_BIN(data->pipeline), "mysink"); > > GST_DEBUG ("gst_native_snapshot 4"); > > if (data->video_sink) > { > GstSample *sample = > gst_base_sink_get_last_sample(GST_BASE_SINK(GST_VIDEO_OVERLAY(data->video_sink > ))); > GstBuffer *buffer = gst_sample_get_buffer(sample); > GST_DEBUG("gst_native_snapshot 6"); > GstCaps *caps = gst_sample_get_caps(sample); > GST_DEBUG ("snapshot caps %" GST_PTR_FORMAT, caps); > GstMapInfo map; > gst_buffer_map(buffer, &map, GST_MAP_READ); > GstVideoInfo info; > gst_video_info_from_caps(&info, caps); > GST_DEBUG("format name is %s", GST_VIDEO_INFO_NAME(&info)); > > // get static method id of createBitmap(int width, int height, > Bitmap.Config config) > jclass java_bitmap_class = (*env)->FindClass(env, > "android/graphics/Bitmap"); > jmethodID mid = (*env)->GetStaticMethodID(env, > java_bitmap_class, "createBitmap", > "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); > > // enum for Bitmap.Config > jclass bcfg_class = (*env)->FindClass(env, > "android/graphics/Bitmap$Config"); > jobject java_bitmap_config = > (*env)->CallStaticObjectMethod(env, bcfg_class, > (*env)->GetStaticMethodID(env,bcfg_clas, "valueOf", > "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;"),(*env)->NewStringUTF(env,"RGB_565")); > > jobject objectbitmap = (*env)->CallStaticObjectMethod(env, > java_bitmap_class, mid, GST_VIDEO_INFO_WIDTH(&info), > GST_VIDEO_INFO_HEIGHT(&info), java_bitmap_config); > > void *pixels = NULL; > int ret = AndroidBitmap_lockPixels(env, objectbitmap, &pixels); > memcpy(pixels, map.data, map.size); > AndroidBitmap_unlockPixels(env, objectbitmap); > > return objectbitmap; > } > else > { > GST_DEBUG("Could not retrieve video sink"); > return NULL; > } > }