QtGStreamer 0.10.1
|
00001 /* 00002 Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published 00006 by the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #include "bin.h" 00018 #include "pad.h" 00019 #include "../QGlib/error.h" 00020 #include <gst/gstbin.h> 00021 #include <gst/gstutils.h> 00022 00023 namespace QGst { 00024 00025 //static 00026 BinPtr Bin::create(const char *name) 00027 { 00028 GstElement *bin = gst_bin_new(name); 00029 if (bin) { 00030 gst_object_ref_sink(bin); 00031 } 00032 return BinPtr::wrap(GST_BIN(bin), false); 00033 } 00034 00035 //static 00036 BinPtr Bin::fromDescription(const char *description, BinFromDescriptionOption ghostUnlinkedPads) 00037 { 00038 GError *error = NULL; 00039 GstElement *e = gst_parse_bin_from_description_full(description, ghostUnlinkedPads, 00040 NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error); 00041 if (error) { 00042 throw QGlib::Error(error); 00043 } 00044 if (e) { 00045 gst_object_ref_sink(e); 00046 } 00047 return BinPtr::wrap(GST_BIN(e), false); 00048 } 00049 00050 bool Bin::add(const ElementPtr & element) 00051 { 00052 return gst_bin_add(object<GstBin>(), element); 00053 } 00054 00055 bool Bin::remove(const ElementPtr & element) 00056 { 00057 return gst_bin_remove(object<GstBin>(), element); 00058 } 00059 00060 ElementPtr Bin::getElementByName(const char *name, RecursionType r) const 00061 { 00062 GstElement *e = NULL; 00063 switch(r) { 00064 case RecurseDown: 00065 e = gst_bin_get_by_name(object<GstBin>(), name); 00066 break; 00067 case RecurseUp: 00068 e = gst_bin_get_by_name_recurse_up(object<GstBin>(), name); 00069 break; 00070 default: 00071 Q_ASSERT_X(false, "QGst::Bin::getElementByName", "Invalid RecursionType"); 00072 } 00073 return ElementPtr::wrap(e, false); 00074 } 00075 00076 ElementPtr Bin::getElementByInterface(QGlib::Type interfaceType) const 00077 { 00078 return ElementPtr::wrap(gst_bin_get_by_interface(object<GstBin>(), interfaceType), false); 00079 } 00080 00081 PadPtr Bin::findUnlinkedPad(PadDirection direction) const 00082 { 00083 return PadPtr::wrap(gst_bin_find_unlinked_pad(object<GstBin>(), 00084 static_cast<GstPadDirection>(direction)), false); 00085 } 00086 00087 bool Bin::recalculateLatency() 00088 { 00089 return gst_bin_recalculate_latency(object<GstBin>()); 00090 } 00091 00092 }