mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
command: make commands dynamic
Ensure format object type.
This commit is contained in:
parent
4d9f2c5161
commit
c44a7c9735
36 changed files with 549 additions and 604 deletions
|
|
@ -211,10 +211,10 @@ typedef struct {
|
|||
PinosClientNodeBuffer *buffers);
|
||||
void (*node_command) (void *object,
|
||||
uint32_t seq,
|
||||
const SpaNodeCommand *command);
|
||||
const SpaCommand *command);
|
||||
void (*port_command) (void *object,
|
||||
uint32_t port_id,
|
||||
const SpaNodeCommand *command);
|
||||
const SpaCommand *command);
|
||||
void (*transport) (void *object,
|
||||
int memfd,
|
||||
uint32_t offset,
|
||||
|
|
|
|||
|
|
@ -836,7 +836,7 @@ client_node_demarshal_node_command (void *object,
|
|||
{
|
||||
PinosProxy *proxy = object;
|
||||
SpaPODIter it;
|
||||
const SpaNodeCommand *command;
|
||||
const SpaCommand *command;
|
||||
uint32_t seq;
|
||||
|
||||
if (!spa_pod_iter_struct (&it, data, size) ||
|
||||
|
|
@ -857,7 +857,7 @@ client_node_demarshal_port_command (void *object,
|
|||
{
|
||||
PinosProxy *proxy = object;
|
||||
SpaPODIter it;
|
||||
const SpaNodeCommand *command;
|
||||
const SpaCommand *command;
|
||||
uint32_t port_id;
|
||||
|
||||
if (!spa_pod_iter_struct (&it, data, size) ||
|
||||
|
|
|
|||
|
|
@ -573,58 +573,45 @@ handle_node_event (PinosStream *stream,
|
|||
}
|
||||
|
||||
static bool
|
||||
handle_node_command (PinosStream *stream,
|
||||
uint32_t seq,
|
||||
const SpaNodeCommand *command)
|
||||
handle_node_command (PinosStream *stream,
|
||||
uint32_t seq,
|
||||
const SpaCommand *command)
|
||||
{
|
||||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
PinosContext *context = stream->context;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
break;
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
pinos_log_debug ("stream %p: pause %d", stream, seq);
|
||||
if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.Pause) {
|
||||
pinos_log_debug ("stream %p: pause %d", stream, seq);
|
||||
|
||||
add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
|
||||
add_async_complete (stream, seq, SPA_RESULT_OK, true);
|
||||
stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
pinos_log_debug ("stream %p: start %d", stream, seq);
|
||||
add_state_change (stream, SPA_NODE_STATE_STREAMING, false);
|
||||
add_async_complete (stream, seq, SPA_RESULT_OK, true);
|
||||
add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
|
||||
add_async_complete (stream, seq, SPA_RESULT_OK, true);
|
||||
stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.Start) {
|
||||
pinos_log_debug ("stream %p: start %d", stream, seq);
|
||||
add_state_change (stream, SPA_NODE_STATE_STREAMING, false);
|
||||
add_async_complete (stream, seq, SPA_RESULT_OK, true);
|
||||
|
||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||
send_need_input (stream);
|
||||
if (impl->direction == SPA_DIRECTION_INPUT)
|
||||
send_need_input (stream);
|
||||
|
||||
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
{
|
||||
pinos_log_warn ("unhandled node command %d", SPA_NODE_COMMAND_TYPE (command));
|
||||
add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED, true);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
SpaNodeCommandClockUpdate *cu = (SpaNodeCommandClockUpdate *) command;
|
||||
if (cu->body.flags.value & SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE) {
|
||||
pinos_properties_set (stream->properties,
|
||||
"pinos.latency.is-live", "1");
|
||||
pinos_properties_setf (stream->properties,
|
||||
"pinos.latency.min", "%"PRId64, cu->body.latency.value);
|
||||
}
|
||||
impl->last_ticks = cu->body.ticks.value;
|
||||
impl->last_rate = cu->body.rate.value;
|
||||
impl->last_monotonic = cu->body.monotonic_time.value;
|
||||
break;
|
||||
stream_set_state (stream, PINOS_STREAM_STATE_STREAMING, NULL);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == context->uri.node_commands.ClockUpdate) {
|
||||
SpaNodeCommandClockUpdate *cu = (SpaNodeCommandClockUpdate *) command;
|
||||
if (cu->body.flags.value & SPA_NODE_COMMAND_CLOCK_UPDATE_FLAG_LIVE) {
|
||||
pinos_properties_set (stream->properties,
|
||||
"pinos.latency.is-live", "1");
|
||||
pinos_properties_setf (stream->properties,
|
||||
"pinos.latency.min", "%"PRId64, cu->body.latency.value);
|
||||
}
|
||||
impl->last_ticks = cu->body.ticks.value;
|
||||
impl->last_rate = cu->body.rate.value;
|
||||
impl->last_monotonic = cu->body.monotonic_time.value;
|
||||
}
|
||||
else {
|
||||
pinos_log_warn ("unhandled node command %d", SPA_COMMAND_TYPE (command));
|
||||
add_async_complete (stream, seq, SPA_RESULT_NOT_IMPLEMENTED, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -853,9 +840,9 @@ client_node_use_buffers (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_node_command (void *object,
|
||||
uint32_t seq,
|
||||
const SpaNodeCommand *command)
|
||||
client_node_node_command (void *object,
|
||||
uint32_t seq,
|
||||
const SpaCommand *command)
|
||||
{
|
||||
PinosProxy *proxy = object;
|
||||
PinosStream *stream = proxy->user_data;
|
||||
|
|
@ -863,9 +850,9 @@ client_node_node_command (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_port_command (void *object,
|
||||
uint32_t port_id,
|
||||
const SpaNodeCommand *command)
|
||||
client_node_port_command (void *object,
|
||||
uint32_t port_id,
|
||||
const SpaCommand *command)
|
||||
{
|
||||
pinos_log_warn ("port command not supported");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,5 @@ pinos_uri_init (PinosURI *uri)
|
|||
uri->spa_monitor = spa_id_map_get_id (uri->map, SPA_MONITOR_URI);
|
||||
|
||||
spa_node_events_map (uri->map, &uri->node_events);
|
||||
spa_node_commands_map (uri->map, &uri->node_commands);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ struct _PinosURI {
|
|||
uint32_t spa_monitor;
|
||||
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
};
|
||||
|
||||
void pinos_uri_init (PinosURI *uri);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ typedef struct {
|
|||
uint32_t *media_subtype;
|
||||
} MediaType;
|
||||
|
||||
static uint32_t format_type;
|
||||
static SpaMediaTypes media_types = { 0, };
|
||||
static SpaMediaSubtypes media_subtypes = { 0, };
|
||||
static SpaMediaSubtypesVideo media_subtypes_video = { 0, };
|
||||
|
|
@ -49,14 +50,17 @@ static SpaAudioFormats audio_formats = { 0, };
|
|||
static void
|
||||
ensure_types (void)
|
||||
{
|
||||
spa_media_types_fill (&media_types, spa_id_map_get_default ());
|
||||
spa_media_subtypes_map (spa_id_map_get_default (), &media_subtypes);
|
||||
spa_media_subtypes_video_map (spa_id_map_get_default (), &media_subtypes_video);
|
||||
spa_media_subtypes_audio_map (spa_id_map_get_default (), &media_subtypes_audio);
|
||||
spa_prop_video_map (spa_id_map_get_default (), &prop_video);
|
||||
spa_prop_audio_map (spa_id_map_get_default (), &prop_audio);
|
||||
spa_video_formats_map (spa_id_map_get_default (), &video_formats);
|
||||
spa_audio_formats_map (spa_id_map_get_default (), &audio_formats);
|
||||
SpaIDMap *map = spa_id_map_get_default ();
|
||||
|
||||
format_type = spa_id_map_get_id (map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&media_types, map);
|
||||
spa_media_subtypes_map (map, &media_subtypes);
|
||||
spa_media_subtypes_video_map (map, &media_subtypes_video);
|
||||
spa_media_subtypes_audio_map (map, &media_subtypes_audio);
|
||||
spa_prop_video_map (map, &prop_video);
|
||||
spa_prop_audio_map (map, &prop_audio);
|
||||
spa_video_formats_map (map, &video_formats);
|
||||
spa_audio_formats_map (map, &audio_formats);
|
||||
}
|
||||
|
||||
static const MediaType media_type_map[] = {
|
||||
|
|
@ -516,7 +520,7 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
|
|||
|
||||
d.b.write = write_pod;
|
||||
|
||||
spa_pod_builder_push_format (&d.b, &f,
|
||||
spa_pod_builder_push_format (&d.b, &f, format_type,
|
||||
*d.type->media_type,
|
||||
*d.type->media_subtype);
|
||||
|
||||
|
|
|
|||
|
|
@ -185,11 +185,12 @@ send_have_output (SpaProxy *this)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_proxy_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_proxy_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaResult res = SPA_RESULT_OK;
|
||||
PinosCore *core;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -199,30 +200,22 @@ spa_proxy_node_send_command (SpaNode *node,
|
|||
if (this->resource == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
core = this->pnode->core;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
/* send start */
|
||||
pinos_client_node_notify_node_command (this->resource,
|
||||
this->seq,
|
||||
command);
|
||||
if (SPA_NODE_COMMAND_TYPE (command) == SPA_NODE_COMMAND_START)
|
||||
send_need_input (this);
|
||||
if (SPA_COMMAND_TYPE (command) == core->uri.node_commands.ClockUpdate) {
|
||||
pinos_client_node_notify_node_command (this->resource,
|
||||
this->seq++,
|
||||
command);
|
||||
}
|
||||
else {
|
||||
/* send start */
|
||||
pinos_client_node_notify_node_command (this->resource,
|
||||
this->seq,
|
||||
command);
|
||||
if (SPA_COMMAND_TYPE (command) == core->uri.node_commands.Start)
|
||||
send_need_input (this);
|
||||
|
||||
res = SPA_RESULT_RETURN_ASYNC (this->seq++);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
pinos_client_node_notify_node_command (this->resource,
|
||||
this->seq++,
|
||||
command);
|
||||
break;
|
||||
res = SPA_RESULT_RETURN_ASYNC (this->seq++);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -790,33 +783,17 @@ static SpaResult
|
|||
spa_proxy_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaProxy *this;
|
||||
SpaResult res = SPA_RESULT_OK;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, SpaProxy, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
break;
|
||||
|
||||
default:
|
||||
spa_log_warn (this->log, "unhandled command %d", SPA_NODE_COMMAND_TYPE (command));
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
spa_log_warn (this->log, "unhandled command %d", SPA_COMMAND_TYPE (command));
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "spa/include/spa/node-command.h"
|
||||
|
||||
#include "pinos/client/pinos.h"
|
||||
#include "pinos/client/interfaces.h"
|
||||
|
||||
|
|
@ -167,7 +169,7 @@ pause_node (PinosNode *this)
|
|||
|
||||
pinos_log_debug ("node %p: pause node", this);
|
||||
{
|
||||
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_PAUSE);
|
||||
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.node_commands.Pause);
|
||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||
pinos_log_debug ("got error %d", res);
|
||||
}
|
||||
|
|
@ -181,7 +183,7 @@ start_node (PinosNode *this)
|
|||
|
||||
pinos_log_debug ("node %p: start node", this);
|
||||
{
|
||||
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_START);
|
||||
SpaCommand cmd = SPA_COMMAND_INIT (this->core->uri.node_commands.Start);
|
||||
if ((res = spa_node_send_command (this->node, &cmd)) < 0)
|
||||
pinos_log_debug ("got error %d", res);
|
||||
}
|
||||
|
|
@ -224,6 +226,7 @@ send_clock_update (PinosNode *this)
|
|||
SpaResult res;
|
||||
SpaNodeCommandClockUpdate cu =
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE_INIT(
|
||||
this->core->uri.node_commands.ClockUpdate,
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE_TIME |
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE_SCALE |
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE_STATE |
|
||||
|
|
@ -245,7 +248,7 @@ send_clock_update (PinosNode *this)
|
|||
&cu.body.monotonic_time.value);
|
||||
}
|
||||
|
||||
if ((res = spa_node_send_command (this->node, (SpaNodeCommand *)&cu)) < 0)
|
||||
if ((res = spa_node_send_command (this->node, (SpaCommand *)&cu)) < 0)
|
||||
pinos_log_debug ("got error %d", res);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
|
||||
typedef struct _PinosNode PinosNode;
|
||||
|
||||
#include <spa/include/spa/clock.h>
|
||||
#include <spa/include/spa/node.h>
|
||||
|
||||
#include <pinos/client/mem.h>
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ no_mem:
|
|||
static SpaResult
|
||||
pinos_port_pause (PinosPort *port)
|
||||
{
|
||||
SpaNodeCommand cmd = SPA_NODE_COMMAND_INIT (SPA_NODE_COMMAND_PAUSE);
|
||||
SpaCommand cmd = SPA_COMMAND_INIT (port->node->core->uri.node_commands.Pause);
|
||||
return spa_node_port_send_command (port->node->node,
|
||||
port->direction,
|
||||
port->port_id,
|
||||
|
|
|
|||
|
|
@ -742,9 +742,9 @@ client_node_marshal_use_buffers (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_marshal_node_command (void *object,
|
||||
uint32_t seq,
|
||||
const SpaNodeCommand *command)
|
||||
client_node_marshal_node_command (void *object,
|
||||
uint32_t seq,
|
||||
const SpaCommand *command)
|
||||
{
|
||||
PinosResource *resource = object;
|
||||
PinosConnection *connection = resource->client->protocol_private;
|
||||
|
|
@ -761,9 +761,9 @@ client_node_marshal_node_command (void *object,
|
|||
}
|
||||
|
||||
static void
|
||||
client_node_marshal_port_command (void *object,
|
||||
uint32_t port_id,
|
||||
const SpaNodeCommand *command)
|
||||
client_node_marshal_port_command (void *object,
|
||||
uint32_t port_id,
|
||||
const SpaCommand *command)
|
||||
{
|
||||
PinosResource *resource = object;
|
||||
PinosConnection *connection = resource->client->protocol_private;
|
||||
|
|
|
|||
58
spa/include/spa/command.h
Normal file
58
spa/include/spa/command.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_COMMAND_H__
|
||||
#define __SPA_COMMAND_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaCommand SpaCommand;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/pod.h>
|
||||
|
||||
#define SPA_COMMAND_URI "http://spaplug.in/ns/command"
|
||||
#define SPA_COMMAND_PREFIX SPA_COMMAND_URI "#"
|
||||
|
||||
typedef struct {
|
||||
SpaPODObjectBody body;
|
||||
} SpaCommandBody;
|
||||
|
||||
struct _SpaCommand {
|
||||
SpaPOD pod;
|
||||
SpaCommandBody body;
|
||||
};
|
||||
|
||||
#define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type)
|
||||
|
||||
#define SPA_COMMAND_INIT(type) \
|
||||
{ { sizeof (SpaCommandBody), SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type } } } \
|
||||
|
||||
#define SPA_COMMAND_INIT_COMPLEX(size,type,...) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, __VA_ARGS__ } } \
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_COMMAND_H__ */
|
||||
|
|
@ -27,9 +27,10 @@ extern "C" {
|
|||
typedef struct _SpaEvent SpaEvent;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/pod-utils.h>
|
||||
#include <spa/pod.h>
|
||||
|
||||
#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)
|
||||
#define SPA_EVENT_URI "http://spaplug.in/ns/event"
|
||||
#define SPA_EVENT_PREFIX SPA_EVENT_URI "#"
|
||||
|
||||
typedef struct {
|
||||
SpaPODObjectBody body;
|
||||
|
|
@ -40,6 +41,8 @@ struct _SpaEvent {
|
|||
SpaEventBody body;
|
||||
};
|
||||
|
||||
#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)
|
||||
|
||||
#define SPA_EVENT_INIT(type) \
|
||||
{ { sizeof (SpaEventBody), SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type } } } \
|
||||
|
|
|
|||
|
|
@ -32,21 +32,22 @@ extern "C" {
|
|||
static inline uint32_t
|
||||
spa_pod_builder_push_format (SpaPODBuilder *builder,
|
||||
SpaPODFrame *frame,
|
||||
uint32_t format_type,
|
||||
uint32_t media_type,
|
||||
uint32_t media_subtype)
|
||||
{
|
||||
const SpaFormat p = { { sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT },
|
||||
{ { 0, 0 },
|
||||
{ { 0, format_type },
|
||||
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_type },
|
||||
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_subtype } } };
|
||||
return spa_pod_builder_push (builder, frame, &p.pod,
|
||||
spa_pod_builder_raw (builder, &p, sizeof(p)));
|
||||
}
|
||||
|
||||
#define spa_pod_builder_format(b,f,media_type,media_subtype,...) \
|
||||
spa_pod_builder_object(b, f, 0, 0, \
|
||||
SPA_POD_TYPE_URI,media_type, \
|
||||
SPA_POD_TYPE_URI,media_subtype, \
|
||||
#define spa_pod_builder_format(b,f,format_type,media_type,media_subtype,...) \
|
||||
spa_pod_builder_object(b, f, 0, format_type, \
|
||||
SPA_POD_TYPE_URI,media_type, \
|
||||
SPA_POD_TYPE_URI,media_subtype, \
|
||||
__VA_ARGS__)
|
||||
|
||||
SpaResult
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ extern "C" {
|
|||
#include <stdarg.h>
|
||||
|
||||
#include <spa/format.h>
|
||||
#include <spa/pod-utils.h>
|
||||
#include <spa/id-map.h>
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
typedef struct _SpaFormat SpaFormat;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/pod-utils.h>
|
||||
#include <spa/pod.h>
|
||||
|
||||
#define SPA_MEDIA_TYPE_URI "http://spaplug.in/ns/media-type"
|
||||
#define SPA_MEDIA_TYPE_PREFIX SPA_MEDIA_TYPE_URI "#"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ spa_headers = [
|
|||
'barrier.h',
|
||||
'buffer.h',
|
||||
'clock.h',
|
||||
'command.h',
|
||||
'defs.h',
|
||||
'dict.h',
|
||||
'event.h',
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _SpaNodeCommand SpaNodeCommand;
|
||||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/command.h>
|
||||
|
||||
#define SPA_NODE_COMMAND_URI "http://spaplug.in/ns/node-command"
|
||||
#define SPA_NODE_COMMAND_PREFIX SPA_NODE_COMMAND_URI "#"
|
||||
|
|
@ -39,34 +37,27 @@ typedef struct _SpaNodeCommand SpaNodeCommand;
|
|||
#define SPA_NODE_COMMAND__Marker SPA_NODE_COMMAND_PREFIX "Marker"
|
||||
#define SPA_NODE_COMMAND__ClockUpdate SPA_NODE_COMMAND_PREFIX "ClockUpdate"
|
||||
|
||||
typedef enum {
|
||||
SPA_NODE_COMMAND_INVALID = 0,
|
||||
SPA_NODE_COMMAND_PAUSE,
|
||||
SPA_NODE_COMMAND_START,
|
||||
SPA_NODE_COMMAND_FLUSH,
|
||||
SPA_NODE_COMMAND_DRAIN,
|
||||
SPA_NODE_COMMAND_MARKER,
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE
|
||||
} SpaNodeCommandType;
|
||||
|
||||
#define SPA_NODE_COMMAND_TYPE(cmd) ((cmd)->body.body.type)
|
||||
|
||||
typedef struct {
|
||||
SpaPODObjectBody body;
|
||||
} SpaNodeCommandBody;
|
||||
uint32_t Pause;
|
||||
uint32_t Start;
|
||||
uint32_t Flush;
|
||||
uint32_t Drain;
|
||||
uint32_t Marker;
|
||||
uint32_t ClockUpdate;
|
||||
} SpaNodeCommands;
|
||||
|
||||
struct _SpaNodeCommand {
|
||||
SpaPOD pod;
|
||||
SpaNodeCommandBody body;
|
||||
};
|
||||
|
||||
#define SPA_NODE_COMMAND_INIT(type) \
|
||||
{ { sizeof (SpaNodeCommandBody), SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type } } } \
|
||||
|
||||
#define SPA_NODE_COMMAND_INIT_COMPLEX(size,type,...) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, __VA_ARGS__ } } \
|
||||
static inline void
|
||||
spa_node_commands_map (SpaIDMap *map, SpaNodeCommands *types)
|
||||
{
|
||||
if (types->Pause == 0) {
|
||||
types->Pause = spa_id_map_get_id (map, SPA_NODE_COMMAND__Pause);
|
||||
types->Start = spa_id_map_get_id (map, SPA_NODE_COMMAND__Start);
|
||||
types->Flush = spa_id_map_get_id (map, SPA_NODE_COMMAND__Flush);
|
||||
types->Drain = spa_id_map_get_id (map, SPA_NODE_COMMAND__Drain);
|
||||
types->Marker = spa_id_map_get_id (map, SPA_NODE_COMMAND__Marker);
|
||||
types->ClockUpdate = spa_id_map_get_id (map, SPA_NODE_COMMAND__ClockUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SpaNodeCommandClockUpdate:
|
||||
|
|
@ -103,18 +94,17 @@ typedef struct {
|
|||
SpaNodeCommandClockUpdateBody body;
|
||||
} SpaNodeCommandClockUpdate;
|
||||
|
||||
#define SPA_NODE_COMMAND_CLOCK_UPDATE_INIT(change_mask,rate,ticks,monotonic_time,offset,scale,state,flags,latency) \
|
||||
SPA_NODE_COMMAND_INIT_COMPLEX (sizeof (SpaNodeCommandClockUpdateBody), \
|
||||
SPA_NODE_COMMAND_CLOCK_UPDATE, \
|
||||
SPA_POD_INT_INIT (change_mask), \
|
||||
SPA_POD_INT_INIT (rate), \
|
||||
SPA_POD_LONG_INIT (ticks), \
|
||||
SPA_POD_LONG_INIT (monotonic_time), \
|
||||
SPA_POD_LONG_INIT (offset), \
|
||||
SPA_POD_INT_INIT (scale), \
|
||||
SPA_POD_INT_INIT (state), \
|
||||
SPA_POD_INT_INIT (flags), \
|
||||
SPA_POD_LONG_INIT (latency))
|
||||
#define SPA_NODE_COMMAND_CLOCK_UPDATE_INIT(type,change_mask,rate,ticks,monotonic_time,offset,scale,state,flags,latency) \
|
||||
SPA_COMMAND_INIT_COMPLEX (sizeof (SpaNodeCommandClockUpdateBody), type, \
|
||||
SPA_POD_INT_INIT (change_mask), \
|
||||
SPA_POD_INT_INIT (rate), \
|
||||
SPA_POD_LONG_INIT (ticks), \
|
||||
SPA_POD_LONG_INIT (monotonic_time), \
|
||||
SPA_POD_LONG_INIT (offset), \
|
||||
SPA_POD_INT_INIT (scale), \
|
||||
SPA_POD_INT_INIT (state), \
|
||||
SPA_POD_INT_INIT (flags), \
|
||||
SPA_POD_LONG_INIT (latency))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ struct _SpaNode {
|
|||
/**
|
||||
* SpaNode::send_command:
|
||||
* @node: a #SpaNode
|
||||
* @command: a #SpaNodeCommand
|
||||
* @command: a #SpaCommand
|
||||
*
|
||||
* Send a command to @node.
|
||||
*
|
||||
|
|
@ -216,8 +216,8 @@ struct _SpaNode {
|
|||
* #SPA_RESULT_INVALID_COMMAND @command is an invalid command
|
||||
* #SPA_RESULT_ASYNC @command is executed asynchronously
|
||||
*/
|
||||
SpaResult (*send_command) (SpaNode *node,
|
||||
SpaNodeCommand *command);
|
||||
SpaResult (*send_command) (SpaNode *node,
|
||||
SpaCommand *command);
|
||||
/**
|
||||
* SpaNode::set_event_callback:
|
||||
* @node: a #SpaNode
|
||||
|
|
@ -542,7 +542,7 @@ struct _SpaNode {
|
|||
SpaResult (*port_send_command) (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command);
|
||||
SpaCommand *command);
|
||||
/**
|
||||
* SpaNode::process_input:
|
||||
* @node: a #SpaNode
|
||||
|
|
|
|||
|
|
@ -269,7 +269,8 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix)
|
|||
SpaPODObjectBody *b = body;
|
||||
SpaPOD *p;
|
||||
|
||||
printf ("%-*sObject: size %d, id %d, type %d\n", prefix, "", size, b->id, b->type);
|
||||
printf ("%-*sObject: size %d, id %d, type %s\n", prefix, "", size, b->id,
|
||||
spa_id_map_get_uri (spa_id_map_get_default(), b->type));
|
||||
SPA_POD_OBJECT_BODY_FOREACH (b, size, p)
|
||||
print_pod_value (p->size, p->type, SPA_POD_BODY (p), prefix + 2);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ id_map_get_id (SpaIDMap *map, const char *uri)
|
|||
if (strcmp (this->uris[i], uri) == 0)
|
||||
return i;
|
||||
}
|
||||
printf ("spa adding %d %s\n", i, uri);
|
||||
this->uris[i] = (char *)uri;
|
||||
this->n_uris++;
|
||||
}
|
||||
|
|
@ -57,8 +56,6 @@ id_map_get_uri (SpaIDMap *map, uint32_t id)
|
|||
{
|
||||
IDMap *this = SPA_CONTAINER_OF (map, IDMap, map);
|
||||
|
||||
printf ("spa get %d\n", id);
|
||||
|
||||
if (id < this->n_uris)
|
||||
return this->uris[id];
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ spa_format_filter (const SpaFormat *format,
|
|||
filter->body.media_subtype.value != format->body.media_subtype.value)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
spa_pod_builder_push_format (result, &f,
|
||||
spa_pod_builder_push_format (result, &f, filter->body.obj_body.type,
|
||||
filter->body.media_type.value,
|
||||
filter->body.media_subtype.value);
|
||||
res = spa_props_filter (result,
|
||||
|
|
|
|||
|
|
@ -155,20 +155,17 @@ do_command (SpaLoop *loop,
|
|||
{
|
||||
SpaALSASink *this = user_data;
|
||||
SpaResult res;
|
||||
SpaNodeCommand *cmd = data;
|
||||
SpaCommand *cmd = data;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (cmd)) {
|
||||
case SPA_NODE_COMMAND_START:
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
0,
|
||||
cmd);
|
||||
break;
|
||||
default:
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
if (SPA_COMMAND_TYPE (cmd) == this->uri.node_commands.Start ||
|
||||
SPA_COMMAND_TYPE (cmd) == this->uri.node_commands.Pause) {
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
0,
|
||||
cmd);
|
||||
}
|
||||
else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
if (async) {
|
||||
SpaNodeEventAsyncComplete ac = SPA_NODE_EVENT_ASYNC_COMPLETE_INIT (this->uri.node_events.AsyncComplete,
|
||||
|
|
@ -184,8 +181,8 @@ do_command (SpaLoop *loop,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_sink_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_alsa_sink_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
|
||||
|
|
@ -194,34 +191,24 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start ||
|
||||
SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_command,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_command,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
|
||||
}
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -325,18 +312,18 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
case 1:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -622,7 +609,7 @@ static SpaResult
|
|||
spa_alsa_sink_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaALSASink *this;
|
||||
SpaResult res;
|
||||
|
|
@ -635,25 +622,19 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
break;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
}
|
||||
else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -796,12 +777,15 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_media_subtypes_audio_map (this->map, &this->uri.media_subtypes_audio);
|
||||
spa_prop_audio_map (this->map, &this->uri.prop_audio);
|
||||
spa_audio_formats_map (this->map, &this->uri.audio_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = alsasink_node;
|
||||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ do_pause (SpaLoop *loop,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_alsa_source_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_alsa_source_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
|
||||
|
|
@ -215,47 +215,37 @@ spa_alsa_source_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_start,
|
||||
++this->seq,
|
||||
0,
|
||||
NULL,
|
||||
this);
|
||||
|
||||
}
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_pause,
|
||||
++this->seq,
|
||||
0,
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_start,
|
||||
++this->seq,
|
||||
0,
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
return spa_loop_invoke (this->data_loop,
|
||||
do_pause,
|
||||
++this->seq,
|
||||
0,
|
||||
NULL,
|
||||
this);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -360,18 +350,18 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
case 1:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
|
@ -679,7 +669,7 @@ static SpaResult
|
|||
spa_alsa_source_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
SpaResult res;
|
||||
|
|
@ -692,25 +682,17 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
break;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
break;
|
||||
} else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
default:
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -862,6 +844,7 @@ alsa_source_init (const SpaHandleFactory *factory,
|
|||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
|
|
@ -869,6 +852,7 @@ alsa_source_init (const SpaHandleFactory *factory,
|
|||
spa_prop_audio_map (this->map, &this->uri.prop_audio);
|
||||
spa_audio_formats_map (this->map, &this->uri.audio_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = alsasource_node;
|
||||
this->clock = alsasource_clock;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
#include <asoundlib.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/node.h>
|
||||
|
|
@ -62,12 +63,14 @@ struct _SpaALSABuffer {
|
|||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaMediaSubtypesAudio media_subtypes_audio;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaALSAState {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaAudioMixer {
|
||||
|
|
@ -107,8 +108,8 @@ update_state (SpaAudioMixer *this, SpaNodeState state)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiomixer_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_audiomixer_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaAudioMixer *this;
|
||||
|
||||
|
|
@ -117,24 +118,15 @@ spa_audiomixer_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +455,7 @@ static SpaResult
|
|||
spa_audiomixer_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -703,6 +695,7 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = audiomixer_node;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
#include <spa/node.h>
|
||||
|
|
@ -39,11 +40,13 @@
|
|||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
typedef struct _SpaAudioTestSrc SpaAudioTestSrc;
|
||||
|
|
@ -300,8 +303,8 @@ update_state (SpaAudioTestSrc *this, SpaNodeState state)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_audiotestsrc_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_audiotestsrc_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
|
||||
|
|
@ -310,58 +313,47 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
struct timespec now;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
struct timespec now;
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
clock_gettime (CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
this->start_time = SPA_TIMESPEC_TO_TIME (&now);
|
||||
else
|
||||
this->start_time = 0;
|
||||
this->sample_count = 0;
|
||||
this->elapsed_time = 0;
|
||||
|
||||
clock_gettime (CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
this->start_time = SPA_TIMESPEC_TO_TIME (&now);
|
||||
else
|
||||
this->start_time = 0;
|
||||
this->sample_count = 0;
|
||||
this->elapsed_time = 0;
|
||||
|
||||
this->started = true;
|
||||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
this->started = false;
|
||||
set_timer (this, false);
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
this->started = true;
|
||||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
this->started = false;
|
||||
set_timer (this, false);
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -471,13 +463,13 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -589,7 +581,7 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
|
|||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
|
||||
|
|
@ -790,7 +782,7 @@ static SpaResult
|
|||
spa_audiotestsrc_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -957,11 +949,13 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_prop_audio_map (this->map, &this->uri.prop_audio);
|
||||
spa_audio_formats_map (this->map, &this->uri.audio_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = audiotestsrc_node;
|
||||
this->clock = audiotestsrc_clock;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaFFMpegDec {
|
||||
|
|
@ -94,8 +95,8 @@ update_state (SpaFFMpegDec *this, SpaNodeState state)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaFFMpegDec *this;
|
||||
|
||||
|
|
@ -104,24 +105,15 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +445,7 @@ static SpaResult
|
|||
spa_ffmpeg_dec_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -533,6 +525,7 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
|
||||
this->node = ffmpeg_dec_node;
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ typedef struct {
|
|||
uint32_t node;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaFFMpegEnc {
|
||||
|
|
@ -101,8 +102,8 @@ spa_ffmpeg_enc_node_set_props (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaFFMpegEnc *this;
|
||||
|
||||
|
|
@ -111,24 +112,15 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -435,7 +427,7 @@ static SpaResult
|
|||
spa_ffmpeg_enc_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -546,6 +538,7 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
|
|
@ -65,12 +66,14 @@ struct _V4l2Buffer {
|
|||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaMediaSubtypesVideo media_subtypes_video;
|
||||
SpaPropVideo prop_video;
|
||||
SpaVideoFormats video_formats;
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -248,7 +251,7 @@ do_pause (SpaLoop *loop,
|
|||
{
|
||||
SpaV4l2Source *this = user_data;
|
||||
SpaResult res;
|
||||
SpaNodeCommand *cmd = data;
|
||||
SpaCommand *cmd = data;
|
||||
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -299,7 +302,7 @@ do_start (SpaLoop *loop,
|
|||
{
|
||||
SpaV4l2Source *this = user_data;
|
||||
SpaResult res;
|
||||
SpaNodeCommand *cmd = data;
|
||||
SpaCommand *cmd = data;
|
||||
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
|
|
@ -321,8 +324,8 @@ do_start (SpaLoop *loop,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_v4l2_source_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_v4l2_source_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
|
||||
|
|
@ -331,66 +334,53 @@ spa_v4l2_source_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
SpaResult res;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
SpaResult res;
|
||||
if (!state->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (!state->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (state->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (state->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if ((res = spa_v4l2_stream_on (this)) < 0)
|
||||
return res;
|
||||
|
||||
return spa_loop_invoke (this->state[0].data_loop,
|
||||
do_start,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
|
||||
if (!state->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (state->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
return spa_loop_invoke (this->state[0].data_loop,
|
||||
do_pause,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
{
|
||||
if (state->started)
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if ((res = spa_v4l2_stream_on (this)) < 0)
|
||||
return res;
|
||||
|
||||
return spa_loop_invoke (this->state[0].data_loop,
|
||||
do_start,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
|
||||
if (!state->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (state->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!state->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
return spa_loop_invoke (this->state[0].data_loop,
|
||||
do_pause,
|
||||
++this->seq,
|
||||
SPA_POD_SIZE (command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.ClockUpdate) {
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -577,7 +567,7 @@ spa_v4l2_source_node_port_get_format (SpaNode *node,
|
|||
b.data = state->format_buffer;
|
||||
b.size = sizeof (state->format_buffer);
|
||||
|
||||
spa_pod_builder_push_format (&b, &f[0],
|
||||
spa_pod_builder_push_format (&b, &f[0], this->uri.format,
|
||||
state->current_format.media_type,
|
||||
state->current_format.media_subtype);
|
||||
|
||||
|
|
@ -784,7 +774,7 @@ static SpaResult
|
|||
spa_v4l2_source_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
SpaResult res;
|
||||
|
|
@ -797,19 +787,14 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
res = spa_v4l2_port_set_enabled (this, false);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
res = spa_v4l2_port_set_enabled (this, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
break;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
res = spa_v4l2_port_set_enabled (this, false);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
res = spa_v4l2_port_set_enabled (this, true);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -972,12 +957,14 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_media_subtypes_video_map (this->map, &this->uri.media_subtypes_video);
|
||||
spa_prop_video_map (this->map, &this->uri.prop_video);
|
||||
spa_video_formats_map (this->map, &this->uri.video_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = v4l2source_node;
|
||||
this->clock = v4l2source_clock;
|
||||
|
|
|
|||
|
|
@ -662,7 +662,7 @@ have_size:
|
|||
media_subtype = *SPA_MEMBER (&this->uri, info->media_subtype_offset, uint32_t);
|
||||
video_format = *SPA_MEMBER (&this->uri, info->format_offset, uint32_t);
|
||||
|
||||
spa_pod_builder_push_format (&b, &f[0],
|
||||
spa_pod_builder_push_format (&b, &f[0], this->uri.format,
|
||||
media_type,
|
||||
media_subtype);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
#include <spa/node.h>
|
||||
|
|
@ -39,11 +40,13 @@
|
|||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t clock;
|
||||
uint32_t format;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropVideo prop_video;
|
||||
SpaVideoFormats video_formats;
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
|
||||
|
|
@ -283,8 +286,8 @@ update_state (SpaVideoTestSrc *this, SpaNodeState state)
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_videotestsrc_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_videotestsrc_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
|
||||
|
|
@ -293,58 +296,47 @@ spa_videotestsrc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
struct timespec now;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
{
|
||||
struct timespec now;
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if (this->started)
|
||||
return SPA_RESULT_OK;
|
||||
clock_gettime (CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
this->start_time = SPA_TIMESPEC_TO_TIME (&now);
|
||||
else
|
||||
this->start_time = 0;
|
||||
this->frame_count = 0;
|
||||
this->elapsed_time = 0;
|
||||
|
||||
clock_gettime (CLOCK_MONOTONIC, &now);
|
||||
if (this->props.live)
|
||||
this->start_time = SPA_TIMESPEC_TO_TIME (&now);
|
||||
else
|
||||
this->start_time = 0;
|
||||
this->frame_count = 0;
|
||||
this->elapsed_time = 0;
|
||||
|
||||
this->started = true;
|
||||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
{
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
this->started = false;
|
||||
set_timer (this, false);
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
}
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
this->started = true;
|
||||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (this->n_buffers == 0)
|
||||
return SPA_RESULT_NO_BUFFERS;
|
||||
|
||||
if (!this->started)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
this->started = false;
|
||||
set_timer (this, false);
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +446,7 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.video, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, 3,
|
||||
this->uri.video_formats.RGB,
|
||||
|
|
@ -592,7 +584,7 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
|
|||
|
||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.video, this->uri.media_subtypes.raw,
|
||||
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
|
||||
|
|
@ -792,7 +784,7 @@ static SpaResult
|
|||
spa_videotestsrc_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -959,11 +951,13 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.clock = spa_id_map_get_id (this->map, SPA_CLOCK_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_prop_video_map (this->map, &this->uri.prop_video);
|
||||
spa_video_formats_map (this->map, &this->uri.video_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = videotestsrc_node;
|
||||
this->clock = videotestsrc_clock;
|
||||
|
|
|
|||
|
|
@ -63,11 +63,13 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
uint32_t format;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaNodeEvents node_events;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaVolume {
|
||||
|
|
@ -178,8 +180,8 @@ spa_volume_node_set_props (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_volume_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_volume_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaVolume *this;
|
||||
|
||||
|
|
@ -188,24 +190,15 @@ spa_volume_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +305,7 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0],
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3,
|
||||
this->uri.audio_formats.S16,
|
||||
|
|
@ -629,7 +622,7 @@ static SpaResult
|
|||
spa_volume_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -844,10 +837,13 @@ volume_init (const SpaHandleFactory *factory,
|
|||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
this->uri.format = spa_id_map_get_id (this->map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_prop_audio_map (this->map, &this->uri.prop_audio);
|
||||
spa_audio_formats_map (this->map, &this->uri.audio_formats);
|
||||
spa_node_events_map (this->map, &this->uri.node_events);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = volume_node;
|
||||
reset_volume_props (&this->props);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ typedef struct {
|
|||
uint32_t node;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaNodeCommands node_commands;
|
||||
} URI;
|
||||
|
||||
struct _SpaXvSink {
|
||||
|
|
@ -166,8 +167,8 @@ spa_xv_sink_node_set_props (SpaNode *node,
|
|||
}
|
||||
|
||||
static SpaResult
|
||||
spa_xv_sink_node_send_command (SpaNode *node,
|
||||
SpaNodeCommand *command)
|
||||
spa_xv_sink_node_send_command (SpaNode *node,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaXvSink *this;
|
||||
|
||||
|
|
@ -176,27 +177,19 @@ spa_xv_sink_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
||||
switch (SPA_NODE_COMMAND_TYPE (command)) {
|
||||
case SPA_NODE_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Start) {
|
||||
spa_xv_start (this);
|
||||
|
||||
case SPA_NODE_COMMAND_START:
|
||||
spa_xv_start (this);
|
||||
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
break;
|
||||
case SPA_NODE_COMMAND_PAUSE:
|
||||
spa_xv_stop (this);
|
||||
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
break;
|
||||
|
||||
case SPA_NODE_COMMAND_FLUSH:
|
||||
case SPA_NODE_COMMAND_DRAIN:
|
||||
case SPA_NODE_COMMAND_MARKER:
|
||||
case SPA_NODE_COMMAND_CLOCK_UPDATE:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.node_commands.Pause) {
|
||||
spa_xv_stop (this);
|
||||
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -471,7 +464,7 @@ static SpaResult
|
|||
spa_xv_sink_node_port_send_command (SpaNode *node,
|
||||
SpaDirection direction,
|
||||
uint32_t port_id,
|
||||
SpaNodeCommand *command)
|
||||
SpaCommand *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -573,6 +566,7 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_node_commands_map (this->map, &this->uri.node_commands);
|
||||
|
||||
this->node = xvsink_node;
|
||||
reset_xv_sink_props (&this->props);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ spa_build (SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
|||
0);
|
||||
#endif
|
||||
|
||||
static uint32_t format_type;
|
||||
static SpaMediaTypes media_types;
|
||||
static SpaMediaSubtypes media_subtypes;
|
||||
static SpaPropVideo prop_video;
|
||||
|
|
@ -95,7 +96,7 @@ do_static_struct (void)
|
|||
} props;
|
||||
} test_format = {
|
||||
{ { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT },
|
||||
{ { 0, 0 },
|
||||
{ { 0, format_type },
|
||||
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_types.video },
|
||||
{ { sizeof (uint32_t), SPA_POD_TYPE_URI }, media_subtypes.raw } },
|
||||
}, {
|
||||
|
|
@ -148,15 +149,17 @@ main (int argc, char *argv[])
|
|||
SpaPODFrame frame[4];
|
||||
uint8_t buffer[1024];
|
||||
SpaFormat *fmt;
|
||||
SpaIDMap *map = spa_id_map_get_default();
|
||||
|
||||
spa_media_types_fill (&media_types, spa_id_map_get_default());
|
||||
spa_media_subtypes_map (spa_id_map_get_default(), &media_subtypes);
|
||||
spa_prop_video_map (spa_id_map_get_default(), &prop_video);
|
||||
spa_video_formats_map (spa_id_map_get_default(), &video_formats);
|
||||
format_type = spa_id_map_get_id (map, SPA_FORMAT_URI);
|
||||
spa_media_types_fill (&media_types, map);
|
||||
spa_media_subtypes_map (map, &media_subtypes);
|
||||
spa_prop_video_map (map, &prop_video);
|
||||
spa_video_formats_map (map, &video_formats);
|
||||
|
||||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||
|
||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_push_format (&b, &frame[0],
|
||||
fmt = SPA_MEMBER (buffer, spa_pod_builder_push_format (&b, &frame[0], format_type,
|
||||
media_types.video,
|
||||
media_subtypes.raw), SpaFormat);
|
||||
spa_pod_builder_push_prop (&b, &frame[1],
|
||||
|
|
@ -189,7 +192,7 @@ main (int argc, char *argv[])
|
|||
|
||||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||
|
||||
spa_pod_builder_format (&b, &frame[0],
|
||||
spa_pod_builder_format (&b, &frame[0], format_type,
|
||||
media_types.video, media_subtypes.raw,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
prop_video.format, SPA_POD_PROP_FLAG_UNSET |
|
||||
|
|
@ -214,7 +217,7 @@ main (int argc, char *argv[])
|
|||
25, 1,
|
||||
0, 1,
|
||||
INT32_MAX, 1,
|
||||
-SPA_POD_TYPE_PROP, &frame[1], 0);
|
||||
-SPA_POD_TYPE_PROP, &frame[1]);
|
||||
|
||||
fmt = SPA_MEMBER (buffer, frame[0].ref, SpaFormat);
|
||||
spa_debug_pod (&fmt->pod);
|
||||
|
|
@ -223,7 +226,7 @@ main (int argc, char *argv[])
|
|||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
SPA_POD_TYPE_OBJECT, &frame[0], 0, 0,
|
||||
SPA_POD_TYPE_OBJECT, &frame[0], 0, format_type,
|
||||
SPA_POD_TYPE_URI, media_types.video,
|
||||
SPA_POD_TYPE_URI, media_subtypes.raw,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/loop.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue