Commit c0096427 authored by Ghislain MARY's avatar Ghislain MARY

Add notion of encoding_capturer and decoding_renderer.

parent f8ca6065
......@@ -81,7 +81,11 @@ enum _MSFilterCategory{
/**used by encoders*/
MS_FILTER_ENCODER,
/**used by decoders*/
MS_FILTER_DECODER
MS_FILTER_DECODER,
/**used by capture filters that perform encoding*/
MS_FILTER_ENCODING_CAPTURER,
/**used by render filters that perform decoding*/
MS_FILTER_DECODING_RENDERER
};
/**
......@@ -90,6 +94,8 @@ enum _MSFilterCategory{
* MS_FILTER_OTHER
* MS_FILTER_ENCODER
* MS_FILTER_DECODER
* MS_FILTER_ENCODING_CAPTURER
* MS_FILTER_DECODING_RENDERER
* </PRE>
* @var MSFilterCategory
*/
......@@ -207,6 +213,24 @@ extern "C"{
*/
MS2_PUBLIC void ms_filter_register(MSFilterDesc *desc);
/**
* Retrieve capture filter that supports encoding to codec name.
*
* @param mime A string indicating the codec.
*
* Returns: a MSFilterDesc if successfull, NULL otherwise.
*/
MS2_PUBLIC MSFilterDesc * ms_filter_get_encoding_capturer(const char *mime);
/**
* Retrieve render filter that supports decoding to codec name.
*
* @param mime A string indicating the codec.
*
* Returns: a MSFilterDesc if successfull, NULL otherwise.
*/
MS2_PUBLIC MSFilterDesc * ms_filter_get_decoding_renderer(const char *mime);
/**
* Retrieve encoders according to codec name.
*
......
......@@ -60,8 +60,11 @@ void ms_filter_unregister_all(){
}
bool_t ms_filter_codec_supported(const char *mime){
MSFilterDesc *enc = ms_filter_get_encoder(mime);
MSFilterDesc *dec = ms_filter_get_decoder(mime);
MSFilterDesc *enc = ms_filter_get_encoding_capturer(mime);
MSFilterDesc *dec = ms_filter_get_decoding_renderer(mime);
if (enc == NULL) enc = ms_filter_get_encoder(mime);
if (dec == NULL) dec = ms_filter_get_decoder(mime);
if(enc!=NULL && dec!=NULL) return TRUE;
......@@ -70,6 +73,52 @@ bool_t ms_filter_codec_supported(const char *mime){
return FALSE;
}
MSFilterDesc * ms_filter_get_encoding_capturer(const char *mime) {
MSList *elem;
for (elem = desc_list; elem != NULL; elem = ms_list_next(elem)) {
MSFilterDesc *desc = (MSFilterDesc *)elem->data;
if (desc->category == MS_FILTER_ENCODING_CAPTURER) {
char *saveptr;
char *enc_fmt = ms_strdup(desc->enc_fmt);
char *token = strtok_r(enc_fmt, " ", &saveptr);
while (token != NULL) {
if (strcasecmp(token, mime) == 0) {
break;
}
token = strtok_r(NULL, " ", &saveptr);
}
ms_free(enc_fmt);
if (token != NULL) return desc;
}
}
return NULL;
}
MSFilterDesc * ms_filter_get_decoding_renderer(const char *mime) {
MSList *elem;
for (elem = desc_list; elem != NULL; elem = ms_list_next(elem)) {
MSFilterDesc *desc = (MSFilterDesc *)elem->data;
if (desc->category == MS_FILTER_DECODING_RENDERER) {
char *saveptr;
char *enc_fmt = ms_strdup(desc->enc_fmt);
char *token = strtok_r(enc_fmt, " ", &saveptr);
while (token != NULL) {
if (strcasecmp(token, mime) == 0) {
break;
}
token = strtok_r(NULL, " ", &saveptr);
}
ms_free(enc_fmt);
if (token != NULL) return desc;
}
}
return NULL;
}
MSFilterDesc * ms_filter_get_encoder(const char *mime){
MSList *elem;
for (elem=desc_list;elem!=NULL;elem=ms_list_next(elem)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment