00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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
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 }