<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Thanks for your suggestion, <br>
    you are right so what I have done is writing the pipeline, making,
    adding and linking elements one by one.<br>
    What happens to me now is that, when dynamically adding audio and
    video pads from tsdemux to their own queues before the parsers, they
    are refused and there is no playout. <br>
    The function for dynamically adding pads is (I know the conditional
    instructions are not implemented in an efficient way as I wrote them
    just to check where it failed):<br>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <blockquote>
      <pre style="background-color:#ffffff;color:#000000;font-family:'DejaVu Sans Mono';font-size:9,0pt;"><small><span style="color:#000080;font-weight:bold;">static void </span>dynamic_addpad(GstElement *src, GstPad *new_pad, CustomData *data) {
    <span style="color:#000080;font-weight:bold;">char</span>* pad_name = gst_pad_get_name(new_pad);
    g_print(<span style="color:#008000;font-weight:bold;">" In dynamic ADDING PAD %s</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>, pad_name);

    <span style="color:#000080;font-weight:bold;">if </span>(g_str_has_prefix(pad_name,<span style="color:#008000;font-weight:bold;">"audio"</span>)) {
        GstElement *q_audio;
        q_audio = gst_bin_get_by_name (GST_BIN(data->pipeline), <span style="color:#008000;font-weight:bold;">"queue_audio"</span>);
        GstPad *audiodemuxsink = gst_element_get_static_pad(q_audio,<span style="color:#008000;font-weight:bold;">"sink"</span>);
        <span style="color:#000080;font-weight:bold;">if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_OK)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio successfully linked!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_WRONG_HIERARCHY)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio link wrong hierarchy!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_WAS_LINKED)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio already linked!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_WRONG_DIRECTION)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio link wrong direction!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_NOFORMAT)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio link noformat!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_NOSCHED)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio link nosched!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,audiodemuxsink) == GST_PAD_LINK_REFUSED)
            g_print(<span style="color:#008000;font-weight:bold;">"Audio link refused!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        g_print (<span style="color:#008000;font-weight:bold;">"Sink pad link: '%s'</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>, pad_name);
        gst_object_unref(q_audio);
    }
    <span style="color:#000080;font-weight:bold;">else if </span>(g_str_has_prefix(pad_name,<span style="color:#008000;font-weight:bold;">"video"</span>)) {
        GstElement *q_video;
        q_video = gst_bin_get_by_name(GST_BIN(data->pipeline), <span style="color:#008000;font-weight:bold;">"queue_video"</span>);
        GstPad *videodemuxsink = gst_element_get_static_pad(q_video,<span style="color:#008000;font-weight:bold;">"sink"</span>);
        <span style="color:#000080;font-weight:bold;">if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_OK)
            g_print(<span style="color:#008000;font-weight:bold;">"Video successfully linked!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_WRONG_HIERARCHY)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link wrong hierarchy!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_WAS_LINKED)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link already linked!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_WRONG_DIRECTION)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link wrong direction!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_NOFORMAT)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link noformat!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_NOSCHED)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link nosched!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        <span style="color:#000080;font-weight:bold;">else if</span>(gst_pad_link(new_pad,videodemuxsink) == GST_PAD_LINK_REFUSED)
            g_print(<span style="color:#008000;font-weight:bold;">"Video link refused!</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>);
        g_print (<span style="color:#008000;font-weight:bold;">"Sink pad link: '%s'</span><span style="color:#000080;font-weight:bold;">\n</span><span style="color:#008000;font-weight:bold;">"</span>, pad_name);
        gst_object_unref(q_video);
    }
}</small></pre>
    </blockquote>
    So the log prints the "Video link refused!" sentence and after that
    one:<br>
    <blockquote><small>05-23 12:38:58.675 8461-8526/com.sample.app
        W/GStreamer+mpegtspacketizer: 0:00:01.503897667 0x9e11a260
        mpegtspacketizer.c:2509:mpegts_packetizer_pts_to_ts Not enough
        information to calculate proper timestamp</small><br>
    </blockquote>
    Which is understandable as there is no linking and therefore it has
    no info. There the log stops and the app does not crash but keeps a
    black video surface.<br>
    Anyway I know where the problem is (dynamic linking) but I would
    appreciate any suggestions to solve it, I don't know why there is a
    link refusement for both audio and video streams, with the
    gst-launch way it was working correctly at this point. And the
    pc-equivalent code works fine exactly as shown on this post.<br>
    The modifications implemented for the main method in android c
    source are as seen here:<br>
    <br>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <blockquote>
      <pre style="background-color:#ffffff;color:#000000;font-family:'DejaVu Sans Mono';font-size:9,0pt;"><small><span style="color:#000080;font-weight:bold;">static void </span>*app_function (<span style="color:#000080;font-weight:bold;">void </span>*userdata) {
    [...]

    GST_DEBUG (<span style="color:#008000;font-weight:bold;">"Creating pipeline in CustomData at %p"</span>, data);

    <span style="color:#808080;font-style:italic;">/* Create our own GLib Main Context and make it the default one */
</span><span style="color:#808080;font-style:italic;">    </span>data->context = g_main_context_new ();
    g_main_context_push_thread_default(data->context);

    <span style="color:#808080;font-style:italic;">/* Build pipeline */
</span><span style="color:#808080;font-style:italic;">    </span>data->pipeline = gst_pipeline_new (<span style="color:#008000;font-weight:bold;">"pipeline"</span>);
    data->httpsrc = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"souphttpsrc"</span>, <span style="color:#008000;font-weight:bold;">"http_src"</span>);
    data->tsdemux = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"tsdemux"</span>, <span style="color:#008000;font-weight:bold;">"demux"</span>);
    data->queue_video = gst_element_factory_make(<span style="color:#008000;font-weight:bold;">"queue2"</span>, <span style="color:#008000;font-weight:bold;">"queue_video"</span>);
    data->h264parse = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"h264parse"</span>, <span style="color:#008000;font-weight:bold;">"h264_parse"</span>);
    data->h264dec = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"avdec_h264"</span>, <span style="color:#008000;font-weight:bold;">"h264dec"</span>);
    data->video_convert = gst_element_factory_make(<span style="color:#008000;font-weight:bold;">"videoconvert"</span>,<span style="color:#008000;font-weight:bold;">"video_convert"</span>);
    data->videosink = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"glimagesink"</span>, <span style="color:#008000;font-weight:bold;">"video_sink"</span>);
    data->queue_audio = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"queue2"</span>, <span style="color:#008000;font-weight:bold;">"queue_audio"</span>);
    data->aacparse = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"aacparse"</span>, <span style="color:#008000;font-weight:bold;">"aacparse"</span>);
    data->faad = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"faad"</span>, <span style="color:#008000;font-weight:bold;">"faad"</span>);
    data->audio_convert = gst_element_factory_make(<span style="color:#008000;font-weight:bold;">"audioconvert"</span>, <span style="color:#008000;font-weight:bold;">"audio_convert"</span>);
    data->audiosink = gst_element_factory_make (<span style="color:#008000;font-weight:bold;">"autoaudiosink"</span>, <span style="color:#008000;font-weight:bold;">"audio_sink"</span>);

    g_signal_connect (data->tsdemux, <span style="color:#008000;font-weight:bold;">"pad-added"</span>, G_CALLBACK (dynamic_addpad), &data);

    gst_bin_add_many(GST_BIN(data->pipeline), data->httpsrc, data->tsdemux, data->queue_video, data->h264parse, data->h264dec, data->video_convert, data->videosink, data->queue_audio, data->aacparse, data->faad, data->audio_convert, data->audiosink, NULL);

    gst_element_link(data->httpsrc, data->tsdemux);
    gst_element_link_many(data->queue_video, data->h264parse, data->h264dec, data->video_convert, data->videosink, NULL);
    gst_element_link_many(data->queue_audio, data->aacparse, data->faad, data->audio_convert, data->audiosink, NULL);
