| 1 | /* |
| 2 | * The example presents how to initialize gstreamermm, read |
| 3 | * version of GStreamer, and use GStreamer option group together |
| 4 | * with your application's option group. |
| 5 | */ |
| 6 | #include <gstreamermm.h>cxx . . $ `<file>/gstreamer/gstreamermm.h`/ |
| 7 | #include <glibmm/optioncontext.h> |
| 8 | |
| 9 | #include <iostream> |
| 10 | |
| 11 | class MainOptionGroupcxx . . $ MainOptionGroup# : public Glibcxx . . $ Glib/::OptionGroupcxx . . $ Glib/OptionGroup# |
| 12 | { |
| 13 | public: |
| 14 | MainOptionGroupcxx . . $ MainOptionGroup#MainOptionGroup(49f6e7a06ebc5aa8).(); |
| 15 | |
| 16 | bool versioncxx . . $ MainOptionGroup#version.; |
| 17 | }; |
| 18 | |
| 19 | MainOptionGroupcxx . . $ MainOptionGroup#::MainOptionGroupcxx . . $ MainOptionGroup#MainOptionGroup(49f6e7a06ebc5aa8).() |
| 20 | : Glibcxx . . $ Glib/::OptionGroupcxx . . $ Glib/OptionGroup#("main_group"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9)., "main group"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).), |
| 21 | versioncxx . . $ MainOptionGroup#version.(false) |
| 22 | { |
| 23 | Glibcxx . . $ Glib/::OptionEntrycxx . . $ Glib/OptionEntry# entry1cxx . . $ Glib/OptionEntry#OptionEntry(49f6e7a06ebc5aa8).; |
| 24 | entry1.set_long_namecxx . . $ Glib/OptionEntry#set_long_name(1ff0bff2cee2bc51).("version"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 25 | entry1.set_short_namecxx . . $ Glib/OptionEntry#set_short_name(3a781f7493a9de53).('v'); |
| 26 | entry1.set_descriptioncxx . . $ Glib/OptionEntry#set_description(1ff0bff2cee2bc51).("Show gstreamer version"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 27 | add_entrycxx . . $ Glib/OptionGroup#add_entry(82a211dd781d3387).(entry1, versioncxx . . $ MainOptionGroup#version.); |
| 28 | } |
| 29 | |
| 30 | static void print_gstreamer_versioncxx . . $ print_gstreamer_version(49f6e7a06ebc5aa8).() |
| 31 | { |
| 32 | guint major, minor, micro, nano; |
| 33 | |
| 34 | // Read GStreamer version |
| 35 | Gstcxx . . $ Gst/::versioncxx . . $ Gst/version(520e0e54372a3f5e).(major, minor, micro, nano); |
| 36 | |
| 37 | stdcxx . . $ std/::stringcxx . . $ std/string# nano_strcxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).; |
| 38 | |
| 39 | switch (nano) { |
| 40 | case 1: nano_str =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "(CSV)"; break; |
| 41 | case 2: nano_str =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "(Prerelease)"; break; |
| 42 | } |
| 43 | |
| 44 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "This program is linked against GStreamer " |
| 45 | <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). major <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "." <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). minor <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "." <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). micro <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "." |
| 46 | <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). nano <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). nano_str <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 47 | } |
| 48 | |
| 49 | int maincxx . . $ main(afcd3168fc1188a4). (int argc, char *argv[]) |
| 50 | { |
| 51 | // Initialize gstreamermm |
| 52 | Gstcxx . . $ Gst/::initcxx . . $ Gst/init(22930d6ef54703eb).(argc, argv); |
| 53 | |
| 54 | Glibcxx . . $ Glib/::OptionContextcxx . . $ Glib/OptionContext# contextcxx . . $ Glib/OptionContext#OptionContext(1ff0bff2cee2bc51).("- gstreamermm init example"cxx . . $ Glib/ustring#ustring(85c52e162fed56f9).); |
| 55 | |
| 56 | MainOptionGroupcxx . . $ MainOptionGroup# main_groupcxx . . $ MainOptionGroup#MainOptionGroup(49f6e7a06ebc5aa8).; |
| 57 | context.set_main_groupcxx . . $ Glib/OptionContext#set_main_group(1fb11a164371f342).(main_group); |
| 58 | |
| 59 | // Get GStreamer option group and add it to the context |
| 60 | Glibcxx . . $ Glib/::OptionGroupcxx . . $ Glib/OptionGroup# gst_group = Gstcxx . . $ Glib/OptionGroup#OptionGroup(f3768ed7fee6ab8).::get_option_groupcxx . . $ Gst/get_option_group(736c17c952ba4903).(); |
| 61 | context.add_groupcxx . . $ Glib/OptionContext#add_group(1fb11a164371f342).(gst_group); |
| 62 | |
| 63 | try |
| 64 | { |
| 65 | context.parsecxx . . $ Glib/OptionContext#parse(82fa2dc335b2ba4e).(argc, argv); |
| 66 | } |
| 67 | catch (const Glibcxx . . $ Glib/::Errorcxx . . $ Glib/Error#& ex) |
| 68 | { |
| 69 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Failed to initialize: " <<cxx . . $ Glib/`operator<<`(d3a65685b7328161). ex.whatcxx . . $ Glib/Error#what(fff0f585954e56f3).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | if (main_group.versioncxx . . $ MainOptionGroup#version.) |
| 74 | { |
| 75 | print_gstreamer_versioncxx . . $ print_gstreamer_version(49f6e7a06ebc5aa8).(); |
| 76 | } |
| 77 | |
| 78 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Run me with --help to see the Application options appended." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 79 | |
| 80 | return 0; |
| 81 | } |