autoaudiosrc/directsoundsrc not working in windows 8.1

Manish manish434k at yahoo.com
Wed Jan 27 09:36:04 PST 2016


Hi I have code to stream video and record audio + video dynamically on
request.

Below code works completely fine in windows 7 system but on Windows 8.1 it
gives error while start recording (see below code).
gstreamer crashes while executing "gst_element_set_state (m_pPipeline,
GST_STATE_PLAYING));" in start recording.

My first assumption was that may be autoaudio src is not supported by
Windows 8.1 so tried autoaudiosrc from command line using gst-launch-1.0 and
it works fine.
I have tried "directsounsrc"  result is same.

Any help is highly appreciated. Thanks


/// ************ video streaming code ************////
//*******************************************///

m_pPipeline = gst_pipeline_new ("pipeline");

    m_pSource       = gst_element_factory_make ("udpsrc","source");
    m_pDepayQueue           = gst_element_factory_make ("queue","q1");
    m_pDepay        = gst_element_factory_make ("rtph264depay","depay");
    m_pAVDec        = gst_element_factory_make ("avdec_h264","avdec");
    m_pConvertQueue           = gst_element_factory_make ("queue","q2");
    m_pVideoConvert = gst_element_factory_make
("videoconvert","videoconvert");
    m_pCapsFilter   = gst_element_factory_make ("capsfilter","caps");
    m_pQueue           = gst_element_factory_make ("queue","q3");
    m_pAppSink      = gst_element_factory_make ("glimagesink","appsink");

    /* Tee that copies the stream to multiple outputs */
    m_pRecorderTee          = gst_element_factory_make("tee", "tee");

  

    if( !m_pSource     || !m_pDepayQueue || !m_pDepay  ||
        !m_pAVDec      || !m_pConvertQueue || !m_pVideoConvert||
        !m_pCapsFilter || !m_pQueue || !m_pAppSink ||
        !m_pRecorderTee )
    {
        g_print("One of the element could not be created...!!");
        return false;
    }

    g_object_set(G_OBJECT(m_pSource),
                             "port",5000,
                             "caps",gst_caps_new_simple("application/x-rtp",
                             "media",G_TYPE_STRING,"video",
                             "clock-rate",G_TYPE_INT,90000,
                            
"encoding-name",G_TYPE_STRING,"H264",NULL),NULL);

    g_object_set(m_pCapsFilter, "caps", gst_caps_new_simple("video/x-raw",
            "format", G_TYPE_STRING, g_gStreamerImageType, NULL), NULL);

    g_object_set(G_OBJECT(m_pVideoConvert),"dither",0, NULL);

   /* we add all elements into the pipeline */
   gst_bin_add_many (GST_BIN (m_pPipeline),
                     m_pSource      ,
                     m_pDepayQueue          ,
                     m_pDepay       ,
                     m_pAVDec       ,
                     m_pRecorderTee         , /*used to create mutiple
output*/
                     m_pConvertQueue          ,
                     m_pVideoConvert,
                     m_pCapsFilter  ,
                     m_pQueue          ,
                     m_pAppSink     ,NULL);

    /* we link the elements together */
    if(gst_element_link_many( m_pSource      ,
                              m_pDepayQueue          ,
                              m_pDepay       ,
                              m_pAVDec       ,
                              m_pRecorderTee         , /*used to create
mutiple output*/
                              NULL )!= TRUE )
    {
       g_print(" 1. element(s) could not be Linked.... logerr\n");
       return false;
    }

    /* we link the elements together */
   if( gst_element_link_many( m_pConvertQueue          ,
                              m_pVideoConvert,
                              m_pCapsFilter  ,
                              m_pQueue          ,
                              m_pAppSink     ,
                              NULL )!= TRUE)
   {
       g_print(" 2. element(s) could not be Linked.... logerr\n");
       return false;
   }

  /* Manually link the Tee, which has "Request" pads */
    if ( !(m_pTee_src_pad_template = gst_element_class_get_pad_template
(GST_ELEMENT_GET_CLASS (m_pRecorderTee), "src_%u")))
    {
        gst_object_unref (m_pPipeline);
        g_critical ("Unable to get pad template");
        return false;
    }

    m_pTee_screen_pad = gst_element_request_pad (m_pRecorderTee,
m_pTee_src_pad_template, NULL, NULL);
    g_print ("Obtained request pad %s for screen  branch.\n",
gst_pad_get_name (m_pTee_screen_pad));
    m_pQueue_screen_pad = gst_element_get_static_pad (m_pConvertQueue,
"sink");
    g_print ("Obtained static pad %s for screen_queue  branch.\n",
gst_pad_get_name (m_pQueue_screen_pad ));

     if( gst_pad_link (m_pTee_screen_pad, m_pQueue_screen_pad) !=
GST_PAD_LINK_OK )
     {
        g_printerr ("Tee could not be linked.\n");
        gst_object_unref (m_pPipeline);
        return false;
     }

     gst_object_unref (m_pQueue_screen_pad);

    /* get sink */
    gst_app_sink_set_drop((GstAppSink*)m_pAppSink, true);
    gst_app_sink_set_max_buffers((GstAppSink*)m_pAppSink, 8);

    GstAppSinkCallbacks callbacks = { NULL, NULL, new_sample };
    gst_app_sink_set_callbacks (GST_APP_SINK(m_pAppSink), &callbacks, this,
NULL);

    GstBus *bus;
    guint bus_watch_id;
    bus = gst_pipeline_get_bus (GST_PIPELINE (m_pPipeline));
    bus_watch_id = gst_bus_add_watch (bus, my_bus_callback, NULL);
    gst_object_unref (bus);

    
    gst_element_set_state(m_pPipeline, GST_STATE_PLAYING);

    return true;
}

