format_sln.c File Reference

RAW SLINEAR Formats. More...

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

Include dependency graph for format_sln.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static struct ast_framegeneric_read (struct ast_filestream *s, int *whennext, unsigned int buf_size)
static int load_module (void)
static struct ast_frameslinear12_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear16_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear192_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear24_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear32_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear44_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear48_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear96_read (struct ast_filestream *s, int *whennext)
static struct ast_frameslinear_read (struct ast_filestream *s, int *whennext)
static int slinear_seek (struct ast_filestream *fs, off_t sample_offset, int whence)
static off_t slinear_tell (struct ast_filestream *fs)
static int slinear_trunc (struct ast_filestream *fs)
static int slinear_write (struct ast_filestream *fs, struct ast_frame *f)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw Signed Linear Audio support (SLN) 8khz-192khz" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_format_def slin12_f
static struct ast_format_def slin16_f
static struct ast_format_def slin192_f
static struct ast_format_def slin24_f
static struct ast_format_def slin32_f
static struct ast_format_def slin44_f
static struct ast_format_def slin48_f
static struct ast_format_def slin96_f
static struct ast_format_def slin_f
static struct ast_format_defslin_list []


Detailed Description

RAW SLINEAR Formats.

Definition in file format_sln.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 281 of file format_sln.c.

static void __unreg_module ( void   )  [static]

Definition at line 281 of file format_sln.c.

static struct ast_frame* generic_read ( struct ast_filestream s,
int *  whennext,
unsigned int  buf_size 
) [static, read]

Definition at line 37 of file format_sln.c.

References AST_FRAME_SET_BUFFER, AST_FRIENDLY_OFFSET, ast_log, ast_filestream::buf, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, ast_filestream::fr, LOG_WARNING, NULL, ast_frame::ptr, and ast_frame::samples.

Referenced by slinear12_read(), slinear16_read(), slinear192_read(), slinear24_read(), slinear32_read(), slinear44_read(), slinear48_read(), slinear96_read(), and slinear_read().

00038 {
00039    int res;
00040    /* Send a frame from the file to the appropriate channel */
00041 
00042    AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, buf_size);
00043    if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) {
00044       if (res)
00045          ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
00046       return NULL;
00047    }
00048    *whennext = s->fr.samples = res/2;
00049    s->fr.datalen = res;
00050    return &s->fr;
00051 }

static int load_module ( void   )  [static]

static struct ast_frame* slinear12_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 132 of file format_sln.c.

References generic_read().

00132 {return generic_read(s, whennext, 480);}

static struct ast_frame* slinear16_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 144 of file format_sln.c.

References generic_read().

00144 {return generic_read(s, whennext, 640);}

static struct ast_frame* slinear192_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 216 of file format_sln.c.

References generic_read().

00216 {return generic_read(s, whennext, 7680);}

static struct ast_frame* slinear24_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 156 of file format_sln.c.

References generic_read().

00156 {return generic_read(s, whennext, 960);}

static struct ast_frame* slinear32_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 168 of file format_sln.c.

References generic_read().

00168 {return generic_read(s, whennext, 1280);}

static struct ast_frame* slinear44_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 180 of file format_sln.c.

References generic_read().

00180 {return generic_read(s, whennext, 1764);}

static struct ast_frame* slinear48_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 192 of file format_sln.c.

References generic_read().

00192 {return generic_read(s, whennext, 1920);}

static struct ast_frame* slinear96_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 204 of file format_sln.c.

References generic_read().

00204 {return generic_read(s, whennext, 3840);}

static struct ast_frame* slinear_read ( struct ast_filestream s,
int *  whennext 
) [static, read]

Definition at line 120 of file format_sln.c.

References generic_read().

00120 {return generic_read(s, whennext, 320);}

static int slinear_seek ( struct ast_filestream fs,
off_t  sample_offset,
int  whence 
) [static]

Definition at line 63 of file format_sln.c.

References ast_log, AST_LOG_WARNING, errno, ast_filestream::f, max, min, ast_frame::offset, and SEEK_FORCECUR.

