{
av_file_context_t *context = (av_file_context_t *)handle->private_info;
int size;
+ size_t need = *len * 2 * context->audio_st.channels;
if (!context->has_audio && context->has_video && switch_queue_size(context->eh.video_queue) > 0) {
memset(data, 0, *len * handle->channels * 2);
return SWITCH_STATUS_SUCCESS;
}
-again:
-
if (!context->file_read_thread_running && switch_buffer_inuse(context->audio_buffer) == 0) {
*len = 0;
return SWITCH_STATUS_FALSE;
switch_mutex_unlock(context->mutex);
if (size == 0) {
- switch_yield(20000);
- goto again;
+ size_t blank = (handle->samplerate / 20) * 2 * handle->real_channels;
+
+ if (need > blank) {
+ need = blank;
+ }
+ memset(data, 0, need);
+ *len = need / 2 / handle->real_channels;
+ } else {
+ *len = size / context->audio_st.channels / 2;
}
- *len = size / context->audio_st.channels / 2;
-
handle->pos += *len;
handle->sample_count += *len;
int ticks = 0;
int max_delta = 1 * AV_TIME_BASE; // 1 second
switch_status_t status = SWITCH_STATUS_SUCCESS;
-
+
if (!context->has_video) return SWITCH_STATUS_FALSE;
if ((flags & SVR_CHECK)) {
st->start_time, st->duration, st->nb_frames, av_q2d(st->time_base));
}
-again: if (0) goto again;
+ again:
if (flags & SVR_BLOCK) {
status = switch_queue_pop(context->eh.video_queue, &pop);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "picture is too late, off: %" SWITCH_INT64_T_FMT " queue size:%u\n", (int64_t)(switch_micro_time_now() - mst->next_pts), switch_queue_size(context->eh.video_queue));
switch_img_free(&img);
+
if (switch_queue_size(context->eh.video_queue) > 0) {
goto again;
} else {
+ mst->next_pts = 0;
return SWITCH_STATUS_BREAK;
}
}
int sent_png;
int last_w;
int last_h;
+ int serno;
switch_image_t *banner_img;
switch_time_t banner_timeout;
struct local_stream_context *next;
switch_image_t *blank_img;
switch_image_t *cover_art;
char *banner_txt;
+ int serno;
};
typedef struct local_stream_source local_stream_source_t;
source->cover_art = switch_img_read_png(png_buf, SWITCH_IMG_FMT_I420);
}
}
-
+
+ source->serno++;
switch_safe_free(source->banner_txt);
title = artist = NULL;
switch_core_timer_next(&timer);
olen = source->samples;
-
+
if (source->chime_total) {
if (source->chime_counter > 0) {
}
}
- retry:
+ retry:
source->has_video = switch_core_file_has_video(use_fh) || source->cover_art || source->banner_txt;
if (switch_core_has_video() && switch_core_file_has_video(use_fh)) {
switch_frame_t vid_frame = { 0 };
+ if (use_fh == &source->chime_fh && switch_core_file_has_video(&fh)) {
+ if (switch_core_file_read_video(&fh, &vid_frame, SVR_FLUSH) == SWITCH_STATUS_SUCCESS) {
+ switch_img_free(&vid_frame.img);
+ }
+ }
+
if (switch_core_file_read_video(use_fh, &vid_frame, SVR_FLUSH) == SWITCH_STATUS_SUCCESS) {
if (vid_frame.img) {
source->has_video = 1;
source->has_video = 0;
}
+ if (use_fh == &source->chime_fh) {
+ olen = source->samples;
+ switch_core_file_read(&fh, abuf, &olen);
+ olen = source->samples;
+ }
+
if (switch_core_file_read(use_fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
switch_core_file_close(use_fh);
flush_video_queue(source->video_q);
if (use_fh == &source->chime_fh) {
source->chime_counter = source->rate * source->chime_freq;
+ use_fh = &fh;
+ } else {
+ is_open = 0;
}
- is_open = 0;
} else {
if (use_fh == &source->chime_fh && source->chime_max) {
source->chime_max_counter += (int32_t)source->samples;
}
}
+ if (context->serno != context->source->serno) {
+ switch_img_free(&context->banner_img);
+ context->banner_timeout = 0;
+ context->serno = context->source->serno;
+ }
+
if (context->source->banner_txt) {
if ((!context->banner_timeout || context->banner_timeout >= now)) {
if (!context->banner_img) {