Debian Codegraph @

examples/basics/bin.cc

raw symbols SCIP
1 /*
2 * This example presents basic usage of the Gst::Bin class.
3 */
4 #include <gstreamermm.h>cxx . . $ `<file>/gstreamer/gstreamermm.h`/
5
6 #include <iostream>
7
8 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
9 {
10 Gstcxx . . $ Gst/::initcxx . . $ Gst/init(22930d6ef54703eb).(argc, argv);
11
12 // Create some elements
13 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> fakesrc = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(bde311d80d2d00e5).("fakesrc"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9)., "source"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
14 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> fakesink = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(bde311d80d2d00e5).("fakesink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9)., "sink"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
15
16 // Create empty bin
17 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Bincxx . . $ Gst/Bin#> bin = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::Bincxx . . $ Gst/Bin#::createcxx . . $ Gst/Bin#create(b51080e4f37e7146).("my-bin"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
18
19 // Add elements to a bin
20 try
21 {
22 bin->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(fakesrc)->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).addcxx . . $ Gst/Bin#add(25e1dc1b4b432bb3).(fakesink);
23 }
24 catch (const stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#& ex)
25 {
26 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Exception while adding: " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ex.whatcxx . . $ std/runtime_error#what(a9f41ea0e82d88cf).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
27 return 1;
28 }
29
30 // Some of the elements are actually a bins, so we can cast
31 // them.
32 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> playbin = Gstcxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439).::ElementFactorycxx . . $ Gst/ElementFactory#::create_elementcxx . . $ Gst/ElementFactory#create_element(1ef5e1ee31814ad5).("playbin"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).);
33 Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Bincxx . . $ Gst/Bin#> playbin_bin = playbin_bincxx . . $ Glib/RefPtr#RefPtr(b50b0f543100b439)..cast_staticcxx . . $ Glib/RefPtr#cast_static(9d87394f87ca1249).(playbin);
34
35 if (!playbin_bin)
36 {
37 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Cannot find playbin element" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
38 return 1;
39 }
40
41
42 // We can also iterate through the elements in the bin
43 Gstcxx . . $ Gst/::Iteratorcxx . . $ Gst/Iterator#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#> it = playbin_bin->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).iterate_recursecxx . . $ Gst/Bin#iterate_recurse(7f8530c72496f9ec).();
44 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "List of elements in the container: " <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
45 while (it.nextcxx . . $ Gst/Iterator#next(13ddd060d74cffe7).())
46 {
47 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " * " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). it->cxx . . $ Gst/Iterator#`operator->`(5a2a78a048fb49a8).get_namecxx . . $ Gst/Object#get_name(fff0f585954e56f3).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
48 }
49
50 // We can also connect to signals emitted by bin, e.g. when
51 // the element has been removed.
52 bin->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).signal_element_removedcxx . . $ Gst/Bin#signal_element_removed(89eed8b771d92eb).().connectcxx . . $ Glib/SignalProxy#connect(23e07d4a2c0735e0).(
53 [cxx . . $ sigc/slot#slot(edcd8b2679e9bd1a).] (const Glibcxx . . $ Glib/::RefPtrcxx . . $ Glib/RefPtr#<Gstcxx . . $ Gst/::Elementcxx . . $ Gst/Element#>& removed_element)
54 {
55 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Element '" <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). removed_element->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).get_namecxx . . $ Gst/Object#get_name(fff0f585954e56f3).()
56 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "' has been removed from the bin" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
57 }
58 );
59
60 bin->cxx . . $ Glib/RefPtr#`operator->`(5a2a78a048fb49a8).removecxx . . $ Gst/Bin#remove(25e1dc1b4b432bb3).(fakesink);
61
62 stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "returning from application..." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
63
64 return 0;
65 }
66