Initial commit.
[qtgstreamer:qtgstreamer.git] / src / qgstbin.cpp
1 /*
2     Copyright (C) 2009  George Kiagiadakis <kiagiadakis.george@gmail.com>
3
4     This library is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published
6     by the Free Software Foundation; either version 2.1 of the License, or
7     (at your option) any later version.
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 Lesser General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "qgstbin.h"
18 #include <gst/gstbin.h>
19
20 namespace QtGstreamer {
21
22 QGstBin::QGstBin(const char *name, QObject *parent)
23     : QGstElement(gst_bin_new(name), parent)
24 {
25 }
26
27 QGstBin::QGstBin(GstBin *gstBin, QObject *parent)
28     : QGstElement(GST_ELEMENT(gstBin), parent)
29 {
30 }
31
32 QGstBin::~QGstBin()
33 {
34 }
35
36 bool QGstBin::add(QGstElement *element)
37 {
38     if ( gst_bin_add(GST_BIN(m_object), GST_ELEMENT(element->m_object)) ) {
39         element->setParent(this);
40         return true;
41     }
42     return false;
43 }
44
45 QGstBin & QGstBin::operator<<(QGstElement *element)
46 {
47     add(element);
48     return *this;
49 }
50
51 bool QGstBin::remove(QGstElement *element)
52 {
53     if ( gst_bin_remove(GST_BIN(m_object), GST_ELEMENT(element->m_object)) ) {
54         element->setParent(NULL);
55         return true;
56     }
57     return false;
58 }
59
60 }
61
62 #include "qgstbin.moc"