gstreamer: Wim Taymans : Add message to request a state change

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

gstreamer: Wim Taymans : Add message to request a state change

Felipe Contreras
Module: gstreamer
Branch: master
Commit: 4b986a4a94c436a3d1dac443ad8da374fe38b6eb
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4b986a4a94c436a3d1dac443ad8da374fe38b6eb

Author: Wim Taymans <[hidden email]>
Date:   Wed Feb 18 15:31:55 2009 +0100

Add message to request a state change

Add a GST_MESSAGE_REQUEST_STATE that can be posted by element when they would
like to have the application change the state of the pipeline. the primary use
case is to pause the pipeline when an audio mixer is mixing a higher priority
stream but it can also be used for other purposes.

Add some docs and a unit test.

Implement the REQUEST_STATE message in gst-launch.

API: gst_message_new_request_state()
API: gst_message_parse_request_state()
API: GST_MESSAGE_REQUEST_STATE

---

 docs/design/part-messages.txt   |    4 +++
 docs/gst/gstreamer-sections.txt |    2 +
 gst/gstmessage.c                |   52 +++++++++++++++++++++++++++++++++++++++
 gst/gstmessage.h                |    8 ++++++
 tests/check/gst/gstmessage.c    |   17 ++++++++++++
 tools/gst-launch.c              |   47 ++++++++++++++++++++++++-----------
 6 files changed, 115 insertions(+), 15 deletions(-)

diff --git a/docs/design/part-messages.txt b/docs/design/part-messages.txt
index aa5f218..cd53e10 100644
--- a/docs/design/part-messages.txt
+++ b/docs/design/part-messages.txt
@@ -128,4 +128,8 @@ Message types
     Posted by elements when the latency in a pipeline changed and a new global
     latency should be calculated by the pipeline or application.
 
+  GST_MESSAGE_REQUEST_STATE:
 
+    Posted by elements when they want to change the state of the pipeline they
+    are in. A typical use case would be an audio sink that requests the pipeline
+    to pause in order to play a higher priority stream.
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index b07d371..751d8e9 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -1089,6 +1089,8 @@ gst_message_parse_async_start
 gst_message_new_async_done
 gst_message_new_structure_change
 gst_message_parse_structure_change
+gst_message_new_request_state
+gst_message_parse_request_state
 <SUBSECTION Standard>
 GstMessageClass
 GST_MESSAGE