00064 {
00065    off_t offset=0, min = 0, cur, max;
00066 
00067    sample_offset <<= 1;
00068 
00069    if ((cur = ftello(fs->f)) < 0) {
00070       ast_log(AST_LOG_WARNING, "Unable to determine current position in sln filestream %p: %s\n", fs, strerror(errno));
00071       return -1;
00072    }
00073 
00074    if (fseeko(fs->f, 0, SEEK_END) < 0) {
00075       ast_log(AST_LOG_WARNING, "Unable to seek to end of sln filestream %p: %s\n", fs, strerror(errno));
00076       return -1;
00077    }
00078 
00079    if ((max = ftello(fs->f)) < 0) {
00080       ast_log(AST_LOG_WARNING, "Unable to determine max position in sln filestream %p: %s\n", fs, strerror(errno));
00081       return -1;
00082    }
00083 
00084    if (whence == SEEK_SET)
00085       offset = sample_offset;
00086    else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
00087       offset = sample_offset + cur;
00088    else if (whence == SEEK_END)
00089       offset = max - sample_offset;
00090    if (whence != SEEK_FORCECUR) {
00091       offset = (offset > max)?max:offset;
00092    }
00093    /* always protect against seeking past begining. */
00094    offset = (offset < min)?min:offset;
00095    return fseeko(fs->f, offset, SEEK_SET);
00096 }

static off_t slinear_tell ( struct ast_filestream fs  )  [static]

Definition at line 115 of file format_sln.c.

References ast_filestream::f.

00116 {
00117    return ftello(fs->f) / 2;
00118 }

static int slinear_trunc ( struct ast_filestream fs  )  [static]

Definition at line 98 of file format_sln.c.

References ast_log, AST_LOG_WARNING, errno, and ast_filestream::f.

00099 {
00100    int fd;
00101    off_t cur;
00102 
00103    if ((fd = fileno(fs->f)) < 0) {
00104       ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for sln filestream %p: %s\n", fs, strerror(errno));
00105       return -1;
00106    }
00107    if ((cur = ftello(fs->f)) < 0) {
00108       ast_log(AST_LOG_WARNING, "Unable to determine current position in sln filestream %p: %s\n", fs, strerror(errno));
00109       return -1;
00110    }
00111    /* Truncate file to current length */
00112    return ftruncate(fd, cur);
00113 }

static int slinear_write ( struct ast_filestream fs,
struct ast_frame f 
) [static]

Definition at line 53 of file format_sln.c.

References ast_log, ast_frame::data, ast_frame::datalen, errno, ast_filestream::f, LOG_WARNING, and ast_frame::ptr.

00054 {
00055    int res;
00056    if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) {
00057          ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno));
00058          return -1;
00059    }
00060    return 0;
00061 }

static int unload_module ( void   )  [static]

Definition at line 263 of file format_sln.c.

References ARRAY_LEN, ast_format_def_unregister(), AST_MODULE_LOAD_FAILURE, and name.

00264 {
00265    int res = 0;
00266    int i = 0;
00267 
00268    for (i = 0; i < ARRAY_LEN(slin_list); i++) {
00269       if (ast_format_def_unregister(slin_list[i]->name)) {
00270          res |= AST_MODULE_LOAD_FAILURE;
00271       }
00272    }
00273    return res;
00274 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Raw Signed Linear Audio support (SLN) 8khz-192khz" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND } [static]

Definition at line 281 of file format_sln.c.

Definition at line 281 of file format_sln.c.

struct ast_format_def slin12_f [static]

Definition at line 133 of file format_sln.c.

struct ast_format_def slin16_f [static]

Definition at line 145 of file format_sln.c.

struct ast_format_def slin192_f [static]

Definition at line 217 of file format_sln.c.

struct ast_format_def slin24_f [static]

Definition at line 157 of file format_sln.c.

struct ast_format_def slin32_f [static]

Definition at line 169 of file format_sln.c.

struct ast_format_def slin44_f [static]

Definition at line 181 of file format_sln.c.

struct ast_format_def slin48_f [static]

Definition at line 193 of file format_sln.c.

struct ast_format_def slin96_f [static]

Definition at line 205 of file format_sln.c.

struct ast_format_def slin_f [static]

Definition at line 121 of file format_sln.c.

struct ast_format_def* slin_list[] [static]

Definition at line 228 of file format_sln.c.


Generated on Thu Apr 16 06:31:07 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6