diff --git a/pinos/gst/gstpinospay.c b/pinos/gst/gstpinospay.c index c7bbf03b8..ba0337102 100644 --- a/pinos/gst/gstpinospay.c +++ b/pinos/gst/gstpinospay.c @@ -368,6 +368,23 @@ gst_pinos_pay_chain_pinos (GstPinosPay *pay, GstBuffer * buffer) g_array_append_val (fdids, p.id); break; } + case PINOS_PACKET_TYPE_FORMAT_CHANGE: + { + PinosPacketFormatChange p; + GstCaps * caps; + + if (!pinos_buffer_iter_parse_format_change (&it, &p)) + continue; + + caps = gst_caps_from_string (p.format); + + gst_element_post_message (GST_ELEMENT (pay), + gst_message_new_element (GST_OBJECT (pay), + gst_structure_new ("PinosPayloaderFormatChange", + "format", GST_TYPE_CAPS, caps, NULL))); + gst_caps_unref (caps); + break; + } default: break; } diff --git a/pinos/server/client-source.c b/pinos/server/client-source.c index ec8ca0ec6..e0f50cb4f 100644 --- a/pinos/server/client-source.c +++ b/pinos/server/client-source.c @@ -115,6 +115,26 @@ bus_handler (GstBus *bus, gst_element_set_state (priv->pipeline, GST_STATE_NULL); break; } + case GST_MESSAGE_ELEMENT: + { + if (gst_message_has_name (message, "PinosPayloaderFormatChange")) { + const GstStructure *str = gst_message_get_structure (message); + GstCaps *caps; + GBytes *format; + gchar *caps_str; + + gst_structure_get (str, "format", GST_TYPE_CAPS, &caps, NULL); + gst_caps_replace (&priv->format, caps); + caps_str = gst_caps_to_string (caps); + + format = g_bytes_new_take (caps_str, strlen (caps_str) + 1); + g_object_set (priv->input, "possible-formats", format, "format", format, NULL); + pinos_source_update_possible_formats (source, format); + pinos_source_update_format (source, format); + g_bytes_unref (format); + } + break; + } default: break; } diff --git a/pinos/server/source-output.c b/pinos/server/source-output.c index 21c188b83..bcdf4ca42 100644 --- a/pinos/server/source-output.c +++ b/pinos/server/source-output.c @@ -179,6 +179,8 @@ pinos_source_output_set_property (GObject *_object, if (priv->format) g_bytes_unref (priv->format); priv->format = g_value_dup_boxed (value); + g_object_set (priv->iface, "format", + g_bytes_get_data (priv->format, NULL), NULL); break; default: diff --git a/pinos/server/source.c b/pinos/server/source.c index a90c8ef43..90373dc8d 100644 --- a/pinos/server/source.c +++ b/pinos/server/source.c @@ -510,6 +510,7 @@ void pinos_source_update_possible_formats (PinosSource *source, GBytes *formats) { PinosSourcePrivate *priv; + GList *walk; g_return_if_fail (PINOS_IS_SOURCE (source)); priv = source->priv; @@ -518,6 +519,22 @@ pinos_source_update_possible_formats (PinosSource *source, GBytes *formats) g_object_set (priv->iface, "possible-formats", g_bytes_get_data (formats, NULL), NULL); + + for (walk = priv->outputs; walk; walk = g_list_next (walk)) + g_object_set (walk->data, "possible-formats", formats, NULL); +} + +void +pinos_source_update_format (PinosSource *source, GBytes *format) +{ + PinosSourcePrivate *priv; + GList *walk; + + g_return_if_fail (PINOS_IS_SOURCE (source)); + priv = source->priv; + + for (walk = priv->outputs; walk; walk = g_list_next (walk)) + g_object_set (walk->data, "format", format, NULL); } PinosSourceOutput * diff --git a/pinos/server/source.h b/pinos/server/source.h index 0a19731e1..ccabf21fe 100644 --- a/pinos/server/source.h +++ b/pinos/server/source.h @@ -95,6 +95,7 @@ void pinos_source_report_idle (PinosSource *source); void pinos_source_report_busy (PinosSource *source); void pinos_source_update_possible_formats (PinosSource *source, GBytes *formats); +void pinos_source_update_format (PinosSource *source, GBytes *format); PinosSourceOutput * pinos_source_create_source_output (PinosSource *source, const gchar *client_path,