David Schleef | 7ae4aaa | 2010-12-15 12:45:38 -0800 | [diff] [blame] | 1 | /* vim: set filetype=c: */ |
David Schleef | da1fe1e | 2010-12-14 19:03:09 -0800 | [diff] [blame] | 2 | |
| 3 | % instance-members |
| 4 | GstPad *sinkpad; |
| 5 | % prototypes |
| 6 | |
| 7 | static GstCaps* gst_replace_sink_getcaps (GstPad *pad); |
| 8 | static gboolean gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps); |
| 9 | static gboolean gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps); |
| 10 | static void gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps); |
| 11 | static gboolean gst_replace_sink_activate (GstPad *pad); |
| 12 | static gboolean gst_replace_sink_activatepush (GstPad *pad, gboolean active); |
| 13 | static gboolean gst_replace_sink_activatepull (GstPad *pad, gboolean active); |
| 14 | static GstPadLinkReturn gst_replace_sink_link (GstPad *pad, GstPad *peer); |
| 15 | static void gst_replace_sink_unlink (GstPad *pad); |
| 16 | static GstFlowReturn gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer); |
| 17 | static GstFlowReturn gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist); |
| 18 | static gboolean gst_replace_sink_event (GstPad *pad, GstEvent *event); |
| 19 | static gboolean gst_replace_sink_query (GstPad *pad, GstQuery *query); |
| 20 | static GstFlowReturn gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size, |
| 21 | GstCaps *caps, GstBuffer **buf); |
| 22 | static GstIterator * gst_replace_sink_iterintlink (GstPad *pad); |
| 23 | |
| 24 | % pad-template |
| 25 | static GstStaticPadTemplate gst_replace_sink_template = |
| 26 | GST_STATIC_PAD_TEMPLATE ("sink", |
| 27 | GST_PAD_SINK, |
| 28 | GST_PAD_ALWAYS, |
| 29 | GST_STATIC_CAPS ("application/unknown") |
| 30 | ); |
| 31 | |
| 32 | % base-init |
Vineeth TM | 8cdfb13 | 2016-03-04 15:50:26 +0900 | [diff] [blame] | 33 | gst_element_class_add_static_pad_template (element_class, |
| 34 | &gst_replace_sink_template); |
David Schleef | da1fe1e | 2010-12-14 19:03:09 -0800 | [diff] [blame] | 35 | % instance-init |
| 36 | |
| 37 | replace->sinkpad = gst_pad_new_from_static_template (&gst_replace_sink_template |
| 38 | , |
| 39 | "sink"); |
| 40 | gst_pad_set_getcaps_function (replace->sinkpad, |
| 41 | GST_DEBUG_FUNCPTR(gst_replace_sink_getcaps)); |
| 42 | gst_pad_set_setcaps_function (replace->sinkpad, |
| 43 | GST_DEBUG_FUNCPTR(gst_replace_sink_setcaps)); |
| 44 | gst_pad_set_acceptcaps_function (replace->sinkpad, |
| 45 | GST_DEBUG_FUNCPTR(gst_replace_sink_acceptcaps)); |
| 46 | gst_pad_set_fixatecaps_function (replace->sinkpad, |
| 47 | GST_DEBUG_FUNCPTR(gst_replace_sink_fixatecaps)); |
| 48 | gst_pad_set_activate_function (replace->sinkpad, |
| 49 | GST_DEBUG_FUNCPTR(gst_replace_sink_activate)); |
| 50 | gst_pad_set_activatepush_function (replace->sinkpad, |
| 51 | GST_DEBUG_FUNCPTR(gst_replace_sink_activatepush)); |
| 52 | gst_pad_set_activatepull_function (replace->sinkpad, |
| 53 | GST_DEBUG_FUNCPTR(gst_replace_sink_activatepull)); |
| 54 | gst_pad_set_link_function (replace->sinkpad, |
| 55 | GST_DEBUG_FUNCPTR(gst_replace_sink_link)); |
| 56 | gst_pad_set_unlink_function (replace->sinkpad, |
| 57 | GST_DEBUG_FUNCPTR(gst_replace_sink_unlink)); |
| 58 | gst_pad_set_chain_function (replace->sinkpad, |
| 59 | GST_DEBUG_FUNCPTR(gst_replace_sink_chain)); |
| 60 | gst_pad_set_chain_list_function (replace->sinkpad, |
| 61 | GST_DEBUG_FUNCPTR(gst_replace_sink_chainlist)); |
| 62 | gst_pad_set_event_function (replace->sinkpad, |
| 63 | GST_DEBUG_FUNCPTR(gst_replace_sink_event)); |
| 64 | gst_pad_set_query_function (replace->sinkpad, |
| 65 | GST_DEBUG_FUNCPTR(gst_replace_sink_query)); |
| 66 | gst_pad_set_bufferalloc_function (replace->sinkpad, |
| 67 | GST_DEBUG_FUNCPTR(gst_replace_sink_bufferalloc)); |
| 68 | gst_pad_set_iterate_internal_links_function (replace->sinkpad, |
| 69 | GST_DEBUG_FUNCPTR(gst_replace_sink_iterintlink)); |
| 70 | gst_element_add_pad (GST_ELEMENT(replace), replace->sinkpad); |
| 71 | |
| 72 | |
| 73 | % methods |
| 74 | |
| 75 | static GstCaps* |
| 76 | gst_replace_sink_getcaps (GstPad *pad) |
| 77 | { |
| 78 | GstReplace *replace; |
| 79 | GstCaps *caps; |
| 80 | |
| 81 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 82 | |
| 83 | GST_DEBUG_OBJECT(replace, "getcaps"); |
| 84 | |
| 85 | caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); |
| 86 | |
| 87 | gst_object_unref (replace); |
| 88 | return caps; |
| 89 | } |
| 90 | |
| 91 | static gboolean |
| 92 | gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps) |
| 93 | { |
| 94 | GstReplace *replace; |
| 95 | |
| 96 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 97 | |
| 98 | GST_DEBUG_OBJECT(replace, "setcaps"); |
| 99 | |
| 100 | |
| 101 | gst_object_unref (replace); |
| 102 | return TRUE; |
| 103 | } |
| 104 | |
| 105 | static gboolean |
| 106 | gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps) |
| 107 | { |
| 108 | GstReplace *replace; |
| 109 | |
| 110 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 111 | |
| 112 | GST_DEBUG_OBJECT(replace, "acceptcaps"); |
| 113 | |
| 114 | |
| 115 | gst_object_unref (replace); |
| 116 | return TRUE; |
| 117 | } |
| 118 | |
| 119 | static void |
| 120 | gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps) |
| 121 | { |
| 122 | GstReplace *replace; |
| 123 | |
| 124 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 125 | |
| 126 | GST_DEBUG_OBJECT(replace, "fixatecaps"); |
| 127 | |
| 128 | |
| 129 | gst_object_unref (replace); |
| 130 | } |
| 131 | |
| 132 | static gboolean |
| 133 | gst_replace_sink_activate (GstPad *pad) |
| 134 | { |
| 135 | GstReplace *replace; |
| 136 | gboolean ret; |
| 137 | |
| 138 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 139 | |
| 140 | GST_DEBUG_OBJECT(replace, "activate"); |
| 141 | |
| 142 | if (gst_pad_check_pull_range (pad)) { |
| 143 | GST_DEBUG_OBJECT (pad, "activating pull"); |
| 144 | ret = gst_pad_activate_pull (pad, TRUE); |
| 145 | } else { |
| 146 | GST_DEBUG_OBJECT (pad, "activating push"); |
| 147 | ret = gst_pad_activate_push (pad, TRUE); |
| 148 | } |
| 149 | |
| 150 | gst_object_unref (replace); |
| 151 | return ret; |
| 152 | } |
| 153 | |
| 154 | static gboolean |
| 155 | gst_replace_sink_activatepush (GstPad *pad, gboolean active) |
| 156 | { |
| 157 | GstReplace *replace; |
| 158 | |
| 159 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 160 | |
| 161 | GST_DEBUG_OBJECT(replace, "activatepush"); |
| 162 | |
| 163 | |
| 164 | gst_object_unref (replace); |
| 165 | return TRUE; |
| 166 | } |
| 167 | |
| 168 | static gboolean |
| 169 | gst_replace_sink_activatepull (GstPad *pad, gboolean active) |
| 170 | { |
| 171 | GstReplace *replace; |
| 172 | |
| 173 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 174 | |
| 175 | GST_DEBUG_OBJECT(replace, "activatepull"); |
| 176 | |
| 177 | |
| 178 | gst_object_unref (replace); |
| 179 | return TRUE; |
| 180 | } |
| 181 | |
| 182 | static GstPadLinkReturn |
| 183 | gst_replace_sink_link (GstPad *pad, GstPad *peer) |
| 184 | { |
| 185 | GstReplace *replace; |
| 186 | |
| 187 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 188 | |
| 189 | GST_DEBUG_OBJECT(replace, "link"); |
| 190 | |
| 191 | |
| 192 | gst_object_unref (replace); |
| 193 | return GST_PAD_LINK_OK; |
| 194 | } |
| 195 | |
| 196 | static void |
| 197 | gst_replace_sink_unlink (GstPad *pad) |
| 198 | { |
| 199 | GstReplace *replace; |
| 200 | |
| 201 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 202 | |
| 203 | GST_DEBUG_OBJECT(replace, "unlink"); |
| 204 | |
| 205 | |
| 206 | gst_object_unref (replace); |
| 207 | } |
| 208 | |
| 209 | static GstFlowReturn |
| 210 | gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer) |
| 211 | { |
| 212 | GstReplace *replace; |
| 213 | |
| 214 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 215 | |
| 216 | GST_DEBUG_OBJECT(replace, "chain"); |
| 217 | |
| 218 | |
| 219 | gst_object_unref (replace); |
| 220 | return GST_FLOW_OK; |
| 221 | } |
| 222 | |
| 223 | static GstFlowReturn |
| 224 | gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist) |
| 225 | { |
| 226 | GstReplace *replace; |
| 227 | |
| 228 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 229 | |
| 230 | GST_DEBUG_OBJECT(replace, "chainlist"); |
| 231 | |
| 232 | |
| 233 | gst_object_unref (replace); |
| 234 | return GST_FLOW_OK; |
| 235 | } |
| 236 | |
| 237 | static gboolean |
| 238 | gst_replace_sink_event (GstPad *pad, GstEvent *event) |
| 239 | { |
| 240 | gboolean res; |
| 241 | GstReplace *replace; |
| 242 | |
| 243 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 244 | |
| 245 | GST_DEBUG_OBJECT(replace, "event"); |
| 246 | |
| 247 | switch (GST_EVENT_TYPE (event)) { |
| 248 | default: |
| 249 | res = gst_pad_event_default (pad, event); |
| 250 | break; |
| 251 | } |
| 252 | |
| 253 | gst_object_unref (replace); |
| 254 | return res; |
| 255 | } |
| 256 | |
| 257 | static gboolean |
| 258 | gst_replace_sink_query (GstPad *pad, GstQuery *query) |
| 259 | { |
| 260 | gboolean res; |
| 261 | GstReplace *replace; |
| 262 | |
| 263 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 264 | |
| 265 | GST_DEBUG_OBJECT(replace, "query"); |
| 266 | |
| 267 | switch (GST_QUERY_TYPE(query)) { |
| 268 | default: |
| 269 | res = gst_pad_query_default (pad, query); |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | gst_object_unref (replace); |
| 274 | return res; |
| 275 | } |
| 276 | |
| 277 | static GstFlowReturn |
| 278 | gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size, |
| 279 | GstCaps *caps, GstBuffer **buf) |
| 280 | { |
| 281 | GstReplace *replace; |
| 282 | |
| 283 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 284 | |
| 285 | GST_DEBUG_OBJECT(replace, "bufferalloc"); |
| 286 | |
| 287 | |
| 288 | *buf = gst_buffer_new_and_alloc (size); |
| 289 | gst_buffer_set_caps (*buf, caps); |
| 290 | |
| 291 | gst_object_unref (replace); |
| 292 | return GST_FLOW_OK; |
| 293 | } |
| 294 | |
| 295 | static GstIterator * |
| 296 | gst_replace_sink_iterintlink (GstPad *pad) |
| 297 | { |
| 298 | GstReplace *replace; |
| 299 | GstIterator *iter; |
| 300 | |
| 301 | replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 302 | |
| 303 | GST_DEBUG_OBJECT(replace, "iterintlink"); |
| 304 | |
| 305 | iter = gst_pad_iterate_internal_links_default (pad); |
| 306 | |
| 307 | gst_object_unref (replace); |
| 308 | return iter; |
| 309 | } |
| 310 | |
| 311 | % end |
| 312 | |