GUAC-236: Add decoder search function.
This commit is contained in:
parent
083e48d089
commit
5149d6d5c4
@ -23,6 +23,7 @@
|
||||
#include "config.h"
|
||||
#include "image-stream.h"
|
||||
#include "jpeg.h"
|
||||
#include "log.h"
|
||||
#include "png.h"
|
||||
|
||||
#ifdef ENABLE_WEBP
|
||||
@ -30,6 +31,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
guacenc_decoder_mapping guacenc_decoder_map[] = {
|
||||
{"image/png", &guacenc_png_decoder},
|
||||
@ -40,3 +42,24 @@ guacenc_decoder_mapping guacenc_decoder_map[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
guacenc_decoder* guacenc_get_decoder(const char* mimetype) {
|
||||
|
||||
/* Search through mapping for the decoder having given mimetype */
|
||||
guacenc_decoder_mapping* current = guacenc_decoder_map;
|
||||
while (current->mimetype != NULL) {
|
||||
|
||||
/* Return decoder if mimetype matches */
|
||||
if (strcmp(current->mimetype, mimetype) == 0)
|
||||
return current->decoder;
|
||||
|
||||
/* Next candidate decoder */
|
||||
current++;
|
||||
|
||||
}
|
||||
|
||||
/* No such decoder */
|
||||
guacenc_log(GUAC_LOG_WARNING, "Support for \"%s\" not present", mimetype);
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
@ -193,5 +193,18 @@ typedef struct guacenc_decoder_mapping {
|
||||
*/
|
||||
extern guacenc_decoder_mapping guacenc_decoder_map[];
|
||||
|
||||
/**
|
||||
* Returns the decoder associated with the given mimetype. If no such decoder
|
||||
* exists, NULL is returned.
|
||||
*
|
||||
* @param mimetype
|
||||
* The image mimetype to return the associated decoder of.
|
||||
*
|
||||
* @return
|
||||
* The decoder associated with the given mimetype, or NULL if no such
|
||||
* decoder exists.
|
||||
*/
|
||||
guacenc_decoder* guacenc_get_decoder(const char* mimetype);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user