summaryrefslogtreecommitdiffstats
path: root/examples/gob/gst-identity2.gob
blob: 9c34cb55fa00c2cc3f916862dc17db69e231e327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

%header{
#include <gst/gst.h>
#include "gst-identity2.h"
#include "gst-identity2-private.h"
%}

class Gst:Identity2 from Gst:Element {
	
  /* plugin init */
  private gboolean
  plugin_init (GModule *module, GstPlugin *plugin)
  {
    static GstElementDetails identity2_details = {
      "GOB Identity",
      "Filter/Effect",
      "Does nothing",
      "1.0",
      "Wim Taymans <wim.taymans@chello.be>",
      "(C) 2001",
    };
    GstElementFactory *factory;

    factory = gst_elementfactory_new ("identity2", TYPE_SELF,
                                      &identity2_details);
    g_return_val_if_fail (factory != NULL, FALSE);

    gst_plugin_add_feature (plugin, &(factory->feature));

    return TRUE;
  }

  /* pads FIXME gob oculd be improved here */
  private GstPad *sinkpad = 
  {
    gst_pad_new ("sink", GST_PAD_SINK);
    gst_element_add_pad (GST_ELEMENT (o), o->_priv->sinkpad);
    gst_pad_set_chain_function (o->_priv->sinkpad, chain);
    gst_pad_set_bufferpool_function (o->_priv->sinkpad, get_bufferpool);
    //gst_pad_set_negotiate_function (o->_priv->sinkpad, negotiate_sink);
  };
  private GstPad *srcpad =
  {
    gst_pad_new ("src", GST_PAD_SRC);
    gst_element_add_pad (GST_ELEMENT (o), o->_priv->srcpad);
    //gst_pad_set_negotiate_function (o->_priv->srcpad, negotiate_src);
  };

  /* arguments */
  /*
  private gboolean loop_based = FALSE; argument BOOL loop_based 
    get { 
      ARG = self->_priv->loop_based; 
    }
    set { 
      self->_priv->loop_based = ARG;
      if (self->_priv->loop_based) {
        gst_element_set_loop_function (GST_ELEMENT (self), loop);
        gst_pad_set_chain_function (self->_priv->sinkpad, NULL);
      }
      else {
        gst_pad_set_chain_function (self->_priv->sinkpad, chain);
        gst_element_set_loop_function (GST_ELEMENT (self), NULL);
      }
    };*/
  private guint sleep_time = 0; argument UINT sleep_time link;
  private gboolean silent = FALSE; argument BOOL silent link;

  /* signals */
  private signal last NONE(NONE) void handoff(self);

  /* core code here */
  private GstBufferPool*
  get_bufferpool (GstPad *pad (check null))
  {
    Self *self = SELF (gst_pad_get_parent (pad));
    
    return gst_pad_get_bufferpool (self->_priv->srcpad);
  }

  /* private GstPadNegotiateReturn
  negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
  {
    Self *self = SELF (gst_pad_get_parent (pad));

    return gst_pad_negotiate_proxy (pad, self->_priv->sinkpad, caps);
  }

  private GstPadNegotiateReturn
  negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
  {
    Self *self = SELF (gst_pad_get_parent (pad));

    return gst_pad_negotiate_proxy (pad, self->_priv->srcpad, caps);
  } */

  private void
  chain (GstPad *pad (check null), GstBuffer *buf (check null))
  {
    Self *self;

    self = SELF (gst_pad_get_parent (pad));

    if (!self->_priv->silent)
      g_print("identity2: chain ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));

      handoff (self);
      gst_pad_push (self->_priv->srcpad, buf);

    if (self->_priv->sleep_time)
      usleep (self->_priv->sleep_time);
  }

  /*private void
  loop (GstElement *element (check null))
  {
    Self *self = SELF (element);
    GstBuffer *buf;

    do {
      buf = gst_pad_pull (self->_priv->sinkpad);
      g_print("identity2: loop ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(self->_priv->sinkpad));

      handoff (self);
      gst_pad_push (self->_priv->srcpad, buf);

      if (self->_priv->sleep_time)
        usleep (self->_priv->sleep_time);

    } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
  }*/
}

%{
GstPluginDesc plugin_desc = {
  GST_VERSION_MAJOR,
  GST_VERSION_MINOR,
  "identity2",
  gst_identity2_plugin_init
};
%}