Added API to construct ADC messages with source and destination.

This commit is contained in:
Jan Vidar Krey 2012-10-02 23:59:11 +02:00
parent 07da142e65
commit 5136525abc
2 changed files with 17 additions and 2 deletions

View File

@ -532,9 +532,9 @@ struct adc_message* adc_msg_create(const char* line)
return adc_msg_parse(line, strlen(line));
}
extern struct adc_message* adc_msg_construct_source(fourcc_t fourcc, sid_t source, size_t size)
struct adc_message* adc_msg_construct_source(fourcc_t fourcc, sid_t source, size_t size)
{
struct adc_message* msg = adc_msg_construct(fourcc, size + 4);
struct adc_message* msg = adc_msg_construct(fourcc, size + 4 + 1);
if (!msg)
return NULL;
@ -543,6 +543,20 @@ extern struct adc_message* adc_msg_construct_source(fourcc_t fourcc, sid_t sourc
return msg;
}
struct adc_message* adc_msg_construct_source_dest(fourcc_t fourcc, sid_t source, sid_t dest, size_t size)
{
struct adc_message* msg = adc_msg_construct(fourcc, size + 4 + 4 + 1);
if (!msg)
return NULL;
adc_msg_add_argument(msg, sid_to_string(source));
adc_msg_add_argument(msg, sid_to_string(dest));
msg->source = source;
msg->target = dest;
return msg;
}
struct adc_message* adc_msg_construct(fourcc_t fourcc, size_t size)
{
struct adc_message* msg = (struct adc_message*) msg_malloc_zero(sizeof(struct adc_message));

View File

@ -96,6 +96,7 @@ extern struct adc_message* adc_msg_construct(fourcc_t fourcc, size_t size);
* in addition pre-allocate 'size' bytes at the end of the message.
*/
extern struct adc_message* adc_msg_construct_source(fourcc_t fourcc, sid_t source, size_t size);
extern struct adc_message* adc_msg_construct_source_dest(fourcc_t fourcc, sid_t source, sid_t dest, size_t size);
/**
* Remove a named argument from the command.