/* * CallWeaver -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, Digium, Inc. * * Mark Spencer * * See http://www.callweaver.org for more information about * the CallWeaver project. Please do not directly contact * any of the maintainers of this project for assistance; * the project provides a web site, mailing lists and IRC * channels for your use. * * This program is free software, distributed under the terms of * the GNU General Public License Version 2. See the LICENSE file * at the top of the source tree. */ /*! \file * \brief General CallWeaver channel definitions for image handling */ #ifndef _CALLWEAVER_IMAGE_H #define _CALLWEAVER_IMAGE_H #include "callweaver/object.h" #include "callweaver/registry.h" #include "callweaver/module.h" /*! \brief structure associated with registering an image format */ struct cw_imager { struct cw_object obj; struct cw_registry_entry *reg_entry; /*! Name */ char *name; /*! Description */ char *desc; /*! Extension(s) (separated by ',' ) */ char *exts; /*! Image format */ int format; /*! Read an image from a file descriptor */ struct cw_frame *(*read_image)(int fd, int len); /*! Identify if this is that type of file */ int (*identify)(int fd); /*! Returns length written */ int (*write_image)(int fd, struct cw_frame *frame); }; extern CW_API_PUBLIC const struct cw_object_isa cw_object_isa_imager; extern CW_API_PUBLIC struct cw_registry imager_registry; #define cw_image_register(ptr) ({ \ const typeof(ptr) __ptr = (ptr); \ /* We know 0 refs means not initialized because we know how objs work \ * internally and we know that registration only happens while the \ * module lock is held. \ */ \ if (!cw_object_refs(__ptr)) \ cw_object_init_obj(&__ptr->obj, &cw_object_isa_imager, CW_OBJECT_CURRENT_MODULE, 0); \ __ptr->reg_entry = cw_registry_add(&imager_registry, 0, &__ptr->obj); \ 0; \ }) #define cw_image_unregister(ptr) ({ \ const typeof(ptr) __ptr = (ptr); \ if (__ptr->reg_entry) \ cw_registry_del(&imager_registry, __ptr->reg_entry); \ 0; \ }) /*! Check for image support on a channel */ /*! * \param chan channel to check * Checks the channel to see if it supports the transmission of images * Returns non-zero if image transmission is supported */ extern CW_API_PUBLIC int cw_supports_images(struct cw_channel *chan); /*! Sends an image */ /*! * \param chan channel to send image on * \param filename filename of image to send (minus extension) * Sends an image on the given channel. * Returns 0 on success, -1 on error */ extern CW_API_PUBLIC int cw_send_image(struct cw_channel *chan, char *filename); /*! Make an image */ /*! * \param filename filename of image to prepare * \param preflang preferred language to get the image...? * \param format the format of the file * Make an image from a filename ??? No estoy positivo * Returns an cw_frame on success, NULL on failure */ extern CW_API_PUBLIC struct cw_frame *cw_read_image(char *filename, char *lang, int format); /*! Initialize image stuff */ /*! * Initializes all the various image stuff. Basically just registers the cli stuff * Returns 0 all the time */ extern int cw_image_init(void); #endif /* _CALLWEAVER_IMAGE_H */