#include <switch.h>
-#define MAX_CORE_THREAD_SESSION_OBJS 128
+#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
+#define SWITCH_MAX_STREAMS 128
/*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
struct switch_core_thread_session {
/*! status of the thread */
int running;
/*! array of void pointers to pass mutiple data objects */
- void *objs[MAX_CORE_THREAD_SESSION_OBJS];
+ void *objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS];
/*! a pointer to a memory pool if the thread has it's own pool */
switch_memory_pool *pool;
};
*/
SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_session *session, void *private);
+/*!
+ \brief Add a logical stream to a session
+ \param session the session to add the stream to
+ \param private an optional pointer to private data for the new stream
+ \return the stream id of the new stream
+ */
+SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private);
+
+/*!
+ \brief Retreive a logical stream from a session
+ \param session the session to add the stream to
+ \param index the index to retrieve
+ \return the private data (if any)
+ */
+SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index);
+
+/*!
+ \brief Determine the number of logical streams a session has
+ \param session the session to query
+ \return the total number of logical streams
+ */
+SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session);
+
/*!
\brief Launch a thread designed to exist within the scope of a given session
\param session a session to allocate the thread from
/*!
\brief Launch a service thread on a session to drop inbound data
\param session the session the launch thread on
+ \param stream_id which logical media channel to use
\param thread_session the thread_session to use
*/
-SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session);
+SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session, int stream_id);
/*!
\brief Request an outgoing session spawned from an existing session using a desired endpoing module
\param session the session to read from
\param frame a NULL pointer to a frame to aim at the newly read frame
\param timeout number of milliseconds to wait for data
+ \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a the frame was read
*/
-SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout);
+SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout, int stream_id);
/*!
\brief Write a frame to a session
\param session the session to write to
\param frame the frame to write
\param timeout number of milliseconds to wait for data
+ \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS a the frame was written
*/
-SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout);
+SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout, int stream_id);
/*!
\brief Send a signal to a channel
\brief Wait for a session to be ready for input
\param session session to wait for
\param timeout number of milliseconds to wait for data
+ \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS if data is available for read within timeframe specified
*/
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout);
+SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout, int stream_id);
/*!
\brief Wait for a session to be ready for output
\param session session to wait for
\param timeout number of milliseconds to wait for data
+ \param stream_id which logical media channel to use
\return SWITCH_STATUS_SUCCESS if the session is available for write within timeframe specified
*/
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout);
+SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout, int stream_id);
/*!
\brief Send DTMF to a session
/*! answers the given session's channel */
switch_status (*answer_channel)(switch_core_session *);
/*! read a frame from a session */
- switch_status (*read_frame)(switch_core_session *, switch_frame **, int, switch_io_flag);
+ switch_status (*read_frame)(switch_core_session *, switch_frame **, int, switch_io_flag, int);
/*! write a frame to a session */
- switch_status (*write_frame)(switch_core_session *, switch_frame *, int, switch_io_flag);
+ switch_status (*write_frame)(switch_core_session *, switch_frame *, int, switch_io_flag, int);
/*! send a kill signal to the session's channel */
switch_status (*kill_channel)(switch_core_session *, int);
/*! wait for the session's channel to be ready to read audio */
- switch_status (*waitfor_read)(switch_core_session *, int);
+ switch_status (*waitfor_read)(switch_core_session *, int, int);
/*! wait for the session's channel to be ready to write audio */
- switch_status (*waitfor_write)(switch_core_session *, int);
+ switch_status (*waitfor_write)(switch_core_session *, int, int);
/*! send a string of DTMF digits to a session's channel */
switch_status (*send_dtmf)(switch_core_session *, char *);
};
SWITCH_FILE_DATA_INT = (1 << 4) - Read data in ints
SWITCH_FILE_DATA_FLOAT = (1 << 5) - Read data in floats
SWITCH_FILE_DATA_DOUBLE = (1 << 6) - Read data in doubles
-SWITCH_FILE_DATA_RAW = (1 << 7) - Read data asis
+SWITCH_FILE_DATA_RAW = (1 << 7) - Read data as is
</pre>
*/
typedef enum {
typedef switch_status (*switch_event_handler)(switch_core_session *);
typedef switch_status (*switch_outgoing_channel_hook)(switch_core_session *, switch_caller_profile *, switch_core_session *);
typedef switch_status (*switch_answer_channel_hook)(switch_core_session *);
-typedef switch_status (*switch_read_frame_hook)(switch_core_session *, switch_frame **, int, switch_io_flag);
-typedef switch_status (*switch_write_frame_hook)(switch_core_session *, switch_frame *, int, switch_io_flag);
+typedef switch_status (*switch_read_frame_hook)(switch_core_session *, switch_frame **, int, switch_io_flag, int);
+typedef switch_status (*switch_write_frame_hook)(switch_core_session *, switch_frame *, int, switch_io_flag, int);
typedef switch_status (*switch_kill_channel_hook)(switch_core_session *, int);
-typedef switch_status (*switch_waitfor_read_hook)(switch_core_session *, int);
-typedef switch_status (*switch_waitfor_write_hook)(switch_core_session *, int);
+typedef switch_status (*switch_waitfor_read_hook)(switch_core_session *, int, int);
+typedef switch_status (*switch_waitfor_write_hook)(switch_core_session *, int, int);
typedef switch_status (*switch_send_dtmf_hook)(switch_core_session *, char *);
typedef switch_status (*switch_api_function)(char *in, char *out, size_t outlen);
static switch_status exosip_on_loopback(switch_core_session *session);
static switch_status exosip_on_transmit(switch_core_session *session);
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static int config_exosip(int reload);
static switch_status parse_sdp_media(sdp_media_t *media, char **dname, char **drate, char **dpayload);
static switch_status exosip_kill_channel(switch_core_session *session, int sig);
struct private_object *tech_pvt;
switch_channel *channel;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
}
-static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status exosip_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
struct private_object *tech_pvt = NULL;
size_t bytes = 0, samples = 0, frames=0, ms=0;
}
-static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status exosip_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
struct private_object *tech_pvt;
switch_channel *channel = NULL;
}
-static switch_status exosip_waitfor_read(switch_core_session *session, int ms)
+static switch_status exosip_waitfor_read(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt;
switch_channel *channel = NULL;
}
-static switch_status exosip_waitfor_write(switch_core_session *session, int ms)
+static switch_status exosip_waitfor_write(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt;
switch_channel *channel = NULL;
switch_codec_interface *codecs[SWITCH_MAX_CODECS];
int num_codecs = 0;
-
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
switch_channel *channel, *orig_channel;
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_codec_interface *codecs[512];
int num_codecs = 0;
-
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
switch_channel *channel, *orig_channel;
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_codec_interface *codecs[512];
int num_codecs = 0;
-
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
static switch_status channel_on_loopback(switch_core_session *session);
static switch_status channel_on_transmit(switch_core_session *session);
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static switch_status channel_kill_channel(switch_core_session *session, int sig);
switch_caller_profile *caller_profile;
unsigned int req = 0, cap = 0;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
}
-static switch_status channel_waitfor_read(switch_core_session *session, int ms)
+static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_waitfor_write(switch_core_session *session, int ms)
+static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_FALSE;
}
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
struct private_object *tech_pvt;
switch_channel *channel;
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
static switch_status channel_on_loopback(switch_core_session *session);
static switch_status channel_on_transmit(switch_core_session *session);
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static switch_status channel_kill_channel(switch_core_session *session, int sig);
switch_channel *channel, *orig_channel;
switch_caller_profile *caller_profile, *originator_caller_profile = NULL;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
}
-static switch_status channel_waitfor_read(switch_core_session *session, int ms)
+static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_waitfor_write(switch_core_session *session, int ms)
+static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
}
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
static switch_status channel_on_loopback(switch_core_session *session);
static switch_status channel_on_transmit(switch_core_session *session);
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static switch_status channel_kill_channel(switch_core_session *session, int sig);
static switch_status engage_device(struct private_object *tech_pvt);
static int dump_info(void);
switch_channel *channel;
switch_caller_profile *caller_profile;
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
}
-static switch_status channel_waitfor_read(switch_core_session *session, int ms)
+static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_waitfor_write(switch_core_session *session, int ms)
+static switch_status channel_waitfor_write(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
return status;
}
-static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status channel_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
struct private_object *tech_pvt;
switch_channel *channel;
+
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
static switch_status wanchan_on_loopback(switch_core_session *session);
static switch_status wanchan_on_transmit(switch_core_session *session);
static switch_status wanchan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status wanchan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status wanchan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status wanchan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status wanchan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static int on_info(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
static int on_hangup(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri_event *event);
-static switch_status wanchan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status wanchan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
struct private_object *tech_pvt;
switch_channel *channel = NULL;
return SWITCH_STATUS_SUCCESS;
}
-static switch_status wanchan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status wanchan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
struct private_object *tech_pvt;
switch_channel *channel = NULL;
char ani2str[4] = "";
//wanpipe_tdm_api_t tdm_api;
+ switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
static switch_status woomerachan_on_loopback(switch_core_session *session);
static switch_status woomerachan_on_transmit(switch_core_session *session);
static switch_status woomerachan_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session);
-static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags);
-static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags);
+static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id);
+static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id);
static switch_status woomerachan_kill_channel(switch_core_session *session, int sig);
static void tech_destroy(private_object *tech_pvt);
static void woomera_printf(woomera_profile *profile, switch_socket_t *socket, char *fmt, ...);
struct private_object *tech_pvt;
switch_channel *channel;
-
+ switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
tech_pvt->profile = &default_profile;
}
-static switch_status woomerachan_waitfor_read(switch_core_session *session, int ms)
+static switch_status woomerachan_waitfor_read(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return switch_socket_waitfor(&tech_pvt->read_poll, ms);
}
-static switch_status woomerachan_waitfor_write(switch_core_session *session, int ms)
+static switch_status woomerachan_waitfor_write(switch_core_session *session, int ms, int stream_id)
{
struct private_object *tech_pvt = NULL;
return switch_socket_waitfor(&tech_pvt->write_poll, ms);
}
-static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
+static switch_status woomerachan_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
return status;
}
-static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags)
+static switch_status woomerachan_write_frame(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id)
{
switch_channel *channel = NULL;
struct private_object *tech_pvt = NULL;
struct private_object *tech_pvt;
switch_channel *channel;
+ switch_core_session_add_stream(session, NULL);
+
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
tech_pvt->profile = &default_profile;
switch_mutex_t *mutex;
switch_thread_cond_t *cond;
+ void *streams[SWITCH_MAX_STREAMS];
+ int stream_count;
+
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
void *private;
};
{
switch_core_thread_session *data = obj;
switch_core_session *session = data->objs[0];
+ int *stream_id = data->objs[1];
switch_channel *channel;
switch_frame *read_frame;
while(data->running > 0) {
- switch(switch_core_session_read_frame(session, &read_frame, -1)) {
+ switch(switch_core_session_read_frame(session, &read_frame, -1, *stream_id)) {
case SWITCH_STATUS_SUCCESS:
break;
case SWITCH_STATUS_TIMEOUT:
}
}
-SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session)
+SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session, int stream_id)
{
thread_session->running = 1;
thread_session->objs[0] = session;
+ thread_session->objs[1] = &stream_id;
switch_core_session_launch_thread(session, switch_core_service_thread, thread_session);
}
return SWITCH_STATUS_SUCCESS;
}
+SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private)
+{
+ session->streams[session->stream_count++] = private;
+ return session->stream_count - 1;
+}
+
+SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index)
+{
+ return session->streams[index];
+}
+
+
+SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session)
+{
+ return session->stream_count;
+}
+
SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
char *endpoint_name,
switch_caller_profile *caller_profile,
return status;
}
-SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout)
+SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout, int stream_id)
{
struct switch_io_event_hook_read_frame *ptr;
switch_status status = SWITCH_STATUS_FALSE;
if (session->endpoint_interface->io_routines->read_frame) {
- if ((status = session->endpoint_interface->io_routines->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP)) == SWITCH_STATUS_SUCCESS) {
+ if ((status = session->endpoint_interface->io_routines->read_frame(session,
+ frame,
+ timeout,
+ SWITCH_IO_FLAG_NOOP,
+ stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.read_frame; ptr ; ptr = ptr->next) {
- if ((status = ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP, stream_id)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
return status;
}
-static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags) {
+static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id) {
struct switch_io_event_hook_write_frame *ptr;
switch_status status = SWITCH_STATUS_FALSE;
if (session->endpoint_interface->io_routines->write_frame) {
- if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags)) == SWITCH_STATUS_SUCCESS) {
+ if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.write_frame; ptr ; ptr = ptr->next) {
- if ((status = ptr->write_frame(session, frame, timeout, flags)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = ptr->write_frame(session, frame, timeout, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
return status;
}
-SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout)
+SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout, int stream_id)
{
switch_status status = SWITCH_STATUS_FALSE;
break;
}
- status = perform_write(session, write_frame, timeout, io_flag);
+ status = perform_write(session, write_frame, timeout, io_flag, stream_id);
return status;
} else {
int used = switch_buffer_inuse(session->raw_write_buffer);
write_frame->datalen = session->read_resampler->to_len * 2;
write_frame->rate = session->read_resampler->to_rate;
}
- status = perform_write(session, write_frame, timeout, io_flag);
+ status = perform_write(session, write_frame, timeout, io_flag, stream_id);
}
}
return status;
}
}
} else {
- status = perform_write(session, frame, timeout, io_flag);
+ status = perform_write(session, frame, timeout, io_flag, stream_id);
}
return status;
}
}
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout)
+SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_session *session, int timeout, int stream_id)
{
struct switch_io_event_hook_waitfor_read *ptr;
switch_status status = SWITCH_STATUS_FALSE;
if (session->endpoint_interface->io_routines->waitfor_read) {
- if ((status = session->endpoint_interface->io_routines->waitfor_read(session, timeout)) == SWITCH_STATUS_SUCCESS) {
+ if ((status = session->endpoint_interface->io_routines->waitfor_read(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.waitfor_read; ptr ; ptr = ptr->next) {
- if ((status = ptr->waitfor_read(session, timeout)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = ptr->waitfor_read(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
}
-SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout)
+SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout, int stream_id)
{
struct switch_io_event_hook_waitfor_write *ptr;
switch_status status = SWITCH_STATUS_FALSE;
if (session->endpoint_interface->io_routines->waitfor_write) {
- if ((status = session->endpoint_interface->io_routines->waitfor_write(session, timeout)) == SWITCH_STATUS_SUCCESS) {
+ if ((status = session->endpoint_interface->io_routines->waitfor_write(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
for (ptr = session->event_hooks.waitfor_write; ptr ; ptr = ptr->next) {
- if ((status = ptr->waitfor_write(session, timeout)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = ptr->waitfor_write(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
break;
}
}
{
switch_channel_state state;
switch_frame *frame;
+ int stream_id;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Standard LOOPBACK\n");
while ((state = switch_channel_get_state(session->channel)) == CS_LOOPBACK) {
- if (switch_core_session_read_frame(session, &frame, -1) == SWITCH_STATUS_SUCCESS) {
- switch_core_session_write_frame(session, frame, -1);
+ for(stream_id = 0; stream_id < session->stream_count; stream_id++) {
+ if (switch_core_session_read_frame(session, &frame, -1, stream_id) == SWITCH_STATUS_SUCCESS) {
+ switch_core_session_write_frame(session, frame, -1, stream_id);
+ }
}
}
}