Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

image.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  ast_imager
 structure associated with registering an image format More...


Functions

int ast_supports_images (struct ast_channel *chan)
 Check for image support on a channel.

int ast_send_image (struct ast_channel *chan, char *filename)
 Sends an image.

ast_frameast_read_image (char *filename, char *preflang, int format)
 Make an image.

int ast_image_register (struct ast_imager *imgdrv)
 Register image format.

void ast_image_unregister (struct ast_imager *imgdrv)
 Unregister an image format.

int ast_image_init (void)
 Initialize image stuff.


Function Documentation

int ast_image_init void   ) 
 

Initialize image stuff.

Initializes all the various image stuff. Basically just registers the cli stuff Returns 0 all the time

Definition at line 201 of file image.c.

References ast_cli_register(), and show_images.

Referenced by main().

00202 { 00203 ast_cli_register(&show_images); 00204 return 0; 00205 }

int ast_image_register struct ast_imager imgdrv  ) 
 

Register image format.

Parameters:
imgdrv Populated ast_imager structure with info to register Registers an image format Returns 0 regardless

Definition at line 38 of file image.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verbose(), ast_imager::desc, ast_imager::name, ast_imager::next, option_verbose, and VERBOSE_PREFIX_2.

00039 { 00040 if (option_verbose > 1) 00041 ast_verbose(VERBOSE_PREFIX_2 "Registered format '%s' (%s)\n", img->name, img->desc); 00042 ast_mutex_lock(&listlock); 00043 img->next = list; 00044 list = img; 00045 ast_mutex_unlock(&listlock); 00046 return 0; 00047 }

void ast_image_unregister struct ast_imager imgdrv  ) 
 

Unregister an image format.

Parameters:
imgdrv pointer to the ast_imager structure you wish to unregister Unregisters the image format passed in Returns nothing

Definition at line 49 of file image.c.

References ast_mutex_lock, ast_mutex_unlock, ast_verbose(), ast_imager::desc, ast_imager::name, ast_imager::next, option_verbose, and VERBOSE_PREFIX_2.

00050 { 00051 struct ast_imager *i, *prev = NULL; 00052 ast_mutex_lock(&listlock); 00053 i = list; 00054 while(i) { 00055 if (i == img) { 00056 if (prev) 00057 prev->next = i->next; 00058 else 00059 list = i->next; 00060 break; 00061 } 00062 prev = i; 00063 i = i->next; 00064 } 00065 ast_mutex_unlock(&listlock); 00066 if (i && (option_verbose > 1)) 00067 ast_verbose(VERBOSE_PREFIX_2 "Unregistered format '%s' (%s)\n", img->name, img->desc); 00068 }

struct ast_frame* ast_read_image char *  filename,
char *  preflang,
int  format
 

Make an image.

Parameters:
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 104 of file image.c.

References ast_log(), ast_mutex_lock, ast_mutex_unlock, and LOG_WARNING.

Referenced by ast_send_image().

00105 { 00106 struct ast_imager *i; 00107 char buf[256]; 00108 char tmp[80]; 00109 char *e; 00110 struct ast_imager *found = NULL; 00111 int fd; 00112 int len=0; 00113 struct ast_frame *f = NULL; 00114 #if 0 /* We need to have some sort of read-only lock */ 00115 ast_mutex_lock(&listlock); 00116 #endif 00117 i = list; 00118 while(!found && i) { 00119 if (i->format & format) { 00120 char *stringp=NULL; 00121 strncpy(tmp, i->exts, sizeof(tmp)-1); 00122 stringp=tmp; 00123 e = strsep(&stringp, "|"); 00124 while(e) { 00125 make_filename(buf, sizeof(buf), filename, preflang, e); 00126 if ((len = file_exists(buf))) { 00127 found = i; 00128 break; 00129 } 00130 make_filename(buf, sizeof(buf), filename, NULL, e); 00131 if ((len = file_exists(buf))) { 00132 found = i; 00133 break; 00134 } 00135 e = strsep(&stringp, "|"); 00136 } 00137 } 00138 i = i->next; 00139 } 00140 if (found) { 00141 fd = open(buf, O_RDONLY); 00142 if (fd > -1) { 00143 if (!found->identify || found->identify(fd)) { 00144 /* Reset file pointer */ 00145 lseek(fd, 0, SEEK_SET); 00146 f = found->read_image(fd,len); 00147 } else 00148 ast_log(LOG_WARNING, "%s does not appear to be a %s file\n", buf, i->name); 00149 close(fd); 00150 } else 00151 ast_log(LOG_WARNING, "Unable to open '%s': %s\n", buf, strerror(errno)); 00152 } else 00153 ast_log(LOG_WARNING, "Image file '%s' not found\n", filename); 00154 #if 0 00155 ast_mutex_unlock(&listlock); 00156 #endif 00157 return f; 00158 }

int ast_send_image struct ast_channel chan,
char *  filename
 

Sends an image.

Parameters:
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 161 of file image.c.

References ast_frfree(), ast_read_image(), ast_channel::language, ast_channel::pvt, and ast_channel_pvt::send_image.

00162 { 00163 struct ast_frame *f; 00164 int res = -1; 00165 if (chan->pvt->send_image) { 00166 f = ast_read_image(filename, chan->language, -1); 00167 if (f) { 00168 res = chan->pvt->send_image(chan, f); 00169 ast_frfree(f); 00170 } 00171 } 00172 return res; 00173 }

int ast_supports_images struct ast_channel chan  ) 
 

Check for image support on a channel.

Parameters:
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 70 of file image.c.

References ast_channel::pvt, and ast_channel_pvt::send_image.

00071 { 00072 if (!chan || !chan->pvt) 00073 return 0; 00074 if (!chan->pvt->send_image) 00075 return 0; 00076 return 1; 00077 }


Generated on Sat Jun 12 16:41:35 2004 for Asterisk by doxygen 1.3.7