Add mapper

Ger rid of static ids for interfaces and replace with something we can
register dynamically
Implement logger.
This commit is contained in:
Wim Taymans 2016-10-07 13:14:32 +02:00
parent a68e5d5124
commit fc4fd1424a
43 changed files with 997 additions and 360 deletions

View file

@ -22,6 +22,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <spa/id-map.h>
#include <spa/log.h>
#include <spa/node.h>
#include <spa/video/format.h>
@ -58,10 +60,18 @@ typedef struct {
SpaPortStatus status;
} SpaFFMpegPort;
typedef struct {
uint32_t node;
} URI;
struct _SpaFFMpegDec {
SpaHandle handle;
SpaNode node;
URI uri;
SpaIDMap *map;
SpaLog *log;
SpaFFMpegDecProps props[2];
SpaNodeEventCallback event_cb;
@ -537,24 +547,39 @@ spa_ffmpeg_dec_get_interface (SpaHandle *handle,
this = (SpaFFMpegDec *) handle;
switch (interface_id) {
case SPA_INTERFACE_ID_NODE:
*interface = &this->node;
break;
default:
return SPA_RESULT_UNKNOWN_INTERFACE;
}
if (interface_id == this->uri.node)
*interface = &this->node;
else
return SPA_RESULT_UNKNOWN_INTERFACE;
return SPA_RESULT_OK;
}
SpaResult
spa_ffmpeg_dec_init (SpaHandle *handle)
spa_ffmpeg_dec_init (SpaHandle *handle,
const SpaDict *info,
const SpaSupport *support,
unsigned int n_support)
{
SpaFFMpegDec *this;
unsigned int i;
handle->get_interface = spa_ffmpeg_dec_get_interface;
this = (SpaFFMpegDec *) handle;
for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_ID_MAP_URI) == 0)
this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_LOG_URI) == 0)
this->log = support[i].data;
}
if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR;
}
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = ffmpeg_dec_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST;

View file

@ -22,6 +22,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <spa/log.h>
#include <spa/id-map.h>
#include <spa/node.h>
#include <spa/video/format.h>
@ -63,10 +65,19 @@ typedef struct {
SpaPortStatus status;
} SpaFFMpegPort;
typedef struct {
uint32_t node;
} URI;
struct _SpaFFMpegEnc {
SpaHandle handle;
SpaNode node;
URI uri;
SpaIDMap *map;
SpaLog *log;
SpaFFMpegEncProps props[2];
SpaNodeEventCallback event_cb;
@ -545,24 +556,39 @@ spa_ffmpeg_enc_get_interface (SpaHandle *handle,
this = (SpaFFMpegEnc *) handle;
switch (interface_id) {
case SPA_INTERFACE_ID_NODE:
*interface = &this->node;
break;
default:
return SPA_RESULT_UNKNOWN_INTERFACE;
}
if (interface_id == this->uri.node)
*interface = &this->node;
else
return SPA_RESULT_UNKNOWN_INTERFACE;
return SPA_RESULT_OK;
}
SpaResult
spa_ffmpeg_enc_init (SpaHandle *handle)
spa_ffmpeg_enc_init (SpaHandle *handle,
const SpaDict *info,
const SpaSupport *support,
unsigned int n_support)
{
SpaFFMpegEnc *this;
unsigned int i;
handle->get_interface = spa_ffmpeg_enc_get_interface;
this = (SpaFFMpegEnc *) handle;
for (i = 0; i < n_support; i++) {
if (strcmp (support[i].uri, SPA_ID_MAP_URI) == 0)
this->map = support[i].data;
else if (strcmp (support[i].uri, SPA_LOG_URI) == 0)
this->log = support[i].data;
}
if (this->map == NULL) {
spa_log_error (this->log, "an id-map is needed");
return SPA_RESULT_ERROR;
}
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
this->node = ffmpeg_enc_node;
this->node.handle = handle;
this->props[1].props.n_prop_info = PROP_ID_LAST;

View file

@ -25,40 +25,38 @@
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
SpaResult spa_ffmpeg_dec_init (SpaHandle *handle);
SpaResult spa_ffmpeg_enc_init (SpaHandle *handle);
SpaResult spa_ffmpeg_dec_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, unsigned int n_support);
SpaResult spa_ffmpeg_enc_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, unsigned int n_support);
static SpaResult
ffmpeg_dec_init (const SpaHandleFactory *factory,
SpaHandle *handle,
const SpaDict *info,
const SpaSupport **support,
const SpaSupport *support,
unsigned int n_support)
{
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
return spa_ffmpeg_dec_init (handle);
return spa_ffmpeg_dec_init (handle, info, support, n_support);
}
static SpaResult
ffmpeg_enc_init (const SpaHandleFactory *factory,
SpaHandle *handle,
const SpaDict *info,
const SpaSupport **support,
const SpaSupport *support,
unsigned int n_support)
{
if (factory == NULL || handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
return spa_ffmpeg_enc_init (handle);
return spa_ffmpeg_enc_init (handle, info, support, n_support);
}
static const SpaInterfaceInfo ffmpeg_interfaces[] =
{
{ SPA_INTERFACE_ID_NODE,
SPA_INTERFACE_ID_NODE_NAME,
SPA_INTERFACE_ID_NODE_DESCRIPTION,
{ SPA_NODE_URI,
},
};