parse additional bus messages

parent fb7d7fea
......@@ -84,30 +84,51 @@ bus_cb (GstBus *bus,
GstMessage *message,
gpointer data)
{
g_autoptr (GError) error = NULL;
g_autofree gchar *msg;
RtpData *rtpdata = data;
g_debug ("Got %s message", GST_MESSAGE_TYPE_NAME (message));
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:
gst_message_parse_error (message, &error, &msg);
g_error ("Error: %s", msg);
break;
{
g_autoptr (GError) error = NULL;
g_autofree gchar *msg = NULL;
gst_message_parse_error (message, &error, &msg);
g_error ("Error: %s", msg);
break;
}
case GST_MESSAGE_WARNING:
gst_message_parse_warning (message, &error, &msg);
g_warning ("Warning: %s", msg);
break;
{
g_autoptr (GError) error = NULL;
g_autofree gchar *msg = NULL;
gst_message_parse_warning (message, &error, &msg);
g_warning ("Warning: %s", msg);
break;
}
case GST_MESSAGE_EOS:
g_debug ("Received end of stream");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_STATE_CHANGED:
{
GstState oldstate;
GstState newstate;
gst_message_parse_state_changed (message, &oldstate, &newstate, NULL);
g_debug ("Element %s has changed state from %s to %s",
GST_OBJECT_NAME (message->src),
gst_element_state_get_name (oldstate),
gst_element_state_get_name (newstate));
break;
}
default:
g_debug ("Unhandled message type");
g_debug ("Got unhandled %s message", GST_MESSAGE_TYPE_NAME (message));
break;
}
/* keep watching for messages on the bus */
......@@ -140,6 +161,8 @@ main (int argc,
gst_init (&argc, &argv);
g_debug ("Capabilities:\n%s", gst_codec_get_gst_capabilities (codec));
/* could also use autoaudiosink instead of pulsesink */
data.audiosink = gst_element_factory_make ("pulsesink", "sink");
data.audiosrc = gst_element_factory_make ("pulsesrc", "source");
......
......@@ -26,3 +26,13 @@ gst_codec_by_name (const gchar *name)
return NULL;
}
gchar *
gst_codec_get_gst_capabilities (GstCodec *codec)
{
return g_strdup_printf ("application/x-rtp,media=(string)audio,clock-rate=(int)%d"
",encoding-name=(string)%s,payload=(int)%d",
codec->clock_rate,
codec->name,
codec->payload_type);
}
......@@ -33,3 +33,4 @@ enum {
};
GstCodec* gst_codec_by_name (const gchar *name);
gchar* gst_codec_get_gst_capabilities (GstCodec *codec);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment