proplist: Add internal API to get stream group

This moves out code from module-stream-restore and makes an internal API
out of it to get a "stream group" for a given sink input or source output.
This is factored out for reuse in module-filter-*.

The stream group basically provides some means of attaching a logical
identification to the stream (by role, application id, etc.).
This commit is contained in:
Arun Raghavan 2011-11-23 16:26:40 +05:30
parent c30a68ebbd
commit 1798c653db
3 changed files with 44 additions and 37 deletions

View file

@ -241,3 +241,33 @@ void pa_init_proplist(pa_proplist *p) {
}
}
}
char *pa_proplist_get_stream_group(pa_proplist *p, const char *prefix, const char *cache) {
const char *r;
char *t;
if (!p)
return NULL;
if (cache && (r = pa_proplist_gets(p, cache)))
return pa_xstrdup(r);
if (!prefix)
prefix = "stream";
if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE)))
t = pa_sprintf_malloc("%s-by-media-role:%s", prefix, r);
else if ((r = pa_proplist_gets(p, PA_PROP_APPLICATION_ID)))
t = pa_sprintf_malloc("%s-by-application-id:%s", prefix, r);
else if ((r = pa_proplist_gets(p, PA_PROP_APPLICATION_NAME)))
t = pa_sprintf_malloc("%s-by-application-name:%s", prefix, r);
else if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_NAME)))
t = pa_sprintf_malloc("%s-by-media-name:%s", prefix, r);
else
t = pa_sprintf_malloc("%s-fallback:%s", prefix, r);
if (cache)
pa_proplist_sets(p, cache, t);
return t;
}

View file

@ -25,5 +25,6 @@
#include <pulse/proplist.h>
void pa_init_proplist(pa_proplist *p);
char *pa_proplist_get_stream_group(pa_proplist *pl, const char *prefix, const char *cache);
#endif