| 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 <iostream> |
| 21 | |
| 22 | int main(int argc, char** argv) |
| 23 | { |
| 24 | Glib::RefPtr<Gst::Pipeline> pipeline; |
| 25 | Glib::RefPtr<Gst::Element> element_source, element_filter, element_sink; |
| 26 | |
| 27 | // Initialize Gstreamermm: |
| 28 | Gst::init(argc, argv); |
| 29 | |
| 30 | // Create pipeline: |
| 31 | pipeline = Gst::Pipeline::create("my-pipeline"); |
| 32 | |
| 33 | // Create elements: |
| 34 | element_source = Gst::ElementFactory::create_element("fakesrc"); |
| 35 | element_filter = Gst::ElementFactory::create_element("identity"); |
| 36 | element_sink = Gst::ElementFactory::create_element("fakesink"); |
| 37 | |
| 38 | // We must add the elements to the pipeline before linking them: |
| 39 | try |
| 40 | { |
| 41 | pipeline->add(element_source)->add(element_filter)->add(element_sink); |
| 42 | } |
| 43 | catch (std::runtime_error& ex) |
| 44 | { |
| 45 | std::cerr << "Exception while adding: " << ex.what() << std::endl; |
| 46 | return 1; |
| 47 | } |
| 48 | |
| 49 | // Link the elements together: |
| 50 | try |
| 51 | { |
| 52 | element_source->link(element_filter)->link(element_sink); |
| 53 | } |
| 54 | catch(const std::runtime_error& error) |
| 55 | { |
| 56 | std::cerr << "Exception while linking: " << error.what() << std::endl; |
| 57 | } |
| 58 | return 0; |
| 59 | } |