diff --git a/gst/gstmessage.c b/gst/gstmessage.c
index df9b5e1..78305bd 100644
--- a/gst/gstmessage.c
+++ b/gst/gstmessage.c
@@ -111,6 +111,7 @@ static GstMessageQuarks message_quarks[] = {
   {GST_MESSAGE_LATENCY, "latency", 0},
   {GST_MESSAGE_ASYNC_START, "async-start", 0},
   {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
+  {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
   {0, NULL, 0}
 };
 
@@ -933,6 +934,35 @@ gst_message_new_latency (GstObject * src)
 }
 
 /**
+ * gst_message_new_request_state:
+ * @src: The object originating the message.
+ * @state: The new requested state
+ *
+ * This message can be posted by elements when they want to have their state
+ * changed. A typical use case would be an audio server that wants to pause the
+ * pipeline because a higher priority stream is being played.
+ *
+ * Returns: The new requst state message.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.23
+ */
+GstMessage *
+gst_message_new_request_state (GstObject * src, GstState state)
+{
+  GstMessage *message;
+  GstStructure *structure;
+
+  structure = gst_structure_empty_new ("GstMessageRequestState");
+  gst_structure_id_set (structure,
+      GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
+  message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
+
+  return message;
+}
+
+/**
  * gst_message_get_structure:
  * @message: The #GstMessage.
  *
@@ -1431,3 +1461,25 @@ gst_message_parse_async_start (GstMessage * message, gboolean * new_base_time)
         g_value_get_boolean (gst_structure_id_get_value (message->structure,
             GST_QUARK (NEW_BASE_TIME)));
 }
+
+/**
+ * gst_message_parse_request_state:
+ * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
+ * @state: Result location for the requested state or NULL
+ *
+ * Extract the requested state from the request_state message.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.23
+ */
+void
+gst_message_parse_request_state (GstMessage * message, GstState * state)
+{
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
+
+  if (state)
+    *state = g_value_get_enum (gst_structure_id_get_value (message->structure,
+            GST_QUARK (NEW_STATE)));
+}
diff --git a/gst/gstmessage.h b/gst/gstmessage.h
index ad13ac0..b1b5b5c 100644
--- a/gst/gstmessage.h
+++ b/gst/gstmessage.h
@@ -81,6 +81,9 @@ typedef struct _GstMessageClass GstMessageClass;
  * pipeline. Since: 0.10.13
  * @GST_MESSAGE_LATENCY: Posted by elements when their latency changes. The
  * pipeline will calculate and distribute a new latency. Since: 0.10.12
+ * @GST_MESSAGE_REQUEST_STATE: Posted by elements when they want the pipeline to
+ * change state. This message is a suggestion to the application which can
+ * decide to perform the state change on (part of) the pipeline. Since: 0.10.23.
  * @GST_MESSAGE_ANY: mask for all of the above messages.
  *
  * The different message types that are available.
@@ -113,6 +116,7 @@ typedef enum
   GST_MESSAGE_LATENCY           = (1 << 19),
   GST_MESSAGE_ASYNC_START       = (1 << 20),
   GST_MESSAGE_ASYNC_DONE        = (1 << 21),
+  GST_MESSAGE_REQUEST_STATE     = (1 << 22),
   GST_MESSAGE_ANY               = ~0
 } GstMessageType;
 
@@ -383,6 +387,10 @@ GstMessage * gst_message_new_structure_change   (GstObject * src, GstStructureCh
 void gst_message_parse_structure_change (GstMessage *message, GstStructureChangeType *type,
                                                     GstElement **owner, gboolean *busy);
 
+/* REQUEST_STATE */
+GstMessage *    gst_message_new_request_state   (GstObject * src, GstState state);
+void            gst_message_parse_request_state (GstMessage * message, GstState *state);
+
 /* custom messages */
 GstMessage * gst_message_new_custom (GstMessageType type,
  GstObject    * src,
diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c
index b2a03f2..39bae40 100644
--- a/tests/check/gst/gstmessage.c
+++ b/tests/check/gst/gstmessage.c
@@ -186,8 +186,25 @@ GST_START_TEST (test_parsing)
      void            gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **debug);
    */
 
+  /* GST_MESSAGE_REQUEST_STATE   */
+  {
+    GstState state;
 
+    state = GST_STATE_PAUSED;
 
+    message = gst_message_new_request_state (NULL, state);
+    fail_if (message == NULL);
+    fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
+    fail_unless (GST_MESSAGE_SRC (message) == NULL);
+
+    /* set some wrong values to check if the parse method overwrites them
+     * with the good values */
+    state = GST_STATE_READY;
+    gst_message_parse_request_state (message, &state);
+    fail_unless (state == GST_STATE_PAUSED);
+
+    gst_message_unref (message);
+  }
 }
 
 GST_END_TEST;
diff --git a/tools/gst-launch.c b/tools/gst-launch.c
index d23f1c7..3930eae 100644
--- a/tools/gst-launch.c
+++ b/tools/gst-launch.c
@@ -523,7 +523,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
         gint percent;
 
         gst_message_parse_buffering (message, &percent);
-        if(!quiet)
+        if (!quiet)
           fprintf (stderr, "%s %d%%  \r", _("buffering..."), percent);
 
         /* no state management needed for live pipelines */
@@ -535,7 +535,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
           buffering = FALSE;
           /* if the desired state is playing, go back */
           if (target_state == GST_STATE_PLAYING) {
-            if(!quiet)
+            if (!quiet)
               fprintf (stderr,
                   _("Done buffering, setting pipeline to PLAYING ...\n"));
             gst_element_set_state (pipeline, GST_STATE_PLAYING);
@@ -545,8 +545,9 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
           /* buffering busy */
           if (buffering == FALSE && target_state == GST_STATE_PLAYING) {
             /* we were not buffering but PLAYING, PAUSE  the pipeline. */
-            if(!quiet)
-              fprintf (stderr, _("Buffering, setting pipeline to PAUSED ...\n"));
+            if (!quiet)
+              fprintf (stderr,
+                  _("Buffering, setting pipeline to PAUSED ...\n"));
             gst_element_set_state (pipeline, GST_STATE_PAUSED);
           }
           buffering = TRUE;
@@ -559,6 +560,21 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
         gst_bin_recalculate_latency (GST_BIN (pipeline));
         break;
       }
+      case GST_MESSAGE_REQUEST_STATE:
+      {
+        GstState state;
+        gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
+
+        gst_message_parse_request_state (message, &state);
+
+        fprintf (stderr, _("Setting state to %s as requested by %s...\n"),
+            gst_element_state_get_name (state), name);
+
+        gst_element_set_state (pipeline, state);
+
+        g_free (name);
+        break;
+      }
       case GST_MESSAGE_APPLICATION:{
         const GstStructure *s;
 
@@ -567,7 +583,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
         if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
           /* this application message is posted when we caught an interrupt and
            * we need to stop the pipeline. */
-          if(!quiet)
+          if (!quiet)
             fprintf (stderr, _("Interrupt: Stopping pipeline ...\n"));
           /* return TRUE when we caught an interrupt */
           res = TRUE;
@@ -728,7 +744,7 @@ main (int argc, char *argv[])
       gst_bin_add (GST_BIN (real_pipeline), pipeline);
       pipeline = real_pipeline;
     }
-    if(!quiet)
+    if (!quiet)
       fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
     ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
 
@@ -739,12 +755,13 @@ main (int argc, char *argv[])
         event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING);
         goto end;
       case GST_STATE_CHANGE_NO_PREROLL:
