File: init_gstreamermm.cc

package info (click to toggle)
gstreamermm-1.0 1.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,508 kB
  • sloc: xml: 68,148; cpp: 6,109; sh: 4,187; makefile: 243; perl: 236
file content (81 lines) | stat: -rw-r--r-- 1,790 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * The example presents how to initialize gstreamermm, read
 * version of GStreamer, and use GStreamer option group together
 * with your application's option group.
 */
#include <gstreamermm.h>
#include <glibmm/optioncontext.h>

#include <iostream>

class MainOptionGroup : public Glib::OptionGroup
{
public:
  MainOptionGroup();

  bool version;
};

MainOptionGroup::MainOptionGroup()
: Glib::OptionGroup("main_group", "main group"),
  version(false)
{
  Glib::OptionEntry entry1;
  entry1.set_long_name("version");
  entry1.set_short_name('v');
  entry1.set_description("Show gstreamer version");
  add_entry(entry1, version);
}

static void print_gstreamer_version()
{
  guint major, minor, micro, nano;

  // Read GStreamer version
  Gst::version(major, minor, micro, nano);

  std::string nano_str;

  switch (nano) {
    case 1: nano_str = "(CSV)"; break;
    case 2: nano_str = "(Prerelease)"; break;
  }

  std::cout << "This program is linked against GStreamer "
      << major << "." << minor << "." << micro << "."
      << nano << " " << nano_str << std::endl;
}

int main (int argc, char *argv[])
{
  // Initialize gstreamermm
  Gst::init(argc, argv);

  Glib::OptionContext context("- gstreamermm init example");

  MainOptionGroup main_group;
  context.set_main_group(main_group);

  // Get GStreamer option group and add it to the context
  Glib::OptionGroup gst_group = Gst::get_option_group();
  context.add_group(gst_group);

  try
  {
    context.parse(argc, argv);
  }
  catch (const Glib::Error& ex)
  {
    std::cerr << "Failed to initialize: " << ex.what() << std::endl;
    return 1;
  }

  if (main_group.version)
  {
    print_gstreamer_version();
  }

  std::cout << "Run me with --help to see the Application options appended." << std::endl;

  return 0;
}