Unable to retrieve the video-sink

Abu Abdullah falcon.sheep at gmail.com
Wed Feb 28 17:42:48 UTC 2018


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
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
	<tr>
        <td style="width: 55px; padding-top: 13px;"><a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif"
alt="" width="46" height="29" style="width: 46px; height: 29px;"
/></a></td>
		<td style="width: 470px; padding-top: 12px; color: #41424e;
font-size: 13px; font-family: Arial, Helvetica, sans-serif;
line-height: 18px;">Virus-free. <a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank" style="color: #4453ea;">www.avast.com</a>
		</td>
	</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1"></a></div>

On Sun, Feb 25, 2018 at 7:45 AM, Abu Abdullah <falcon.sheep at gmail.com> 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;
>     }
> }


More information about the gstreamer-android mailing list