-        if(!quiet)
-          fprintf (stderr, _("Pipeline is live and does not need PREROLL ...\n"));
+        if (!quiet)
+          fprintf (stderr,
+              _("Pipeline is live and does not need PREROLL ...\n"));
         is_live = TRUE;
         break;
       case GST_STATE_CHANGE_ASYNC:
-        if(!quiet)
+        if (!quiet)
           fprintf (stderr, _("Pipeline is PREROLLING ...\n"));
         caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED);
         if (caught_error) {
@@ -754,7 +771,7 @@ main (int argc, char *argv[])
         state = GST_STATE_PAUSED;
         /* fallthrough */
       case GST_STATE_CHANGE_SUCCESS:
-        if(!quiet)
+        if (!quiet)
           fprintf (stderr, _("Pipeline is PREROLLED ...\n"));
         break;
     }
@@ -767,7 +784,7 @@ main (int argc, char *argv[])
       GstClockTime tfthen, tfnow;
       GstClockTimeDiff diff;
 
-      if(!quiet)
+      if (!quiet)
         fprintf (stderr, _("Setting pipeline to PLAYING ...\n"));
 
       if (gst_element_set_state (pipeline,
@@ -804,24 +821,24 @@ main (int argc, char *argv[])
     /* iterate mainloop to process pending stuff */
     while (g_main_context_iteration (NULL, FALSE));
 
-    if(!quiet)
+    if (!quiet)
       fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
     gst_element_set_state (pipeline, GST_STATE_PAUSED);
     if (!caught_error)
       gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
-    if(!quiet)
+    if (!quiet)
       fprintf (stderr, _("Setting pipeline to READY ...\n"));
     gst_element_set_state (pipeline, GST_STATE_READY);
     gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
 
   end:
-    if(!quiet)
+    if (!quiet)
       fprintf (stderr, _("Setting pipeline to NULL ...\n"));
     gst_element_set_state (pipeline, GST_STATE_NULL);
     gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
   }
 
-  if(!quiet)
+  if (!quiet)
     fprintf (stderr, _("Freeing pipeline ...\n"));
   gst_object_unref (pipeline);
 



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Felipe Contreras
Hi,

I picked this commit as an example because actually I have some comments:

On Thu, Feb 19, 2009 at 12:54 AM,  <[hidden email]> wrote:
> Module: gstreamer
> Branch: master
> Commit: 4b986a4a94c436a3d1dac443ad8da374fe38b6eb
> URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>
> Author: Wim Taymans <[hidden email]>
> Date:   Wed Feb 18 15:31:55 2009 +0100
>
> Add message to request a state change

<snip/>

>         gst_message_parse_buffering (message, &percent);
> -        if(!quiet)
> +        if (!quiet)
>           fprintf (stderr, "%s %d%%  \r", _("buffering..."), percent);

This has nothing to do with 'adding a message to request a state
change' right? So I guess ideally it should be in a separate commit;
it just adds noise here.

--
Felipe Contreras

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Edward Hervey
Administrator
In reply to this post by Felipe Contreras
Hi,

  This looks really neat. A few comments though.

  If the commit is not done to the master branch, is it possible to have
that in the subject ? Something like the following:
  "<module> [<branchname>]: <author> : <subject>"

  What happens for gigantic push with plenty of commits ? I did one a
day or two ago in gst-plugins-bad.

  It might be better to have a message-only (i.e. everything down to
'---') version for the current commit list, and use the ones with
patches on another mailing list. In fact... I'm wondering if we
shouldn't create new mailing lists now that we've switched to git, I can
have them created within the day on freedesktop.org. Something like
gst-commits@... and gst-commits-full@...

    Edward

On Thu, 2009-02-19 at 00:54 +0200, [hidden email] wrote:

> Module: gstreamer
> Branch: master
> Commit: 4b986a4a94c436a3d1dac443ad8da374fe38b6eb
> URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>
> Author: Wim Taymans <[hidden email]>
> Date:   Wed Feb 18 15:31:55 2009 +0100
>
> Add message to request a state change
>
> Add a GST_MESSAGE_REQUEST_STATE that can be posted by element when they would
> like to have the application change the state of the pipeline. the primary use
> case is to pause the pipeline when an audio mixer is mixing a higher priority
> stream but it can also be used for other purposes.
>
> Add some docs and a unit test.
>
> Implement the REQUEST_STATE message in gst-launch.
>
> API: gst_message_new_request_state()
> API: gst_message_parse_request_state()
> API: GST_MESSAGE_REQUEST_STATE
>
> ---
>
>  docs/design/part-messages.txt   |    4 +++
>  docs/gst/gstreamer-sections.txt |    2 +
>  gst/gstmessage.c                |   52 +++++++++++++++++++++++++++++++++++++++
>  gst/gstmessage.h                |    8 ++++++
>  tests/check/gst/gstmessage.c    |   17 ++++++++++++
>  tools/gst-launch.c              |   47 ++++++++++++++++++++++++-----------
>  6 files changed, 115 insertions(+), 15 deletions(-)
>
> diff --git a/docs/design/part-messages.txt b/docs/design/part-messages.txt
> index aa5f218..cd53e10 100644
> --- a/docs/design/part-messages.txt
> +++ b/docs/design/part-messages.txt
> @@ -128,4 +128,8 @@ Message types
>      Posted by elements when the latency in a pipeline changed and a new global
>      latency should be calculated by the pipeline or application.
>  
> +  GST_MESSAGE_REQUEST_STATE:
>  
> +    Posted by elements when they want to change the state of the pipeline they
> +    are in. A typical use case would be an audio sink that requests the pipeline
> +    to pause in order to play a higher priority stream.
> diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
> index b07d371..751d8e9 100644
> --- a/docs/gst/gstreamer-sections.txt
> +++ b/docs/gst/gstreamer-sections.txt
> @@ -1089,6 +1089,8 @@ gst_message_parse_async_start
>  gst_message_new_async_done
>  gst_message_new_structure_change
>  gst_message_parse_structure_change
> +gst_message_new_request_state
> +gst_message_parse_request_state
>  <SUBSECTION Standard>
>  GstMessageClass
>  GST_MESSAGE
> diff --git a/gst/gstmessage.c b/gst/gstmessage.c
> index df9b5e1..78305bd 100644
> --- a/gst/gstmessage.c
> +++ b/gst/gstmessage.c
> @@ -111,6 +111,7 @@ static GstMessageQuarks message_quarks[] = {
>    {GST_MESSAGE_LATENCY, "latency", 0},
>    {GST_MESSAGE_ASYNC_START, "async-start", 0},
>    {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
> +  {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
>    {0, NULL, 0}
>  };
>  
> @@ -933,6 +934,35 @@ gst_message_new_latency (GstObject * src)
>  }
>  
>  /**
> + * gst_message_new_request_state:
> + * @src: The object originating the message.
> + * @state: The new requested state
> + *
> + * This message can be posted by elements when they want to have their state
> + * changed. A typical use case would be an audio server that wants to pause the
> + * pipeline because a higher priority stream is being played.
> + *
> + * Returns: The new requst state message.
> + *
> + * MT safe.
> + *
> + * Since: 0.10.23
> + */
> +GstMessage *
> +gst_message_new_request_state (GstObject * src, GstState state)
> +{
> +  GstMessage *message;
> +  GstStructure *structure;
> +
> +  structure = gst_structure_empty_new ("GstMessageRequestState");
> +  gst_structure_id_set (structure,
> +      GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
> +  message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
> +
> +  return message;
> +}
> +
> +/**
>   * gst_message_get_structure:
>   * @message: The #GstMessage.
>   *
> @@ -1431,3 +1461,25 @@ gst_message_parse_async_start (GstMessage * message, gboolean * new_base_time)
>          g_value_get_boolean (gst_structure_id_get_value (message->structure,
>              GST_QUARK (NEW_BASE_TIME)));
>  }
> +
> +/**
> + * gst_message_parse_request_state:
> + * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
> + * @state: Result location for the requested state or NULL
> + *
> + * Extract the requested state from the request_state message.
> + *
> + * MT safe.
> + *
> + * Since: 0.10.23
> + */
> +void
> +gst_message_parse_request_state (GstMessage * message, GstState * state)
> +{
> +  g_return_if_fail (GST_IS_MESSAGE (message));
> +  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
> +
> +  if (state)
> +    *state = g_value_get_enum (gst_structure_id_get_value (message->structure,
> +            GST_QUARK (NEW_STATE)));
> +}
> diff --git a/gst/gstmessage.h b/gst/gstmessage.h
> index ad13ac0..b1b5b5c 100644
> --- a/gst/gstmessage.h
> +++ b/gst/gstmessage.h
> @@ -81,6 +81,9 @@ typedef struct _GstMessageClass GstMessageClass;
>   * pipeline. Since: 0.10.13
>   * @GST_MESSAGE_LATENCY: Posted by elements when their latency changes. The
>   * pipeline will calculate and distribute a new latency. Since: 0.10.12
> + * @GST_MESSAGE_REQUEST_STATE: Posted by elements when they want the pipeline to
> + * change state. This message is a suggestion to the application which can
> + * decide to perform the state change on (part of) the pipeline. Since: 0.10.23.
>   * @GST_MESSAGE_ANY: mask for all of the above messages.
>   *
>   * The different message types that are available.
> @@ -113,6 +116,7 @@ typedef enum
>    GST_MESSAGE_LATENCY           = (1 << 19),
>    GST_MESSAGE_ASYNC_START       = (1 << 20),
>    GST_MESSAGE_ASYNC_DONE        = (1 << 21),
> +  GST_MESSAGE_REQUEST_STATE     = (1 << 22),
>    GST_MESSAGE_ANY               = ~0
>  } GstMessageType;
>  
> @@ -383,6 +387,10 @@ GstMessage * gst_message_new_structure_change   (GstObject * src, GstStructureCh
>  void gst_message_parse_structure_change (GstMessage *message, GstStructureChangeType *type,
>                                                      GstElement **owner, gboolean *busy);
>  
> +/* REQUEST_STATE */
> +GstMessage *    gst_message_new_request_state   (GstObject * src, GstState state);
> +void            gst_message_parse_request_state (GstMessage * message, GstState *state);
> +
>  /* custom messages */
>  GstMessage * gst_message_new_custom (GstMessageType type,
>   GstObject    * src,
> diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c
> index b2a03f2..39bae40 100644
> --- a/tests/check/gst/gstmessage.c
> +++ b/tests/check/gst/gstmessage.c
> @@ -186,8 +186,25 @@ GST_START_TEST (test_parsing)
>       void            gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **debug);
>     */
>  
> +  /* GST_MESSAGE_REQUEST_STATE   */
> +  {
> +    GstState state;
>  
> +    state = GST_STATE_PAUSED;
>  
> +    message = gst_message_new_request_state (NULL, state);
> +    fail_if (message == NULL);
> +    fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
> +    fail_unless (GST_MESSAGE_SRC (message) == NULL);
> +
> +    /* set some wrong values to check if the parse method overwrites them
> +     * with the good values */
> +    state = GST_STATE_READY;
> +    gst_message_parse_request_state (message, &state);
> +    fail_unless (state == GST_STATE_PAUSED);
> +
> +    gst_message_unref (message);
> +  }
>  }
>  
>  GST_END_TEST;
> diff --git a/tools/gst-launch.c b/tools/gst-launch.c
> index d23f1c7..3930eae 100644
> --- a/tools/gst-launch.c
> +++ b/tools/gst-launch.c
> @@ -523,7 +523,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
>          gint percent;
>  
>          gst_message_parse_buffering (message, &percent);
> -        if(!quiet)
> +        if (!quiet)
>            fprintf (stderr, "%s %d%%  \r", _("buffering..."), percent);
>  
>          /* no state management needed for live pipelines */
> @@ -535,7 +535,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
>            buffering = FALSE;
>            /* if the desired state is playing, go back */
>            if (target_state == GST_STATE_PLAYING) {
> -            if(!quiet)
> +            if (!quiet)
>                fprintf (stderr,
>                    _("Done buffering, setting pipeline to PLAYING ...\n"));
>              gst_element_set_state (pipeline, GST_STATE_PLAYING);
> @@ -545,8 +545,9 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
>            /* buffering busy */
>            if (buffering == FALSE && target_state == GST_STATE_PLAYING) {
>              /* we were not buffering but PLAYING, PAUSE  the pipeline. */
> -            if(!quiet)
> -              fprintf (stderr, _("Buffering, setting pipeline to PAUSED ...\n"));
> +            if (!quiet)
> +              fprintf (stderr,
> +                  _("Buffering, setting pipeline to PAUSED ...\n"));
>              gst_element_set_state (pipeline, GST_STATE_PAUSED);
>            }
>            buffering = TRUE;
> @@ -559,6 +560,21 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
>          gst_bin_recalculate_latency (GST_BIN (pipeline));
>          break;
>        }
> +      case GST_MESSAGE_REQUEST_STATE:
> +      {
> +        GstState state;
> +        gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
> +
> +        gst_message_parse_request_state (message, &state);
> +
> +        fprintf (stderr, _("Setting state to %s as requested by %s...\n"),
> +            gst_element_state_get_name (state), name);
> +
> +        gst_element_set_state (pipeline, state);
> +
> +        g_free (name);
> +        break;
> +      }
>        case GST_MESSAGE_APPLICATION:{
>          const GstStructure *s;
>  
> @@ -567,7 +583,7 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
>          if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
>            /* this application message is posted when we caught an interrupt and
>             * we need to stop the pipeline. */
> -          if(!quiet)
> +          if (!quiet)
>              fprintf (stderr, _("Interrupt: Stopping pipeline ...\n"));
>            /* return TRUE when we caught an interrupt */
>            res = TRUE;
> @@ -728,7 +744,7 @@ main (int argc, char *argv[])
>        gst_bin_add (GST_BIN (real_pipeline), pipeline);
>        pipeline = real_pipeline;
>      }
> -    if(!quiet)
> +    if (!quiet)
>        fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
>      ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
>  
> @@ -739,12 +755,13 @@ main (int argc, char *argv[])
>          event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING);
>          goto end;
>        case GST_STATE_CHANGE_NO_PREROLL:
> -        if(!quiet)
> -          fprintf (stderr, _("Pipeline is live and does not need PREROLL ...\n"));
> +        if (!quiet)
> +          fprintf (stderr,
> +              _("Pipeline is live and does not need PREROLL ...\n"));
>          is_live = TRUE;
>          break;
>        case GST_STATE_CHANGE_ASYNC:
> -        if(!quiet)
> +        if (!quiet)
>            fprintf (stderr, _("Pipeline is PREROLLING ...\n"));
>          caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED);
>          if (caught_error) {
> @@ -754,7 +771,7 @@ main (int argc, char *argv[])
>          state = GST_STATE_PAUSED;
>          /* fallthrough */
>        case GST_STATE_CHANGE_SUCCESS:
> -        if(!quiet)
> +        if (!quiet)
>            fprintf (stderr, _("Pipeline is PREROLLED ...\n"));
>          break;
>      }
> @@ -767,7 +784,7 @@ main (int argc, char *argv[])
>        GstClockTime tfthen, tfnow;
>        GstClockTimeDiff diff;
>  
> -      if(!quiet)
> +      if (!quiet)
>          fprintf (stderr, _("Setting pipeline to PLAYING ...\n"));
>  
>        if (gst_element_set_state (pipeline,
> @@ -804,24 +821,24 @@ main (int argc, char *argv[])
>      /* iterate mainloop to process pending stuff */
>      while (g_main_context_iteration (NULL, FALSE));
>  
> -    if(!quiet)
> +    if (!quiet)
>        fprintf (stderr, _("Setting pipeline to PAUSED ...\n"));
>      gst_element_set_state (pipeline, GST_STATE_PAUSED);
>      if (!caught_error)
>        gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
> -    if(!quiet)
> +    if (!quiet)
>        fprintf (stderr, _("Setting pipeline to READY ...\n"));
>      gst_element_set_state (pipeline, GST_STATE_READY);
>      gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
>  
>    end:
> -    if(!quiet)
> +    if (!quiet)
>        fprintf (stderr, _("Setting pipeline to NULL ...\n"));
>      gst_element_set_state (pipeline, GST_STATE_NULL);
>      gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
>    }
>  
> -  if(!quiet)
> +  if (!quiet)
>      fprintf (stderr, _("Freeing pipeline ...\n"));
>    gst_object_unref (pipeline);
>  
>
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Felipe Contreras
On Thu, Feb 19, 2009 at 11:47 AM, Edward Hervey <[hidden email]> wrote:
> Hi,
>
>  This looks really neat. A few comments though.
>
>  If the commit is not done to the master branch, is it possible to have
> that in the subject ? Something like the following:
>  "<module> [<branchname>]: <author> : <subject>"

Sure:

             push @notice, "Diff:   $gitweb_url/diff/?id=$obj" if $gitweb_url;
         }

