PARA_DEBUG_LOG("offset #%d: %zu\n", i, chunk_table[i]);
}
return 1;
-
}
long unsigned aac_set_chunk_tv(mp4AudioSpecificConfig *mp4ASC)
break;
case SI_STREAM_START:
if (sscanf(line + ilen + 1, "%lu.%lu", &sec, &usec) == 2) {
- struct timeval tmp, delay;
+ struct timeval a_start, delay;
delay.tv_sec = conf.stream_delay_arg / 1000;
delay.tv_usec = (conf.stream_delay_arg % 1000) * 1000;
stat_task->server_stream_start.tv_sec = sec;
stat_task->server_stream_start.tv_usec = usec;
if (stat_task->sa_time_diff_sign < 0)
tv_add(&stat_task->server_stream_start,
- &stat_task->sa_time_diff, &tmp);
+ &stat_task->sa_time_diff, &a_start);
else
tv_diff(&stat_task->server_stream_start,
- &stat_task->sa_time_diff, &tmp);
- tv_add(&tmp, &delay, &initial_delay_barrier);
+ &stat_task->sa_time_diff, &a_start);
+ tv_add(&a_start, &delay, &initial_delay_barrier);
}
break;
case SI_CURRENT_TIME:
}
for (i = conf.receiver_given - 1; i >= 0; i--) {
char *arg = conf.receiver_arg[i];
- char *recv = strchr(arg, ':');
+ char *recv_arg = strchr(arg, ':');
PARA_INFO_LOG("arg: %s\n", arg);
ret = -E_MISSING_COLON;
- if (!recv)
+ if (!recv_arg)
goto out;
- *recv = '\0';
- recv++;
+ *recv_arg = '\0';
+ recv_arg++;
ret = get_audio_format_num(arg);
if (ret < 0)
goto out;
- afi[ret].receiver_conf = check_receiver_arg(recv, &receiver_num);
+ afi[ret].receiver_conf = check_receiver_arg(recv_arg, &receiver_num);
if (!afi[ret].receiver_conf) {
ret = -E_RECV_SYNTAX;
goto out;
__malloc static char *decoder_flags(void)
{
int i;
- char decoder_flags[MAX_STREAM_SLOTS + 1];
+ char flags[MAX_STREAM_SLOTS + 1];
FOR_EACH_SLOT(i) {
struct slot_info *s = &slot[i];
flag += 1;
if (s->wng)
flag += 2;
- decoder_flags[i] = flag;
+ flags[i] = flag;
}
- decoder_flags[MAX_STREAM_SLOTS] = '\0';
+ flags[MAX_STREAM_SLOTS] = '\0';
return make_message("%s:%s\n", status_item_list[SI_DECODER_FLAGS],
- decoder_flags);
+ flags);
}
static int dump_commands(int fd)
static char **get_all_atts(int *num_atts)
{
int fd = client_cmd("laa");
- FILE *pipe;
+ FILE *f;
char **ret = NULL, *buf;
if (fd < 0)
return NULL;
- pipe = fdopen(fd, "r");
- if (!pipe) {
+ f = fdopen(fd, "r");
+ if (!f) {
close(fd);
return NULL;
}
*num_atts = 0;
buf = para_malloc(MAXLINE * sizeof(char));
- while (fgets(buf, MAXLINE - 1, pipe) && *buf) {
+ while (fgets(buf, MAXLINE - 1, f) && *buf) {
size_t n = strlen(buf);
buf[n - 1] = '\0';
if (choice_len < n - 1)
static int dccp_write(int fd, const char *buf, size_t len)
{
- size_t send, written = 0;
+ size_t size, written = 0;
int ret;
again:
- send = PARA_MIN(1024, len - written);
- ret = write(fd, buf + written, send);
+ size = PARA_MIN(1024, len - written);
+ ret = write(fd, buf + written, size);
if (ret < 0)
goto err_out;
written += ret;
* \sa select(2) select_tut(2)
*/
int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout)
+ struct timeval *timeout_tv)
{
int ret, err;
do {
- ret = select(n, readfds, writefds, NULL, timeout);
+ ret = select(n, readfds, writefds, NULL, timeout_tv);
err = errno;
} while (ret < 0 && err == EINTR);
if (ret < 0)
int file_exists(const char *);
int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout);
+ struct timeval *timeout_tv);
int mark_fd_nonblock(int fd);
void para_fd_set(int fd, fd_set *fds, int *max_fileno);
__must_check int para_fread(void *dest, size_t nbytes, size_t nmemb, FILE *stream);
static int check_gc_args(struct grab_client *gc)
{
int i;
- struct grab_client_args_info *conf = gc->conf;
+ struct grab_client_args_info *c = gc->conf;
char **mv = grab_client_cmdline_parser_mode_values;
- PARA_INFO_LOG("filter_num: %d\n", gc->conf->filter_num_arg);
+ PARA_INFO_LOG("filter_num: %d\n", c->filter_num_arg);
for (i = 0; mv[i]; i++)
- if (!strcmp(conf->mode_arg, mv[i]))
+ if (!strcmp(c->mode_arg, mv[i]))
break;
if (!mv[i])
return -E_GC_SYNTAX;
gc->mode = i;
gc->audio_format_num = -1;
- if (conf->audio_format_given) {
- gc->audio_format_num = get_audio_format_num(conf->audio_format_arg);
+ if (c->audio_format_given) {
+ gc->audio_format_num = get_audio_format_num(c->audio_format_arg);
if (gc->audio_format_num < 0)
return gc->audio_format_num;
}
- if (conf->slot_arg > MAX_STREAM_SLOTS)
+ if (c->slot_arg > MAX_STREAM_SLOTS)
return -E_BAD_GC_SLOT;
- if (conf->filter_num_arg <= 0)
+ if (c->filter_num_arg <= 0)
return -E_BAD_GC_FILTER_NUM;
- if (conf->audio_format_given) {
- if (num_filters(gc->audio_format_num) < conf->filter_num_arg)
+ if (c->audio_format_given) {
+ if (num_filters(gc->audio_format_num) < c->filter_num_arg)
return -E_BAD_GC_FILTER_NUM;
} else
- if (conf->filter_num_arg > max_num_filters())
+ if (c->filter_num_arg > max_num_filters())
return -E_BAD_GC_FILTER_NUM;
return 1;
* \sa filter_chain_info::filters, inactive_grab_client_list,
* activate_grab_client
*/
-void activate_inactive_grab_clients(int slot, int audio_format_num,
+void activate_inactive_grab_clients(int slot_num, int audio_format_num,
struct list_head *filter_list)
{
struct grab_client *gc, *tmp;
list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
// PARA_INFO_LOG("checking inactive grab client %p\n", gc);
- if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot)
+ if (gc->conf->slot_arg >= 0 && gc->conf->slot_arg != slot_num)
continue;
if (gc->audio_format_num >= 0 && gc->audio_format_num !=
audio_format_num)
{
struct rb_entry *rbe = NULL;
unsigned lines;
- int i, first_rbe, scroll;
+ int i, first_rbe, num_scroll;
/* the entry that is going to vanish */
rbe = ringbuffer_get(bot_win_rb, scroll_position);
if (!rbe)
goto err_out;
- scroll = NUM_LINES(rbe->len);
+ num_scroll = NUM_LINES(rbe->len);
first_rbe = first_visible_rbe(&lines);
if (first_rbe < 0 || (first_rbe == ringbuffer_filled(bot_win_rb) - 1))
goto err_out;
scroll_position++;
- wscrl(bot.win, -scroll);
+ wscrl(bot.win, -num_scroll);
i = draw_top_rbe(&lines);
if (i < 0)
goto err_out;
- while (i > 0 && lines < scroll) {
+ while (i > 0 && lines < num_scroll) {
int rbe_lines;
rbe = ringbuffer_get(bot_win_rb, --i);
if (!rbe)
continue;
if (hc->status == HTTP_READY_TO_STREAM) {
int hlen;
- char *buf = afs_get_header(&hlen);
- if (buf && hlen > 0 && current_chunk) {
+ char *hbuf = afs_get_header(&hlen);
+ if (hbuf && hlen > 0 && current_chunk) {
/* need to send header */
PARA_INFO_LOG("queueing header: %d\n", hlen);
- if (queue_packet(hc, buf, hlen) < 0)
+ if (queue_packet(hc, hbuf, hlen) < 0)
continue;
} else
PARA_INFO_LOG("%s", "no need to queue header\n");
tv_divide(fcount, &total_time, &af->chunk_tv);
rewind(mp3.file);
PARA_DEBUG_LOG("chunk_time: %lums\n", tv2ms(&af->chunk_tv));
- tv_scale(30, &af->chunk_tv, &af->eof_tv);
+ tv_scale(3, &af->chunk_tv, &af->eof_tv);
PARA_DEBUG_LOG("eof timeout: %lu\n", tv2ms(&af->eof_tv));
return 1;
}
* activate encryption for one file descriptor
*
* \param fd the file descriptor
- * \param recv the function used for decrypting received data
- * \param send the function used for encrypting before sending
+ * \param recv_f the function used for decrypting received data
+ * \param send_f the function used for encrypting before sending
* \param private_data user data supplied by the caller
*/
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
void *private_data)
{
if (fd + 1 > cda_size) {
(fd + 1 - cda_size) * sizeof(struct crypt_data));
cda_size = fd + 1;
}
- crypt_data_array[fd].recv = recv;
- crypt_data_array[fd].send = send;
+ crypt_data_array[fd].recv = recv_f;
+ crypt_data_array[fd].send = send_f;
crypt_data_array[fd].private_data = private_data;
PARA_INFO_LOG("rc4 encryption activated for fd %d\n", fd);
}
goto out;
ret = 1;
out:
- if (ret < 0)
- PARA_NOTICE_LOG("did not receive pattern '%s'\n", pattern);
+ if (ret < 0) {
+ PARA_NOTICE_LOG("n = %d, did not receive pattern '%s'\n", n, pattern);
+ if (n > 0)
+ PARA_NOTICE_LOG("recvd: %s\n", buf);
+ }
free(buf);
return ret;
}
ssize_t send_cred_buffer(int, char*);
int recv_pattern(int fd, const char *pattern, size_t bufsize);
int init_tcp_socket(int port);
-void enable_crypt(int fd, crypt_function *recv, crypt_function *send,
+void enable_crypt(int fd, crypt_function *recv_f, crypt_function *send_f,
void *private_data);
void disable_crypt(int fd);
static int header_len, oggbuf_len, vi_channels;
static char *header, *oggbuf;
static ssize_t *chunk_table, max_chunk_len;
-struct audio_format_handler *af;
+static struct audio_format_handler *af;
static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal,
num_chunks;
continue;
}
if (j < 0)
- tv_scale(i + 2, &af->chunk_tv, &af->eof_tv);
+ tv_scale(i, &af->chunk_tv, &af->eof_tv);
for (j = lp; j < i; j++)
chunk_table[j] = chunk_table[i];
lp = i;
oggbuf_len = 0;
}
-static int ogg_save_header(FILE *file, int header_len)
+static int ogg_save_header(FILE *file, int len)
{
int ret;
- header = para_malloc(header_len);
+ header = para_malloc(len);
rewind(file);
- ret = read(fileno(file), header, header_len);
- if (ret != header_len)
+ ret = read(fileno(file), header, len);
+ if (ret != len)
return -E_OGG_READ;
return 1;
}
static int ortp_recv_open(struct receiver_node *rn)
{
struct private_ortp_recv_data *pord;
- struct ortp_recv_args_info *conf = rn->conf;
+ struct ortp_recv_args_info *c = rn->conf;
rn->buf = para_calloc(CHUNK_SIZE);
rn->private_data = para_calloc(sizeof(struct private_ortp_recv_data));
pord = rn->private_data;
pord->session = rtp_session_new(RTP_SESSION_RECVONLY);
- PARA_NOTICE_LOG("receiving from %s:%d\n", conf->host_arg, conf->port_arg);
- rtp_session_set_local_addr(pord->session, conf->host_arg, conf->port_arg);
+ PARA_NOTICE_LOG("receiving from %s:%d\n", c->host_arg, c->port_arg);
+ rtp_session_set_local_addr(pord->session, c->host_arg, c->port_arg);
rtp_session_set_payload_type(pord->session, PAYLOAD_AUDIO_CONTINUOUS);
- if (conf->jitter_compensation_arg) {
+ if (c->jitter_compensation_arg) {
rtp_session_enable_adaptive_jitter_compensation(pord->session, TRUE);
rtp_session_set_jitter_compensation(pord->session,
- conf->jitter_compensation_arg);
+ c->jitter_compensation_arg);
}
return 1;
}
void d2tv(double, struct timeval*);
void tv_add(const struct timeval*, const struct timeval *, struct timeval *);
void tv_scale(const unsigned long, const struct timeval *, struct timeval *);
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
struct timeval *result);
int tv_convex_combination(const long a, const struct timeval *tv1,
const long b, const struct timeval *tv2,
*/
static int command_handler(void)
{
- FILE *pipe;
+ FILE *f;
unsigned count = 0;
char text[MAXLINE]="";
char buf[MAXLINE]="";
if (text[0] == '!') {
if (text[1] == '\0')
return 1;
- pipe = popen(text + 1, "r");
+ f = popen(text + 1, "r");
} else {
sprintf(buf, BINDIR "/para_client %s 2>&1", text);
- pipe = popen(buf, "r");
+ f = popen(buf, "r");
}
- if (!pipe)
+ if (!f)
return 0;
fill_output_rect();
- while(fgets(text, MAXLINE - 1, pipe)) {
+ while(fgets(text, MAXLINE - 1, f)) {
int len;
tab2space(text);
update_all();
hit_key("Hit any key to return");
out: fill_output_rect();
- pclose(pipe);
+ pclose(f);
return 1;
}
SDL_RWops *rwop;
int fds[3] = {0, 1, 0};
pid_t pid;
- FILE *pipe;
+ FILE *f;
if (para_exec_cmdline_pid(&pid, args_info.pic_cmd_arg, fds) < 0)
return NULL;
- pipe = fdopen(fds[1], "r");
- if (!pipe)
+ f = fdopen(fds[1], "r");
+ if (!f)
return NULL;
- if (!(rwop = SDL_RWFromFP(pipe, 0)))
+ if (!(rwop = SDL_RWFromFP(f, 0)))
return NULL;
return IMG_LoadJPG_RW(rwop);
}
* Read stat line from pipe if pipe is ready, call update_status to
* display information.
*/
-static int draw_status(int pipe)
+static int draw_status(int fd)
{
fd_set rfds;
int ret;
tv.tv_sec = 0;
tv.tv_usec = 3000000;
FD_ZERO(&rfds);
- FD_SET(pipe, &rfds);
- ret = para_select(pipe + 1, &rfds, NULL, &tv);
+ FD_SET(fd, &rfds);
+ ret = para_select(fd + 1, &rfds, NULL, &tv);
if (ret <= 0)
return 0;
- if (read_audiod_pipe(pipe, update_status) > 0)
+ if (read_audiod_pipe(fd, update_status) > 0)
return 1;
free(stat_items[SI_STATUS_BAR].content);
stat_items[SI_STATUS_BAR].content =
*/
int main(int argc, char *argv[])
{
- int i, ret, pipe;
+ int i, ret, fd;
SDLKey sym;
sdl_gui_cmdline_parser(argc, argv, &args_info);
height = args_info.height_arg;
// printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg);
init_stat_items();
- pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+ fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
init_SDL();
for (i = 0; fonts[i].name[0]; i++) {
char buf[MAXLINE];
update_input();
}
for (;;) {
- ret = draw_status(pipe);
+ ret = draw_status(fd);
if (ret < 0) {
- close(pipe);
- pipe = -1;
+ close(fd);
+ fd = -1;
}
if (SDL_QuitRequested())
clean_exit(0);
|| sym == SDLK_COMPOSE
)
continue;
- if (pipe < 0) {
-// printf("closing pipe\n");
- kill(0, SIGINT);
- close(pipe);
-// printf("pipe closed\n");
+ if (fd < 0) {
+ kill(0, SIGINT);
+ close(fd);
}
fill_input_rect();
update_input();
print_help();
update_pic();
SDL_UpdateRect(screen, 0, 0, 0, 0);
- pipe = para_open_audiod_pipe(args_info.stat_cmd_arg);
+ fd = para_open_audiod_pipe(args_info.stat_cmd_arg);
break;
}
}
/**
* compute fraction of given struct timeval
*
- * \param div the integer value to divide by
+ * \param divider the integer value to divide by
* \param tv the timevalue to divide
* \param result holds (1 / mult) * tv upon return
*/
-void tv_divide(const unsigned long div, const struct timeval *tv,
+void tv_divide(const unsigned long divisor, const struct timeval *tv,
struct timeval *result)
{
- long unsigned q = tv->tv_usec / div;
- result->tv_sec = tv->tv_sec / div;
- result->tv_usec = (tv->tv_sec - result->tv_sec * div) * 1000 * 1000 / div;
+ long unsigned q = tv->tv_usec / divisor;
+ result->tv_sec = tv->tv_sec / divisor;
+ result->tv_usec = (tv->tv_sec - result->tv_sec * divisor)
+ * 1000 * 1000 / divisor;
if (result->tv_usec + q >= 1000 * 1000) {
result->tv_sec++;
result->tv_usec = 1000 * 1000 - result->tv_usec - q;
*/
static void check_wav_pre_select(__a_unused struct sched *s, struct task *t)
{
- struct check_wav_task *cwt = t->private_data;
+ struct check_wav_task *wt = t->private_data;
unsigned char *a;
- if (*cwt->loaded < WAV_HEADER_LEN) {
- t->ret = *cwt->eof? -E_PREMATURE_END : 1;
+ if (*wt->loaded < WAV_HEADER_LEN) {
+ t->ret = *wt->eof? -E_PREMATURE_END : 1;
return;
}
- cwt->channels = 2;
- cwt->samplerate = 44100;
- a = (unsigned char*)cwt->buf;
+ wt->channels = 2;
+ wt->samplerate = 44100;
+ a = (unsigned char*)wt->buf;
t->ret = -E_NO_WAV_HEADER;
if (a[0] != 'R' || a[1] != 'I' || a[2] != 'F' || a[3] != 'F')
return;
- cwt->channels = (unsigned) a[22];
- cwt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
- *cwt->loaded -= WAV_HEADER_LEN;
- memmove(cwt->buf, cwt->buf + WAV_HEADER_LEN, *cwt->loaded);
+ wt->channels = (unsigned) a[22];
+ wt->samplerate = a[24] + (a[25] << 8) + (a[26] << 16) + (a[27] << 24);
+ *wt->loaded -= WAV_HEADER_LEN;
+ memmove(wt->buf, wt->buf + WAV_HEADER_LEN, *wt->loaded);
t->ret = -E_WAV_HEADER_SUCCESS;
- PARA_INFO_LOG("channels: %d, sample rate: %d\n", cwt->channels, cwt->samplerate);
+ PARA_INFO_LOG("channels: %d, sample rate: %d\n", wt->channels, wt->samplerate);
}
static void initial_delay_pre_select(struct sched *s, struct task *t)
{
- struct initial_delay_task *idt = t->private_data;
+ struct initial_delay_task *dt = t->private_data;
struct timeval diff;
t->ret = -E_NO_DELAY;
- if (!idt->start_time.tv_sec && !idt->start_time.tv_usec)
+ if (!dt->start_time.tv_sec && !dt->start_time.tv_usec)
return;
t->ret = -E_DELAY_TIMEOUT;
- if (tv_diff(now, &idt->start_time, &diff) > 0)
+ if (tv_diff(now, &dt->start_time, &diff) > 0)
return;
t->ret = 1;
if (tv_diff(&s->timeout , &diff, NULL) > 0)
static struct writer_node_group *check_args(void)
{
int i, ret = -E_WRITE_SYNTAX;
- struct writer_node_group *wng = NULL;
+ struct writer_node_group *g = NULL;
if (conf.list_writers_given) {
char *msg = NULL;
free(msg);
exit(EXIT_SUCCESS);
}
-// if (conf.prebuffer_arg < 0 || conf.prebuffer_arg > 100)
-// goto out;
if (conf.start_time_given) {
long unsigned sec, usec;
if (sscanf(conf.start_time_arg, "%lu:%lu",
idt.start_time.tv_usec = usec;
}
if (!conf.writer_given) {
- wng = setup_default_wng();
+ g = setup_default_wng();
ret = 1;
goto out;
}
- wng = wng_new(conf.writer_given);
+ g = wng_new(conf.writer_given);
ret = -E_WRITE_SYNTAX;
for (i = 0; i < conf.writer_given; i++) {
int writer_num;
- wng->writer_nodes[i].conf = check_writer_arg(
+ g->writer_nodes[i].conf = check_writer_arg(
conf.writer_arg[i], &writer_num);
- if (!wng->writer_nodes[i].conf)
+ if (!g->writer_nodes[i].conf)
goto out;
- wng->writer_nodes[i].writer = &writers[writer_num];
+ g->writer_nodes[i].writer = &writers[writer_num];
}
ret = 1;
out:
if (ret > 0)
- return wng;
- free(wng);
+ return g;
+ free(g);
return NULL;
}