summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ad5e77)
raw | patch | inline | side by side (parent: 8ad5e77)
author | Wim Taymans <wim.taymans@gmail.com> | |
Sat, 8 Oct 2005 12:36:36 +0000 (12:36 +0000) | ||
committer | Wim Taymans <wim.taymans@gmail.com> | |
Sat, 8 Oct 2005 12:36:36 +0000 (12:36 +0000) |
Original commit message from CVS:
* gst/gstmessage.c: (gst_message_new_custom),
(gst_message_new_eos), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_clock_provide),
(gst_message_new_new_clock), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_parse_state_changed),
(gst_message_parse_clock_provide), (gst_message_parse_new_clock):
* gst/gstmessage.h:
Clean up.
Added clock related messages.
* gst/gstpipeline.c: (gst_pipeline_change_state):
Post message when the clock changed.
* tools/gst-launch.c: (event_loop):
Print new clock.
* gst/gstmessage.c: (gst_message_new_custom),
(gst_message_new_eos), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_clock_provide),
(gst_message_new_new_clock), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_parse_state_changed),
(gst_message_parse_clock_provide), (gst_message_parse_new_clock):
* gst/gstmessage.h:
Clean up.
Added clock related messages.
* gst/gstpipeline.c: (gst_pipeline_change_state):
Post message when the clock changed.
* tools/gst-launch.c: (event_loop):
Print new clock.
ChangeLog | patch | blob | history | |
gst/gstmessage.c | patch | blob | history | |
gst/gstmessage.h | patch | blob | history | |
gst/gstpipeline.c | patch | blob | history | |
tools/gst-launch.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 706ff46ae56768c10de86f55d509ffb516a8dfff..d0e88fe9618d513dce1a058e7220f8bfba8e646b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2005-10-08 Wim Taymans <wim@fluendo.com>
+
+ * gst/gstmessage.c: (gst_message_new_custom),
+ (gst_message_new_eos), (gst_message_new_error),
+ (gst_message_new_warning), (gst_message_new_tag),
+ (gst_message_new_state_changed), (gst_message_new_clock_provide),
+ (gst_message_new_new_clock), (gst_message_new_segment_start),
+ (gst_message_new_segment_done), (gst_message_parse_state_changed),
+ (gst_message_parse_clock_provide), (gst_message_parse_new_clock):
+ * gst/gstmessage.h:
+ Clean up.
+ Added clock related messages.
+
+ * gst/gstpipeline.c: (gst_pipeline_change_state):
+ Post message when the clock changed.
+
+ * tools/gst-launch.c: (event_loop):
+ Print new clock.
+
2005-10-08 Tim-Philipp Müller <tim at centricular dot net>
* tools/gst-inspect.c: (print_element_properties_info):
diff --git a/gst/gstmessage.c b/gst/gstmessage.c
index 41d1b7c75a037e4f897674782c638902c43ba9e4..80e25cc12efd504a383d28cc3d6ee65a2b8d0516 100644 (file)
--- a/gst/gstmessage.c
+++ b/gst/gstmessage.c
{GST_MESSAGE_BUFFERING, "buffering", 0},
{GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
{GST_MESSAGE_STEP_DONE, "step-done", 0},
+ {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
+ {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
{GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
{GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
{GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
{GST_MESSAGE_APPLICATION, "application", 0},
+ {GST_MESSAGE_ELEMENT, "element", 0},
{GST_MESSAGE_SEGMENT_START, "segment-start", 0},
{GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
{0, NULL, 0}
return copy;
}
-static GstMessage *
-gst_message_new (GstMessageType type, GstObject * src)
+/**
+ * gst_message_new_custom:
+ * @type: The #GstMessageType to distinguish messages
+ * @src: The object originating the message.
+ * @structure: The structure for the message. The message will take ownership of
+ * the structure.
+ *
+ * Create a new custom-typed message. This can be used for anything not
+ * handled by other message-specific functions to pass a message to the
+ * app. The structure field can be NULL.
+ *
+ * Returns: The new message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_custom (GstMessageType type, GstObject * src,
+ GstStructure * structure)
{
GstMessage *message;
message->src = NULL;
GST_CAT_DEBUG (GST_CAT_MESSAGE, "NULL message source");
}
- message->structure = NULL;
+ if (structure) {
+ gst_structure_set_parent_refcount (structure,
+ &message->mini_object.refcount);
+ }
+ message->structure = structure;
return message;
}
{
GstMessage *message;
- message = gst_message_new (GST_MESSAGE_EOS, src);
+ message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
return message;
}
gst_message_new_error (GstObject * src, GError * error, gchar * debug)
{
GstMessage *message;
- GstStructure *s;
- message = gst_message_new (GST_MESSAGE_ERROR, src);
- /* gst_structure_new takes copies of the types passed in */
- s = gst_structure_new ("GstMessageError", "gerror", GST_TYPE_G_ERROR, error,
- "debug", G_TYPE_STRING, debug, NULL);
- gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
- message->structure = s;
+ message = gst_message_new_custom (GST_MESSAGE_ERROR, src,
+ gst_structure_new ("GstMessageError", "gerror", GST_TYPE_G_ERROR, error,
+ "debug", G_TYPE_STRING, debug, NULL));
return message;
}
gst_message_new_warning (GstObject * src, GError * error, gchar * debug)
{
GstMessage *message;
- GstStructure *s;
- message = gst_message_new (GST_MESSAGE_WARNING, src);
- /* gst_structure_new takes copies of the types passed in */
- s = gst_structure_new ("GstMessageWarning", "gerror", GST_TYPE_G_ERROR, error,
- "debug", G_TYPE_STRING, debug, NULL);
- gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
- message->structure = s;
+ message = gst_message_new_custom (GST_MESSAGE_WARNING, src,
+ gst_structure_new ("GstMessageWarning", "gerror", GST_TYPE_G_ERROR, error,
+ "debug", G_TYPE_STRING, debug, NULL));
return message;
}
g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
- message = gst_message_new (GST_MESSAGE_TAG, src);
- gst_structure_set_parent_refcount (tag_list, &message->mini_object.refcount);
- message->structure = tag_list;
+ message =
+ gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
return message;
}
GstState old, GstState new, GstState pending)
{
GstMessage *message;
- GstStructure *s;
- message = gst_message_new (GST_MESSAGE_STATE_CHANGED, src);
+ message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src,
+ gst_structure_new ("GstMessageState",
+ "old-state", GST_TYPE_STATE, (gint) old,
+ "new-state", GST_TYPE_STATE, (gint) new,
+ "pending-state", GST_TYPE_STATE, (gint) pending, NULL));
+
+ return message;
+}
+
+/**
+ * gst_message_new_clock_provide:
+ * @src: The object originating the message.
+ * @ready: TRUE if the sender can provide a clock
+ *
+ * Create a clock provide message. This message is posted whenever an
+ * element is ready to provide a clock or lost its ability to provide
+ * a clock (maybe because it paused or became EOS).
+ *
+ * This message is mainly used internally to manage the clock
+ * selection.
+ *
+ * Returns: The new provide clock message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_clock_provide (GstObject * src, gboolean ready)
+{
+ GstMessage *message;
+
+ message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src,
+ gst_structure_new ("GstMessageClockProvide",
+ "ready", G_TYPE_BOOLEAN, ready, NULL));
- s = gst_structure_new ("GstMessageState",
- "old-state", GST_TYPE_STATE, (gint) old,
- "new-state", GST_TYPE_STATE, (gint) new,
- "pending-state", GST_TYPE_STATE, (gint) pending, NULL);
- gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
- message->structure = s;
+ return message;
+}
+
+/**
+ * gst_message_new_new_clock:
+ * @src: The object originating the message.
+ * @clock: the new selected clock
+ *
+ * Create a new clock message. This message is posted whenever the
+ * pipeline selectes a new clock for the pipeline.
+ *
+ * Returns: The new new clock message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_new_clock (GstObject * src, GstClock * clock)
+{
+ GstMessage *message;
+
+ message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src,
+ gst_structure_new ("GstMessageNewClock",
+ "clock", GST_TYPE_CLOCK, clock, NULL));
return message;
}
gst_message_new_segment_start (GstObject * src, GstClockTime timestamp)
{
GstMessage *message;
- GstStructure *s;
-
- message = gst_message_new (GST_MESSAGE_SEGMENT_START, src);
- s = gst_structure_new ("GstMessageSegmentStart", "timestamp", G_TYPE_INT64,
- (gint64) timestamp, NULL);
- gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
- message->structure = s;
+ message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src,
+ gst_structure_new ("GstMessageSegmentStart", "timestamp", G_TYPE_INT64,
+ (gint64) timestamp, NULL));
return message;
}
gst_message_new_segment_done (GstObject * src, GstClockTime timestamp)
{
GstMessage *message;
- GstStructure *s;
- message = gst_message_new (GST_MESSAGE_SEGMENT_DONE, src);
-
- s = gst_structure_new ("GstMessageSegmentDone", "timestamp", G_TYPE_INT64,
- (gint64) timestamp, NULL);
- gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
- message->structure = s;
+ message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src,
+ gst_structure_new ("GstMessageSegmentDone", "timestamp", G_TYPE_INT64,
+ (gint64) timestamp, NULL));
return message;
}
return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
}
-/**
- * gst_message_new_custom:
- * @type: The #GstMessageType to distinguish messages
- * @src: The object originating the message.
- * @structure: The structure for the message. The message will take ownership of
- * the structure.
- *
- * Create a new custom-typed message. This can be used for anything not
- * handled by other message-specific functions to pass a message to the
- * app. The structure field can be NULL.
- *
- * Returns: The new message.
- *
- * MT safe.
- */
-GstMessage *
-gst_message_new_custom (GstMessageType type, GstObject * src,
- GstStructure * structure)
-{
- GstMessage *message;
-
- message = gst_message_new (type, src);
- if (structure) {
- gst_structure_set_parent_refcount (structure,
- &message->mini_object.refcount);
- message->structure = structure;
- }
- return message;
-}
-
/**
* gst_message_get_structure:
* @message: The #GstMessage.
GST_TYPE_STATE, (gint *) pending);
}
+/**
+ * gst_message_parse_clock_provide:
+ * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
+ * @ready: If the src can provide a clock or not.
+ *
+ * Extracts the ready flag from the GstMessage.
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_clock_provide (GstMessage * message, gboolean * ready)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
+
+ if (ready)
+ gst_structure_get_boolean (message->structure, "ready", ready);
+}
+
+/**
+ * gst_message_parse_new_clock:
+ * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
+ * @clock: A pointer to hold the selected new clock
+ *
+ * Extracts the new clock from the GstMessage.
+ * The clock object returned remains valid until the message is freed.
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
+{
+ const GValue *clock_gvalue;
+
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
+
+ clock_gvalue = gst_structure_get_value (message->structure, "clock");
+ g_return_if_fail (clock_gvalue != NULL);
+ g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
+
+ if (clock)
+ *clock = (GstClock *) g_value_get_object (clock_gvalue);
+}
+
/**
* gst_message_parse_error:
* @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
diff --git a/gst/gstmessage.h b/gst/gstmessage.h
index 313863873135949f54c7734d769ad51e0b2d4466..e86d92ba3b41cd80c0fe4c6330844759d945cb82 100644 (file)
--- a/gst/gstmessage.h
+++ b/gst/gstmessage.h
* @GST_MESSAGE_BUFFERING: the pipeline is buffering
* @GST_MESSAGE_STATE_CHANGED: a state change happened
* @GST_MESSAGE_STEP_DONE: a framestep finished.
+ * @GST_MESSAGE_CLOCK_PROVIDE: an element notifies it capability of providing
+ * a clock.
+ * @GST_MESSAGE_CLOCK_LOST: The current clock as selected by the pipeline became
+ * unusable. The pipeline will select a new clock on the
+ * next PLAYING state change.
* @GST_MESSAGE_NEW_CLOCK: a new clock was selected in the pipeline
* @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed.
* @GST_MESSAGE_STREAM_STATUS: status about a stream, emitted when it starts,
* @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment.
* @GST_MESSAGE_ANY: mask for all of the above messages.
*/
+/* NOTE: keep in sync with quark registration in gstmessage.c */
typedef enum
{
GST_MESSAGE_UNKNOWN = 0,
GST_MESSAGE_BUFFERING = (1 << 5),
GST_MESSAGE_STATE_CHANGED = (1 << 6),
GST_MESSAGE_STEP_DONE = (1 << 7),
- GST_MESSAGE_NEW_CLOCK = (1 << 8),
- GST_MESSAGE_STRUCTURE_CHANGE = (1 << 9),
- GST_MESSAGE_STREAM_STATUS = (1 << 10),
- GST_MESSAGE_APPLICATION = (1 << 11),
- GST_MESSAGE_ELEMENT = (1 << 12),
- GST_MESSAGE_SEGMENT_START = (1 << 13),
- GST_MESSAGE_SEGMENT_DONE = (1 << 14),
+ GST_MESSAGE_CLOCK_PROVIDE = (1 << 8),
+ GST_MESSAGE_CLOCK_LOST = (1 << 9),
+ GST_MESSAGE_NEW_CLOCK = (1 << 10),
+ GST_MESSAGE_STRUCTURE_CHANGE = (1 << 11),
+ GST_MESSAGE_STREAM_STATUS = (1 << 12),
+ GST_MESSAGE_APPLICATION = (1 << 13),
+ GST_MESSAGE_ELEMENT = (1 << 14),
+ GST_MESSAGE_SEGMENT_START = (1 << 15),
+ GST_MESSAGE_SEGMENT_DONE = (1 << 16),
GST_MESSAGE_ANY = 0xffffffff
} GstMessageType;
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list);
GstMessage * gst_message_new_state_changed (GstObject * src, GstState old_state,
GstState new_state, GstState pending);
+GstMessage * gst_message_new_clock_provide (GstObject * src, gboolean ready);
+GstMessage * gst_message_new_clock_lost (GstObject * src);
+GstMessage * gst_message_new_new_clock (GstObject * src, GstClock *clock);
GstMessage * gst_message_new_segment_start (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_segment_done (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_application (GstObject * src, GstStructure * structure);
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
void gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
GstState *new_state, GstState *pending);
+void gst_message_parse_clock_provide (GstMessage *message, gboolean *ready);
+void gst_message_parse_new_clock (GstMessage *message, GstClock **clock);
void gst_message_parse_segment_start (GstMessage *message, GstClockTime *timestamp);
void gst_message_parse_segment_done (GstMessage *message, GstClockTime *timestamp);
diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c
index c18aa9648f8351c4b07c5315bc0497220e34518f..db7683a87c1bd6c1bfbcd14e598c39d417e53d69 100644 (file)
--- a/gst/gstpipeline.c
+++ b/gst/gstpipeline.c
/* when going to playing, select a clock */
if ((clock = gst_element_provide_clock (element))) {
GstClockTime start_time;
-
- /* distribute the clock */
- gst_element_set_clock (element, clock);
+ gboolean new_clock;
/* get start time */
start_time = gst_clock_get_time (clock);
- gst_object_unref (clock);
GST_LOCK (element);
+ new_clock = element->clock != clock;
element->base_time = start_time -
pipeline->stream_time + pipeline->delay;
GST_DEBUG ("stream_time=%" GST_TIME_FORMAT ", start_time=%"
GST_TIME_ARGS (pipeline->stream_time),
GST_TIME_ARGS (start_time), GST_TIME_ARGS (element->base_time));
GST_UNLOCK (element);
+
+ /* now distribute the clock */
+ gst_element_set_clock (element, clock);
+
+ if (new_clock) {
+ /* if we selected a new clock, let the app know about it */
+ gst_element_post_message (element,
+ gst_message_new_new_clock (GST_OBJECT_CAST (element), clock));
+ }
+
+ gst_object_unref (clock);
} else {
GST_DEBUG ("no clock, using base time of 0");
gst_element_set_base_time (element, 0);
diff --git a/tools/gst-launch.c b/tools/gst-launch.c
index 6f2d42dfe7f0e7b6e13955dc1bc0538fda78dfc3..5bb82be29106d732368052e8b2a1d53bef60cf22 100644 (file)
--- a/tools/gst-launch.c
+++ b/tools/gst-launch.c
}
switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_NEW_CLOCK:
+ {
+ GstClock *clock;
+
+ gst_message_parse_new_clock (message, &clock);
+
+ g_print ("new clock: %p\n", clock);
+ break;
+ }
case GST_MESSAGE_EOS:
g_print (_
("Got EOS from element \"%s\".\n"),