char file[1024];
switch_set_string(file, path);
-
+
+ if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
+ return SWITCH_STATUS_FALSE;
+ }
+
if ((ext = strrchr((char *)path, '.')) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
return SWITCH_STATUS_GENERR;
} else if (handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "youtube"))) {
format = "flv";
- handle->samplerate = 44100;
switch_snprintf(file, sizeof(file), "rtmp://%s", path);
}
flags |= SWITCH_FOPEN_READ;
}
- switch_buffer_create_dynamic(&context->audio_buffer, 512, 512, 1024000);
+ switch_buffer_create_dynamic(&context->audio_buffer, 512, 512, 0);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sample rate: %d, channels: %d\n", handle->samplerate, handle->channels);
avformat_network_init();
}
+ if (handle->mm.samplerate) {
+ handle->mm.samplerate = handle->samplerate;
+ }
+
+ if (!handle->mm.ab) {
+ handle->mm.ab = 128;
+ }
+
if (fmt->video_codec != AV_CODEC_ID_NONE) {
const AVCodecDescriptor *desc;
}
+
handle->mm.samplerate = 44100;
handle->mm.ab = 128;
//inuse = switch_buffer_inuse(context->audio_buffer);
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "inuse: %d samples: %d bytes: %d\n", inuse, context->audio_st.frame->nb_samples, bytes);
- while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes) {
+ while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes * 5) {
AVPacket pkt = { 0 };
int got_packet = 0;
int ret;
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
}
+
+ break;
}