~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to examples/app/appsrc_ex.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2007-05-03 19:52:54 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20070503195254-4dovmz251nut3yrt
Tags: 0.10.4+cvs20070502-1
* New CVS snapshot.
* debian/rules,
  debian/build-deps.in:
  + Update build dependencies.
* debian/gstreamer-plugins-bad-multiverse.install:
  + Add x264 plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
#ifdef HAVE_CONFIG_H
 
4
#include "config.h"
 
5
#endif
 
6
 
 
7
#include <gst/gst.h>
 
8
#include <gst/app/gstappsrc.h>
 
9
#include <gst/app/gstappbuffer.h>
 
10
#include <gst/app/gstappsink.h>
 
11
 
 
12
#include <stdio.h>
 
13
#include <string.h>
 
14
 
 
15
 
 
16
typedef struct _App App;
 
17
struct _App
 
18
{
 
19
  GstElement *pipe;
 
20
  GstElement *src;
 
21
  GstElement *id;
 
22
  GstElement *sink;
 
23
};
 
24
 
 
25
App s_app;
 
26
 
 
27
static void dont_eat_my_chicken_wings (void *priv);
 
28
 
 
29
int
 
30
main (int argc, char *argv[])
 
31
{
 
32
  App *app = &s_app;
 
33
  int i;
 
34
 
 
35
  gst_init (&argc, &argv);
 
36
 
 
37
  app->pipe = gst_pipeline_new (NULL);
 
38
  g_assert (app->pipe);
 
39
 
 
40
  app->src = gst_element_factory_make ("appsrc", NULL);
 
41
  g_assert (app->src);
 
42
  gst_bin_add (GST_BIN (app->pipe), app->src);
 
43
 
 
44
  app->id = gst_element_factory_make ("identity", NULL);
 
45
  g_assert (app->id);
 
46
  gst_bin_add (GST_BIN (app->pipe), app->id);
 
47
 
 
48
  app->sink = gst_element_factory_make ("appsink", NULL);
 
49
  g_assert (app->sink);
 
50
  gst_bin_add (GST_BIN (app->pipe), app->sink);
 
51
 
 
52
  gst_element_link (app->src, app->id);
 
53
  gst_element_link (app->id, app->sink);
 
54
 
 
55
  gst_element_set_state (app->pipe, GST_STATE_PLAYING);
 
56
 
 
57
  for (i = 0; i < 10; i++) {
 
58
    GstBuffer *buf;
 
59
    void *data;
 
60
 
 
61
    data = malloc (100);
 
62
    memset (data, i, 100);
 
63
 
 
64
    printf ("%d: creating buffer for pointer %p\n", i, data);
 
65
    buf = gst_app_buffer_new (data, 100, dont_eat_my_chicken_wings, data);
 
66
    gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
 
67
  }
 
68
 
 
69
  gst_app_src_end_of_stream (GST_APP_SRC (app->src));
 
70
 
 
71
  while (!gst_app_sink_end_of_stream (GST_APP_SINK (app->sink))) {
 
72
    GstBuffer *buf;
 
73
 
 
74
    buf = gst_app_sink_pull_buffer (GST_APP_SINK (app->sink));
 
75
    gst_buffer_unref (buf);
 
76
  }
 
77
 
 
78
  return 0;
 
79
}
 
80
 
 
81
static void
 
82
dont_eat_my_chicken_wings (void *priv)
 
83
{
 
84
  printf ("freeing buffer for pointer %p\n", priv);
 
85
  free (priv);
 
86
}