~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/examples/manual/dynformat.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-10-08 09:59:20 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20121008095920-3k2vlenl0zf6lu7i
Tags: 1.0.1-1
* New upstream stable release:
  + debian/libgstreamer.symbols:
    - Add new symbols.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*** block  from ../../../docs/manual/advanced-dataaccess.xml ***/
 
3
#include <stdlib.h>
 
4
 
 
5
#include <gst/gst.h>
 
6
 
 
7
#define MAX_ROUND 100
 
8
 
 
9
int
 
10
main (int argc, char **argv)
 
11
{
 
12
  GstElement *pipe, *filter;
 
13
  GstCaps *caps;
 
14
  gint width, height;
 
15
  gint xdir, ydir;
 
16
  gint round;
 
17
  GstMessage *message;
 
18
 
 
19
  gst_init (&argc, &argv);
 
20
 
 
21
  pipe = gst_parse_launch_full ("videotestsrc ! capsfilter name=filter ! "
 
22
             "ximagesink", NULL, GST_PARSE_FLAG_NONE, NULL);
 
23
  g_assert (pipe != NULL);
 
24
 
 
25
  filter = gst_bin_get_by_name (GST_BIN (pipe), "filter");
 
26
  g_assert (filter);
 
27
 
 
28
  width = 320;
 
29
  height = 240;
 
30
  xdir = ydir = -10;
 
31
 
 
32
  for (round = 0; round < MAX_ROUND; round++) {
 
33
    gchar *capsstr;
 
34
    g_print ("resize to %dx%d (%d/%d)   \r", width, height, round, MAX_ROUND);
 
35
 
 
36
    /* we prefer our fixed width and height but allow other dimensions to pass
 
37
     * as well */
 
38
    capsstr = g_strdup_printf ("video/x-raw, width=(int)%d, height=(int)%d",
 
39
        width, height);
 
40
 
 
41
    caps = gst_caps_from_string (capsstr);
 
42
    g_free (capsstr);
 
43
    g_object_set (filter, "caps", caps, NULL);
 
44
    gst_caps_unref (caps);
 
45
 
 
46
    if (round == 0)
 
47
      gst_element_set_state (pipe, GST_STATE_PLAYING);
 
48
 
 
49
    width += xdir;
 
50
    if (width >= 320)
 
51
      xdir = -10;
 
52
    else if (width < 200)
 
53
      xdir = 10;
 
54
 
 
55
    height += ydir;
 
56
    if (height >= 240)
 
57
      ydir = -10;
 
58
    else if (height < 150)
 
59
      ydir = 10;
 
60
 
 
61
    message =
 
62
        gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
 
63
        50 * GST_MSECOND);
 
64
    if (message) {
 
65
      g_print ("got error           \n");
 
66
 
 
67
      gst_message_unref (message);
 
68
    }
 
69
  }
 
70
  g_print ("done                    \n");
 
71
 
 
72
  gst_object_unref (filter);
 
73
  gst_element_set_state (pipe, GST_STATE_NULL);
 
74
  gst_object_unref (pipe);
 
75
 
 
76
  return 0;
 
77
}