-        if ($ref eq "master")
-        {
-            $subject = $repos_name . ": " . $info{"author_name"} . ":
" . ${$info{"log"}}[0];
-        }
-        else
-        {
-            $subject = $repos_name . ": " . $ref . ": " .
$info{"author_name"} . ": " . ${$info{"log"}}[0];
-        }
+        $subject = $repos_name . ": " . $info{"author_name"} . ": " .
${$info{"log"}}[0];
     }

     mail_notification($commitlist_address, $subject, "text/plain;
charset=UTF-8", @notice);

>  What happens for gigantic push with plenty of commits ? I did one a
> day or two ago in gst-plugins-bad.

I noticed that push :)

As I explained earlier, if there's more than 100 commits in a push
there will be a single email with the summary of the commits. The
number can be configured with $max_individual_notices.

>  It might be better to have a message-only (i.e. everything down to
> '---') version for the current commit list, and use the ones with
> patches on another mailing list. In fact... I'm wondering if we
> shouldn't create new mailing lists now that we've switched to git, I can
> have them created within the day on freedesktop.org. Something like
> gst-commits@... and gst-commits-full@...

Maybe... this script will not always return the whole diff, only when
it's less than 10000 bytes, and again, the number can be configured
with $max_diff_size.

Keep in mind that the email has the url to cgit, which contains the diff also.

