<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all.<div><br><div>My application consist of pushing images from a folder (actually now is not reading the info, but is emulate this bytes values with black to almost white) to a gstremaer pipeline (appsrc --> videoconvert --> capsfilter --> omxh264enc -->h264parse --> rtph264pay -->udpsink ) using the appsrc plugin. </div><div><br></div><div>In addition, I would like that the program runs until I want to. Hence there is a loop which calls "push" function infinite times.  </div><div><br></div><div>THE CODE: </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>#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, *capsFilter;</div><div>        GstCaps *capsSource, *capsConvert;</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>  </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>  "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-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>//3-CAPS Filter</div><div><span style="white-space:pre">       </span>capsFilter = gst_element_factory_make ("capsfilter", NULL);</div><div><span style="white-space:pre"> </span>capsConvert = gst_caps_new_simple ("video/x-raw",</div><div>          "format",  G_TYPE_STRING, "I420", NULL);</div><div><span style="white-space:pre">        </span>g_object_set(capsFilter, "caps", capsConvert, NULL);</div><div><br></div><div><span style="white-space:pre">       </span>//4-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><br></div><div><span style="white-space:pre">       </span>//5-PARSSING</div><div><span style="white-space:pre">  </span>parse = gst_element_factory_make ("h264parse", "parse");  </div><div><br></div><div> <span style="white-space:pre">   </span>//6-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>//7-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><br></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 || !convert ||  !capsFilter ||  !enc || !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, convert, capsFilter, enc, parse, rtppay, sink, NULL);</div><div><span style="white-space:pre">   </span>if (gst_element_link_many (source, convert, capsFilter, enc, 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>}</div><div><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><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>}<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 compile without errors, but when I execute I obtain the next output. I do not know how to continue, because it seem like the speed of feeding is wrong or maybe an allocation memory issue. Please, if someone could help me, I would be very grateful. </div><div><br></div><div>DEBUG INFO </div><div>ubuntu@tegra-ubuntu:~/mario/Project/MarioApp/Images_app$ ./ALLIMAGESMEMGST </div><div>0:00:00.060633916  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1147:gst_app_src_set_caps:<appsrc0> setting caps to video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.060954416  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1300:gst_app_src_set_max_bytes:<appsrc0> setting max-bytes to 655360</div><div><br></div><div>(ALLIMAGESMEMGST:4114): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstAppSrc' has no property named 'width'</div><div>0:00:00.070510333  4114   0x139d20 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>0:00:00.091209833  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.093006166  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.095336833  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096090833  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096366500  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096731416  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>Inside NvxLiteH264DecoderLowLatencyInitNvxLiteH264DecoderLowLatencyInit set DPB and Mjstreaming0:00:00.123102833  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:742:gst_app_src_start:<appsrc0> starting</div><div>0:00:00.123251750  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1222:gst_app_src_get_size:<appsrc0> getting size of -1</div><div>0:00:00.123316083  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:865:gst_app_src_do_seek:<appsrc0> seeking to 0, format bytes</div><div>0:00:00.123684083  4114   0x14bbb0 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.124006083  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x181160</div><div>0:00:00.124418750  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x181200</div><div>0:00:00.124764333  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.124814416  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.124853666  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1523:gst_app_src_push_buffer_full:<appsrc0> waiting for free space</div><div>0:00:00.125336916  4114   0x14bbb0 WARN                GST_PADS gstpad.c:3669:gst_pad_peer_query:<appsrc0:src> could not send sticky events</div><div>0:00:00.125457583  4114   0x14bbb0 DEBUG                 appsrc gstappsrc.c:1052:gst_app_src_create:<appsrc0> we have buffer 0x181160 of size 327680</div><div>0:00:00.126733083  4114   0x14bbb0 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<appsrc0> error: Internal data flow error.</div><div>0:00:00.126812416  4114   0x14bbb0 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<appsrc0> error: streaming task paused, reason not-negotiated (-4)</div><div>0:00:00.128321250  4114   0x14bbb0 WARN               baseparse gstbaseparse.c:1153:gst_base_parse_sink_event_default:<parse> error: No valid frames found before end of stream</div><div>0:00:00.126777250  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x1812a0</div><div>0:00:00.128696000  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.128746333  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.128783583  4114   0x139d20 DEBUG                 appsrc gstappsrc.c:1523:gst_app_src_push_buffer_full:<appsrc0> waiting for free space</div><div> </div><div> Thank you very much in advance.</div></div></div></div></div></div></div></div></div></div></div>