| 1 |
/* vim: set filetype=c: */ |
| 2 |
|
| 3 |
% instance-members |
| 4 |
GstPad *srcpad; |
| 5 |
% prototypes |
| 6 |
|
| 7 |
static GstCaps* gst_replace_src_getcaps (GstPad *pad); |
| 8 |
static gboolean gst_replace_src_setcaps (GstPad *pad, GstCaps *caps); |
| 9 |
static gboolean gst_replace_src_acceptcaps (GstPad *pad, GstCaps *caps); |
| 10 |
static void gst_replace_src_fixatecaps (GstPad *pad, GstCaps *caps); |
| 11 |
static gboolean gst_replace_src_activate (GstPad *pad); |
| 12 |
static gboolean gst_replace_src_activatepush (GstPad *pad, gboolean active); |
| 13 |
static gboolean gst_replace_src_activatepull (GstPad *pad, gboolean active); |
| 14 |
static GstPadLinkReturn gst_replace_src_link (GstPad *pad, GstPad *peer); |
| 15 |
static void gst_replace_src_unlink (GstPad *pad); |
| 16 |
static GstFlowReturn gst_replace_src_getrange (GstPad *pad, guint64 offset, guint length, |
| 17 |
GstBuffer **buffer); |
| 18 |
static gboolean gst_replace_src_event (GstPad *pad, GstEvent *event); |
| 19 |
static gboolean gst_replace_src_query (GstPad *pad, GstQuery *query); |
| 20 |
static GstIterator * gst_replace_src_iterintlink (GstPad *pad); |
| 21 |
|
| 22 |
% pad-template |
| 23 |
static GstStaticPadTemplate gst_replace_src_template = |
| 24 |
GST_STATIC_PAD_TEMPLATE ("src", |
| 25 |
GST_PAD_SRC, |
| 26 |
GST_PAD_ALWAYS, |
| 27 |
GST_STATIC_CAPS ("application/unknown") |
| 28 |
); |
| 29 |
|
| 30 |
% base-init |
| 31 |
gst_element_class_add_static_pad_template (element_class, |
| 32 |
&gst_replace_src_template); |
| 33 |
% instance-init |
| 34 |
|
| 35 |
replace->srcpad = gst_pad_new_from_static_template (&gst_replace_src_template |
| 36 |
, |
| 37 |
"src"); |
| 38 |
gst_pad_set_getcaps_function (replace->srcpad, |
| 39 |
GST_DEBUG_FUNCPTR(gst_replace_src_getcaps)); |
| 40 |
gst_pad_set_setcaps_function (replace->srcpad, |
| 41 |
GST_DEBUG_FUNCPTR(gst_replace_src_setcaps)); |
| 42 |
gst_pad_set_acceptcaps_function (replace->srcpad, |
| 43 |
GST_DEBUG_FUNCPTR(gst_replace_src_acceptcaps)); |
| 44 |
gst_pad_set_fixatecaps_function (replace->srcpad, |
| 45 |
GST_DEBUG_FUNCPTR(gst_replace_src_fixatecaps)); |
| 46 |
gst_pad_set_activate_function (replace->srcpad, |
| 47 |
GST_DEBUG_FUNCPTR(gst_replace_src_activate)); |
| 48 |
gst_pad_set_activatepush_function (replace->srcpad, |
| 49 |
GST_DEBUG_FUNCPTR(gst_replace_src_activatepush)); |
| 50 |
gst_pad_set_activatepull_function (replace->srcpad, |
| 51 |
GST_DEBUG_FUNCPTR(gst_replace_src_activatepull)); |
| 52 |
gst_pad_set_link_function (replace->srcpad, |
| 53 |
GST_DEBUG_FUNCPTR(gst_replace_src_link)); |
| 54 |
gst_pad_set_unlink_function (replace->srcpad, |
| 55 |
GST_DEBUG_FUNCPTR(gst_replace_src_unlink)); |
| 56 |
gst_pad_set_getrange_function (replace->srcpad, |
| 57 |
GST_DEBUG_FUNCPTR(gst_replace_src_getrange)); |
| 58 |
gst_pad_set_event_function (replace->srcpad, |
| 59 |
GST_DEBUG_FUNCPTR(gst_replace_src_event)); |
| 60 |
gst_pad_set_query_function (replace->srcpad, |
| 61 |
GST_DEBUG_FUNCPTR(gst_replace_src_query)); |
| 62 |
gst_pad_set_iterate_internal_links_function (replace->srcpad, |
| 63 |
GST_DEBUG_FUNCPTR(gst_replace_src_iterintlink)); |
| 64 |
gst_element_add_pad (GST_ELEMENT(replace), replace->srcpad); |
| 65 |
|
| 66 |
|
| 67 |
% methods |
| 68 |
|
| 69 |
static GstCaps* |
| 70 |
gst_replace_src_getcaps (GstPad *pad) |
| 71 |
{ |
| 72 |
GstReplace *replace; |
| 73 |
GstCaps *caps; |
| 74 |
|
| 75 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 76 |
|
| 77 |
GST_DEBUG_OBJECT(replace, "getcaps"); |
| 78 |
|
| 79 |
caps = gst_pad_get_pad_template_caps (pad); |
| 80 |
|
| 81 |
gst_object_unref (replace); |
| 82 |
return caps; |
| 83 |
} |
| 84 |
|
| 85 |
static gboolean |
| 86 |
gst_replace_src_setcaps (GstPad *pad, GstCaps *caps) |
| 87 |
{ |
| 88 |
GstReplace *replace; |
| 89 |
|
| 90 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 91 |
|
| 92 |
GST_DEBUG_OBJECT(replace, "setcaps"); |
| 93 |
|
| 94 |
|
| 95 |
gst_object_unref (replace); |
| 96 |
return TRUE; |
| 97 |
} |
| 98 |
|
| 99 |
static gboolean |
| 100 |
gst_replace_src_acceptcaps (GstPad *pad, GstCaps *caps) |
| 101 |
{ |
| 102 |
GstReplace *replace; |
| 103 |
|
| 104 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 105 |
|
| 106 |
GST_DEBUG_OBJECT(replace, "acceptcaps"); |
| 107 |
|
| 108 |
|
| 109 |
gst_object_unref (replace); |
| 110 |
return TRUE; |
| 111 |
} |
| 112 |
|
| 113 |
static void |
| 114 |
gst_replace_src_fixatecaps (GstPad *pad, GstCaps *caps) |
| 115 |
{ |
| 116 |
GstReplace *replace; |
| 117 |
|
| 118 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 119 |
|
| 120 |
GST_DEBUG_OBJECT(replace, "fixatecaps"); |
| 121 |
|
| 122 |
|
| 123 |
gst_object_unref (replace); |
| 124 |
} |
| 125 |
|
| 126 |
static gboolean |
| 127 |
gst_replace_src_activate (GstPad *pad) |
| 128 |
{ |
| 129 |
GstReplace *replace; |
| 130 |
gboolean ret; |
| 131 |
|
| 132 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 133 |
|
| 134 |
GST_DEBUG_OBJECT(replace, "activate"); |
| 135 |
|
| 136 |
if (gst_pad_check_pull_range (pad)) { |
| 137 |
GST_DEBUG_OBJECT (pad, "activating pull"); |
| 138 |
ret = gst_pad_activate_pull (pad, TRUE); |
| 139 |
} else { |
| 140 |
GST_DEBUG_OBJECT (pad, "activating push"); |
| 141 |
ret = gst_pad_activate_push (pad, TRUE); |
| 142 |
} |
| 143 |
|
| 144 |
gst_object_unref (replace); |
| 145 |
return ret; |
| 146 |
} |
| 147 |
|
| 148 |
static gboolean |
| 149 |
gst_replace_src_activatepush (GstPad *pad, gboolean active) |
| 150 |
{ |
| 151 |
GstReplace *replace; |
| 152 |
|
| 153 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 154 |
|
| 155 |
GST_DEBUG_OBJECT(replace, "activatepush"); |
| 156 |
|
| 157 |
|
| 158 |
gst_object_unref (replace); |
| 159 |
return TRUE; |
| 160 |
} |
| 161 |
|
| 162 |
static gboolean |
| 163 |
gst_replace_src_activatepull (GstPad *pad, gboolean active) |
| 164 |
{ |
| 165 |
GstReplace *replace; |
| 166 |
|
| 167 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 168 |
|
| 169 |
GST_DEBUG_OBJECT(replace, "activatepull"); |
| 170 |
|
| 171 |
|
| 172 |
gst_object_unref (replace); |
| 173 |
return TRUE; |
| 174 |
} |
| 175 |
|
| 176 |
static GstPadLinkReturn |
| 177 |
gst_replace_src_link (GstPad *pad, GstPad *peer) |
| 178 |
{ |
| 179 |
GstReplace *replace; |
| 180 |
|
| 181 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 182 |
|
| 183 |
GST_DEBUG_OBJECT(replace, "link"); |
| 184 |
|
| 185 |
|
| 186 |
gst_object_unref (replace); |
| 187 |
return GST_PAD_LINK_OK; |
| 188 |
} |
| 189 |
|
| 190 |
static void |
| 191 |
gst_replace_src_unlink (GstPad *pad) |
| 192 |
{ |
| 193 |
GstReplace *replace; |
| 194 |
|
| 195 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 196 |
|
| 197 |
GST_DEBUG_OBJECT(replace, "unlink"); |
| 198 |
|
| 199 |
|
| 200 |
gst_object_unref (replace); |
| 201 |
} |
| 202 |
|
| 203 |
static GstFlowReturn |
| 204 |
gst_replace_src_getrange (GstPad *pad, guint64 offset, guint length, |
| 205 |
GstBuffer **buffer) |
| 206 |
{ |
| 207 |
GstReplace *replace; |
| 208 |
|
| 209 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 210 |
|
| 211 |
GST_DEBUG_OBJECT(replace, "getrange"); |
| 212 |
|
| 213 |
|
| 214 |
gst_object_unref (replace); |
| 215 |
return GST_FLOW_OK; |
| 216 |
} |
| 217 |
|
| 218 |
static gboolean |
| 219 |
gst_replace_src_event (GstPad *pad, GstEvent *event) |
| 220 |
{ |
| 221 |
gboolean res; |
| 222 |
GstReplace *replace; |
| 223 |
|
| 224 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 225 |
|
| 226 |
GST_DEBUG_OBJECT(replace, "event"); |
| 227 |
|
| 228 |
switch (GST_EVENT_TYPE (event)) { |
| 229 |
default: |
| 230 |
res = gst_pad_event_default (pad, event); |
| 231 |
break; |
| 232 |
} |
| 233 |
|
| 234 |
gst_object_unref (replace); |
| 235 |
return res; |
| 236 |
} |
| 237 |
|
| 238 |
static gboolean |
| 239 |
gst_replace_src_query (GstPad *pad, GstQuery *query) |
| 240 |
{ |
| 241 |
gboolean res; |
| 242 |
GstReplace *replace; |
| 243 |
|
| 244 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 245 |
|
| 246 |
GST_DEBUG_OBJECT(replace, "query"); |
| 247 |
|
| 248 |
switch (GST_QUERY_TYPE(query)) { |
| 249 |
default: |
| 250 |
res = gst_pad_query_default (pad, query); |
| 251 |
break; |
| 252 |
} |
| 253 |
|
| 254 |
gst_object_unref (replace); |
| 255 |
return res; |
| 256 |
} |
| 257 |
|
| 258 |
static GstIterator * |
| 259 |
gst_replace_src_iterintlink (GstPad *pad) |
| 260 |
{ |
| 261 |
GstReplace *replace; |
| 262 |
GstIterator *iter; |
| 263 |
|
| 264 |
replace = GST_REPLACE (gst_pad_get_parent (pad)); |
| 265 |
|
| 266 |
GST_DEBUG_OBJECT(replace, "iterintlink"); |
| 267 |
|
| 268 |
iter = gst_pad_iterate_internal_links_default (pad); |
| 269 |
|
| 270 |
gst_object_unref (replace); |
| 271 |
return iter; |
| 272 |
} |
| 273 |
|
| 274 |
% end |
| 275 |
|