| 1 | /* gstreamermm - a C++ wrapper for gstreamer |
| 2 | * |
| 3 | * Copyright 2008 The gstreamermm Development Team |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 |
| 7 | * as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | #include <gstreamermm.h> |
| 20 | #include <glibmm/optioncontext.h> |
| 21 | #include <iostream> |
| 22 | |
| 23 | Glib::OptionEntry make_entry(const Glib::ustring& long_name, const gchar& short_name, const Glib::ustring& description) |
| 24 | { |
| 25 | Glib::OptionEntry m_OptionEntry; |
| 26 | |
| 27 | if(!long_name.empty()) |
| 28 | m_OptionEntry.set_long_name(long_name); |
| 29 | if(short_name) |
| 30 | m_OptionEntry.set_short_name(short_name); |
| 31 | if(!description.empty()) |
| 32 | m_OptionEntry.set_description(description); |
| 33 | |
| 34 | return m_OptionEntry; |
| 35 | } |
| 36 | |
| 37 | int main(int argc, char** argv) |
| 38 | { |
| 39 | bool silent = false; |
| 40 | std::string path; |
| 41 | |
| 42 | Glib::OptionGroup m_OptionGroup("name", "description", "help description"); |
| 43 | Glib::OptionContext m_OptionContext("- Your application"); |
| 44 | |
| 45 | m_OptionGroup.add_entry(make_entry("silent", 's', "do not output status information"), silent); |
| 46 | m_OptionGroup.add_entry_filename(make_entry("output", 'o', "save xml representation of pipeline to file and exit"), path); |
| 47 | |
| 48 | m_OptionContext.set_main_group(m_OptionGroup); |
| 49 | |
| 50 | Glib::OptionGroup m_GstOptiongroup = Gst::get_option_group(); |
| 51 | m_OptionContext.add_group(m_GstOptiongroup); |
| 52 | |
| 53 | try |
| 54 | { |
| 55 | m_OptionContext.parse(argc, argv); |
| 56 | } |
| 57 | catch(const Glib::OptionError& error) |
| 58 | { |
| 59 | std::cout << "Failed to initialize: " << error.what() << std::endl; |
| 60 | return 1; |
| 61 | } |
| 62 | |
| 63 | std::cout << "Run me with --help to see the Application options appended.\n"; |
| 64 | return 0; |
| 65 | } |