Go to the source code of this file.
Data Structures | |
struct | ast_imager |
structure associated with registering an image format More... | |
Functions | |
int | ast_image_init (void) |
int | ast_image_register (struct ast_imager *imgdrv) |
void | ast_image_unregister (struct ast_imager *imgdrv) |
ast_frame * | ast_read_image (char *filename, const char *preflang, int format) |
int | ast_send_image (struct ast_channel *chan, char *filename) |
int | ast_supports_images (struct ast_channel *chan) |
Definition in file image.h.
int ast_image_init | ( | void | ) |
Initializes all the various image stuff. Basically just registers the cli stuff Returns 0 all the time
Definition at line 221 of file image.c.
References ast_cli_register_multiple(), and cli_image.
Referenced by main().
00222 { 00223 ast_cli_register_multiple(cli_image, sizeof(cli_image) / sizeof(struct ast_cli_entry)); 00224 return 0; 00225 }
int ast_image_register | ( | struct ast_imager * | imgdrv | ) |
imgdrv | Populated ast_imager structure with info to register Registers an image format Returns 0 regardless |
Definition at line 52 of file image.c.
References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_verbose(), ast_imager::desc, ast_imager::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by load_module().
00053 { 00054 if (option_verbose > 1) 00055 ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc); 00056 AST_LIST_LOCK(&imagers); 00057 AST_LIST_INSERT_HEAD(&imagers, img, list); 00058 AST_LIST_UNLOCK(&imagers); 00059 return 0; 00060 }
void ast_image_unregister | ( | struct ast_imager * | imgdrv | ) |
imgdrv | pointer to the ast_imager structure you wish to unregister Unregisters the image format passed in Returns nothing |
Definition at line 62 of file image.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_verbose(), ast_imager::desc, ast_imager::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by unload_module().
00063 { 00064 struct ast_imager *i; 00065 00066 AST_LIST_LOCK(&imagers); 00067 AST_LIST_TRAVERSE_SAFE_BEGIN(&imagers, i, list) { 00068 if (i == img) { 00069 AST_LIST_REMOVE_CURRENT(&imagers, list); 00070 break; 00071 } 00072 } 00073 AST_LIST_TRAVERSE_SAFE_END 00074 AST_LIST_UNLOCK(&imagers); 00075 if (i && (option_verbose > 1)) 00076 ast_verbose(VERBOSE_PREFIX_2 "Unregistered format '%s' (%s)\n", img->name, img->desc); 00077 }
struct ast_frame* ast_read_image | ( | char * | filename, | |
const char * | preflang, | |||
int | format | |||
) |
filename | filename of image to prepare | |
preflang | preferred language to get the image...? | |
format | the format of the file Make an image from a filename ??? No estoy positivo Returns an ast_frame on success, NULL on failure |
Definition at line 113 of file image.c.
References ast_copy_string(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), errno, ast_imager::exts, f, file_exists(), ast_imager::format, ast_imager::identify, len(), LOG_WARNING, make_filename(), ast_imager::name, and ast_imager::read_image.
Referenced by ast_send_image().
00114 { 00115 struct ast_imager *i; 00116 char buf[256]; 00117 char tmp[80]; 00118 char *e; 00119 struct ast_imager *found = NULL; 00120 int fd; 00121 int len=0; 00122 struct ast_frame *f = NULL; 00123 00124 AST_LIST_LOCK(&imagers); 00125 AST_LIST_TRAVERSE(&imagers, i, list) { 00126 if (i->format & format) { 00127 char *stringp=NULL; 00128 ast_copy_string(tmp, i->exts, sizeof(tmp)); 00129 stringp=tmp; 00130 e = strsep(&stringp, "|"); 00131 while(e) { 00132 make_filename(buf, sizeof(buf), filename, preflang, e); 00133 if ((len = file_exists(buf))) { 00134 found = i; 00135 break; 00136 } 00137 make_filename(buf, sizeof(buf), filename, NULL, e); 00138 if ((len = file_exists(buf))) { 00139 found = i; 00140 break; 00141 } 00142 e = strsep(&stringp, "|"); 00143 } 00144 } 00145 if (found) 00146 break; 00147 } 00148 00149 if (found) { 00150 fd = open(buf, O_RDONLY); 00151 if (fd > -1) { 00152 if (!found->identify || found->identify(fd)) { 00153 /* Reset file pointer */ 00154 lseek(fd, 0, SEEK_SET); 00155 f = found->read_image(fd,len); 00156 } else 00157 ast_log(LOG_WARNING, "%s does not appear to be a %s file\n", buf, found->name); 00158 close(fd); 00159 } else 00160 ast_log(LOG_WARNING, "Unable to open '%s': %s\n", buf, strerror(errno)); 00161 } else 00162 ast_log(LOG_WARNING, "Image file '%s' not found\n", filename); 00163 00164 AST_LIST_UNLOCK(&imagers); 00165 00166 return f; 00167 }
int ast_send_image | ( | struct ast_channel * | chan, | |
char * | filename | |||
) |
chan | channel to send image on | |
filename | filename of image to send (minus extension) Sends an image on the given channel. Returns 0 on success, -1 on error |
Definition at line 169 of file image.c.
References ast_frfree, ast_read_image(), f, ast_channel::language, ast_channel_tech::send_image, and ast_channel::tech.
Referenced by handle_sendimage(), and sendimage_exec().
00170 { 00171 struct ast_frame *f; 00172 int res = -1; 00173 if (chan->tech->send_image) { 00174 f = ast_read_image(filename, chan->language, -1); 00175 if (f) { 00176 res = chan->tech->send_image(chan, f); 00177 ast_frfree(f); 00178 } 00179 } 00180 return res; 00181 }
int ast_supports_images | ( | struct ast_channel * | chan | ) |
chan | channel to check Checks the channel to see if it supports the transmission of images Returns non-zero if image transmission is supported |
Definition at line 79 of file image.c.
References ast_channel_tech::send_image, and ast_channel::tech.
Referenced by sendimage_exec().
00080 { 00081 if (!chan || !chan->tech) 00082 return 0; 00083 if (!chan->tech->send_image) 00084 return 0; 00085 return 1; 00086 }