[Freeswitch-svn] [commit] r7973 - in freeswitch/trunk/src: . include
Freeswitch SVN
anthm at freeswitch.org
Thu Mar 27 18:22:46 EDT 2008
Author: anthm
Date: Thu Mar 27 18:22:46 2008
New Revision: 7973
Modified:
freeswitch/trunk/src/include/switch_loadable_module.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/switch_core_codec.c
freeswitch/trunk/src/switch_core_io.c
Log:
fix some stuff
Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h (original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h Thu Mar 27 18:22:46 2008
@@ -306,11 +306,14 @@
break; \
}
+SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void);
+
#define SWITCH_ADD_CODEC(codec_int, int_name) \
for (;;) { \
- codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
- codec_int->interface_name = switch_core_strdup(pool, int_name); \
- break; \
+ codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
+ codec_int->interface_name = switch_core_strdup(pool, int_name); \
+ codec_int->codec_id = switch_core_codec_next_id(); \
+ break; \
}
@@ -373,7 +376,7 @@
impl->encode = encode;
impl->decode = decode;
impl->destroy = destroy;
-
+ impl->codec_id = codec_interface->codec_id;
impl->next = codec_interface->implementations;
codec_interface->implementations = impl;
}
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Thu Mar 27 18:22:46 2008
@@ -560,6 +560,7 @@
switch_core_codec_decode_func_t decode;
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy;
+ uint32_t codec_id;
struct switch_codec_implementation *next;
};
@@ -569,6 +570,7 @@
const char *interface_name;
/*! a list of codec implementations related to the codec */
switch_codec_implementation_t *implementations;
+ uint32_t codec_id;
struct switch_codec_interface *next;
};
Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c (original)
+++ freeswitch/trunk/src/switch_core_codec.c Thu Mar 27 18:22:46 2008
@@ -35,6 +35,14 @@
#include <switch.h>
#include "private/switch_core_pvt.h"
+static uint32_t CODEC_ID = 0;
+
+SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void)
+{
+ return CODEC_ID++;
+}
+
+
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
{
switch_event_t *event;
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Mar 27 18:22:46 2008
@@ -323,7 +323,6 @@
}
if (session->read_codec) {
-
if (session->read_resampler) {
short *data = read_frame->data;
switch_mutex_lock(session->resample_mutex);
@@ -353,6 +352,7 @@
goto done;
}
}
+
if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->bytes_per_frame) {
if (perfect) {
@@ -484,7 +484,7 @@
switch_status_t status = SWITCH_STATUS_FALSE;
switch_frame_t *enc_frame = NULL, *write_frame = frame;
- unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0, do_resample = 0;
+ unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0, do_resample = 0, ptime_mismatch = 0;
switch_io_flag_t io_flag = SWITCH_IO_FLAG_NOOP;
switch_assert(session != NULL);
@@ -514,6 +514,9 @@
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
need_codec = TRUE;
+ if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
+ ptime_mismatch = TRUE;
+ }
}
if (session->write_codec && !frame->codec) {
@@ -525,13 +528,13 @@
}
if (session->bugs && !need_codec) {
- do_bugs = 1;
- need_codec = 1;
+ do_bugs = TRUE;
+ need_codec = TRUE;
}
if (frame->codec->implementation->actual_samples_per_second != session->write_codec->implementation->actual_samples_per_second) {
- need_codec = 1;
- do_resample = 1;
+ need_codec = TRUE;
+ do_resample = TRUE;
}
if (need_codec) {
@@ -671,7 +674,7 @@
}
if (do_bugs) {
- do_write = 1;
+ do_write = TRUE;
write_frame = frame;
goto done;
}
@@ -768,7 +771,7 @@
} else {
rate = session->write_codec->implementation->actual_samples_per_second;
}
-
+
status = switch_core_codec_encode(session->write_codec,
frame->codec,
enc_frame->data,
@@ -776,7 +779,6 @@
rate,
session->enc_write_frame.data,
&session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
-
switch (status) {
case SWITCH_STATUS_RESAMPLE:
session->enc_write_frame.codec = session->write_codec;
@@ -804,10 +806,12 @@
case SWITCH_STATUS_SUCCESS:
session->enc_write_frame.codec = session->write_codec;
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
- session->enc_write_frame.timestamp = frame->timestamp;
+ if (!ptime_mismatch) {
+ session->enc_write_frame.timestamp = frame->timestamp;
+ session->enc_write_frame.seq = frame->seq;
+ }
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
- session->enc_write_frame.seq = frame->seq;
session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
write_frame = &session->enc_write_frame;
break;
@@ -855,6 +859,7 @@
if (flag & SFF_CNG) {
switch_set_flag(write_frame, SFF_CNG);
}
+
if ((status = perform_write(session, write_frame, timeout, io_flag, stream_id)) != SWITCH_STATUS_SUCCESS) {
break;
}
@@ -865,7 +870,7 @@
}
}
} else {
- do_write = 1;
+ do_write = TRUE;
}
done:
More information about the Freeswitch-svn
mailing list