<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all, I'm Mario again.<div><br></div><div>I did some changes:</div><div><ul><li>Add some queues</li><li>Add some caps filters</li></ul><div>The new code is: </div><div><br></div><div><div>#include <gst/gst.h></div><div>#include <stddef.h></div><div>#include <stdlib.h></div><div>#include <string.h></div><div>#include <stdio.h></div><div>#include <gst/app/gstappsrc.h></div><div>#include <gst/app/gstappsink.h></div><div>#include <malloc.h></div><div>#include <unistd.h></div><div>#define TOP 10</div><div>#define HEIGHTF 512</div><div>#define WIDTHF 640</div><div><br></div><div><br></div><div>int main(int argc, char *argv[])</div><div>{</div><div><span style="white-space:pre">        </span></div><div> <span style="white-space:pre">    </span>GstElement *pipeline, *source, *convert, *enc, *parse, *rtppay, *sink, *capsFilter1, *capsFilter2, *queue1, *queue2;</div><div>        GstCaps *capsSource, *capsConvert, *capsEnc;</div><div><span style="white-space:pre">   </span>GstBus *bus;</div><div><span style="white-space:pre">  </span>GstMessage *msg;</div><div><span style="white-space:pre">      </span>GstStateChangeReturn ret;</div><div><span style="white-space:pre">     </span>GstFlowReturn Ret;</div><div><span style="white-space:pre">    </span>GstClockTime timestamp = 0;</div><div><span style="white-space:pre">           </span>  </div><div><span style="white-space:pre">  </span>/* Initialize GStreamer */</div><div><span style="white-space:pre">    </span>gst_init (&argc, &argv);</div><div><br></div><div><span style="white-space:pre">     </span>/* Create the elements */</div><div><span style="white-space:pre">     </span>//1-SOURCE</div><div><span style="white-space:pre">    </span>source = gst_element_factory_make ("appsrc", NULL);</div><div><span style="white-space:pre"> </span>//Source caps</div><div>        capsSource = gst_caps_new_simple ("video/x-raw",</div><div>          "format",  G_TYPE_STRING, "GRAY8",</div><div>          "width", G_TYPE_INT, 640,</div><div>          "height", G_TYPE_INT, 512, </div><div><span style="white-space:pre">  </span>  "framerate", GST_TYPE_FRACTION, 25, 1,</div><div><span style="white-space:pre">   </span>  "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,</div><div><span style="white-space:pre">   </span>  "interlace-mode", G_TYPE_STRING, "progressive", NULL) ;</div><div>        gst_app_src_set_caps (GST_APP_SRC(source), capsSource);</div><div><span style="white-space:pre">      </span>//Set the block propierty to TRUE</div><div><span style="white-space:pre">     </span>g_object_set(source, "block", TRUE, NULL);</div><div><span style="white-space:pre">  </span>//Set the max-bytes propierty<span style="white-space:pre">        </span></div><div><span style="white-space:pre">      </span>g_object_set(source, "max-bytes", 655360, NULL);</div><div><br></div><div><span style="white-space:pre">   </span>//2-FIRST Queue</div><div><span style="white-space:pre">       </span>queue1 = gst_element_factory_make ("queue", NULL);</div><div><br></div><div><span style="white-space:pre"> </span>//3-CONVERSION </div><div><span style="white-space:pre">      </span>convert = gst_element_factory_make ("videoconvert", NULL);</div><div><br></div><div><span style="white-space:pre"> </span>//4-CAPS Filter1</div><div><span style="white-space:pre">      </span>capsFilter1 = gst_element_factory_make ("capsfilter", NULL);</div><div><span style="white-space:pre">        </span>capsConvert = gst_caps_new_simple ("video/x-raw", </div><div> <span style="white-space:pre">       </span> "format",  G_TYPE_STRING, "I420", NULL);</div><div><span style="white-space:pre">        </span>g_object_set(capsFilter1, "caps", capsConvert, NULL);</div><div><br></div><div><span style="white-space:pre">      </span>//5-SECOND queue</div><div><span style="white-space:pre">      </span>queue2 = gst_element_factory_make ("queue", NULL);</div><div><br></div><div><span style="white-space:pre"> </span>//6-CODEC </div><div><span style="white-space:pre">   </span>enc = gst_element_factory_make ("omxh264enc", "enc");</div><div><span style="white-space:pre">     </span>g_object_set(enc, "bitrate", 1000000, NULL);</div><div><span style="white-space:pre">        </span>g_object_set(enc, "profile", 1, NULL);</div><div><span style="white-space:pre">      </span>g_object_set(enc, "control-rate", 2, NULL);</div><div><br></div><div><span style="white-space:pre">        </span>//7-CAPS filter2</div><div><span style="white-space:pre">      </span>capsFilter2 = gst_element_factory_make ("capsfilter", NULL);</div><div><span style="white-space:pre">        </span>capsEnc = gst_caps_new_simple ("video/x-h264",</div><div>          "stream-format",  G_TYPE_STRING, "byte-stream", NULL);</div><div><span style="white-space:pre">     </span>g_object_set(capsFilter2, "caps", capsEnc, NULL);</div><div><span style="white-space:pre">   </span>//8-PARSSING</div><div><span style="white-space:pre">  </span>parse = gst_element_factory_make ("h264parse", "parse"); </div><div><span style="white-space:pre">        </span>g_object_set (G_OBJECT (parse), "config-interval", 1,  NULL);  </div><div><br></div><div> <span style="white-space:pre">       </span>//9-RTP PAYLOAD</div><div><span style="white-space:pre">       </span>rtppay = gst_element_factory_make ("rtph264pay", "rtppay");</div><div><span style="white-space:pre">       </span>g_object_set (G_OBJECT (rtppay), "ssrc", 575096457,  NULL);</div><div><br></div><div><span style="white-space:pre">       </span>//10-DESTINATION</div><div><span style="white-space:pre">      </span>sink = gst_element_factory_make ("udpsink", "sink");</div><div><span style="white-space:pre">      </span>g_object_set(G_OBJECT (sink), "host", "127.0.0.1", NULL );</div><div><span style="white-space:pre">        </span>g_object_set(G_OBJECT (sink), "port", 9078, NULL );</div><div><span style="white-space:pre"> </span>g_object_set(G_OBJECT (sink), "sync", FALSE, NULL );</div><div><br></div><div><span style="white-space:pre">       </span>/* Create the empty pipeline */</div><div> <span style="white-space:pre">     </span>pipeline = gst_pipeline_new ("test-pipeline");</div><div><span style="white-space:pre">      </span> </div><div><span style="white-space:pre">    </span>if (!pipeline || !source || !queue1 || !convert ||  !capsFilter1 || !queue2 || !enc || !capsFilter2 || !parse || !rtppay || !sink) {</div><div><span style="white-space:pre"> </span>  g_printerr ("Not all elements could be created.\n"); </div><div><span style="white-space:pre">   </span>  return -1;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span>/* Build the pipeline */</div><div><span style="white-space:pre">      </span>gst_bin_add_many (GST_BIN (pipeline), source, queue1, convert, capsFilter1, queue2, enc, capsFilter2, parse, rtppay, sink, NULL);</div><div><span style="white-space:pre">     </span>if (gst_element_link_many (source, queue1, convert, capsFilter1 , queue2, enc, capsFilter2, parse, rtppay, sink, NULL) != TRUE) { </div><div><span style="white-space:pre">   </span>    g_printerr ("Elements could not be linked.\n");</div><div><span style="white-space:pre">       </span>    gst_object_unref (pipeline);</div><div><span style="white-space:pre">    </span>    return -1;</div><div><span style="white-space:pre">      </span>}</div><div><span style="white-space:pre">     </span>/* Start playing */</div><div><span style="white-space:pre">   </span>ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div><span style="white-space:pre">    </span>if (ret == GST_STATE_CHANGE_FAILURE) {</div><div><span style="white-space:pre">        </span>    g_printerr ("Unable to set the pipeline to the playing state.\n");</div><div><span style="white-space:pre">    </span>    gst_object_unref (pipeline);</div><div><span style="white-space:pre">    </span>    return -1;</div><div><span style="white-space:pre">      </span>}<span style="white-space:pre">    </span></div><div><br></div><div><span style="white-space:pre">     </span>//CREATE AND FEED BUFFER</div><div><span style="white-space:pre">      </span>GstBuffer *buf;</div><div><span style="white-space:pre">       </span>GstMapInfo map;<span style="white-space:pre">              </span></div><div><span style="white-space:pre">      </span>int imageCount=0;</div><div><br></div><div><span style="white-space:pre">    </span>while (imageCount<TOP){</div><div><span style="white-space:pre">            </span>//Allocate and create Buffer</div><div><span style="white-space:pre">          </span>buf=gst_buffer_new_and_alloc(HEIGHTF*WIDTHF);</div><div><span style="white-space:pre">         </span>//To avoid coping in memory</div><div><span style="white-space:pre">           </span>gst_buffer_map(buf, &map, GST_MAP_WRITE);</div><div><span style="white-space:pre">         </span>// We set the buffer to values from 0 (black) to 234 (almost white)</div><div><span style="white-space:pre">           </span>memset (map.data, 26*imageCount, HEIGHTF*WIDTHF);</div><div><span style="white-space:pre">             </span>//Unmap</div><div><span style="white-space:pre">               </span>gst_buffer_unmap(buf, &map);</div><div><br></div><div><span style="white-space:pre">             </span>//Timestamps</div><div><span style="white-space:pre">          </span>//Set frame timestamp</div><div><span style="white-space:pre"> </span>    <span style="white-space:pre">       </span>GST_BUFFER_PTS      (buf) = timestamp;</div><div><span style="white-space:pre">     </span>    <span style="white-space:pre">       </span>GST_BUFFER_DTS      (buf) = timestamp;<span style="white-space:pre">    </span></div><div><span style="white-space:pre">      </span>    <span style="white-space:pre">       </span>GST_BUFFER_DURATION (buf) = gst_util_uint64_scale_int (1, GST_SECOND, 1);</div><div><span style="white-space:pre">     </span>    <span style="white-space:pre">       </span>timestamp += GST_BUFFER_DURATION (buf);</div><div><span style="white-space:pre">       </span>    <span style="white-space:pre">       </span>printf("Frame is at %lu\n", timestamp);</div><div><br></div><div><span style="white-space:pre">            </span>//Push</div><div><span style="white-space:pre">                </span>Ret=gst_app_src_push_buffer(GST_APP_SRC(source), buf);</div><div><span style="white-space:pre">                </span>if (Ret!=GST_FLOW_OK) </div><div><span style="white-space:pre">                       </span>printf ("\nError pushing buffer");</div><div><span style="white-space:pre">          </span>//keep the loop alive<span style="white-space:pre">                </span></div><div><span style="white-space:pre">              </span>imageCount++;</div><div><span style="white-space:pre">         </span>if(imageCount==10)</div><div><span style="white-space:pre">                    </span>imageCount=0;</div><div><span style="white-space:pre">         </span>usleep(20000);</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">    </span>gst_app_src_end_of_stream (GST_APP_SRC (source));</div><div><span style="white-space:pre">     </span>printf("End Program.\n");</div><div><span style="white-space:pre">   </span>usleep(100000);</div><div><span style="white-space:pre">       </span></div><div><br></div><div><span style="white-space:pre">     </span></div><div><span style="white-space:pre">      </span>/* Wait until error or EOS */</div><div><span style="white-space:pre"> </span>bus = gst_element_get_bus (pipeline);</div><div><span style="white-space:pre"> </span>msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);</div><div><br></div><div><span style="white-space:pre">    </span>/* Parse message */</div><div><span style="white-space:pre">   </span>if (msg != NULL) {</div><div><span style="white-space:pre">    </span>GError *err;</div><div><span style="white-space:pre">  </span>gchar *debug_info;</div><div><br></div><div><span style="white-space:pre">           </span>switch (GST_MESSAGE_TYPE (msg)) {</div><div><span style="white-space:pre">                     </span>case GST_MESSAGE_ERROR:</div><div><span style="white-space:pre">                       </span>gst_message_parse_error (msg, &err, &debug_info);</div><div><span style="white-space:pre">                     </span>g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);</div><div><span style="white-space:pre">                        </span>g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");</div><div><span style="white-space:pre">                     </span>g_clear_error (&err);</div><div><span style="white-space:pre">                     </span>g_free (debug_info);</div><div><span style="white-space:pre">                  </span>break;</div><div><span style="white-space:pre">                </span>      case GST_MESSAGE_EOS:</div><div><span style="white-space:pre">                        </span>g_print ("End-Of-Stream reached.\n");</div><div><span style="white-space:pre">                       </span>break;</div><div><span style="white-space:pre">                </span>      default:</div><div><span style="white-space:pre">                     </span>/* We should not reach here because we only asked for ERRORs and EOS */</div><div><span style="white-space:pre">                       </span>g_printerr ("Unexpected message received.\n");</div><div><span style="white-space:pre">                      </span>break;</div><div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">     </span>gst_message_unref (msg);</div><div><span style="white-space:pre">      </span>}</div><div><br></div><div><span style="white-space:pre">    </span>/* Free resources */</div><div><span style="white-space:pre">  </span>gst_object_unref (bus);</div><div><span style="white-space:pre">       </span>gst_element_set_state (pipeline, GST_STATE_NULL);</div><div><span style="white-space:pre">     </span>gst_object_unref (pipeline);/* Create the empty pipeline */</div><div><span style="white-space:pre">   </span>pipeline = gst_pipeline_new ("test-pipeline");</div><div><br></div><div><br></div><div><br></div><div><span style="white-space:pre">   </span>return 0;</div><div>}</div></div><div><br></div><div>It still compile without errors but the new warnings are: </div><div><br></div><div><div>(ALLIMAGESMEM:7075): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstAppSrc' has no property named 'width'</div><div>0:00:00.080860250  7075   0x1523a0 WARN                     omx /dvs/git/dirty/git-master_linux/external/gstreamer/gst-omx/omx/gstomx.c:2814:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /home/ubuntu/.config:/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)</div><div>Inside NvxLiteH264DecoderLowLatencyInitNvxLiteH264DecoderLowLatencyInit set DPB and MjstreamingFrame is at 0</div><div>0:00:00.131855000  7075   0x1508c0 FIXME                default gstutils.c:3648:gst_pad_create_stream_id_printf_valist:<appsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id</div><div>0:00:00.150974000  7075   0x150a90 FIXME           videoencoder gstvideoencoder.c:591:gst_video_encoder_setcaps:<enc> GstVideoEncoder::reset() is deprecated</div><div>Framerate set to : 25 at NvxVideoEncoderSetParameter0:00:00.151198417  7075   0x150a90 WARN              omxh264enc /dvs/git/dirty/git-master_linux/external/gstreamer/gst-omx/omx/gstomxh264enc.c:252:gst_omx_h264_enc_set_format:<enc> Setting profile/level not supported by component</div><div>NvMMLiteOpen : Block : BlockType = 4 </div><div>Frame is at 0</div><div>===== MSENC =====</div><div>NvMMLiteBlockCreate : Block : BlockType = 4 </div><div>===== MSENC blits (mode: 1) into tiled surfaces =====</div><div>Frame is at 0</div><div>0:00:00.172950750  7075 0xb3605350 DEBUG             omxh264enc /dvs/git/dirty/git-master_linux/external/gstreamer/gst-omx/omx/gstomxh264enc.c:565:gst_omx_h264_enc_handle_output_frame:<enc> got codecconfig in byte-stream format</div><div>0:00:00.177570500  7075 0xb3605350 ERROR            omxvideoenc /dvs/git/dirty/git-master_linux/external/gstreamer/gst-omx/omx/gstomxvideoenc.c:982:gst_omx_video_enc_handle_output_frame:<enc> No corresponding frame found</div><div>0:00:00.188272417  7075 0xb3605350 WARN               h264parse gsth264parse.c:957:gst_h264_parse_handle_frame:<parse> no SPS/PPS yet, nal Type: 1 Slice, Size: 1462 will be dropped</div><div>Frame is at 0</div></div><div><br></div><div>Any help is welcome.</div><div><br></div><div>Thanks in advance. </div><div><br></div><div>Mario.</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
</blockquote></div></div></div></div></div>