Thu Jul 9 13:41:18 2009

Asterisk developer's documentation


format_jpeg.c File Reference

JPEG File format support. More...

#include "asterisk.h"
#include "asterisk/mod_format.h"
#include "asterisk/module.h"
#include "asterisk/image.h"
#include "asterisk/endian.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int jpeg_identify (int fd)
static struct ast_framejpeg_read_image (int fd, int len)
static int jpeg_write_image (int fd, struct ast_frame *fr)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "JPEG (Joint Picture Experts Group) Image Format" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, }
static const struct ast_module_infoast_module_info = &__mod_info
static struct ast_imager jpeg_format


Detailed Description

JPEG File format support.

Definition in file format_jpeg.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 115 of file format_jpeg.c.

static void __unreg_module ( void   )  [static]

Definition at line 115 of file format_jpeg.c.

static int jpeg_identify ( int  fd  )  [static]

Definition at line 58 of file format_jpeg.c.

References buf.

00059 {
00060    char buf[10];
00061    int res;
00062    res = read(fd, buf, sizeof(buf));
00063    if (res < sizeof(buf))
00064       return 0;
00065    if (memcmp(buf + 6, "JFIF", 4))
00066       return 0;
00067    return 1;
00068 }

static struct ast_frame* jpeg_read_image ( int  fd,
int  len 
) [static]

Definition at line 36 of file format_jpeg.c.

References AST_FORMAT_JPEG, AST_FRAME_IMAGE, ast_frisolate(), ast_log(), buf, errno, and LOG_WARNING.

00037 {
00038    struct ast_frame fr;
00039    int res;
00040    char buf[65536];
00041    if (len > sizeof(buf) || len < 0) {
00042       ast_log(LOG_WARNING, "JPEG image too large to read\n");
00043       return NULL;
00044    }
00045    res = read(fd, buf, len);
00046    if (res < len) {
00047       ast_log(LOG_WARNING, "Only read %d of %d bytes: %s\n", res, len, strerror(errno));
00048    }
00049    memset(&fr, 0, sizeof(fr));
00050    fr.frametype = AST_FRAME_IMAGE;
00051    fr.subclass = AST_FORMAT_JPEG;
00052    fr.data = buf;
00053    fr.src = "JPEG Read";
00054    fr.datalen = len;
00055    return ast_frisolate(&fr);
00056 }

static int jpeg_write_image ( int  fd,
struct ast_frame fr 
) [static]

Definition at line 70 of file format_jpeg.c.

References AST_FORMAT_JPEG, AST_FRAME_IMAGE, ast_log(), ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, LOG_WARNING, and ast_frame::subclass.

00071 {
00072    int res=0;
00073    if (fr->frametype != AST_FRAME_IMAGE) {
00074       ast_log(LOG_WARNING, "Not an image\n");
00075       return -1;
00076    }
00077    if (fr->subclass != AST_FORMAT_JPEG) {
00078       ast_log(LOG_WARNING, "Not a jpeg image\n");
00079       return -1;
00080    }
00081    if (fr->datalen) {
00082       res = write(fd, fr->data, fr->datalen);
00083       if (res != fr->datalen) {
00084          ast_log(LOG_WARNING, "Only wrote %d of %d bytes: %s\n", res, fr->datalen, strerror(errno));
00085          return -1;
00086       }
00087    }
00088    return res;
00089 }

static int load_module ( void   )  [static]

Definition at line 101 of file format_jpeg.c.

References ast_image_register(), AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, and jpeg_format.

00102 {
00103    if (ast_image_register(&jpeg_format))
00104       return AST_MODULE_LOAD_FAILURE;
00105    return AST_MODULE_LOAD_SUCCESS;
00106 }

static int unload_module ( void   )  [static]

Definition at line 108 of file format_jpeg.c.

References ast_image_unregister(), and jpeg_format.

00109 {
00110    ast_image_unregister(&jpeg_format);
00111 
00112    return 0;
00113 }  


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "JPEG (Joint Picture Experts Group) Image Format" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static]

Definition at line 115 of file format_jpeg.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 115 of file format_jpeg.c.

struct ast_imager jpeg_format [static]

Definition at line 91 of file format_jpeg.c.

Referenced by load_module(), and unload_module().


Generated on Thu Jul 9 13:41:18 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7