Therefore I think the only valid reason the ml with the actuall diff
make sense is if somebody wants to make comments to some particular
lines, but I think a manual diff would server the purpose. The only
reason would be to avoid one click to the cgit url, but I don't think
that's a valid one.


BTW, I noticed there's an extra space after the author name, so I'm
attaching a new one (try 4) with a fix for that and your suggestion.

Cheers.

--
Felipe Contreras

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

post-receive (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Peter Kjellerstedt
In reply to this post by Edward Hervey
> -----Original Message-----
> From: Edward Hervey [mailto:[hidden email]]
> Sent: den 19 februari 2009 10:48
> To: Discussion of the development of GStreamer
> Subject: Re: [gst-devel] gstreamer: Wim Taymans : Add message to
> request a state change
>
> Hi,
>
>   This looks really neat. A few comments though.
>
>   If the commit is not done to the master branch, is it possible to
> have
> that in the subject ? Something like the following:
>   "<module> [<branchname>]: <author> : <subject>"
>
>   What happens for gigantic push with plenty of commits ? I did one a
> day or two ago in gst-plugins-bad.
>
>   It might be better to have a message-only (i.e. everything down to
> '---') version for the current commit list, and use the ones with
> patches on another mailing list. In fact... I'm wondering if we
> shouldn't create new mailing lists now that we've switched to git, I
> can
> have them created within the day on freedesktop.org. Something like
> gst-commits@... and gst-commits-full@...
>
>     Edward

Do we really need the author in the subject? In most cases it will
be the same as the committer, which then will equal the sender of
the mail, and in any case the author is mentioned a couple of lines
into the body of the mail.

//Peter


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Edward Hervey
Administrator
On Thu, 2009-02-19 at 17:09 +0100, Peter Kjellerstedt wrote:

> > -----Original Message-----
> > From: Edward Hervey [mailto:[hidden email]]
> > Sent: den 19 februari 2009 10:48
> > To: Discussion of the development of GStreamer
> > Subject: Re: [gst-devel] gstreamer: Wim Taymans : Add message to
> > request a state change
> >
> > Hi,
> >
> >   This looks really neat. A few comments though.
> >
> >   If the commit is not done to the master branch, is it possible to
> > have
> > that in the subject ? Something like the following:
> >   "<module> [<branchname>]: <author> : <subject>"
> >
> >   What happens for gigantic push with plenty of commits ? I did one a
> > day or two ago in gst-plugins-bad.
> >
> >   It might be better to have a message-only (i.e. everything down to
> > '---') version for the current commit list, and use the ones with
> > patches on another mailing list. In fact... I'm wondering if we
> > shouldn't create new mailing lists now that we've switched to git, I
> > can
> > have them created within the day on freedesktop.org. Something like
> > gst-commits@... and gst-commits-full@...
> >
> >     Edward
>
> Do we really need the author in the subject? In most cases it will
> be the same as the committer, which then will equal the sender of
> the mail, and in any case the author is mentioned a couple of lines
> into the body of the mail.

  I think the consensus, also with discussions on IRC, is that the
author name in the subject is pointless. I'll therefore remove it.

   Edward

>
> //Peter
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Stefan Sauer
In reply to this post by Felipe Contreras
Felipe Contreras schrieb:

> Hi,
>
> I picked this commit as an example because actually I have some comments:
>
> On Thu, Feb 19, 2009 at 12:54 AM,  <[hidden email]> wrote:
>> Module: gstreamer
>> Branch: master
>> Commit: 4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>> URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>>
>> Author: Wim Taymans <[hidden email]>
>> Date:   Wed Feb 18 15:31:55 2009 +0100
>>
>> Add message to request a state change
>
> <snip/>
>
>>         gst_message_parse_buffering (message, &percent);
>> -        if(!quiet)
>> +        if (!quiet)
>>           fprintf (stderr, "%s %d%%  \r", _("buffering..."), percent);
>
> This has nothing to do with 'adding a message to request a state
> change' right? So I guess ideally it should be in a separate commit;
> it just adds noise here.
>

Do we want separate commits for gst-indent changes? The problem is that if there
are things that gst-indent complains about, it won't allow you to commit the
unindented code and then run indent and do a second commit with those changes.
And forcing someone to commit hunks manually sounds overkill to me.

Stefan


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer: Wim Taymans : Add message to request a state change

Felipe Contreras
On Sat, Feb 21, 2009 at 2:30 PM, Stefan Kost <[hidden email]> wrote:

> Felipe Contreras schrieb:
>> Hi,
>>
>> I picked this commit as an example because actually I have some comments:
>>
>> On Thu, Feb 19, 2009 at 12:54 AM,  <[hidden email]> wrote:
>>> Module: gstreamer
>>> Branch: master
>>> Commit: 4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>>> URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=4b986a4a94c436a3d1dac443ad8da374fe38b6eb
>>>
>>> Author: Wim Taymans <[hidden email]>
>>> Date:   Wed Feb 18 15:31:55 2009 +0100
>>>
>>> Add message to request a state change
>>
>> <snip/>
>>
>>>         gst_message_parse_buffering (message, &percent);
>>> -        if(!quiet)
>>> +        if (!quiet)
>>>           fprintf (stderr, "%s %d%%  \r", _("buffering..."), percent);
>>
>> This has nothing to do with 'adding a message to request a state
>> change' right? So I guess ideally it should be in a separate commit;
>> it just adds noise here.
>>
>
> Do we want separate commits for gst-indent changes? The problem is that if there
> are things that gst-indent complains about, it won't allow you to commit the
> unindented code and then run indent and do a second commit with those changes.
> And forcing someone to commit hunks manually sounds overkill to me.

That's one the reasons why I think running gst-indent automatically is
a bad idea.

And regarding committing hunks 'manually', that can be easily solved
with git add --patch, just click 'y' to the hunks you want in. Yes,
it's manual but at least it's not tedious.

For a good read regarding the problem and solution a-la-git:
http://tomayko.com/writings/the-thing-about-git

IMHO commits should be logically independent (not do two things at a
time), if the process makes that difficult, well then the process
needs to be fixed.

--
Felipe Contreras

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel