Skip to content
Snippets Groups Projects
Commit cafec9d0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

rtp: add module capabilities for RTP payload type parsers

parent 504d5aa6
No related branches found
No related tags found
No related merge requests found
......@@ -151,6 +151,40 @@ static const struct vlc_rtp_pt_owner_operations vlc_rtp_pt_owner_ops = {
vlc_rtp_es_request, vlc_rtp_mux_request,
};
int vlc_rtp_pt_instantiate(vlc_object_t *obj, struct vlc_rtp_pt *restrict pt,
const struct vlc_sdp_pt *restrict desc)
{
char modname[32];
int ret = VLC_ENOTSUP;
if (strchr(desc->name, ',') != NULL)
/* Comma has special meaning in vlc_module_match(), forbid it */
return VLC_EINVAL;
if ((size_t)snprintf(modname, sizeof (modname), "%s/%s",
desc->media->type, desc->name) >= sizeof (modname))
return VLC_ENOTSUP; /* Outlandish media type with long name */
module_t **mods;
ssize_t n = vlc_module_match("rtp parser", modname, true, &mods, NULL);
for (ssize_t i = 0; i < n; i++) {
vlc_rtp_parser_cb cb = vlc_module_map(vlc_object_logger(obj), mods[i]);
if (cb == NULL)
continue;
ret = cb(obj, pt, desc);
if (ret == VLC_SUCCESS) {
msg_Dbg(obj, "- module \"%s\"", module_get_name(mods[i], true));
assert(pt->ops != NULL);
ret = 0;
break;
}
}
free(mods);
return ret;
}
/**
* Extracts port number from "[host]:port" or "host:port" strings,
* and remove brackets from the host name.
......
......@@ -244,6 +244,30 @@ static inline void vlc_rtp_es_send(struct vlc_rtp_es *es, block_t *block)
*/
extern struct vlc_rtp_es *const vlc_rtp_es_dummy;
/**
* Callback prototype for RTP parser module.
*
* This is the callback prototype for any RTP payload format parser module.
*
* \param obj VLC object for logging and configuration
* \param pt RTP payload type
* \param desc[in] SDP payload format description and type mapping
*
* \return VLC_SUCCESS on success, an error code on failure.
*/
typedef int (*vlc_rtp_parser_cb)(vlc_object_t *obj, struct vlc_rtp_pt *pt,
const struct vlc_sdp_pt *desc);
#define set_rtp_parser_callback(cb) \
{ \
vlc_rtp_parser_cb cb__ = (cb); (void) cb__; \
set_callback(cb); \
set_capability("rtp parser", 0); \
}
int vlc_rtp_pt_instantiate(vlc_object_t *obj, struct vlc_rtp_pt *restrict pt,
const struct vlc_sdp_pt *restrict desc);
void rtp_autodetect(vlc_object_t *, rtp_session_t *,
const struct vlc_rtp_pt_owner *restrict);
......
......@@ -258,9 +258,12 @@ static struct vlc_rtp_pt *vlc_rtp_pt_create(vlc_object_t *obj,
pt->owner = *owner;
pt->frequency = desc->clock_rate;
pt->channel_count = desc->channel_count;
if (vlc_rtp_pt_instantiate(obj, pt, desc) == 0)
return pt;
pt->ops = NULL;
/* TODO: introduce module (capabilities) for payload types */
if (strcmp(desc->media->type, "audio") == 0) {
if (strcmp(desc->name, "PCMU") == 0)
pt->ops = &rtp_audio_pcmu;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment