Re: Fixing the Gst::Message classes
- From: José Alburquerque <jaalburquerque cox net>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list gnome org
- Subject: Re: Fixing the Gst::Message classes
- Date: Tue, 11 Dec 2007 16:00:38 -0500
José Alburquerque wrote:
Murray Cumming wrote:
On Tue, 2007-12-11 at 18:27 +0100, Murray Cumming wrote:
That's done and checked in. We now have a Gst::wrap() system that is
completely independent of Glib::wrap(), for use with
Gst::MiniObject-derived classes. It works like Glib::wrap() but will not
return the same C++ instance when called twice with the same GObject
instance. Hopefully it will be useful.
However, this is not actually useful for the Gst::Message-derived
classes, because there are no such derived GTypes in gstreamer. We made
the C++ classes up. I filed a bug about this in gstreamer but it's
highly unlikely to change:
http://bugzilla.gnome.org/show_bug.cgi?id=503085
So we probably need yet another wrap() function, which could be a simple
hard-coded switch/case as a static method of Gst::Message. Would you
like to try that?
Sure. The switch/case is exactly the way I thought it could be done.
Thanks.
-Jose
Okay, I think I managed to make the changes. When I test the wrapping
here I get the following output:
[02:58][jose sweety:~/Projects/Programming/gstreamermm-devel/tests]$
./test-miniobject-wrap
C++ message instance is !NULL: 1
message is a Gst::MessageWarning: 0
Is this right? Also, the ogg player stopped working so I want to test
my changes a little more. At any rate, here are my changes so far, but
I may need to make more.
-Jose
Index: ChangeLog
===================================================================
--- ChangeLog (revision 102)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2007-12-11 José Alburquerque <jaalburquerque cox com>
+
+ * gst/src/message.ccg: added Gst::Message::wrap() methods
+ * gst/src/message.hg: added Gst::Message::wrap() method declarations
+ * tools/m4/convert_gst.m4: changed GstMessage conversion to use
+ Gt::Message::wrap()
+
2007-12-11 Murray Cumming <murrayc murrayc com>
* gst/gstmm/init.cc: Call gst_wrap_register_init() to stop the
Index: gst/src/message.ccg
===================================================================
--- gst/src/message.ccg (revision 102)
+++ gst/src/message.ccg (working copy)
@@ -23,14 +23,14 @@
Glib::RefPtr<Message> MessageApplication::create(const Glib::RefPtr<Object>& src, Structure& structure)
{
GstMessage* message = gst_message_new_application(src->gobj(), structure.gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageClockProvide
Glib::RefPtr<Message> MessageClockProvide::create(const Glib::RefPtr<Object>& src, const Glib::RefPtr<Clock>& clock, bool ready)
{
GstMessage* message = gst_message_new_clock_provide(src->gobj(), clock->gobj(), ready);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
/* TODO: Commented out to fix the build - there is no declaration in the .hg file. murrayc.
@@ -52,7 +52,7 @@
Glib::RefPtr<Message> MessageClockLost::create(const Glib::RefPtr<Object>& src, const Glib::RefPtr<Clock>& clock)
{
GstMessage* message = gst_message_new_clock_lost(src->gobj(), clock->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
void MessageClockLost::parse(Glib::RefPtr<Clock>& clock)
@@ -66,28 +66,28 @@
Glib::RefPtr<Message> MessageCustom::create(MessageType type, const Glib::RefPtr<Object>& src, Structure& structure)
{
GstMessage* message = gst_message_new_custom(GstMessageType(type), src->gobj(), structure.gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageElement
Glib::RefPtr<Message> MessageElement::create(const Glib::RefPtr<Object>& src, Structure& structure)
{
GstMessage* message = gst_message_new_element(src->gobj(), structure.gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageEOS
Glib::RefPtr<Message> MessageEos::create(const Glib::RefPtr<Object>& src)
{
GstMessage* message = gst_message_new_eos(src->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageError
Glib::RefPtr<Message> MessageError::create(const Glib::RefPtr<Object>& src, Glib::Error& error, const std::string& debug)
{
GstMessage* message = gst_message_new_error(src->gobj(), error.gobj(),(gchar*)(debug.c_str()));
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
void MessageError::parse(Glib::Error& error, std::string& debug)
@@ -125,84 +125,160 @@
Glib::RefPtr<Message> MessageInfo::create(const Glib::RefPtr<Object>& src, Glib::Error& error, const std::string& debug)
{
GstMessage* message = gst_message_new_info(src->gobj(), error.gobj(),(gchar*)(debug.c_str()));
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageNewClock
Glib::RefPtr<Message> MessageNewClock::create(const Glib::RefPtr<Object>& src, const Glib::RefPtr<Clock>& clock)
{
GstMessage* message = gst_message_new_new_clock(src->gobj(), clock->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageSegmentDone
Glib::RefPtr<Message> MessageSegmentDone::create(const Glib::RefPtr<Object>& src, Format format, gint64 position)
{
GstMessage* message = gst_message_new_segment_done(src->gobj(), GstFormat(format), position);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageSegmentStart
Glib::RefPtr<Message> MessageSegmentStart::create(const Glib::RefPtr<Object>& src, Format format, gint64 position)
{
GstMessage* message = gst_message_new_segment_start(src->gobj(), GstFormat(format), position);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageStateChanged
Glib::RefPtr<Message> MessageStateChanged::create(const Glib::RefPtr<Object>& src, State oldstate, State newstate, State pending)
{
GstMessage* message = gst_message_new_state_changed(src->gobj(), GstState(oldstate), GstState(newstate), GstState(pending));
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageBuffering
Glib::RefPtr<Message> MessageBuffering::create(const Glib::RefPtr<Object>& src, int percent)
{
GstMessage* message = gst_message_new_buffering(src->gobj(), percent);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageWarning
Glib::RefPtr<Message> MessageWarning::create(const Glib::RefPtr<Object>& src, Glib::Error& error, const std::string& debug)
{
GstMessage* message = gst_message_new_warning(src->gobj(), error.gobj(),(gchar*)(debug.c_str()));
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageDuration
Glib::RefPtr<Message> MessageDuration::create(const Glib::RefPtr<Object>& src, Format format, gint64 position)
{
GstMessage* message = gst_message_new_duration(src->gobj(), GstFormat(format), position);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageStateDirty
Glib::RefPtr<Message> MessageStateDirty::create(const Glib::RefPtr<Object>& src)
{
GstMessage* message = gst_message_new_state_dirty(src->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageAsyncStart
Glib::RefPtr<Message> MessageAsyncStart::create(const Glib::RefPtr<Object>& src, bool new_base_time)
{
GstMessage* message = gst_message_new_async_start(src->gobj(), new_base_time);
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageAsyncDone
Glib::RefPtr<Message> MessageAsyncDone::create(const Glib::RefPtr<Object>& src)
{
GstMessage* message = gst_message_new_async_done(src->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
// MessageLatency
Glib::RefPtr<Message> MessageLatency::create(const Glib::RefPtr<Object>& src)
{
GstMessage* message = gst_message_new_latency(src->gobj());
- return Gst::wrap(message, false);
+ return wrap(message, false);
}
+Glib::RefPtr<Message> Message::wrap(GstMessage* message) {
+ wrap(message, false);
+}
+
+Glib::RefPtr<Message> Message::wrap(GstMessage* message, bool take_copy) {
+
+ Glib::RefPtr<Message> result;
+
+ switch (GST_MESSAGE_TYPE(message)) {
+ GST_MESSAGE_EOS:
+ result = Glib::RefPtr<MessageEos>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_ERROR:
+ result = Glib::RefPtr<MessageError>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_WARNING:
+ result = Glib::RefPtr<MessageWarning>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_INFO:
+ result = Glib::RefPtr<MessageInfo>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_BUFFERING:
+ result = Glib::RefPtr<MessageBuffering>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_STATE_CHANGED:
+ result = Glib::RefPtr<MessageStateChanged>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_STATE_DIRTY:
+ result = Glib::RefPtr<MessageStateDirty>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_CLOCK_PROVIDE:
+ result = Glib::RefPtr<MessageClockProvide>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_CLOCK_LOST:
+ result = Glib::RefPtr<MessageClockLost>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_NEW_CLOCK:
+ result = Glib::RefPtr<MessageNewClock>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_APPLICATION:
+ result = Glib::RefPtr<MessageApplication>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_ELEMENT:
+ result = Glib::RefPtr<MessageElement>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_SEGMENT_START:
+ result = Glib::RefPtr<MessageSegmentStart>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_SEGMENT_DONE:
+ result = Glib::RefPtr<MessageSegmentDone>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_DURATION:
+ result = Glib::RefPtr<MessageDuration>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_LATENCY:
+ result = Glib::RefPtr<MessageLatency>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_ASYNC_START:
+ result = Glib::RefPtr<MessageAsyncStart>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ GST_MESSAGE_ASYNC_DONE:
+ result = Glib::RefPtr<MessageAsyncDone>::cast_dynamic(Gst::wrap(message, take_copy));
+ break;
+ //TODO: GST_MESSAGE_UNKNOWN:
+ //TODO: GST_MESSAGE_TAG:
+ //TODO: GST_MESSAGE_STEP_DONE:
+ //TODO: GST_MESSAGE_STRUCTURE_CHANGE:
+ //TODO: GST_MESSAGE_STREAM_STATUS:
+ //TODO: GST_MESSAGE_ANY:
+ default:
+ result = Gst::wrap(message, take_copy);
+ }
+
+ return result;
+}
+
} //namespace Gst
Index: gst/src/message.hg
===================================================================
--- gst/src/message.hg (revision 102)
+++ gst/src/message.hg (working copy)
@@ -21,6 +21,8 @@
public:
_MEMBER_GET(message_type, type, MessageType, GstMessageType)
+ static Glib::RefPtr<Message> wrap(GstMessage* message);
+ static Glib::RefPtr<Message> wrap(GstMessage* message, bool take_copy);
protected:
Index: tools/m4/convert_gst.m4
===================================================================
--- tools/m4/convert_gst.m4 (revision 102)
+++ tools/m4/convert_gst.m4 (working copy)
@@ -36,8 +36,8 @@
_CONVERSION(`const Glib::RefPtr<Pad>&',`GstPad*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Element>&',`GstElement*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Clock>&',`GstClock*',__CONVERT_REFPTR_TO_P)
-_CONVERSION(`GstMessage*',`Glib::RefPtr<Message>',`Gst::wrap($3)')
-_CONVERSION(`GstMessage*',`Glib::RefPtr<const Message>',`Gst::wrap($3)')
+_CONVERSION(`GstMessage*',`Glib::RefPtr<Message>',`wrap($3)')
+_CONVERSION(`GstMessage*',`Glib::RefPtr<const Message>',`wrap($3)')
_CONVERSION(`const Glib::RefPtr<Message>&',`GstMessage*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<Caps>&',`GstCaps*',__CONVERT_REFPTR_TO_P)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]