Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
8cf8eb6b
Commit
8cf8eb6b
authored
4 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
m-default-nodes: move common code to a new header
parent
0a53ddd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/module-default-nodes.c
+3
-50
3 additions, 50 deletions
modules/module-default-nodes.c
modules/module-default-nodes/common.h
+62
-0
62 additions, 0 deletions
modules/module-default-nodes/common.h
with
65 additions
and
50 deletions
modules/module-default-nodes.c
+
3
−
50
View file @
8cf8eb6b
...
...
@@ -9,37 +9,14 @@
#include
<wp/wp.h>
#include
<errno.h>
#include
<pipewire/keys.h>
#include
<spa/utils/json.h>
#define DEFAULT_CONFIG_KEYS 1
#include
"module-default-nodes/common.h"
#define NAME "default-nodes"
#define DEFAULT_SAVE_INTERVAL_MS 1000
#define DEFAULT_USE_PERSISTENT_STORAGE TRUE
enum
{
AUDIO_SINK
,
AUDIO_SOURCE
,
VIDEO_SOURCE
,
N_DEFAULT_NODES
};
static
const
gchar
*
DEFAULT_KEY
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"default.audio.sink"
,
[
AUDIO_SOURCE
]
=
"default.audio.source"
,
[
VIDEO_SOURCE
]
=
"default.video.source"
,
};
static
const
gchar
*
DEFAULT_CONFIG_KEY
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"default.configured.audio.sink"
,
[
AUDIO_SOURCE
]
=
"default.configured.audio.source"
,
[
VIDEO_SOURCE
]
=
"default.configured.video.source"
,
};
static
const
gchar
*
MEDIA_CLASS
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"Audio/Sink"
,
[
AUDIO_SOURCE
]
=
"Audio/Source"
,
[
VIDEO_SOURCE
]
=
"Video/Source"
,
};
enum
{
PROP_0
,
PROP_SAVE_INTERVAL_MS
,
...
...
@@ -189,30 +166,6 @@ reevaluate_default_node (WpDefaultNodes * self, WpMetadata *m, gint node_t)
}
}
static
int
json_object_find
(
const
char
*
obj
,
const
char
*
key
,
char
*
value
,
size_t
len
)
{
struct
spa_json
it
[
2
];
const
char
*
v
;
char
k
[
128
];
spa_json_init
(
&
it
[
0
],
obj
,
strlen
(
obj
));
if
(
spa_json_enter_object
(
&
it
[
0
],
&
it
[
1
])
<=
0
)
return
-
EINVAL
;
while
(
spa_json_get_string
(
&
it
[
1
],
k
,
sizeof
(
k
)
-
1
)
>
0
)
{
if
(
strcmp
(
k
,
key
)
==
0
)
{
if
(
spa_json_get_string
(
&
it
[
1
],
value
,
len
)
<=
0
)
continue
;
return
0
;
}
else
{
if
(
spa_json_next
(
&
it
[
1
],
&
v
)
<=
0
)
break
;
}
}
return
-
ENOENT
;
}
static
void
on_metadata_changed
(
WpMetadata
*
m
,
guint32
subject
,
const
gchar
*
key
,
const
gchar
*
type
,
const
gchar
*
value
,
gpointer
d
)
...
...
This diff is collapsed.
Click to expand it.
modules/module-default-nodes/common.h
0 → 100644
+
62
−
0
View file @
8cf8eb6b
/* WirePlumber
*
* Copyright © 2021 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include
<glib.h>
#include
<errno.h>
#include
<spa/utils/json.h>
enum
{
AUDIO_SINK
,
AUDIO_SOURCE
,
VIDEO_SOURCE
,
N_DEFAULT_NODES
};
static
const
gchar
*
DEFAULT_KEY
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"default.audio.sink"
,
[
AUDIO_SOURCE
]
=
"default.audio.source"
,
[
VIDEO_SOURCE
]
=
"default.video.source"
,
};
#if DEFAULT_CONFIG_KEYS
static
const
gchar
*
DEFAULT_CONFIG_KEY
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"default.configured.audio.sink"
,
[
AUDIO_SOURCE
]
=
"default.configured.audio.source"
,
[
VIDEO_SOURCE
]
=
"default.configured.video.source"
,
};
#endif
static
const
gchar
*
MEDIA_CLASS
[
N_DEFAULT_NODES
]
=
{
[
AUDIO_SINK
]
=
"Audio/Sink"
,
[
AUDIO_SOURCE
]
=
"Audio/Source"
,
[
VIDEO_SOURCE
]
=
"Video/Source"
,
};
static
int
json_object_find
(
const
char
*
obj
,
const
char
*
key
,
char
*
value
,
size_t
len
)
{
struct
spa_json
it
[
2
];
const
char
*
v
;
char
k
[
128
];
spa_json_init
(
&
it
[
0
],
obj
,
strlen
(
obj
));
if
(
spa_json_enter_object
(
&
it
[
0
],
&
it
[
1
])
<=
0
)
return
-
EINVAL
;
while
(
spa_json_get_string
(
&
it
[
1
],
k
,
sizeof
(
k
)
-
1
)
>
0
)
{
if
(
strcmp
(
k
,
key
)
==
0
)
{
if
(
spa_json_get_string
(
&
it
[
1
],
value
,
len
)
<=
0
)
continue
;
return
0
;
}
else
{
if
(
spa_json_next
(
&
it
[
1
],
&
v
)
<=
0
)
break
;
}
}
return
-
ENOENT
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment