[Bug 770308] New: When setting Pipeline for the GST_MESSAGE_READY state of the V4L2SRC element to stop the video, I give a PLAY state when the V4L2 element to display the "busy device" error

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Wed Aug 24 00:36:45 UTC 2016


https://bugzilla.gnome.org/show_bug.cgi?id=770308

            Bug ID: 770308
           Summary: When setting Pipeline for the GST_MESSAGE_READY state
                    of the V4L2SRC element to stop the video, I give a
                    PLAY state when the V4L2 element to display the "busy
                    device" error
    Classification: Platform
           Product: GStreamer
           Version: 1.8.0
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gstreamer (core)
          Assignee: gstreamer-bugs at lists.freedesktop.org
          Reporter: dasimazn at 163.com
        QA Contact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

Created attachment 334048
  --> https://bugzilla.gnome.org/attachment.cgi?id=334048&action=edit
souce code

When setting Pipeline for the GST_MESSAGE_READY state of the V4L2SRC element to
stop the video, I give a PLAY state again ,The V4L2 element  display the "busy
device" error, please tell me how to solve this problem, thank you very much.

My c code:
#include <string.h>
#include <gst/gst.h> 
#include <sys/wait.h>

int main (int argc,char *argv[])
{

    gst_init (&argc, &argv);

    GstElement *pevPipeline;
    GstElement *sink;
    GstElement *camPrevSrc;
    GstBus *bus;
    GstMessage *msg;
    GstElement *tee, *camPrev_Queue, *camRecord_Queue;
    GstElement *camPrevfilter,*camRecordfilter  ,*h264parse;
    GstCaps    *camPrevCaps, *camRecordCaps;
    gchar      *input_device , *camRecordFileName;

    GstElement *mp4Mux,*nvOmx_H264enc;
    GstPad     *tee_camPrev_pad, *tee_camRecord_pad;
    GstPad     *queue_camPrev_pad, *queue_camRecord_pad;
    GstElement *fileSink;
    GstPadTemplate *tee_src_pad_template;


  pevPipeline = gst_pipeline_new ("xvoverlay");
  camPrevSrc = gst_element_factory_make ("v4l2src", NULL);
  input_device = "/dev/video0";
  camPrevfilter = gst_element_factory_make("capsfilter",NULL);
  camPrevCaps =
gst_caps_from_string("video/x-raw,width=1280,height=720,framerate=60/1");

  g_object_set(G_OBJECT(camPrevSrc),"device",input_device,NULL);
  g_object_set(G_OBJECT(camPrevfilter),"caps",camPrevCaps,NULL);

  //record video picture pipeline
  fileSink          = gst_element_factory_make("filesink",NULL);
  camRecordCaps     =
gst_caps_from_string("video/x-raw,width=1280,height=720,framerate=60/1");
  tee               = gst_element_factory_make("tee", NULL);
  camPrev_Queue     = gst_element_factory_make("queue2",NULL);
  mp4Mux            = gst_element_factory_make("mp4mux",NULL);
  camRecord_Queue   = gst_element_factory_make("queue2",NULL);
  camRecordfilter   = gst_element_factory_make("capsfilter",NULL);
  camRecordFileName = "/home/ubuntu/family.mp4";
  nvOmx_H264enc     = gst_element_factory_make("omxh264enc",NULL); 
//omxh264enc
  h264parse         = gst_element_factory_make("h264parse",NULL);


  g_object_set(G_OBJECT(camRecordfilter),"caps",camRecordCaps,NULL);
  g_object_set(G_OBJECT(fileSink),"location",camRecordFileName,NULL);

  //config and link cam_pipline
  if ((sink = gst_element_factory_make ("xvimagesink", NULL))) {  //
  }

  if (sink == NULL)
    g_error ("Couldn't find a working video sink.");


  if(!pevPipeline || ! camPrevSrc || !tee || !camPrev_Queue || !camPrevfilter
|| !sink
          || !camRecord_Queue || !camRecordfilter || !nvOmx_H264enc||
!h264parse || !mp4Mux || !fileSink){
      g_error ("Someting error.");
  }

  //src link to sink
  gst_bin_add_many (GST_BIN (pevPipeline), camPrevSrc, tee ,camPrev_Queue,
camPrevfilter,sink,
                       
camRecord_Queue,camRecordfilter,nvOmx_H264enc,h264parse,mp4Mux,fileSink,NULL);

  if(gst_element_link_many(camPrevSrc,tee,NULL) != TRUE ||
          gst_element_link_many(camPrev_Queue,camPrevfilter, sink,NULL) != TRUE
||
            
gst_element_link_many(camRecord_Queue,camRecordfilter,nvOmx_H264enc,h264parse,mp4Mux,fileSink,NULL)
!= TRUE){
      g_printerr("Elements could not be linked.\n");
      gst_object_unref(pevPipeline);
  }

  if(mp4Mux==NULL){
       g_printerr("Error: mp4Mux == Null\n");
  }

  if(tee==NULL){
       g_printerr("Error: TEE == Null\n");
  }

  tee_src_pad_template = gst_element_class_get_pad_template(
GST_ELEMENT_GET_CLASS( tee ), "src_%u" );
   if (tee_src_pad_template == NULL){
       g_printerr("Error: tee_src_pad_template == Null\n");
   }

   tee_camPrev_pad      =
gst_element_request_pad(tee,tee_src_pad_template,NULL,NULL);
   g_print("Obtained reques pad %s for tee_camPrev_pad branch.\n",
gst_pad_get_name(tee_camPrev_pad));
   queue_camPrev_pad    = gst_element_get_static_pad(camPrev_Queue,"sink");

   tee_camRecord_pad    =
gst_element_request_pad(tee,tee_src_pad_template,NULL,NULL);
   g_print("Obtained reques pad %s for tee_camRecord_pad branch.\n",
gst_pad_get_name(tee_src_pad_template));
   queue_camRecord_pad  = gst_element_get_static_pad(camRecord_Queue,"sink");

   if(gst_pad_link(tee_camPrev_pad,queue_camPrev_pad) != GST_PAD_LINK_OK ||
          gst_pad_link(tee_camRecord_pad,queue_camRecord_pad) !=
GST_PAD_LINK_OK) {
       g_printerr("Tee could not be linked.\n");
       gst_object_unref(pevPipeline);
   }

   gst_object_unref(queue_camPrev_pad);
   gst_object_unref(queue_camRecord_pad);

  GstStateChangeReturn sret;

  /* we know what the video sink is in this case (xvimagesink), so we can
   * just set it directly here now (instead of waiting for a
   * prepare-window-handle element message in a sync bus handler and setting
   * it there) */

      sret = gst_element_set_state (pevPipeline, GST_STATE_PLAYING);
    if (sret == GST_STATE_CHANGE_FAILURE) {
            gst_element_set_state (pevPipeline, GST_STATE_NULL);
            gst_object_unref (pevPipeline);
        }

    bus=gst_element_get_bus(pevPipeline);
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,GST_MESSAGE_EOS
| GST_MESSAGE_ERROR);
    if (msg != NULL)  
        gst_message_unref (msg);  
      //gst_object_unref (bus);  

    sleep(10);
    gst_element_set_state (pevPipeline, GST_STATE_READY);  /*Stop video*/
    sleep(10);
    gst_element_set_state (pevPipeline, GST_STATE_PLAY);   /*play video*/
    sleep(10);
    return 0;
}

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list