/// ************ Start Recording ************////
//*******************************************///


 m_pRecordQueue = gst_element_factory_make("queue", "capture_queue");

    m_pVideoConvert = gst_element_factory_make("videoconvert",
"videoconvert");

    m_pAudioSrc = gst_element_factory_make("autoaudiosrc", "audiosrc");

    m_pAudioQueue1 = gst_element_factory_make("queue", "audio_q1");

    m_pAudioConvert = gst_element_factory_make("audioconvert",
"audioconvert");

    m_pAudioQueue2 = gst_element_factory_make("queue", "audio_q2");

    m_pAviMux = gst_element_factory_make("avimux", "avimux");

    m_pFilesink = gst_element_factory_make("filesink", "file-output");

    char m_cpData[200] = {0};
    strcpy(m_cpData, filename.toStdString().c_str());

    g_object_set(G_OBJECT(m_pFilesink),"location",m_cpData, NULL);

    m_pBin = gst_bin_new ("recording");

    /* Check if all elements are created or not*/
    if (!m_pBin || !m_pRecordQueue || !m_pVideoConvert || !m_pAudioSrc ||
!m_pAudioQueue1 || !m_pAudioConvert || !m_pAudioQueue2 || !m_pAviMux ||
!m_pFilesink) {
        g_print("One or more element(s) could not be created ....
logerr\n");
        return false;
    }

    gst_element_set_state (m_pPipeline, GST_STATE_PAUSED);

    gst_bin_add(GST_BIN (m_pPipeline),m_pBin);
    gst_bin_add_many (GST_BIN (m_pBin), m_pRecordQueue,
m_pVideoConvert,m_pAudioSrc,m_pAudioQueue1,m_pAudioConvert,m_pAudioQueue2,
m_pAviMux, m_pFilesink,NULL);

    /* we link the elements together */
    if(gst_element_link_many( m_pRecordQueue,m_pVideoConvert, NULL )!= TRUE)
    {
        g_print(" element(s) could not be Linked.... logerr\n");
        return false;
    }

    /* we link the elements together */
    if(gst_element_link_many(
m_pAudioSrc,m_pAudioQueue1,m_pAudioConvert,m_pAudioQueue2, NULL )!= TRUE)
    {
        g_print(" element(s) could not be Linked.... logerr\n");
        return false;
    }

    if ( !(m_pMux_sink_vpad_template = gst_element_class_get_pad_template
(GST_ELEMENT_GET_CLASS (m_pAviMux), "video_%u")))
    {
        gst_object_unref (m_pPipeline);
        g_critical ("Unable to get pad template");
        return false;
    }

    m_pMux_video_pad = gst_element_request_pad (m_pAviMux,
m_pMux_sink_vpad_template, NULL, NULL);
    g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name
(m_pMux_video_pad));

    m_pDecoder_src_pad = gst_element_get_static_pad (m_pVideoConvert,
"src");
    g_print ("Obtained static pad %s for decoder_src_pad ...\n",
gst_pad_get_name (m_pDecoder_src_pad));

    if (gst_pad_link (m_pDecoder_src_pad, m_pMux_video_pad) !=
GST_PAD_LINK_OK) {
        g_printerr ("audio pads could not be linked.\n");
        gst_object_unref (m_pPipeline);
        return false;
    }

    gst_object_unref (m_pDecoder_src_pad);

    /* we link the elements together */
    if(gst_element_link_many( m_pAviMux,m_pFilesink, NULL )!= TRUE)
    {
        g_print(" element(s) could not be Linked.... logerr\n");
        return false;
    }

    if ( !(m_pMux_sink_pad_template = gst_element_class_get_pad_template
(GST_ELEMENT_GET_CLASS (m_pAviMux), "audio_%u")))
    {
        gst_object_unref (m_pPipeline);
        g_critical ("Unable to get pad template");
        return false;
    }

    m_pMux_audio_pad = gst_element_request_pad (m_pAviMux,
m_pMux_sink_pad_template, NULL, NULL);
    g_print ("Obtained request pad %s for audio branch.\n", gst_pad_get_name
(m_pMux_audio_pad));

    m_pQueue_audio_pad = gst_element_get_static_pad (m_pAudioQueue2, "src");
    g_print ("Obtained static pad %s for queue_audio_pad ...\n",
gst_pad_get_name (m_pQueue_audio_pad));

    if (gst_pad_link (m_pQueue_audio_pad, m_pMux_audio_pad) !=
GST_PAD_LINK_OK) {
        g_printerr ("audio pads could not be linked.\n");
        gst_object_unref (m_pPipeline);
        return false;
    }

    gst_object_unref (m_pQueue_audio_pad);

    m_pTee_video_pad = gst_element_request_pad (m_pRecorderTee,
m_pTee_src_pad_template, NULL, NULL);
    g_print ("Obtained request pad %s for video branch.\n", gst_pad_get_name
(m_pTee_video_pad));
    m_pQueue_video_pad = gst_element_get_static_pad (m_pRecordQueue,
"sink");
    g_print ("Obtained static pad %s for capture_queue  branch.\n",
gst_pad_get_name (m_pQueue_video_pad));

    // Create ghost pads on the bin and link to queues
    m_pRecord_bin_pad = gst_ghost_pad_new("videosink", m_pQueue_video_pad);
    gst_pad_set_active (m_pRecord_bin_pad, TRUE);
    gst_element_add_pad(m_pBin, m_pRecord_bin_pad);

   //record_bin_pad = gst_element_get_static_pad (bin, "videosink");
   g_print ("pad  %s for recording  branch.\n", gst_pad_get_name
(m_pRecord_bin_pad));

   if (gst_pad_link (m_pTee_video_pad, m_pRecord_bin_pad) !=
GST_PAD_LINK_OK) {
        g_printerr ("Tee could not be linked.\n");
        gst_object_unref (m_pPipeline);
        return false;
   }

    gst_object_unref (m_pQueue_video_pad);

    gst_element_set_state (m_pPipeline, GST_STATE_PLAYING));

//*********************************************************//






--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/autoaudiosrc-directsoundsrc-not-working-in-windows-8-1-tp4675514.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list