layout_group_t *lg = NULL;
switch_image_t *write_img = NULL, *file_img = NULL;
uint32_t timestamp = 0;
- switch_timer_t file_timer = { 0 };
if (conference->video_layout_group) {
lg = switch_core_hash_find(conference->layout_group_hash, conference->video_layout_group);
conference->video_timer_reset = 1;
packet = switch_core_alloc(conference->pool, SWITCH_RECOMMENDED_BUFFER_SIZE);
- switch_core_timer_init(&file_timer, "soft", 1, 90, NULL);
while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT) && switch_test_flag(conference, CFLAG_VIDEO_MUXING)) {
switch_bool_t need_refresh = SWITCH_FALSE, need_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
if (conference->canvas->play_file) {
conference->canvas->reset_video = 1;
conference->canvas->play_file = 0;
-
- //if (file_timer.interval) {
- // switch_core_timer_destroy(&file_timer);
- //}
-
+
conference->canvas->timer.interval = 1;
conference->canvas->timer.samples = 90;
}
write_img = file_img = write_frame.img;
- //switch_core_timer_sync(&file_timer);
- //timestamp = file_timer.samplecount;
+
switch_core_timer_sync(&conference->canvas->timer);
timestamp = conference->canvas->timer.samplecount;
}
switch_core_timer_destroy(&conference->canvas->timer);
- if (file_timer.interval) {
- switch_core_timer_destroy(&file_timer);
- }
-
destroy_canvas(&conference->canvas);
return NULL;
flags = SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT;
if (conference->members_with_video && switch_test_flag(conference, CFLAG_TRANSCODE_VIDEO)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Vido FLAG\n");
flags |= SWITCH_FILE_FLAG_VIDEO;
}
/* Open the file */
fnode->fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
- if (switch_core_file_open(&fnode->fh, file, channels, conference->rate, flags, pool) !=
- SWITCH_STATUS_SUCCESS) {
+ if (switch_core_file_open(&fnode->fh, file, channels, conference->rate, flags, pool) != SWITCH_STATUS_SUCCESS) {
switch_event_t *event;
if (test_eflag(conference, EFLAG_PLAY_FILE) &&
static void vlc_mediaplayer_av_error_callback(const libvlc_event_t * event, void * data)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) data;
- vlc_video_context_t *vcontext = acontext->vcontext;
+ vlc_file_context_t *acontext = data;
+ vlc_video_context_t *vcontext = NULL;
+ int status;
- int status = libvlc_media_get_state(vcontext->m);
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return;
+ }
+ }
+
+ status = libvlc_media_get_state(vcontext->m);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Got a libvlc_MediaPlayerEncounteredError callback. mediaPlayer Status: %d\n", status);
if (status == libvlc_Error) {
}
static void vlc_media_av_state_callback(const libvlc_event_t * event, void * data)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) data;
- vlc_video_context_t *vcontext = acontext->vcontext;
int new_state = event->u.media_state_changed.new_state;
-
+ vlc_file_context_t *acontext = data;
+ vlc_video_context_t *vcontext = NULL;
+
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return;
+ }
+ }
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Got a libvlc_MediaStateChanged callback. New state: %d\n", new_state);
if (new_state == libvlc_Ended || new_state == libvlc_Error || new_state == 6) {
vcontext->err = 1;
void vlc_file_play_audio_callback(void *data, const void *samples, unsigned count, int64_t pts) {
- vlc_file_context_t *acontext = (vlc_file_context_t *) data;
- vlc_video_context_t *vcontext = acontext->vcontext;
-
+ vlc_file_context_t *acontext = data;
+ vlc_video_context_t *vcontext = NULL;
switch_size_t bytes;
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return;
+ }
+ }
+
switch_mutex_lock(vcontext->audio_mutex);
bytes = switch_buffer_inuse(vcontext->audio_buffer);
static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image_t *img)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
- switch_memory_pool_t *pool = acontext->pool;
+ switch_memory_pool_t *pool;
int64_t pts = 0;
char *imem_main, *imem_slave;
unsigned char audio_data_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
switch_size_t audio_datalen;
uint32_t offset = 500;
const char *tmp;
+ vlc_file_context_t *acontext = handle->private_info;
const char * opts[25] = {
*vlc_args,
switch_core_sprintf(acontext->pool, "--sout=%s", acontext->path)
};
int argc = 2;
+ vlc_video_context_t *vcontext;
+
+
+ vcontext = acontext->vcontext;
+ pool = acontext->pool;
+
+
vcontext = switch_core_alloc(acontext->pool, sizeof(vlc_video_context_t));
static switch_status_t vlc_file_av_open(switch_file_handle_t *handle, const char *path)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) handle->private_info;
- vlc_video_context_t *vcontext;
libvlc_event_manager_t *mp_event_manager, *m_event_manager;
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext;
+
+ if (acontext) {
+ vcontext = acontext->vcontext;
+ }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC open %s for reading\n", acontext->path);
vlc_file_context_t *context;
libvlc_event_manager_t *mp_event_manager, *m_event_manager;
char *ext = NULL;
+ switch_file_t *fd = NULL;
+ const char *realpath = NULL;
context = switch_core_alloc(handle->memory_pool, sizeof(*context));
context->pool = handle->memory_pool;
context->vlc_handle = libvlc_new(sizeof(vlc_args)/sizeof(char *), vlc_args);
+ realpath = path;
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) &&
(ext = strrchr(path, '.')) && !strcasecmp(ext, ".mp4")) {
+ realpath = path;
path = switch_core_sprintf(context->pool, "#transcode{vcodec=h264,acodec=mp3}:std{access=file,mux=mp4,dst=%s}", path);
}
context->path = switch_core_strdup(context->pool, path);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC attempt to open %s %s %s %s\n",
+ context->path, switch_test_flag(handle, SWITCH_FILE_FLAG_READ) ? "read" : "",
+ switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) ? "write" : "",
+ switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) ? "video" : ""
+ );
+
if (!switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_buffer_create_dynamic(&(context->audio_buffer), VLC_BUFFER_SIZE, VLC_BUFFER_SIZE * 8, 0);
context->pts = 0;
}
+ if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
+ if (switch_file_open(&fd, realpath, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
+ SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) == SWITCH_STATUS_SUCCESS) {
+ switch_file_close(fd);
+ } else {
+ return SWITCH_STATUS_GENERR;
+ }
+ }
+
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t vlc_file_av_read(switch_file_handle_t *handle, void *data, size_t *len)
{
- vlc_file_context_t *acontext = handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
-
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext = NULL;
size_t bytes = *len * sizeof(int16_t) * handle->channels, read;
libvlc_state_t status;
+
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
if (vcontext->err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC ended\n");
return SWITCH_STATUS_GENERR;
static switch_status_t vlc_file_read_video(switch_file_handle_t *handle, switch_frame_t *frame)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
void *pop;
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext = NULL;
+
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return SWITCH_STATUS_FALSE;
+ }
+ }
if (vcontext->err) {
return SWITCH_STATUS_FALSE;
static switch_status_t vlc_file_write_video(switch_file_handle_t *handle, switch_frame_t *frame)
{
- vlc_file_context_t *acontext = (vlc_file_context_t *) handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext = NULL;
+
+ if (acontext) {
+ vcontext = acontext->vcontext;
+ }
if (vcontext && vcontext->err) {
return SWITCH_STATUS_FALSE;
static switch_status_t vlc_file_av_write(switch_file_handle_t *handle, void *data, size_t *len)
{
- vlc_file_context_t *acontext = handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
size_t bytes = *len * sizeof(int16_t) * handle->channels;
int64_t pts;
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext = NULL;
+
+ if (acontext) {
+ vcontext = acontext->vcontext;
+ }
if (!vcontext) {
return SWITCH_STATUS_SUCCESS;
static switch_status_t vlc_file_av_close(switch_file_handle_t *handle)
{
- vlc_file_context_t *acontext = handle->private_info;
- vlc_video_context_t *vcontext = acontext->vcontext;
+ vlc_file_context_t *acontext = handle->private_info;
+ vlc_video_context_t *vcontext = NULL;
+ if (acontext) {
+ if (!(vcontext = acontext->vcontext)) {
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
vcontext->ending = 1;
if (vcontext && vcontext->video_queue) {
vlc_file_supported_formats[0] = "vlc";
vlc_file_supported_formats[1] = "mp4"; /* maybe add config for this mod to enable or disable */
- vlc_file_supported_formats[1] = "mov"; /* maybe add config for this mod to enable or disable */
+ vlc_file_supported_formats[2] = "mov"; /* maybe add config for this mod to enable or disable */
file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
file_interface->interface_name = modname;