| 1 |
/* vim: set filetype=c: */ |
| 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 |
| 33 |
gst_element_class_add_static_pad_template (element_class, |
| 34 |
&gst_replace_sink_template); |
| 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, *tcaps; |
| 80 |
|
| 81 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 82 |
|
| 83 |
GST_DEBUG_OBJECT(replace, "getcaps"); |
| 84 |
|
| 85 |
tcaps = gst_pad_get_pad_template_caps (pad); |
| 86 |
caps = gst_caps_copy (tcaps); |
| 87 |
gst_caps_unref (tcaps); |
| 88 |
|
| 89 |
gst_object_unref (replace); |
| 90 |
return caps; |
| 91 |
} |
| 92 |
|
| 93 |
static gboolean |
| 94 |
gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps) |
| 95 |
{ |
| 96 |
GstReplace *replace; |
| 97 |
|
| 98 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 99 |
|
| 100 |
GST_DEBUG_OBJECT(replace, "setcaps"); |
| 101 |
|
| 102 |
|
| 103 |
gst_object_unref (replace); |
| 104 |
return TRUE; |
| 105 |
} |
| 106 |
|
| 107 |
static gboolean |
| 108 |
gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps) |
| 109 |
{ |
| 110 |
GstReplace *replace; |
| 111 |
|
| 112 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 113 |
|
| 114 |
GST_DEBUG_OBJECT(replace, "acceptcaps"); |
| 115 |
|
| 116 |
|
| 117 |
gst_object_unref (replace); |
| 118 |
return TRUE; |
| 119 |
} |
| 120 |
|
| 121 |
static void |
| 122 |
gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps) |
| 123 |
{ |
| 124 |
GstReplace *replace; |
| 125 |
|
| 126 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 127 |
|
| 128 |
GST_DEBUG_OBJECT(replace, "fixatecaps"); |
| 129 |
|
| 130 |
|
| 131 |
gst_object_unref (replace); |
| 132 |
} |
| 133 |
|
| 134 |
static gboolean |
| 135 |
gst_replace_sink_activate (GstPad *pad) |
| 136 |
{ |
| 137 |
GstReplace *replace; |
| 138 |
gboolean ret; |
| 139 |
|
| 140 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 141 |
|
| 142 |
GST_DEBUG_OBJECT(replace, "activate"); |
| 143 |
|
| 144 |
if (gst_pad_check_pull_range (pad)) { |
| 145 |
GST_DEBUG_OBJECT (pad, "activating pull"); |
| 146 |
ret = gst_pad_activate_pull (pad, TRUE); |
| 147 |
} else { |
| 148 |
GST_DEBUG_OBJECT (pad, "activating push"); |
| 149 |
ret = gst_pad_activate_push (pad, TRUE); |
| 150 |
} |
| 151 |
|
| 152 |
gst_object_unref (replace); |
| 153 |
return ret; |
| 154 |
} |
| 155 |
|
| 156 |
static gboolean |
| 157 |
gst_replace_sink_activatepush (GstPad *pad, gboolean active) |
| 158 |
{ |
| 159 |
GstReplace *replace; |
| 160 |
|
| 161 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 162 |
|
| 163 |
GST_DEBUG_OBJECT(replace, "activatepush"); |
| 164 |
|
| 165 |
|
| 166 |
gst_object_unref (replace); |
| 167 |
return TRUE; |
| 168 |
} |
| 169 |
|
| 170 |
static gboolean |
| 171 |
gst_replace_sink_activatepull (GstPad *pad, gboolean active) |
| 172 |
{ |
| 173 |
GstReplace *replace; |
| 174 |
|
| 175 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 176 |
|
| 177 |
GST_DEBUG_OBJECT(replace, "activatepull"); |
| 178 |
|
| 179 |
|
| 180 |
gst_object_unref (replace); |
| 181 |
return TRUE; |
| 182 |
} |
| 183 |
|
| 184 |
static GstPadLinkReturn |
| 185 |
gst_replace_sink_link (GstPad *pad, GstPad *peer) |
| 186 |
{ |
| 187 |
GstReplace *replace; |
| 188 |
|
| 189 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 190 |
|
| 191 |
GST_DEBUG_OBJECT(replace, "link"); |
| 192 |
|
| 193 |
|
| 194 |
gst_object_unref (replace); |
| 195 |
return GST_PAD_LINK_OK; |
| 196 |
} |
| 197 |
|
| 198 |
static void |
| 199 |
gst_replace_sink_unlink (GstPad *pad) |
| 200 |
{ |
| 201 |
GstReplace *replace; |
| 202 |
|
| 203 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 204 |
|
| 205 |
GST_DEBUG_OBJECT(replace, "unlink"); |
| 206 |
|
| 207 |
|
| 208 |
gst_object_unref (replace); |
| 209 |
} |
| 210 |
|
| 211 |
static GstFlowReturn |
| 212 |
gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer) |
| 213 |
{ |
| 214 |
GstReplace *replace; |
| 215 |
|
| 216 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 217 |
|
| 218 |
GST_DEBUG_OBJECT(replace, "chain"); |
| 219 |
|
| 220 |
|
| 221 |
gst_object_unref (replace); |
| 222 |
return GST_FLOW_OK; |
| 223 |
} |
| 224 |
|
| 225 |
static GstFlowReturn |
| 226 |
gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist) |
| 227 |
{ |
| 228 |
GstReplace *replace; |
| 229 |
|
| 230 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 231 |
|
| 232 |
GST_DEBUG_OBJECT(replace, "chainlist"); |
| 233 |
|
| 234 |
|
| 235 |
gst_object_unref (replace); |
| 236 |
return GST_FLOW_OK; |
| 237 |
} |
| 238 |
|
| 239 |
static gboolean |
| 240 |
gst_replace_sink_event (GstPad *pad, GstEvent *event) |
| 241 |
{ |
| 242 |
gboolean res; |
| 243 |
GstReplace *replace; |
| 244 |
|
| 245 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 246 |
|
| 247 |
GST_DEBUG_OBJECT(replace, "event"); |
| 248 |
|
| 249 |
switch (GST_EVENT_TYPE (event)) { |
| 250 |
default: |
| 251 |
res = gst_pad_event_default (pad, event); |
| 252 |
break; |
| 253 |
} |
| 254 |
|
| 255 |
gst_object_unref (replace); |
| 256 |
return res; |
| 257 |
} |
| 258 |
|
| 259 |
static gboolean |
| 260 |
gst_replace_sink_query (GstPad *pad, GstQuery *query) |
| 261 |
{ |
| 262 |
gboolean res; |
| 263 |
GstReplace *replace; |
| 264 |
|
| 265 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 266 |
|
| 267 |
GST_DEBUG_OBJECT(replace, "query"); |
| 268 |
|
| 269 |
switch (GST_QUERY_TYPE(query)) { |
| 270 |
default: |
| 271 |
res = gst_pad_query_default (pad, query); |
| 272 |
break; |
| 273 |
} |
| 274 |
|
| 275 |
gst_object_unref (replace); |
| 276 |
return res; |
| 277 |
} |
| 278 |
|
| 279 |
static GstFlowReturn |
| 280 |
gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size, |
| 281 |
GstCaps *caps, GstBuffer **buf) |
| 282 |
{ |
| 283 |
GstReplace *replace; |
| 284 |
|
| 285 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 286 |
|
| 287 |
GST_DEBUG_OBJECT(replace, "bufferalloc"); |
| 288 |
|
| 289 |
|
| 290 |
*buf = gst_buffer_new_and_alloc (size); |
| 291 |
gst_buffer_set_caps (*buf, caps); |
| 292 |
|
| 293 |
gst_object_unref (replace); |
| 294 |
return GST_FLOW_OK; |
| 295 |
} |
| 296 |
|
| 297 |
static GstIterator * |
| 298 |
gst_replace_sink_iterintlink (GstPad *pad) |
| 299 |
{ |
| 300 |
GstReplace *replace; |
| 301 |
GstIterator *iter; |
| 302 |
|
| 303 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 304 |
|
| 305 |
GST_DEBUG_OBJECT(replace, "iterintlink"); |
| 306 |
|
| 307 |
iter = gst_pad_iterate_internal_links_default (pad); |
| 308 |
|
| 309 |
gst_object_unref (replace); |
| 310 |
return iter; |
| 311 |
} |
| 312 |
|
| 313 |
% end |
| 314 |
|