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 21:37:50 -0500
José Alburquerque wrote:
I fixed the player by changing the call message->get_type() to
message->get_message_type() in on_bus_message(). I'll now try to figure
out how to get Gst::Message wrapping to work appropriately. When I'm
done, I'll send a diff.
-Jose
The good news is that I was able to implement a Gst::Message::wrap()
method and modify gstmm to use it for wrapping messages. Unfortunately,
I think I've reached my C++ knowledge limit :-). It looks like the
Gst::Message::wrap() method should return the appropriate class based on
the "message type", however, I tested with the modified
test-mini-object-wrap test (to use the new Gst::Message::wrap() method)
and also by trying to cast a Gst::Message (wrapped form a
Gst::MessageError) to a Gst::MessageError in the on_bus_message()
function of the ogg player example (by using RefPtr<...>::cast_dynamic)
and both tests were unsuccessful.
At this point I'm pretty much stuck so I'm hoping you might be able to
shed some light on what I'm doing. Would you be able to look at my
changes? Thanks.
-Jose
Index: ChangeLog
===================================================================
--- ChangeLog (revision 102)
+++ ChangeLog (working copy)
@@ -1,3 +1,20 @@
+2007-12-11 José Alburquerque <jaalburquerque cox com>
+
+ * examples/ogg_player/main.cc: changed call message->get_type() to
+ message->get_message_type() in on_bus_message()
+ * gst/src/bus.ccg: changed SignalProxy_Watch_glib_callback() to use
+ Gst::Message::wrap() instead of Gst::wrap() for message
+ * gst/src/bus.hg: changed GstMessage* conversion macro to use
+ Gst::Message::wrap()
+ * gst/src/message.ccg: changed Gst::wrap() calls in Message classes to
+ Gst::Message::wrap() in create() methods and added an attempt at the
+ new Gst::Message::wrap() method
+ * gst/src/message.hg: added Gst::Message::wrap() declaration
+ * tests/test-miniobject-wrap.cc: modified to use Gst::Message::wrap()
+ form message wrapping
+ * tools/m4/convert_gst.m4: changed GstMessage conversions to use
+ Gst::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,159 @@
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, bool take_copy) {
+
+ Glib::RefPtr<Message> result;
+
+ if (!message)
+ return result;
+
+ switch (GST_MESSAGE_TYPE(message)) {
+ case GST_MESSAGE_EOS:
+ result = Glib::RefPtr<MessageEos>( reinterpret_cast<Gst::MessageEos*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_ERROR:
+ result = Glib::RefPtr<MessageError>( reinterpret_cast<Gst::MessageError*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_WARNING:
+ result = Glib::RefPtr<MessageWarning>( reinterpret_cast<Gst::MessageWarning*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_INFO:
+ result = Glib::RefPtr<MessageInfo>( reinterpret_cast<Gst::MessageInfo*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_BUFFERING:
+ result = Glib::RefPtr<MessageBuffering>( reinterpret_cast<Gst::MessageBuffering*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_STATE_CHANGED:
+ result = Glib::RefPtr<MessageStateChanged>( reinterpret_cast<Gst::MessageStateChanged*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_STATE_DIRTY:
+ result = Glib::RefPtr<MessageStateDirty>( reinterpret_cast<Gst::MessageStateDirty*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_CLOCK_PROVIDE:
+ result = Glib::RefPtr<MessageClockProvide>( reinterpret_cast<Gst::MessageClockProvide*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_CLOCK_LOST:
+ result = Glib::RefPtr<MessageClockLost>( reinterpret_cast<Gst::MessageClockLost*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_NEW_CLOCK:
+ result = Glib::RefPtr<MessageNewClock>( reinterpret_cast<Gst::MessageNewClock*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_APPLICATION:
+ result = Glib::RefPtr<MessageApplication>( reinterpret_cast<Gst::MessageApplication*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_ELEMENT:
+ result = Glib::RefPtr<MessageElement>( reinterpret_cast<Gst::MessageElement*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_SEGMENT_START:
+ result = Glib::RefPtr<MessageSegmentStart>( reinterpret_cast<Gst::MessageSegmentStart*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_SEGMENT_DONE:
+ result = Glib::RefPtr<MessageSegmentDone>( reinterpret_cast<Gst::MessageSegmentDone*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_DURATION:
+ result = Glib::RefPtr<MessageDuration>( reinterpret_cast<Gst::MessageDuration*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_LATENCY:
+ result = Glib::RefPtr<MessageLatency>( reinterpret_cast<Gst::MessageLatency*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_ASYNC_START:
+ result = Glib::RefPtr<MessageAsyncStart>( reinterpret_cast<Gst::MessageAsyncStart*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ case GST_MESSAGE_ASYNC_DONE:
+ result = Glib::RefPtr<MessageAsyncDone>( reinterpret_cast<Gst::MessageAsyncDone*>(Gst::wrap_auto((GstMiniObject*)(message), take_copy)) );
+ break;
+ //TODO: case GST_MESSAGE_UNKNOWN:
+ //TODO: case GST_MESSAGE_TAG:
+ //TODO: case GST_MESSAGE_STEP_DONE:
+ //TODO: case GST_MESSAGE_STRUCTURE_CHANGE:
+ //TODO: case GST_MESSAGE_STREAM_STATUS:
+ //TODO: case 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,7 @@
public:
_MEMBER_GET(message_type, type, MessageType, GstMessageType)
+ static Glib::RefPtr<Message> wrap(GstMessage* message, bool take_copy=false);
protected:
@@ -28,7 +29,7 @@
Structure structure_;
};
-class MessageApplication : public Gst::Message
+class MessageApplication : public Message
{
public:
static Glib::RefPtr<Message> create(const Glib::RefPtr<Object>& src, Structure& structure);
Index: gst/src/bus.ccg
===================================================================
--- gst/src/bus.ccg (revision 102)
+++ gst/src/bus.ccg (working copy)
@@ -7,7 +7,7 @@
try
{
#endif //GLIBMM_EXCEPTIONS_ENABLED
- return (*the_slot)(Glib::wrap(bus, true), Gst::wrap(message, true));
+ return (*the_slot)(Glib::wrap(bus, true), Gst::Message::wrap(message, true));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
}
catch(...)
Index: gst/src/bus.hg
===================================================================
--- gst/src/bus.hg (revision 102)
+++ gst/src/bus.hg (working copy)
@@ -45,7 +45,7 @@
_WRAP_METHOD(void remove_signal_watch(), gst_bus_remove_signal_watch)
_IGNORE(gst_bus_add_signal_watch)
-#m4 _CONVERSION(`GstMessage*',`const Glib::RefPtr<Message>&', `Gst::wrap($3, true)')
+#m4 _CONVERSION(`GstMessage*',`const Glib::RefPtr<Message>&', `Gst::Message::wrap($3, true)')
_WRAP_SIGNAL(void message(const Glib::RefPtr<Message>& message), "message")
_WRAP_SIGNAL(void sync_message(const Glib::RefPtr<Message>& message), "sync-message")
};
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)
Index: tests/test-miniobject-wrap.cc
===================================================================
--- tests/test-miniobject-wrap.cc (revision 102)
+++ tests/test-miniobject-wrap.cc (working copy)
@@ -9,7 +9,7 @@
GError* cerror = g_error_new_literal(GST_CORE_ERROR, GST_CORE_ERROR_FAILED, "test error message");
GstMessage* cmessage = gst_message_new_warning(cobject, cerror, "test debug text");
- Glib::RefPtr<Gst::Message> message = Gst::wrap(cmessage);
+ Glib::RefPtr<Gst::Message> message = Gst::Message::wrap(cmessage);
std::cout << "C++ message instance is !NULL: " << (bool)(message) << std::endl;
Index: examples/ogg_player/main.cc
===================================================================
--- examples/ogg_player/main.cc (revision 102)
+++ examples/ogg_player/main.cc (working copy)
@@ -6,7 +6,7 @@
bool on_bus_message(const Glib::RefPtr<Gst::Bus>& bus, const Glib::RefPtr<Gst::Message>& message)
{
- switch (message->get_type()) {
+ switch (message->get_message_type()) {
case Gst::MESSAGE_EOS:
std::cout << "End of stream" << std::endl;
mainloop->quit();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]