SWITCH_MODULE_DEFINITION(mod_fsv, mod_fsv_load, NULL, NULL);
#define VID_BIT (1 << 31)
-#define VERSION 4201
+#define VERSION 4202
struct file_header {
int32_t version;
uint32_t audio_rate;
uint32_t audio_ptime;
switch_time_t created;
+ int channels;
};
struct record_helper {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
switch_frame_t *read_frame;
- int bytes;
-
+ int bytes, j = 0;
+
while (switch_channel_ready(channel)) {
status = switch_core_session_read_video_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
continue;
}
+ if (j < 240 && (++j % 60) == 0) {
+ switch_core_session_request_video_refresh(session);
+ }
+
bytes = read_frame->packetlen | VID_BIT;
switch_mutex_lock(eh->mutex);
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
} else {
if (switch_channel_test_flag(channel, CF_VIDEO)) {
struct file_header h;
memset(&h, 0, sizeof(h));
+
vid_codec = switch_core_session_get_video_read_codec(session);
h.version = VERSION;
}
h.audio_rate = read_impl.samples_per_second;
h.audio_ptime = read_impl.microseconds_per_packet / 1000;
+ h.channels = read_impl.number_of_channels;
if (write(fd, &h, sizeof(h)) != sizeof(h)) {
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "File write failed");
eh.mutex = mutex;
eh.fd = fd;
switch_core_media_start_engine_function(session, SWITCH_MEDIA_TYPE_VIDEO, record_video_thread, &eh);
+ switch_core_session_request_video_refresh(session);
}
goto end;
}
+ if (!h.channels) h.channels = 1;
+
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
h.audio_rate,
h.audio_ptime,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ h.channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
} else {