examples: use PW_KEY_TARGET_OBJECT

In examples, tell people how to use target.object.
This commit is contained in:
Pauli Virtanen 2022-01-16 19:48:43 +02:00
parent de65fd442f
commit ca87d40448
16 changed files with 94 additions and 65 deletions

View file

@ -120,6 +120,7 @@ int main(int argc, char *argv[])
struct data data = { 0, };
const struct spa_pod *params[1];
uint8_t buffer[1024];
struct pw_properties *props;
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
pw_init(&argc, &argv);
@ -142,14 +143,17 @@ int main(int argc, char *argv[])
* you need to listen to is the process event where you need to produce
* the data.
*/
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio",
PW_KEY_MEDIA_CATEGORY, "Playback",
PW_KEY_MEDIA_ROLE, "Music",
NULL);
if (argc > 1)
/* Set stream target if given on command line */
pw_properties_set(props, PW_KEY_TARGET_OBJECT, argv[1]);
data.stream = pw_stream_new_simple(
pw_main_loop_get_loop(data.loop),
"audio-src",
pw_properties_new(
PW_KEY_MEDIA_TYPE, "Audio",
PW_KEY_MEDIA_CATEGORY, "Playback",
PW_KEY_MEDIA_ROLE, "Music",
NULL),
props,
&stream_events,
&data);
@ -165,7 +169,7 @@ int main(int argc, char *argv[])
* called in a realtime thread. */
pw_stream_connect(data.stream,
PW_DIRECTION_OUTPUT,
argc > 1 ? (uint32_t)atoi(argv[1]) : PW_ID_ANY,
PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS,

View file

@ -472,7 +472,7 @@ static void make_node(struct data *data)
props = pw_properties_new(PW_KEY_NODE_AUTOCONNECT, "true", NULL);
if (data->path)
pw_properties_set(props, PW_KEY_NODE_TARGET, data->path);
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data->path);
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Stream/Input/Video");
pw_properties_set(props, PW_KEY_MEDIA_TYPE, "Video");
pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, "Capture");

View file

@ -483,7 +483,7 @@ static void make_node(struct data *data)
PW_KEY_MEDIA_ROLE, "Music",
NULL);
if (data->path)
pw_properties_set(props, PW_KEY_NODE_TARGET, data->path);
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data->path);
data->impl_node.iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_Node,

View file

@ -93,7 +93,7 @@ static int make_node(struct data *data)
if (data->path) {
pw_properties_set(props, PW_KEY_NODE_AUTOCONNECT, "true");
pw_properties_set(props, PW_KEY_NODE_TARGET, data->path);
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data->path);
}
data->proxy = pw_core_export(data->core,

View file

@ -263,7 +263,7 @@ int main(int argc, char *argv[])
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "DSP",
PW_KEY_NODE_AUTOCONNECT, data.target ? "true" : "false",
PW_KEY_NODE_TARGET, data.target,
PW_KEY_TARGET_OBJECT, data.target,
PW_KEY_MEDIA_CLASS, "Stream/Input/Video",
NULL),
&filter_events,

View file

