#include "asterisk.h"
#include "asterisk/mod_format.h"
#include "asterisk/module.h"
#include "asterisk/endian.h"
Go to the source code of this file.
Data Structures | |
struct | h263_desc |
Defines | |
#define | BUF_SIZE 32768 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | h263_open (struct ast_filestream *s) |
static struct ast_frame * | h263_read (struct ast_filestream *s, int *whennext) |
static int | h263_seek (struct ast_filestream *fs, off_t sample_offset, int whence) |
static off_t | h263_tell (struct ast_filestream *fs) |
static int | h263_trunc (struct ast_filestream *fs) |
static int | h263_write (struct ast_filestream *fs, struct ast_frame *f) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw H.263 data" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_format | h263_f |
Definition in file format_h263.c.
#define BUF_SIZE 32768 |
Definition at line 49 of file format_h263.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 203 of file format_h263.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 203 of file format_h263.c.
static int h263_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 56 of file format_h263.c.
References ast_log(), ast_filestream::f, and LOG_WARNING.
00057 { 00058 unsigned int ts; 00059 int res; 00060 00061 if ((res = fread(&ts, 1, sizeof(ts), s->f)) < sizeof(ts)) { 00062 ast_log(LOG_WARNING, "Empty file!\n"); 00063 return -1; 00064 } 00065 return 0; 00066 }
static struct ast_frame* h263_read | ( | struct ast_filestream * | s, | |
int * | whennext | |||
) | [static] |
Definition at line 68 of file format_h263.c.
References ast_filestream::_private, AST_FORMAT_H263, AST_FRAME_SET_BUFFER, AST_FRAME_VIDEO, AST_FRIENDLY_OFFSET, ast_log(), ast_filestream::buf, BUF_SIZE, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, ast_frame::delivery, errno, ast_filestream::f, ast_filestream::fr, ast_frame::frametype, h263_desc::lastts, len(), LOG_WARNING, ast_frame::mallocd, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, and ast_frame::ts.
00069 { 00070 int res; 00071 format_t mark; 00072 unsigned short len; 00073 unsigned int ts; 00074 struct h263_desc *fs = (struct h263_desc *)s->_private; 00075 00076 /* Send a frame from the file to the appropriate channel */ 00077 if ((res = fread(&len, 1, sizeof(len), s->f)) < 1) 00078 return NULL; 00079 len = ntohs(len); 00080 mark = (len & 0x8000) ? 1 : 0; 00081 len &= 0x7fff; 00082 if (len > BUF_SIZE) { 00083 ast_log(LOG_WARNING, "Length %d is too long\n", len); 00084 return NULL; 00085 } 00086 s->fr.frametype = AST_FRAME_VIDEO; 00087 s->fr.subclass.codec = AST_FORMAT_H263; 00088 s->fr.mallocd = 0; 00089 AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); 00090 if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { 00091 if (res) 00092 ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); 00093 return NULL; 00094 } 00095 s->fr.samples = fs->lastts; /* XXX what ? */ 00096 s->fr.datalen = len; 00097 s->fr.subclass.codec |= mark; 00098 s->fr.delivery.tv_sec = 0; 00099 s->fr.delivery.tv_usec = 0; 00100 if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) { 00101 fs->lastts = ntohl(ts); 00102 *whennext = fs->lastts * 4/45; 00103 } else 00104 *whennext = 0; 00105 return &s->fr; 00106 }
static int h263_seek | ( | struct ast_filestream * | fs, | |
off_t | sample_offset, | |||
int | whence | |||
) | [static] |
static off_t h263_tell | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 167 of file format_h263.c.
References ast_filestream::f.
00168 { 00169 off_t offset = ftello(fs->f); 00170 return offset; /* XXX totally bogus, needs fixing */ 00171 }
static int h263_trunc | ( | struct ast_filestream * | fs | ) | [static] |
Definition at line 150 of file format_h263.c.
References ast_log(), AST_LOG_WARNING, errno, and ast_filestream::f.
00151 { 00152 int fd; 00153 off_t cur; 00154 00155 if ((fd = fileno(fs->f)) < 0) { 00156 ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for h263 filestream %p: %s\n", fs, strerror(errno)); 00157 return -1; 00158 } 00159 if ((cur = ftello(fs->f)) < 0) { 00160 ast_log(AST_LOG_WARNING, "Unable to determine current position in h263 filestream %p: %s\n", fs, strerror(errno)); 00161 return -1; 00162 } 00163 /* Truncate file to current length */ 00164 return ftruncate(fd, cur); 00165 }
static int h263_write | ( | struct ast_filestream * | fs, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 108 of file format_h263.c.
References AST_FORMAT_H263, AST_FRAME_VIDEO, ast_getformatname(), ast_log(), errno, ast_filestream::f, f, len(), and LOG_WARNING.
00109 { 00110 int res; 00111 unsigned int ts; 00112 unsigned short len; 00113 format_t subclass; 00114 format_t mark=0; 00115 if (f->frametype != AST_FRAME_VIDEO) { 00116 ast_log(LOG_WARNING, "Asked to write non-video frame!\n"); 00117 return -1; 00118 } 00119 subclass = f->subclass.codec; 00120 if (subclass & 0x1) 00121 mark=0x8000; 00122 subclass &= ~0x1; 00123 if (subclass != AST_FORMAT_H263) { 00124 ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(f->subclass.codec)); 00125 return -1; 00126 } 00127 ts = htonl(f->samples); 00128 if ((res = fwrite(&ts, 1, sizeof(ts), fs->f)) != sizeof(ts)) { 00129 ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno)); 00130 return -1; 00131 } 00132 len = htons(f->datalen | mark); 00133 if ((res = fwrite(&len, 1, sizeof(len), fs->f)) != sizeof(len)) { 00134 ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); 00135 return -1; 00136 } 00137 if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { 00138 ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); 00139 return -1; 00140 } 00141 return 0; 00142 }
static int load_module | ( | void | ) | [static] |
Definition at line 187 of file format_h263.c.
References ast_format_register, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, and h263_f.
00188 { 00189 if (ast_format_register(&h263_f)) 00190 return AST_MODULE_LOAD_FAILURE; 00191 return AST_MODULE_LOAD_SUCCESS; 00192 }
static int unload_module | ( | void | ) | [static] |
Definition at line 194 of file format_h263.c.
References ast_format_unregister(), h263_f, and ast_format::name.
00195 { 00196 return ast_format_unregister(h263_f.name); 00197 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw H.263 data" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND } [static] |
Definition at line 203 of file format_h263.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 203 of file format_h263.c.
struct ast_format h263_f [static] |