[Top][All Lists]

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

Re: [Linphone-developers] Mediastreamer2: check if a filter is a source

From: Aymeric Moizard
Subject: Re: [Linphone-developers] Mediastreamer2: check if a filter is a source
Date: Tue, 10 Mar 2009 11:59:22 +0100 (CET)

On Mon, 9 Mar 2009, damico wrote:

Hi all,

Hi Michelle,

I'm proposing a little modification to mediastreamer API:
In order to check if a MSFilter is a source we must look at ninputs member of the description: if it is 0 is a source, otherwise a filter. Maybe it is more useful check if a istance of a filter is used as a source or not. My idea is to check if "there is a configured input" instead to check if "an input could be configured". By the attached patch I could use the same filter as a filter or a source simply by liking or not to other filters. Moreover, ms_filter_is_source() could be used in the process callback of the filter too for choosing if we must produce samples of filter incoming samples.

I hope it could be useful...

Note: the patch preserves a backward compatibility with the old implementations.

I understand this behavior is the one you expect, but it looks not
100% backward compatible.

It look to me you should use the PUMP flag instead for your filter.
You would then probably get the exact same behavior you are looking




Index: include/mediastreamer2/msfilter.h
--- include/mediastreamer2/msfilter.h    (revision 313)
+++ include/mediastreamer2/msfilter.h    (working copy)
@@ -333,6 +333,15 @@
MSFilterId ms_filter_get_id(MSFilter *f);

+ * Check if a filter is a source: no input are linked to that filter.
+ *
+ * @param f        A MSFilter object.
+ *
+ * Returns: TRUE if f is a source, FALSE otherwise.
+ */
+bool_t ms_filter_is_source(MSFilter *f);
* Destroy a filter object.
* @param f        A MSFilter object.
Index: src/msticker.c
--- src/msticker.c    (revision 313)
+++ src/msticker.c    (working copy)
@@ -106,7 +106,7 @@
   MSFilter *f;
-        if (f->desc->ninputs==0){
+        if (ms_filter_is_source(f)){
@@ -190,7 +190,7 @@

static void call_process(MSFilter *f){
   bool_t process_done=FALSE;
-    if (f->desc->ninputs==0 || f->desc->flags & MS_FILTER_IS_PUMP){
+    if (ms_filter_is_source(f) || f->desc->flags & MS_FILTER_IS_PUMP){
       while (ms_filter_inputs_have_data(f)) {
Index: src/msfilter.c
--- src/msfilter.c    (revision 313)
+++ src/msfilter.c    (working copy)
@@ -233,3 +233,14 @@
   if (f->notify!=NULL)
+bool_t ms_filter_is_source(MSFilter *f){
+    int i;
+    for (i=0;i<f->desc->ninputs;++i){
+        if (f->inputs[i]){
+            return FALSE;
+        }
+    }
+    return TRUE;

Linphone-developers mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]