51 #define LOCAL_MPG_123 "/usr/local/bin/mpg123"
52 #define MPG_123 "/usr/bin/mpg123"
77 static char *
app =
"MP3Player";
79 static int mp3play(
const char *filename,
int fd)
92 dup2(fd, STDOUT_FILENO);
96 if (!strncasecmp(filename,
"http://", 7)) {
98 execl(
LOCAL_MPG_123,
"mpg123",
"-q",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
100 execl(
MPG_123,
"mpg123",
"-q",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
102 execlp(
"mpg123",
"mpg123",
"-q",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
104 else if (strstr(filename,
".m3u")) {
106 execl(
LOCAL_MPG_123,
"mpg123",
"-q",
"-z",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000",
"-@", filename, (
char *)NULL);
108 execl(
MPG_123,
"mpg123",
"-q",
"-z",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000",
"-@", filename, (
char *)NULL);
110 execlp(
"mpg123",
"mpg123",
"-q",
"-z",
"-s",
"-b",
"1024",
"-f",
"8192",
"--mono",
"-r",
"8000",
"-@", filename, (
char *)NULL);
114 execl(
MPG_123,
"mpg123",
"-q",
"-s",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
116 execl(
LOCAL_MPG_123,
"mpg123",
"-q",
"-s",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
118 execlp(
"mpg123",
"mpg123",
"-q",
"-s",
"-f",
"8192",
"--mono",
"-r",
"8000", filename, (
char *)NULL);
121 fprintf(stderr,
"Execute of mpg123 failed\n");
125 static int timed_read(
int fd,
void *data,
int datalen,
int timeout)
128 struct pollfd fds[1];
130 fds[0].events = POLLIN;
136 return read(fd, data, datalen);
178 if (!strncasecmp(data,
"http://", 7)) {
191 res =
timed_read(fds[0], myf.frdata,
sizeof(myf.frdata), timeout);
196 myf.f.samples = res / 2;
199 myf.f.src = __PRETTY_FUNCTION__;
200 myf.f.delivery.tv_sec = 0;
201 myf.f.delivery.tv_usec = 0;
202 myf.f.data.ptr = myf.frdata;
223 ast_debug(1,
"Null frame == hangup() detected\n");
243 if (!res && owriteformat)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
Support for translation of data formats. translate.c.
static int timed_read(int fd, void *data, int datalen, int timeout)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int unload_module(void)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_poll(a, b, c)
Asterisk internal frame definitions.
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Core PBX routines and definitions.
int ast_set_priority(int)
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy ac...
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
static int mp3play(const char *filename, int fd)
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
static int load_module(void)
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
static int mp3_exec(struct ast_channel *chan, const char *data)
Asterisk module definitions.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_opt_high_priority