[calls] sip: media-pipeline: Allow pausing pipeline



commit 86e76380c2864b999ff944e05ca6fb1266ce43bd
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Mon Feb 28 11:24:33 2022 +0100

    sip: media-pipeline: Allow pausing pipeline
    
    We want to pause a pipeline in the multi call scenario.

 plugins/sip/calls-sip-media-pipeline.c | 19 ++++++++++++++++---
 plugins/sip/calls-sip-media-pipeline.h |  3 ++-
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/plugins/sip/calls-sip-media-pipeline.c b/plugins/sip/calls-sip-media-pipeline.c
index bf4b4cb5..bd747a61 100644
--- a/plugins/sip/calls-sip-media-pipeline.c
+++ b/plugins/sip/calls-sip-media-pipeline.c
@@ -822,11 +822,24 @@ calls_sip_media_pipeline_stop (CallsSipMediaPipeline *self)
 
 
 void
-calls_sip_media_pipeline_pause (CallsSipMediaPipeline *self)
+calls_sip_media_pipeline_pause (CallsSipMediaPipeline *self,
+                                gboolean               pause)
 {
   g_return_if_fail (CALLS_IS_SIP_MEDIA_PIPELINE (self));
 
-  g_debug ("Pause/unpause media pipeline");
-  self->is_running = FALSE;
+  if (self->is_running != pause)
+    return;
+
+  g_debug ("%s media pipeline", self->is_running ?
+           "Pausing" :
+           "Unpausing");
+  gst_element_set_state (self->recv_pipeline, self->is_running ?
+                         GST_STATE_PAUSED :
+                         GST_STATE_PLAYING);
+  gst_element_set_state (self->send_pipeline, self->is_running ?
+                         GST_STATE_PAUSED :
+                         GST_STATE_PLAYING);
+
+  self->is_running = !self->is_running;
 }
 
diff --git a/plugins/sip/calls-sip-media-pipeline.h b/plugins/sip/calls-sip-media-pipeline.h
index 16ebe192..ec58fb48 100644
--- a/plugins/sip/calls-sip-media-pipeline.h
+++ b/plugins/sip/calls-sip-media-pipeline.h
@@ -38,6 +38,7 @@ G_DECLARE_FINAL_TYPE (CallsSipMediaPipeline, calls_sip_media_pipeline, CALLS, SI
 CallsSipMediaPipeline* calls_sip_media_pipeline_new                    (MediaCodecInfo *codec);
 void                   calls_sip_media_pipeline_start                  (CallsSipMediaPipeline *self);
 void                   calls_sip_media_pipeline_stop                   (CallsSipMediaPipeline *self);
-void                   calls_sip_media_pipeline_pause                  (CallsSipMediaPipeline *self);
+void                   calls_sip_media_pipeline_pause                  (CallsSipMediaPipeline *self,
+                                                                        gboolean               pause);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]