<span style="color:#808080;font-style:italic;">
</span><span style="color:#808080;font-style:italic;">    </span><span style="color:#000080;font-weight:bold;">if </span>(error) {
        gchar *message = g_strdup_printf(<span style="color:#008000;font-weight:bold;">"Unable to build pipeline: %s"</span>, error->message);
        g_clear_error (&error);
        set_ui_message(message, data);
        g_free (message);
        <span style="color:#000080;font-weight:bold;">return </span>NULL;
    }
    [...]
}</small></pre>
    </blockquote>
    Thanks for your time, <br>
    <br>
    Dani<br>
    <br>
    <div class="moz-cite-prefix">El 18/05/16 a las 14:31, Sebastian
      Dröge escribió:<br>
    </div>
    <blockquote cite="mid:1463574707.2897.23.camel@centricular.com"
      type="cite">
      <pre wrap="">On Di, 2016-05-17 at 11:12 +0200, Dani wrote:
</pre>
      <blockquote type="cite">
        <pre wrap=""> 
So as this function is called, when it used to be a playbin, just by
adding the GST_STATE_READY and the g_object_set() for the uri worked
fine. Now I have a working pipeline with a checked .ts and it
initially works, but not when this function is called. The debug logs
for the location property gets changed but what happens is that the
app gets paused (no crash at all) with the outdated video. The
initially working pipeline -using gst_parse_launch()- is:

souphttpsrc name=http_src location=<a class="moz-txt-link-freetext" href="http://192.168.0.32/videos/sintel">http://192.168.0.32/videos/sintel</a>.
ts ! queue ! tsdemux name=demux 
demux. ! queue ! h264parse ! avdec_h264 ! videoconvert ! glimagesink
name=video_sink 
demux. ! queue ! aacparse ! faad ! audioconvert ! autoaudiosink
name=audio_sink


The related log is:
[...]
</pre>
      </blockquote>
      <pre wrap="">
Can you get a full log? But in general, re-using gst_parse_launch()
pipelines (that is, going back to READY/NULL and starting them again)
is generally not working well. It's better to recreate the whole
pipeline.

If you want to re-use pipelines, you better build them manually instead
and handle the linking of pads in your code.

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>