@ -419,6 +419,7 @@ int main(int argc, char *argv[])
const struct spa_pod *params[2];
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct pw_properties *props;
int res, n_params;
pw_init(&argc, &argv);
@ -440,19 +441,22 @@ int main(int argc, char *argv[])
* you need to listen to is the process event where you need to consume
* the data provided to you.
*/
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
data.path = argc > 1 ? argv[1] : NULL;
if (data.path)
/* Set stream target if given on command line */
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.path);
data.stream = pw_stream_new_simple(
pw_main_loop_get_loop(data.loop),
"video-play-reneg",
pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
"video-play-fixate",
props,
&stream_events,
&data);
data.path = argc > 1 ? argv[1] : NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
return -1;
@ -477,7 +481,7 @@ int main(int argc, char *argv[])
*/
if ((res = pw_stream_connect(data.stream,
PW_DIRECTION_INPUT,
data.path ? (uint32_t)atoi(data.path) : PW_ID_ANY,
PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
params, n_params)) /* extra parameters, see above */ < 0) {

View file

@ -493,6 +493,7 @@ int main(int argc, char *argv[])
const struct spa_pod *params[2];
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct pw_properties *props;
int res, n_params;
pw_init(&argc, &argv);
@ -517,20 +518,23 @@ int main(int argc, char *argv[])
* you need to listen to is the process event where you need to consume
* the data provided to you.
*/
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
PW_KEY_PRIORITY_DRIVER, "10000",
NULL),
data.path = argc > 1 ? argv[1] : NULL;
if (data.path)
/* Set stream target if given on command line */
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.path);
data.stream = pw_stream_new_simple(
pw_main_loop_get_loop(data.loop),
"video-play",
pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
PW_KEY_PRIORITY_DRIVER, "10000",
NULL),
props,
&stream_events,
&data);
data.path = argc > 1 ? argv[1] : NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
return -1;
@ -552,7 +556,7 @@ int main(int argc, char *argv[])
*/
if ((res = pw_stream_connect(data.stream,
PW_DIRECTION_INPUT,
data.path ? (uint32_t)atoi(data.path) : PW_ID_ANY,
PW_ID_ANY,
PW_STREAM_FLAG_DRIVER | /* we're driver, we pull */
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */

View file

@ -346,6 +346,7 @@ int main(int argc, char *argv[])
const struct spa_pod *params[2];
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct pw_properties *props;
int res, n_params;
pw_init(&argc, &argv);
@ -367,19 +368,22 @@ int main(int argc, char *argv[])
* you need to listen to is the process event where you need to consume
* the data provided to you.
*/
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
data.path = argc > 1 ? argv[1] : NULL;
if (data.path)
/* Set stream target if given on command line */
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.path);
data.stream = pw_stream_new_simple(
pw_main_loop_get_loop(data.loop),
"video-play-reneg",
pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
props,
&stream_events,
&data);
data.path = argc > 1 ? argv[1] : NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
return -1;
@ -401,7 +405,7 @@ int main(int argc, char *argv[])
*/
if ((res = pw_stream_connect(data.stream,
PW_DIRECTION_INPUT,
data.path ? (uint32_t)atoi(data.path) : PW_ID_ANY,
PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
params, n_params)) /* extra parameters, see above */ < 0) {

View file

@ -439,6 +439,7 @@ int main(int argc, char *argv[])
const struct spa_pod *params[2];
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct pw_properties *props;
int res, n_params;
pw_init(&argc, &argv);
@ -460,19 +461,21 @@ int main(int argc, char *argv[])
* you need to listen to is the process event where you need to consume
* the data provided to you.
*/
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
data.path = argc > 1 ? argv[1] : NULL;
if (data.path)
pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.path);
data.stream = pw_stream_new_simple(
pw_main_loop_get_loop(data.loop),
"video-play",
pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera",
NULL),
props,
&stream_events,
&data);
data.path = argc > 1 ? argv[1] : NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
return -1;
@ -494,7 +497,7 @@ int main(int argc, char *argv[])
*/
if ((res = pw_stream_connect(data.stream,
PW_DIRECTION_INPUT,
data.path ? (uint32_t)atoi(data.path) : PW_ID_ANY,
PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
PW_STREAM_FLAG_INACTIVE | /* we will activate ourselves */
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */

View file

@ -442,7 +442,7 @@ int main(int argc, char *argv[])
* the server. */
pw_stream_connect(data.stream,
PW_DIRECTION_OUTPUT,
PW_ID_ANY, /* link to any node */
PW_ID_ANY,
PW_STREAM_FLAG_DRIVER |
PW_STREAM_FLAG_ALLOC_BUFFERS,
params, 1);

View file

@ -578,7 +578,7 @@ int main(int argc, char *argv[])
* the server. */
pw_stream_connect(data.stream,
PW_DIRECTION_OUTPUT,
PW_ID_ANY, /* link to any node */
PW_ID_ANY,
PW_STREAM_FLAG_DRIVER |
PW_STREAM_FLAG_ALLOC_BUFFERS,
params, 2);

View file

@ -487,7 +487,7 @@ int main(int argc, char *argv[])
* the server. */
pw_stream_connect(data.stream,
PW_DIRECTION_OUTPUT,
PW_ID_ANY, /* link to any node */
PW_ID_ANY,
PW_STREAM_FLAG_DRIVER |
PW_STREAM_FLAG_ALLOC_BUFFERS,
params, 1);