Blame tests/icles/benchmark-appsrc.c

Packit 0652a1
/* GStreamer appsink benchmark
Packit 0652a1
 * Copyright (C) 2018 Tim-Philipp Müller <tim centricular com>
Packit 0652a1
Packit 0652a1
 * This library is free software; you can redistribute it and/or
Packit 0652a1
 * modify it under the terms of the GNU Library General Public
Packit 0652a1
 * License as published by the Free Software Foundation; either
Packit 0652a1
 * version 2 of the License, or (at your option) any later version.
Packit 0652a1
 *
Packit 0652a1
 * This library is distributed in the hope that it will be useful,
Packit 0652a1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 0652a1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 0652a1
 * Library General Public License for more details.
Packit 0652a1
 *
Packit 0652a1
 * You should have received a copy of the GNU Library General Public
Packit 0652a1
 * License along with this library; if not, write to the
Packit 0652a1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 0652a1
 * Boston, MA 02110-1301, USA.
Packit 0652a1
 */
Packit 0652a1
Packit 0652a1
#ifdef HAVE_CONFIG_H
Packit 0652a1
#include "config.h"
Packit 0652a1
#endif
Packit 0652a1
#include <gst/gst.h>
Packit 0652a1
#include <gst/app/app.h>
Packit 0652a1
Packit 0652a1
#define NUM_BUFFERS 40000000
Packit 0652a1
Packit 0652a1
int
Packit 0652a1
main (int argc, char **argv)
Packit 0652a1
{
Packit 0652a1
  GstElement *src, *sink, *pipeline;
Packit 0652a1
  GstBuffer *buf;
Packit 0652a1
  gint i;
Packit 0652a1
Packit 0652a1
  gst_init (&argc, &argv);
Packit 0652a1
Packit 0652a1
  pipeline = gst_pipeline_new (NULL);
Packit 0652a1
Packit 0652a1
  src = gst_element_factory_make ("appsrc", NULL);
Packit 0652a1
  sink = gst_element_factory_make ("fakesink", NULL);
Packit 0652a1
Packit 0652a1
  gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
Packit 0652a1
  gst_element_link_many (src, sink, NULL);
Packit 0652a1
Packit 0652a1
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
Packit 0652a1
Packit 0652a1
  buf = gst_buffer_new ();
Packit 0652a1
Packit 0652a1
  for (i = 0; i < NUM_BUFFERS; ++i) {
Packit 0652a1
    gst_app_src_push_buffer (GST_APP_SRC (src), gst_buffer_ref (buf));
Packit 0652a1
  }
Packit 0652a1
  gst_app_src_end_of_stream (GST_APP_SRC (src));
Packit 0652a1
Packit 0652a1
  gst_buffer_unref (buf);
Packit 0652a1
  gst_element_set_state (pipeline, GST_STATE_NULL);
Packit 0652a1
Packit 0652a1
  return 0;
Packit 0652a1
}