Debian Codegraph @

tests/plugins/foo.h

raw symbols SCIP
1 /*
2 * foo.h
3 *
4 * Created on: Aug 1, 2013
5 * Author: m.kolny
6 */
7
8 #ifndef TESTS_PLUGINS_FOO_H_
9 #define TESTS_PLUGINS_FOO_H_
10
11 #include <gstreamermm.h>
12 #include <gstreamermm/private/element_p.h>
13 #include <assert.h>
14
15 class Foo : public Gst::Element
16 {
17 Glib::RefPtr<Gst::Pad> sinkpad;
18 Glib::RefPtr<Gst::Pad> srcpad;
19 Glib::Property<Glib::ustring> sample_property;
20
21 public:
22 static void class_init(Gst::ElementClass<Foo> *klass)
23 {
24 klass->set_metadata("foo_longname",
25 "foo_classification", "foo_detail_description", "foo_detail_author");
26
27 klass->add_pad_template(Gst::PadTemplate::create("sink", Gst::PAD_SINK, Gst::PAD_ALWAYS,
28 Gst::Caps::create_any()));
29 klass->add_pad_template(Gst::PadTemplate::create("src", Gst::PAD_SRC, Gst::PAD_ALWAYS,
30 Gst::Caps::create_any()));
31 }
32
33 Gst::FlowReturn chain(const Glib::RefPtr<Gst::Pad> & /* pad */, Glib::RefPtr<Gst::Buffer> &buf)
34 {
35 buf = buf->create_writable();
36 assert(buf->gobj()->mini_object.refcount==1);
37 Gst::MapInfo mapinfo;
38 buf->map(mapinfo, Gst::MAP_WRITE);
39 std::sort(mapinfo.get_data(), mapinfo.get_data() + mapinfo.get_size());
40 buf->unmap(mapinfo);
41 assert(buf->gobj()->mini_object.refcount==1);
42 return srcpad->push(std::move(buf));
43 }
44
45 explicit Foo(GstElement *gobj)
46 : Glib::ObjectBase(typeid (Foo)), // type must be registered before use
47 Gst::Element(gobj),
48 sample_property(*this, "sample_property", "def_val")
49
50 {
51 add_pad(sinkpad = Gst::Pad::create(get_pad_template("sink"), "sink"));
52 add_pad(srcpad = Gst::Pad::create(get_pad_template("src"), "src"));
53 sinkpad->set_chain_function(sigc::mem_fun(*this, &Foo::chain));
54 }
55
56 static bool register_foo(Glib::RefPtr<Gst::Plugin> plugin)
57 {
58 Gst::ElementFactory::register_element(plugin, "foomm", 10, Gst::register_mm_type<Foo>("foo"));
59
60 return true;
61 }
62 };
63
64 #endif /* TESTS_PLUGINS_FOO_H_ */