mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
examples: use PW_KEY_TARGET_OBJECT
In examples, tell people how to use target.object.
This commit is contained in:
parent
de65fd442f
commit
ca87d40448
16 changed files with 94 additions and 65 deletions
|
|
@ -96,7 +96,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_OUTPUT,
|
PW_DIRECTION_OUTPUT,
|
||||||
argc > 1 ? (uint32_t)atoi(argv[1]) : PW_ID_ANY,
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_AUTOCONNECT |
|
PW_STREAM_FLAG_AUTOCONNECT |
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS |
|
PW_STREAM_FLAG_MAP_BUFFERS |
|
||||||
PW_STREAM_FLAG_RT_PROCESS,
|
PW_STREAM_FLAG_RT_PROCESS,
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ Now we're ready to connect the stream and run the main loop:
|
||||||
pw_main_loop_run(data.loop);
|
pw_main_loop_run(data.loop);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
To connect we specify that we have a `PW_DIRECTION_OUTPUT` stream. `PW_ID_ANY`
|
To connect we specify that we have a `PW_DIRECTION_OUTPUT` stream. The third argument
|
||||||
means that we are ok with connecting to any consumer. Next we set some flags:
|
is always `PW_ID_ANY`. Next we set some flags:
|
||||||
|
|
||||||
- `PW_STREAM_FLAG_AUTOCONNECT`: Automatically connect this stream. This instructs
|
- `PW_STREAM_FLAG_AUTOCONNECT`: Automatically connect this stream. This instructs
|
||||||
the session manager to link us to some consumer.
|
the session manager to link us to some consumer.
|
||||||
|
|
|
||||||
|
|
@ -83,19 +83,23 @@ int main(int argc, char *argv[])
|
||||||
const struct spa_pod *params[1];
|
const struct spa_pod *params[1];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
struct pw_properties *props;
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
pw_init(&argc, &argv);
|
||||||
|
|
||||||
data.loop = pw_main_loop_new(NULL);
|
data.loop = pw_main_loop_new(NULL);
|
||||||
|
|
||||||
|
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
|
||||||
|
PW_KEY_MEDIA_CATEGORY, "Capture",
|
||||||
|
PW_KEY_MEDIA_ROLE, "Camera",
|
||||||
|
NULL);
|
||||||
|
if (argc > 1)
|
||||||
|
pw_properties_set(props, PW_KEY_TARGET_OBJECT, argv[1]);
|
||||||
|
|
||||||
data.stream = pw_stream_new_simple(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-capture",
|
"video-capture",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
|
|
@ -122,7 +126,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
PW_DIRECTION_INPUT,
|
||||||
argc > 1 ? (uint32_t)atoi(argv[1]) : PW_ID_ANY,
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_AUTOCONNECT |
|
PW_STREAM_FLAG_AUTOCONNECT |
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS,
|
PW_STREAM_FLAG_MAP_BUFFERS,
|
||||||
params, 1);
|
params, 1);
|
||||||
|
|
|
||||||
|
|
@ -23,18 +23,25 @@ We create a stream object with different properties to make it a Camera
|
||||||
Video Capture stream.
|
Video Capture stream.
|
||||||
|
|
||||||
\code{.c}
|
\code{.c}
|
||||||
|
props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video",
|
||||||
|
PW_KEY_MEDIA_CATEGORY, "Capture",
|
||||||
|
PW_KEY_MEDIA_ROLE, "Camera",
|
||||||
|
NULL);
|
||||||
|
if (argc > 1)
|
||||||
|
pw_properties_set(props, PW_KEY_TARGET_OBJECT, argv[1]);
|
||||||
|
|
||||||
data.stream = pw_stream_new_simple(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-capture",
|
"video-capture",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
|
We also optionally allow the user to pass the name of the target node where the session
|
||||||
|
manager is supposed to connect the node. The user may also give the value of the
|
||||||
|
unique target node serial (`PW_KEY_OBJECT_SERIAL`) as the value.
|
||||||
|
|
||||||
In addition to the `process` event, we are also going to listen to a new event,
|
In addition to the `process` event, we are also going to listen to a new event,
|
||||||
`param_changed`:
|
`param_changed`:
|
||||||
|
|
||||||
|
|
@ -122,7 +129,7 @@ Now we're ready to connect the stream and run the main loop:
|
||||||
\code{.c}
|
\code{.c}
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
PW_DIRECTION_INPUT,
|
||||||
argc > 1 ? (uint32_t)atoi(argv[1]) : PW_ID_ANY,
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_AUTOCONNECT |
|
PW_STREAM_FLAG_AUTOCONNECT |
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS,
|
PW_STREAM_FLAG_MAP_BUFFERS,
|
||||||
params, 1);
|
params, 1);
|
||||||
|
|
@ -130,9 +137,8 @@ Now we're ready to connect the stream and run the main loop:
|
||||||
pw_main_loop_run(data.loop);
|
pw_main_loop_run(data.loop);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
To connect we specify that we have a `PW_DIRECTION_INPUT` stream. `PW_ID_ANY`
|
To connect we specify that we have a `PW_DIRECTION_INPUT` stream. The third
|
||||||
means that we are ok with connecting to any producer. We also allow the user
|
argument is always `PW_ID_ANY`.
|
||||||
to pass an optional target id.
|
|
||||||
|
|
||||||
We're setting the `PW_STREAM_FLAG_AUTOCONNECT` flag to make an automatic
|
We're setting the `PW_STREAM_FLAG_AUTOCONNECT` flag to make an automatic
|
||||||
connection to a suitable camera and `PW_STREAM_FLAG_MAP_BUFFERS` to let the
|
connection to a suitable camera and `PW_STREAM_FLAG_MAP_BUFFERS` to let the
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ int main(int argc, char *argv[])
|
||||||
struct data data = { 0, };
|
struct data data = { 0, };
|
||||||
const struct spa_pod *params[1];
|
const struct spa_pod *params[1];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
|
struct pw_properties *props;
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
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
|
* you need to listen to is the process event where you need to produce
|
||||||
* the data.
|
* 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(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"audio-src",
|
"audio-src",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Audio",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Playback",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Music",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
|
|
@ -165,7 +169,7 @@ int main(int argc, char *argv[])
|
||||||
* called in a realtime thread. */
|
* called in a realtime thread. */
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_OUTPUT,
|
PW_DIRECTION_OUTPUT,
|
||||||
argc > 1 ? (uint32_t)atoi(argv[1]) : PW_ID_ANY,
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_AUTOCONNECT |
|
PW_STREAM_FLAG_AUTOCONNECT |
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS |
|
PW_STREAM_FLAG_MAP_BUFFERS |
|
||||||
PW_STREAM_FLAG_RT_PROCESS,
|
PW_STREAM_FLAG_RT_PROCESS,
|
||||||
|
|
|
||||||
|
|
@ -472,7 +472,7 @@ static void make_node(struct data *data)
|
||||||
|
|
||||||
props = pw_properties_new(PW_KEY_NODE_AUTOCONNECT, "true", NULL);
|
props = pw_properties_new(PW_KEY_NODE_AUTOCONNECT, "true", NULL);
|
||||||
if (data->path)
|
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_CLASS, "Stream/Input/Video");
|
||||||
pw_properties_set(props, PW_KEY_MEDIA_TYPE, "Video");
|
pw_properties_set(props, PW_KEY_MEDIA_TYPE, "Video");
|
||||||
pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, "Capture");
|
pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, "Capture");
|
||||||
|
|
|
||||||
|
|
@ -483,7 +483,7 @@ static void make_node(struct data *data)
|
||||||
PW_KEY_MEDIA_ROLE, "Music",
|
PW_KEY_MEDIA_ROLE, "Music",
|
||||||
NULL);
|
NULL);
|
||||||
if (data->path)
|
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(
|
data->impl_node.iface = SPA_INTERFACE_INIT(
|
||||||
SPA_TYPE_INTERFACE_Node,
|
SPA_TYPE_INTERFACE_Node,
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ static int make_node(struct data *data)
|
||||||
|
|
||||||
if (data->path) {
|
if (data->path) {
|
||||||
pw_properties_set(props, PW_KEY_NODE_AUTOCONNECT, "true");
|
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,
|
data->proxy = pw_core_export(data->core,
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ int main(int argc, char *argv[])
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
PW_KEY_MEDIA_CATEGORY, "Capture",
|
||||||
PW_KEY_MEDIA_ROLE, "DSP",
|
PW_KEY_MEDIA_ROLE, "DSP",
|
||||||
PW_KEY_NODE_AUTOCONNECT, data.target ? "true" : "false",
|
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",
|
PW_KEY_MEDIA_CLASS, "Stream/Input/Video",
|
||||||
NULL),
|
NULL),
|
||||||
&filter_events,
|
&filter_events,
|
||||||
|
|
|
||||||
|
|
@ -419,6 +419,7 @@ int main(int argc, char *argv[])
|
||||||
const struct spa_pod *params[2];
|
const struct spa_pod *params[2];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
struct pw_properties *props;
|
||||||
int res, n_params;
|
int res, n_params;
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
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
|
* you need to listen to is the process event where you need to consume
|
||||||
* the data provided to you.
|
* 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(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-play-reneg",
|
"video-play-fixate",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
data.path = argc > 1 ? argv[1] : NULL;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -477,7 +481,7 @@ int main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
if ((res = pw_stream_connect(data.stream,
|
if ((res = pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
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_AUTOCONNECT | /* try to automatically connect this stream */
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
||||||
params, n_params)) /* extra parameters, see above */ < 0) {
|
params, n_params)) /* extra parameters, see above */ < 0) {
|
||||||
|
|
|
||||||
|
|
@ -493,6 +493,7 @@ int main(int argc, char *argv[])
|
||||||
const struct spa_pod *params[2];
|
const struct spa_pod *params[2];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
struct pw_properties *props;
|
||||||
int res, n_params;
|
int res, n_params;
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
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
|
* you need to listen to is the process event where you need to consume
|
||||||
* the data provided to you.
|
* 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(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-play",
|
"video-play",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
PW_KEY_PRIORITY_DRIVER, "10000",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
data.path = argc > 1 ? argv[1] : NULL;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -552,7 +556,7 @@ int main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
if ((res = pw_stream_connect(data.stream,
|
if ((res = pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
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_DRIVER | /* we're driver, we pull */
|
||||||
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
|
PW_STREAM_FLAG_AUTOCONNECT | /* try to automatically connect this stream */
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,7 @@ int main(int argc, char *argv[])
|
||||||
const struct spa_pod *params[2];
|
const struct spa_pod *params[2];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
struct pw_properties *props;
|
||||||
int res, n_params;
|
int res, n_params;
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
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
|
* you need to listen to is the process event where you need to consume
|
||||||
* the data provided to you.
|
* 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(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-play-reneg",
|
"video-play-reneg",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
data.path = argc > 1 ? argv[1] : NULL;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -401,7 +405,7 @@ int main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
if ((res = pw_stream_connect(data.stream,
|
if ((res = pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
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_AUTOCONNECT | /* try to automatically connect this stream */
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
||||||
params, n_params)) /* extra parameters, see above */ < 0) {
|
params, n_params)) /* extra parameters, see above */ < 0) {
|
||||||
|
|
|
||||||
|
|
@ -439,6 +439,7 @@ int main(int argc, char *argv[])
|
||||||
const struct spa_pod *params[2];
|
const struct spa_pod *params[2];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||||
|
struct pw_properties *props;
|
||||||
int res, n_params;
|
int res, n_params;
|
||||||
|
|
||||||
pw_init(&argc, &argv);
|
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
|
* you need to listen to is the process event where you need to consume
|
||||||
* the data provided to you.
|
* 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(
|
data.stream = pw_stream_new_simple(
|
||||||
pw_main_loop_get_loop(data.loop),
|
pw_main_loop_get_loop(data.loop),
|
||||||
"video-play",
|
"video-play",
|
||||||
pw_properties_new(
|
props,
|
||||||
PW_KEY_MEDIA_TYPE, "Video",
|
|
||||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
|
||||||
PW_KEY_MEDIA_ROLE, "Camera",
|
|
||||||
NULL),
|
|
||||||
&stream_events,
|
&stream_events,
|
||||||
&data);
|
&data);
|
||||||
|
|
||||||
data.path = argc > 1 ? argv[1] : NULL;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
fprintf(stderr, "can't initialize SDL: %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -494,7 +497,7 @@ int main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
if ((res = pw_stream_connect(data.stream,
|
if ((res = pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_INPUT,
|
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_AUTOCONNECT | /* try to automatically connect this stream */
|
||||||
PW_STREAM_FLAG_INACTIVE | /* we will activate ourselves */
|
PW_STREAM_FLAG_INACTIVE | /* we will activate ourselves */
|
||||||
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
PW_STREAM_FLAG_MAP_BUFFERS, /* mmap the buffer data for us */
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ int main(int argc, char *argv[])
|
||||||
* the server. */
|
* the server. */
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_OUTPUT,
|
PW_DIRECTION_OUTPUT,
|
||||||
PW_ID_ANY, /* link to any node */
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_DRIVER |
|
PW_STREAM_FLAG_DRIVER |
|
||||||
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
||||||
params, 1);
|
params, 1);
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ int main(int argc, char *argv[])
|
||||||
* the server. */
|
* the server. */
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_OUTPUT,
|
PW_DIRECTION_OUTPUT,
|
||||||
PW_ID_ANY, /* link to any node */
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_DRIVER |
|
PW_STREAM_FLAG_DRIVER |
|
||||||
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
||||||
params, 2);
|
params, 2);
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ int main(int argc, char *argv[])
|
||||||
* the server. */
|
* the server. */
|
||||||
pw_stream_connect(data.stream,
|
pw_stream_connect(data.stream,
|
||||||
PW_DIRECTION_OUTPUT,
|
PW_DIRECTION_OUTPUT,
|
||||||
PW_ID_ANY, /* link to any node */
|
PW_ID_ANY,
|
||||||
PW_STREAM_FLAG_DRIVER |
|
PW_STREAM_FLAG_DRIVER |
|
||||||
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
PW_STREAM_FLAG_ALLOC_BUFFERS,
|
||||||
params, 1);
|
params, 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue