#include "asterisk.h"
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/sched.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_FIRST | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static const 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 58 of file format_h263.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 200 of file format_h263.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 200 of file format_h263.c.
static int h263_open | ( | struct ast_filestream * | s | ) | [static] |
Definition at line 65 of file format_h263.c.
References ast_log(), LOG_WARNING, and s.
00066 { 00067 unsigned int ts; 00068 int res; 00069 00070 if ((res = fread(&ts, 1, sizeof(ts), s->f)) < sizeof(ts)) { 00071 ast_log(LOG_WARNING, "Empty file!\n"); 00072 return -1; 00073 } 00074 return 0; 00075 }
static struct ast_frame* h263_read | ( | struct ast_filestream * | s, | |
int * | whennext | |||
) | [static] |
Definition at line 77 of file format_h263.c.
References AST_FORMAT_H263, AST_FRAME_SET_BUFFER, AST_FRAME_VIDEO, AST_FRIENDLY_OFFSET, ast_log(), BUF_SIZE, errno, h263_desc::lastts, len(), LOG_WARNING, s, and ast_frame::ts.
00078 { 00079 int res; 00080 int mark; 00081 unsigned short len; 00082 unsigned int ts; 00083 struct h263_desc *fs = (struct h263_desc *)s->_private; 00084 00085 /* Send a frame from the file to the appropriate channel */ 00086 if ((res = fread(&len, 1, sizeof(len), s->f)) < 1) 00087 return NULL; 00088 len = ntohs(len); 00089 mark = (len & 0x8000) ? 1 : 0; 00090 len &= 0x7fff; 00091 if (len > BUF_SIZE) { 00092 ast_log(LOG_WARNING, "Length %d is too long\n", len); 00093 return NULL; 00094 } 00095 s->fr.frametype = AST_FRAME_VIDEO; 00096 s->fr.subclass = AST_FORMAT_H263; 00097 s->fr.mallocd = 0; 00098 AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); 00099 if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { 00100 if (res) 00101 ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); 00102 return NULL; 00103 } 00104 s->fr.samples = fs->lastts; /* XXX what ? */ 00105 s->fr.datalen = len; 00106 s->fr.subclass |= mark; 00107 s->fr.delivery.tv_sec = 0; 00108 s->fr.delivery.tv_usec = 0; 00109 if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) { 00110 fs->lastts = ntohl(ts); 00111 *whennext = fs->lastts * 4/45; 00112 } else 00113 *whennext = 0; 00114 return &s->fr; 00115 }
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, and offset.
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 159 of file format_h263.c.
References ast_filestream::f.
00160 { 00161 /* Truncate file to current length */ 00162 if (ftruncate(fileno(fs->f), ftello(fs->f)) < 0) 00163 return -1; 00164 return 0; 00165 }
static int h263_write | ( | struct ast_filestream * | fs, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 117 of file format_h263.c.
References AST_FORMAT_H263, AST_FRAME_VIDEO, ast_log(), errno, ast_filestream::f, f, len(), and LOG_WARNING.
00118 { 00119 int res; 00120 unsigned int ts; 00121 unsigned short len; 00122 int subclass; 00123 int mark=0; 00124 if (f->frametype != AST_FRAME_VIDEO) { 00125 ast_log(LOG_WARNING, "Asked to write non-video frame!\n"); 00126 return -1; 00127 } 00128 subclass = f->subclass; 00129 if (subclass & 0x1) 00130 mark=0x8000; 00131 subclass &= ~0x1; 00132 if (subclass != AST_FORMAT_H263) { 00133 ast_log(LOG_WARNING, "Asked to write non-h263 frame (%d)!\n", f->subclass); 00134 return -1; 00135 } 00136 ts = htonl(f->samples); 00137 if ((res = fwrite(&ts, 1, sizeof(ts), fs->f)) != sizeof(ts)) { 00138 ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno)); 00139 return -1; 00140 } 00141 len = htons(f->datalen | mark); 00142 if ((res = fwrite(&len, 1, sizeof(len), fs->f)) != sizeof(len)) { 00143 ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); 00144 return -1; 00145 } 00146 if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { 00147 ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); 00148 return -1; 00149 } 00150 return 0; 00151 }
static int load_module | ( | void | ) | [static] |
Definition at line 187 of file format_h263.c.
References ast_format_register, and h263_f.
00188 { 00189 return ast_format_register(&h263_f); 00190 }
static int unload_module | ( | void | ) | [static] |
Definition at line 192 of file format_h263.c.
References ast_format_unregister(), h263_f, and ast_format::name.
00193 { 00194 return ast_format_unregister(h263_f.name); 00195 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_FIRST | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 200 of file format_h263.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 200 of file format_h263.c.
struct ast_format h263_f [static] |