gnomemm r2126 - in gstreamermm/trunk: . gstreamer/src tests
- From: jaalburqu svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r2126 - in gstreamermm/trunk: . gstreamer/src tests
- Date: Wed, 25 Mar 2009 02:07:17 +0000 (UTC)
Author: jaalburqu
Date: Wed Mar 25 02:07:17 2009
New Revision: 2126
URL: http://svn.gnome.org/viewvc/gnomemm?rev=2126&view=rev
Log:
2009-03-24 Josà Alburquerque <jaalburqu svn gnome org>
* gstreamer/src/bin.ccg: Corrected comments on what happens when add()
or remove() fail to add/remove elements.
* gstreamer/src/bin.hg: Added @throws directive to remove() docs so
users know that remove() throws an exception on failure.
* gstreamer/src/element.ccg:
* gstreamer/src/element.hg: Added a null element check in link().
Removed duplicate include.
* gstreamer/src/ghostpad.ccg:
* gstreamer/src/ghostpad.hg: Modified constructors to throw exceptions
if construction fails. Added docs to constructors so that users know
that constructors throw exceptions. Corrected some docs.
* tests/test-ghost-pad.cc: Modified test so that it runs successfully;
uncommenting commented sections exemplifies how exceptions are thrown
on construction failure.
* gstreamer/src/filter.ccg: Corrected returned ListHandle<> ownership
type.
* gstreamer/src/colorbalance.ccg:
* gstreamer/src/format.ccg:
* gstreamer/src/preset.ccg: Spacing.
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/gstreamer/src/bin.ccg
gstreamermm/trunk/gstreamer/src/bin.hg
gstreamermm/trunk/gstreamer/src/colorbalance.ccg
gstreamermm/trunk/gstreamer/src/element.ccg
gstreamermm/trunk/gstreamer/src/element.hg
gstreamermm/trunk/gstreamer/src/filter.ccg
gstreamermm/trunk/gstreamer/src/format.ccg
gstreamermm/trunk/gstreamer/src/ghostpad.ccg
gstreamermm/trunk/gstreamer/src/ghostpad.hg
gstreamermm/trunk/gstreamer/src/preset.ccg
gstreamermm/trunk/tests/test-ghost-pad.cc
Modified: gstreamermm/trunk/gstreamer/src/bin.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bin.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/bin.ccg Wed Mar 25 02:07:17 2009
@@ -53,12 +53,13 @@
const bool result = gst_bin_add(gobj(), celement);
- // If addition successful, return RefPtr<..> to this bin, otherwise return
- // null RefPtr<...>
+ // If addition successful, return RefPtr<..> to this bin, otherwise throw an
+ // exception
if(result)
return Glib::wrap(gobj(), true);
else
- throw std::runtime_error("Failed to add " + element->get_name() + " element.");
+ throw std::runtime_error("Failed to add " + element->get_name() +
+ " element.");
}
Glib::RefPtr<Gst::Bin> Bin::remove(const Glib::RefPtr<Gst::Element>& element)
@@ -68,12 +69,13 @@
const bool result = gst_bin_remove(gobj(), Glib::unwrap(element));
- // If removal successful, return RefPtr<..> to this bin, otherwise return
- // null RefPtr<...>
+ // If removal successful, return RefPtr<..> to this bin, otherwise throw an
+ // exception
if(result)
return Glib::wrap(gobj(), true);
else
- throw std::runtime_error("Failed to remove " + element->get_name() + " element.");
+ throw std::runtime_error("Failed to remove " + element->get_name() +
+ " element.");
}
} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/bin.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/bin.hg (original)
+++ gstreamermm/trunk/gstreamer/src/bin.hg Wed Mar 25 02:07:17 2009
@@ -20,7 +20,6 @@
#include <gstreamermm/element.h>
#include <gstreamermm/childproxy.h>
#include <gstreamermm/pad.h>
-#include <stdexcept> //Because add() throws std::runtime_error.
_DEFS(gstreamermm,gst)
@@ -176,8 +175,9 @@
* MT safe.
*
* element the Gst::Element to remove
- * Returns this Gst::Bin if successful (for further removing if wanted), null
- * otherwise
+ * Returns this Gst::Bin if successful, for chained calls to remove().
+ *
+ * @throws std::runtime_error if the Bin does not want to remove the Element.
*/
Glib::RefPtr<Gst::Bin> remove(const Glib::RefPtr<Gst::Element>& element);
_IGNORE(gst_bin_remove, gst_bin_remove_many)
Modified: gstreamermm/trunk/gstreamer/src/colorbalance.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/colorbalance.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/colorbalance.ccg Wed Mar 25 02:07:17 2009
@@ -17,10 +17,10 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
- #include <gstreamermm/colorbalancechannel.h>
+#include <gstreamermm/colorbalancechannel.h>
- namespace Gst
- {
+namespace Gst
+{
#ifdef GLIBMM_VFUNCS_ENABLED
const GList* ColorBalance_Class::list_channels_vfunc_callback(GstColorBalance* self)
Modified: gstreamermm/trunk/gstreamer/src/element.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/element.ccg Wed Mar 25 02:07:17 2009
@@ -59,6 +59,9 @@
Glib::RefPtr<Gst::Element> Element::link(const Glib::RefPtr<Gst::Element>& dest)
{
+ if (!dest)
+ throw std::runtime_error("Failed to link null element.");
+
const bool result = gst_element_link(gobj(), dest->gobj());
if(result)
Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg (original)
+++ gstreamermm/trunk/gstreamer/src/element.hg Wed Mar 25 02:07:17 2009
@@ -24,7 +24,6 @@
#include <gstreamermm/event.h>
#include <gstreamermm/message.h>
#include <gstreamermm/query.h>
-#include <stdexcept> //Because link() throws std::runtime_error
_DEFS(gstreamermm,gst)
Modified: gstreamermm/trunk/gstreamer/src/filter.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/filter.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/filter.ccg Wed Mar 25 02:07:17 2009
@@ -51,7 +51,7 @@
Filter::run(const Glib::ListHandle<Glib::RefPtr<Glib::Object> >& list, const SlotFilter& slot, bool first)
{
SlotFilter* slot_copy = new SlotFilter(slot);
- return Glib::ListHandle< Glib::RefPtr<Glib::Object> >(gst_filter_run(list.data(), &Filter_Filter_gstreamermm_callback, first, slot_copy), Glib::OWNERSHIP_SHALLOW);
+ return Glib::ListHandle< Glib::RefPtr<Glib::Object> >(gst_filter_run(list.data(), &Filter_Filter_gstreamermm_callback, first, slot_copy), Glib::OWNERSHIP_DEEP);
}
} //namespace Gst
Modified: gstreamermm/trunk/gstreamer/src/format.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/format.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/format.ccg Wed Mar 25 02:07:17 2009
@@ -71,7 +71,7 @@
return gst_formats_contains((GstFormat*)((formats).data()), (GstFormat)(format));
}
-bool get_format_details(Format format, FormatDefinition &def)
+bool get_format_details(Format format, FormatDefinition& def)
{
const GstFormatDefinition* gstdef = gst_format_get_details(GstFormat(format));
Modified: gstreamermm/trunk/gstreamer/src/ghostpad.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/ghostpad.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/ghostpad.ccg Wed Mar 25 02:07:17 2009
@@ -17,6 +17,8 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdexcept>
+#include <sstream>
#include <gst/gstghostpad.h>
#include <gstreamermm/padtemplate.h>
@@ -28,15 +30,21 @@
GhostPad::GhostPad(const Glib::ustring& name,
const Glib::RefPtr<Gst::Pad>& target)
: _CONSTRUCT("name", name.c_str(),
- "direction", (GstPadDirection) target->get_direction())
+ "direction",
+ ((target) ? ((GstPadDirection) target->get_direction()) : GST_PAD_UNKNOWN))
{
+ if (!target)
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ " const Glib::RefPtr<Gst::Pad>&): "
+ "Failed to construct ghost pad (name = " + name + ") from null target.");
+
if (!gst_ghost_pad_construct(gobj()) ||
!gst_ghost_pad_set_target(gobj(), target->gobj()))
{
- g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
" const Glib::RefPtr<Gst::Pad>&): "
- "Unsuccessful construction of ghost pad (name = %s, target = %s).",
- name.c_str(), target->get_name().c_str());
+ "Unsuccessful construction of ghost pad (name = " + name +
+ ", target = " + target->get_name() + ").");
}
}
@@ -45,9 +53,12 @@
{
if (!gst_ghost_pad_construct(gobj()))
{
- g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&, PadDirection):"
- " Unsuccessful construction of ghost pad (name = %s, direction = %d).",
- name.c_str(), direction);
+ std::stringstream int_conv_stream;
+ int_conv_stream << direction;
+
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&, "
+ "PadDirection): Unsuccessful construction of ghost pad (name = " +
+ name + ", direction = " + int_conv_stream.str() + ").");
}
}
@@ -55,31 +66,44 @@
const Glib::RefPtr<Gst::Pad>& target,
const Glib::RefPtr<Gst::PadTemplate>& templ)
: _CONSTRUCT("name", name.c_str(), "direction",
- (GstPadDirection) target->get_direction(), "template", templ->gobj())
+ ((target) ? ((GstPadDirection) target->get_direction()) : GST_PAD_UNKNOWN),
+ "template", ((templ) ? templ->gobj() : 0))
{
+ if (!target || !templ)
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ " const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::PadTemplate>&):"
+ " Failed to construct ghost pad (name = " + name + ") from null "
+ "target or template.");
+
if (!gst_ghost_pad_construct(gobj()) ||
!gst_ghost_pad_set_target(gobj(), target->gobj()))
{
- g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
" const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::PadTemplate>&):"
- " Unsuccessful construction of ghost pad "
- "(name = %s, target = %s, templ = %s).",
- name.c_str(), target->get_name().c_str(),
- templ->get_name_template().c_str());
+ " Unsuccessful construction of ghost pad (name = " + name +
+ ", target = " + target->get_name() + ", templ = " +
+ templ->get_name_template() + ").");
}
}
GhostPad::GhostPad(const Glib::ustring& name,
const Glib::RefPtr<Gst::PadTemplate>& templ)
: _CONSTRUCT("name", name.c_str(), "direction",
- (GstPadDirection) templ->get_direction(), "template", templ->gobj())
+ ((templ) ? ((GstPadDirection) templ->get_direction()) : GST_PAD_UNKNOWN),
+ "template", ((templ) ? templ->gobj() : 0))
{
+ if (!templ)
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ " const Glib::RefPtr<Gst::PadTemplate>&): "
+ "Failed to construct ghost pad (name = " + name +
+ ") from null template.");
+
if (!gst_ghost_pad_construct(gobj()))
{
- g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
+ throw std::runtime_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
" const Glib::RefPtr<Gst::PadTemplate>&): "
- "Unsuccessful construction of ghost pad (name = %s, templ = %s).",
- name.c_str(), templ->get_name_template().c_str());
+ "Unsuccessful construction of ghost pad (name = " + name +
+ ", templ = " + templ->get_name_template() + ").");
}
}
Modified: gstreamermm/trunk/gstreamer/src/ghostpad.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/ghostpad.hg (original)
+++ gstreamermm/trunk/gstreamer/src/ghostpad.hg Wed Mar 25 02:07:17 2009
@@ -48,15 +48,43 @@
_CLASS_GOBJECT(GhostPad, GstGhostPad, GST_GHOST_PAD, Pad, GstPad)
protected:
+ /** Creates a Gst::GhostPad from a target pad.
+ * @param name The name of the Gst::GhostPad.
+ * @param target The target pad.
+ *
+ * @throws std::runtime_error if Gst::GhostPad construction fails.
+ */
GhostPad(const Glib::ustring& name, const Glib::RefPtr<Gst::Pad>& target);
+
+ /** Creates a Gst::GhostPad with a specified name and direction.
+ * @param name The name of the Gst::GhostPad.
+ * @param direction The direction of the Gst::GhostPad.
+ *
+ * @throws std::runtime_error if Gst::GhostPad construction fails.
+ */
GhostPad(const Glib::ustring& name, PadDirection direction);
+
+ /** Creates a Gst::GhostPad from a target pad and a pad template.
+ * @param name The name of the Gst::GhostPad.
+ * @param target The target pad.
+ * @param templ The pad template.
+ *
+ * @throws std::runtime_error if Gst::GhostPad construction fails.
+ */
GhostPad(const Glib::ustring& name, const Glib::RefPtr<Gst::Pad>& target, const Glib::RefPtr<Gst::PadTemplate>& templ);
+
+ /** Creates a Gst::GhostPad from a pad template.
+ * @param name The name of the Gst::GhostPad.
+ * @param templ The pad template.
+ *
+ * @throws std::runtime_error if Gst::GhostPad construction fails.
+ */
GhostPad(const Glib::ustring& name, const Glib::RefPtr<Gst::PadTemplate>& templ);
_IGNORE(gst_ghost_pad_construct)
public:
- /** Create a new ghostpad with @a target as the target. The direction will be
- * taken from the target pad. @a target must be unlinked.
+ /** Create a new Gst::GhostPad with @a target as the target. The direction
+ * will be taken from the target pad. @a target must be unlinked.
*
* @param name The name of the new pad.
* @param target The pad to ghost.
@@ -64,33 +92,34 @@
*/
_WRAP_CREATE(const Glib::ustring& name, const Glib::RefPtr<Gst::Pad>& target)
- /** Create a new ghostpad without a target with the given direction. A target
- * can be set on the ghostpad later with the set_target() function.
+ /** Create a new Gst::GhostPad without a target with the given direction. A
+ * target can be set on the Gst::GhostPad later with the set_target()
+ * function.
*
- * The created ghostpad will not have a padtemplate.
+ * The created Gst::GhostPad will not have a padtemplate.
*
- * @param name The name of the new pad.
- * @param dir The direction of the ghostpad.
+ * @param name The name of the new Gst::GhostPad.
+ * @param dir The direction of the Gst::GhostPad.
* @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
*/
_WRAP_CREATE(const Glib::ustring& name, PadDirection dir)
- /** Create a new ghostpad with @a target as the target. The direction will be
- * taken from the target pad. The template used on the ghostpad will be
- * template.
+ /** Create a new Gst::GhostPad with @a target as the target. The direction
+ * will be taken from the target pad. The template used on the Gst::GhostPad
+ * will be template.
*
- * @param name The name of the new pad.
+ * @param name The name of the new Gst::GhostPad.
* @param target The pad to ghost.
- * @param templ The Gst::PadTemplate to use on the ghostpad.
+ * @param templ The Gst::PadTemplate to use on the Gst::GhostPad.
* @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
*/
_WRAP_CREATE(const Glib::ustring& name, const Glib::RefPtr<Gst::Pad>& target, const Glib::RefPtr<Gst::PadTemplate>& templ)
- /** Create a new ghostpad based on @a templ, without setting a target. The
- * direction will be taken from @a templ.
+ /** Create a new Gst::GhostPad based on @a templ, without setting a target.
+ * The direction will be taken from @a templ.
*
- * @param name The name of the new pad.
- * @param templ The Gst::PadTemplate to create the ghostpad from.
+ * @param name The name of the new Gst::GhostPad.
+ * @param templ The Gst::PadTemplate to create the Gst::GhostPad from.
* @return A new Gst::GhostPad, or an empty RefPtr in case of an error.
*/
_WRAP_CREATE(const Glib::ustring& name, const Glib::RefPtr<Gst::PadTemplate>& templ)
Modified: gstreamermm/trunk/gstreamer/src/preset.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/preset.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/preset.ccg Wed Mar 25 02:07:17 2009
@@ -77,7 +77,6 @@
typedef gchar** RType;
return RType();
}
-
gchar** Preset_Class::get_property_names_vfunc_callback(GstPreset* self)
{
Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
@@ -122,7 +121,6 @@
typedef gchar** RType;
return RType();
}
-
gboolean Preset_Class::get_meta_vfunc_callback(GstPreset* self, const gchar* name, const gchar* tag, gchar** value)
{
Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
@@ -173,7 +171,6 @@
typedef gboolean RType;
return RType();
}
-
Glib::StringArrayHandle Gst::Preset::get_preset_names_vfunc() const
{
BaseClassType *const base = static_cast<BaseClassType*>(
@@ -187,7 +184,6 @@
typedef Glib::StringArrayHandle RType;
return Glib::StringArrayHandle(0, Glib::OWNERSHIP_NONE);
}
-
Glib::StringArrayHandle Gst::Preset::get_property_names_vfunc() const
{
BaseClassType *const base = static_cast<BaseClassType*>(
@@ -201,7 +197,6 @@
typedef Glib::StringArrayHandle RType;
return Glib::StringArrayHandle(0, Glib::OWNERSHIP_NONE);
}
-
bool Gst::Preset::get_meta_vfunc(const Glib::ustring& name, const Glib::ustring& tag, Glib::ustring& value)
{
BaseClassType *const base = static_cast<BaseClassType*>(
Modified: gstreamermm/trunk/tests/test-ghost-pad.cc
==============================================================================
--- gstreamermm/trunk/tests/test-ghost-pad.cc (original)
+++ gstreamermm/trunk/tests/test-ghost-pad.cc Wed Mar 25 02:07:17 2009
@@ -48,12 +48,14 @@
std::cout << "Successfully created pad '" << pad2->get_name() <<
"'; direction = " << pad2->get_direction() << "." << std::endl;
-//Comment the following gpad1 lines to remove the warning while creating the
-//ghost pad:
+// Uncomment the following to get an exception of a failed target pad ghostpad
+// construction.
+/*
Glib::RefPtr<Gst::GhostPad> gpad1 = Gst::GhostPad::create("gpad1", pad1);
if (gpad1)
std::cout << "Successfully created pad '" << gpad1->get_name() <<
"'; direction = " << gpad1->get_direction() << "." << std::endl;
+*/
Glib::RefPtr<Gst::GhostPad> gpad2 =
Gst::GhostPad::create("gpad2", Gst::PAD_SRC);
@@ -61,13 +63,15 @@
std::cout << "Successfully created pad '" << gpad2->get_name() <<
"'; direction = " << gpad2->get_direction() << "." << std::endl;
-//Comment the following gpad3 lines to remove the warning while creating the
-//ghost pad:
+// Uncomment the following to see a failed target pad/template ghostpad
+// construction.
+/*
Glib::RefPtr<Gst::GhostPad> gpad3 =
Gst::GhostPad::create("gpad3", pad1, templ);
if (gpad3)
std::cout << "Successfully created pad '" << gpad3->get_name() <<
"'; direction = " << gpad3->get_direction() << "." << std::endl;
+*/
Glib::RefPtr<Gst::GhostPad> gpad4 =
Gst::GhostPad::create("gpad4", templ);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]