1 /** 2 * @file media.h 3 * 4 * @brief Media data handling. 5 * @author David Suárez 6 * @author Chris Lightfoot 7 * @date Sun, 28 Oct 2018 16:14:56 +0100 8 * 9 * Copyright (c) 2002 Chris Lightfoot. 10 * Email: chris@ex-parrot.com; WWW: http://www.ex-parrot.com/~chris/ 11 * 12 * Copyright (c) 2018 David Suárez. 13 * Email: david.sephirot@gmail.com 14 * 15 */ 16 17 #ifndef __MEDIA_H__ 18 #define __MEDIA_H__ 19 20 #ifdef HAVE_CONFIG_H 21 #include <config.h> 22 #endif 23 24 #include <stddef.h> 25 26 /** 27 * @brief Number of media types we recognize. 28 */ 29 #define NMEDIATYPES 5 30 31 /* TODO: NMEDIATYPES -> NMEDIA_DRIVERS */ 32 33 /** 34 * @brief Bit field to characterise types of media which we can extract. 35 */ 36 typedef enum mediatype { 37 MEDIATYPE_IMAGE = 1, 38 MEDIATYPE_AUDIO = 1 << 1, 39 MEDIATYPE_TEXT = 1 << 2 40 } mediatype_t; 41 42 /** 43 * @brief Info for each media driver. 44 */ 45 typedef struct mediadrv { 46 /** Media name: gif, jpeg ... */ 47 char *name; 48 49 /** Type of media @see mediatype_t */ 50 enum mediatype type; 51 52 /** Function to find data for the media the driver knows about */ 53 unsigned char *(*find_data)(const unsigned char *data, const size_t len, unsigned char **found, size_t *foundlen); 54 55 /** Pointer to function to dispatch this type of media; this should be initialized by the user */ 56 void (*dispatch_data)(const char *mname, const unsigned char *data, const size_t len); 57 } mediadrv_t; 58 59 /** 60 * @brief Contains the runtime drivers for the configured capture media type 61 */ 62 typedef struct drivers { 63 mediatype_t type; 64 mediadrv_t** list; 65 int count; 66 } drivers_t; 67 68 /** 69 * @brief Obtains a list of media drivers. 70 * 71 * @param filter to this media type 72 * @return drivers list (should be freed with close_media_drivers method) 73 */ 74 drivers_t* get_drivers_for_mediatype(mediatype_t type); 75 76 /** 77 * @brief Frees from memory the drivers list. 78 * 79 * @param drivers the list 80 * @return none 81 */ 82 void close_media_drivers(drivers_t* drivers); 83 84 #endif /* __MEDIA_H__ */ 85