<html><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:16px"><div id="yiv2752612395"><div id="yui_3_16_0_1_1428924319953_2719"><div style="background-color: rgb(255, 255, 255);" id="yui_3_16_0_1_1428924319953_2718"><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594"><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">Hi Liuting Du,</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">I am not answering your question, but it may help :)</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">I do a similar thing for taking snapshot images, but I use an appsink instead of a filesink. Basically I convert the GstSample into an Android Bitmap and call a Java method to handle it:</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">the pipeline part:</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">videosrc ! queue ! decodebin ! tee name=t ! videoconvert ! queue ! autovideosink t. ! videoconvert ! video/x-raw,format=(string)RGB16 ! appsink name=snap</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstElement *appsink = gst_bin_get_by_name (GST_BIN (data->pipeline), "snap");</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">if (!appsink) {</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    GST_ERROR ("Could not retrieve appsink");</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    gst_element_set_state (data->pipeline, GST_STATE_NULL);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    return NULL;</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">}</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">gst_app_sink_set_drop (GST_APP_SINK (appsink), TRUE);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">gst_app_sink_set_max_buffers (GST_APP_SINK (appsink), 1);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">The reason I fixed the pixel color to RGB16 is for the Bitmap.Config (see below). Then when you need the snapshot image:</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstSample *sample;</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">sample = gst_app_sink_pull_sample (GST_APP_SINK(data->appsink));</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">And then create the bitmap (you do error checking/exception handling):</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstBuffer *buffer = gst_sample_get_buffer (sample);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstCaps *caps = gst_sample_get_caps (sample);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GST_DEBUG ("snapshot caps %" GST_PTR_FORMAT, caps);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstMapInfo map;</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">gst_buffer_map (buffer, &map, GST_MAP_READ);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GstVideoInfo info;</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">gst_video_info_from_caps (&info, caps);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">GST_DEBUG ("format name is %s", GST_VIDEO_INFO_NAME(&info));</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">// get static method id of createBitmap(int width, int height, Bitmap.Config config)</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">jclass java_bitmap_class = (*env)->FindClass (env, "android/graphics/Bitmap");</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">jmethodID mid = </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    (*env)->GetStaticMethodID (env, java_bitmap_class, </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">// enum for Bitmap.Config </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">jclass bcfg_class = </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    (*env)->FindClass (env, "android/graphics/Bitmap$Config");</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">jobject java_bitmap_config = </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    (*env)->CallStaticObjectMethod (env, bcfg_class, </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    (*env)->GetStaticMethodID (env, bcfg_class, "valueOf",</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">        "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;"), </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">    (*env)->NewStringUTF (env, "RGB_565"));</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">// creat the Bitmap object</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">bitmap = </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">  (*env)->CallStaticObjectMethod (env, java_bitmap_class, mid, </div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">  GST_VIDEO_INFO_WIDTH(&info), GST_VIDEO_INFO_HEIGHT(&info), java_bitmap_config);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style=""><br class="" style=""></div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">void *pixels = NULL;</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">int ret = AndroidBitmap_lockPixels (env, bitmap, &pixels);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">memcpy (pixels, map.data, map.size);</div><div dir="ltr" id="yiv2752612395yui_3_16_0_1_1428919647473_3594" class="" style="">AndroidBitmap_unlockPixels(env, bitmap);</div><div style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;" class="" id="yui_3_16_0_1_1428924319953_11051"><br class="" style=""></div></div><div style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;"></div><div id="yiv2752612395yui_3_16_0_1_1428919647473_3637" style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;"><br></div><div id="yiv2752612395yui_3_16_0_1_1428919647473_3637" style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;" dir="ltr">Good luck!</div><div id="yiv2752612395yui_3_16_0_1_1428919647473_3637" style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;"> </div><div class="yiv2752612395signature" id="yiv2752612395yui_3_16_0_1_1428919647473_3683" style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;"><div id="yiv2752612395yui_3_16_0_1_1428919647473_3682">Regards,</div><div id="yiv2752612395yui_3_16_0_1_1428919647473_3684">Alexandre Moreno<br clear="none"></div></div>  <br clear="none"><div class="yiv2752612395qtdSeparateBR" id="yui_3_16_0_1_1428924319953_2717" style="color: rgb(0, 0, 0); font-family: verdana, helvetica, sans-serif; font-size: 16px;"><br clear="none"><br clear="none"></div></div></div></div><div class=".yiv2752612395yahoo_quoted"> <div style="font-family:verdana, helvetica, sans-serif;font-size:16px;"> <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div dir="ltr"> <font size="2" face="Arial"> El Viernes 10 de abril de 2015 21:25, Liuting Du <liuting@evercam.io> escribió:<br clear="none"> </font> </div>  <br clear="none"><br clear="none"> <div class="yiv2752612395y_msg_container"><div class="qtdSeparateBR"><br><br></div><div class="yiv2752612395yqt0945956286" id="yiv2752612395yqt72045"><div id="yiv2752612395"><div dir="ltr">Hi,<br clear="none"><br clear="none">I am developing an Android RTSP player using Gstreamer 1.0. The basic requirement is to make the player load RTSP stream fast and and also allow the user to take snapshots from the video and save it as an image file, without influencing the video stream.<br clear="none"><br clear="none">I forked the demo app and made some small changes on the demo code to meet the basic requirements. This is the forked repo: <a rel="nofollow" shape="rect" target="_blank" href="https://github.com/liutingdu/gst-launch-remote">https://github.com/liutingdu/gst-launch-remote</a><br clear="none"><br clear="none">The pileline I am using is:<br clear="none"><br clear="none">rtspsrc protocols=4 location=rtsp://<a rel="nofollow" shape="rect" target="_blank" onclick="return theMainWindow.showLinkWarning(this)" href="http://172.16.0.21:9021/h264/ch1/main/av_stream">172.16.0.21:9021/h264/ch1/main/av_stream</a> user-id=admin user-pw=12345 latency=0 drop-on-latency=1 ! decodebin ! videoconvert ! autovideosink<div><br clear="none"></div><div>While the video is playing,  I tried to launch a new pipeline for taking snapshot using filesink:</div><div><br clear="none"></div><div>rtspsrc protocols=4 location=rtsp://<a rel="nofollow" shape="rect" target="_blank" onclick="return theMainWindow.showLinkWarning(this)" href="http://172.16.0.21:9021/h264/ch1/main/av_stream">172.16.0.21:9021/h264/ch1/main/av_stream</a> user-id=admin user-pw=12345 latency=0 drop-on-latency=1 ! jpegenc ! filesink location=/sdcard/snapshot.jpeg<br clear="none"><br clear="none"></div><div>It saves the snapshot image but always interrupt the video that is currently playing, tried to launch the pileline in a new Java thread but got no luck.</div><div><br clear="none"></div><div>After searching around, there seems are some possible approaches:</div><div><br clear="none"></div><div>1. Use the 'tee' plugin to attach and detach the filesink</div><div><br clear="none"></div><div>    rtspsrc ...... ! decodebin ! tee name=t ! queue ! videoconvert ! autovideosink t. ! queue ! jpegenc ! filesink location=/snapshot.jpeg</div><div><br clear="none"></div><div>    But by simply launching this pipeline, it doesn't seem to be working.</div><div><br clear="none"></div><div>    Maybe it requires making lots of changes on the C code to dynamically attach new pipeline?</div><div><br clear="none"></div><div>2. I've got a suggestion from someone who knows about Gstreamer, to use 'tee' with 'intervideosink' and 'intervideosrc'.</div><div><br clear="none"></div><div>    But the 'intervideosink' element is not installed on the Android distribution at all?</div><div><br clear="none"></div><div>Then I am stuck with all approaches.. so the questions are: </div><div><br clear="none"></div><div>1. Is any of the approaches listed above will definitely work and is leading me to the right direction?</div><div>2. If any of them will work, what are the necessary changes that need to be made, and is there any detailed document or sample available somewhere?</div><div>3. If none of them is correct, any suggestions?</div><div><br clear="none"></div><div>I am completely new to C and Gstreamer, any help would be highly appreciated.</div><div><br clear="none"></div><div>Thanks in advance,</div><div><br clear="none"></div><div>Liuting</div><div><br clear="none"></div><div><br clear="none"></div></div></div></div><br clear="none">_______________________________________________<br clear="none">gstreamer-android mailing list<br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:gstreamer-android@lists.freedesktop.org" target="_blank" href="mailto:gstreamer-android@lists.freedesktop.org">gstreamer-android@lists.freedesktop.org</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-android">http://lists.freedesktop.org/mailman/listinfo/gstreamer-android</a><br clear="none"><br clear="none"><br clear="none"></div>  </div> </div>  </div></div></body></html>