]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
stream id stuff
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 9 Jan 2006 18:40:56 +0000 (18:40 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 9 Jan 2006 18:40:56 +0000 (18:40 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@307 d0543943-73ff-0310-b7d9-9358b9ac24b2

12 files changed:
src/include/switch_core.h
src/include/switch_module_interfaces.h
src/include/switch_types.h
src/mod/endpoints/mod_exosip/mod_exosip.c
src/mod/endpoints/mod_exosip/mod_exosip_ccrtp.c
src/mod/endpoints/mod_exosip/mod_exosip_ucl.c
src/mod/endpoints/mod_iaxchan/mod_iaxchan.c
src/mod/endpoints/mod_opalchan/mod_opalchan.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_wanchan/mod_wanchan.c
src/mod/endpoints/mod_woomerachan/mod_woomerachan.c
src/switch_core.c

index f2e891ce8afcae6307f9e524796987ccb0fcbd20..ff97cb98178e7f93b1a4da9c1c03ee911b251e4f 100644 (file)
@@ -44,14 +44,15 @@ extern "C" {
 
 #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;
 };
@@ -227,6 +228,29 @@ SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *sess
 */
 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
@@ -244,9 +268,10 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *
 /*! 
   \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
@@ -273,18 +298,20 @@ SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_ses
   \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
@@ -298,17 +325,19 @@ SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_sessi
   \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
index b1eadf9f79c6a38c9c8775c48e80c480804f8f8b..057da07edcd6b9c115c124016d08de4113930366 100644 (file)
@@ -145,15 +145,15 @@ struct switch_io_routines {
        /*! 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 *);
 };
index b44f08bbb223a0fcc53793b4b8dffebf16c8ddd6..e1c380706afd44d6c25f9c1585babe8f07cf9a98 100644 (file)
@@ -228,7 +228,7 @@ SWITCH_FILE_DATA_SHORT =        (1 <<  3) - Read data in shorts
 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 {
@@ -329,11 +329,11 @@ typedef switch_caller_extension *(*switch_dialplan_hunt_function)(switch_core_se
 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);
 
index 5f798d34f7e05b0c9dd9cf2c1803e13629b1d4e5..611116022b4283d96e9e06e0249cb2c712710b0d 100644 (file)
@@ -145,8 +145,8 @@ static switch_status exosip_on_hangup(switch_core_session *session);
 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);
@@ -368,6 +368,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
                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);
@@ -520,7 +521,7 @@ static switch_status exosip_answer_channel(switch_core_session *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;
@@ -597,7 +598,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
 }
 
 
-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;
@@ -668,7 +669,7 @@ static switch_status exosip_kill_channel(switch_core_session *session, int sig)
 
 }
 
-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;
@@ -683,7 +684,7 @@ static switch_status exosip_waitfor_read(switch_core_session *session, int ms)
 }
 
 
-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;
@@ -779,7 +780,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
                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);
index 4d895ca0fcf80fce871411c872280644860b9d2c..751d33c12830989502471ef1f7e4481c8319d098 100644 (file)
@@ -369,6 +369,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
                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);
@@ -771,7 +772,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
                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);
index 54c3b0364cfa6c6fd56a3a967f766de266955e0a..dca8a34789c5b2a8e5bedf986b7d3b314fe7fddc 100644 (file)
@@ -385,6 +385,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
                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);
@@ -838,7 +839,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
                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);
index b86a62598fc7d6e8b2d6fd81843972862d8a9e34..6a4deb9fe48b51baab18115e5be22747d8b3ef04 100644 (file)
@@ -325,8 +325,8 @@ static switch_status channel_on_ring(switch_core_session *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);
 
 
@@ -490,6 +490,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
                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);
@@ -543,7 +544,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
 
 }
 
-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;
 
@@ -553,7 +554,7 @@ static switch_status channel_waitfor_read(switch_core_session *session, int ms)
        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;
 
@@ -580,7 +581,7 @@ static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
        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;
@@ -613,7 +614,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
        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;
@@ -861,6 +862,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
                                                        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);
index 8aae7ecb7deed69108408f0d69d3beb68ee45ac8..8b251fa2e7a417a72dc6f96b914c62e59fa143ee 100644 (file)
@@ -66,8 +66,8 @@ static switch_status channel_on_ring(switch_core_session *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);
 
 
@@ -184,6 +184,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
                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);
@@ -228,7 +229,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
 
 }
 
-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;
 
@@ -238,7 +239,7 @@ static switch_status channel_waitfor_read(switch_core_session *session, int ms)
        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;
 
@@ -249,7 +250,7 @@ static switch_status channel_waitfor_write(switch_core_session *session, int ms)
 
 }
 
-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;
@@ -265,7 +266,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
        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;
index 51e7ec29bda01fceb5cfba70508df6703e350e14..b716cca52fbf8fa32c6ef8d671b249281044c044 100644 (file)
@@ -107,8 +107,8 @@ static switch_status channel_on_ring(switch_core_session *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);
 static switch_status engage_device(struct private_object *tech_pvt);
 static int dump_info(void);
@@ -300,6 +300,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
                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);
@@ -334,7 +335,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
 
 }
 
-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;
 
@@ -344,7 +345,7 @@ static switch_status channel_waitfor_read(switch_core_session *session, int ms)
        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;
 
@@ -367,7 +368,7 @@ static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
     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;
@@ -398,7 +399,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
        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;
@@ -778,6 +779,8 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
        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);
index 3fd80800847f0554b2c8c06c9a0c7e131d99633f..3d2ee407588c957b84965e7f807d2562436fddc7 100644 (file)
@@ -154,8 +154,8 @@ static switch_status wanchan_on_hangup(switch_core_session *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);
@@ -266,7 +266,7 @@ static switch_status wanchan_answer_channel(switch_core_session *session)
 
 
 
-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;
@@ -312,7 +312,7 @@ static switch_status wanchan_read_frame(switch_core_session *session, switch_fra
        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;
@@ -466,6 +466,7 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri
                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);
index 9ecbf59f110ec136eabf4345f7f9aa0270fab8c5..c3403b29d12d70f76dda6f06cd354f86075e62a4 100644 (file)
@@ -172,8 +172,8 @@ static switch_status woomerachan_on_ring(switch_core_session *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, ...);
@@ -350,7 +350,7 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
                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;
@@ -388,7 +388,7 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
 
 }
 
-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;
 
@@ -398,7 +398,7 @@ static switch_status woomerachan_waitfor_read(switch_core_session *session, int
        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;
 
@@ -409,7 +409,7 @@ static switch_status woomerachan_waitfor_write(switch_core_session *session, int
        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;
@@ -440,7 +440,7 @@ static switch_status woomerachan_read_frame(switch_core_session *session, switch
        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;
@@ -1246,6 +1246,8 @@ static void *woomera_thread_run(void *obj)
                                        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;
index fb1f2e0f0e705197dd99b85cdfd8017c01ccedae..84c812d4206f744a07e5079b7f7ddb78b7434b38 100644 (file)
@@ -78,6 +78,9 @@ struct switch_core_session {
        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;
 };
@@ -469,6 +472,7 @@ static void *switch_core_service_thread(switch_thread *thread, void *obj)
 {
        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;
 
@@ -478,7 +482,7 @@ static void *switch_core_service_thread(switch_thread *thread, void *obj)
 
 
        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:
@@ -512,10 +516,11 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *
        }
 }
 
-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);
 }
 
@@ -617,6 +622,23 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_sessio
        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,
@@ -690,7 +712,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_ses
        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;
@@ -698,9 +720,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
 
 
        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;
                                }
                        }
@@ -840,14 +866,14 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
        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;
                                }
                        }
@@ -856,7 +882,7 @@ static switch_status perform_write(switch_core_session *session, switch_frame *f
        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;
@@ -982,7 +1008,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
                                        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);
@@ -1056,7 +1082,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
                                                                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;
@@ -1064,7 +1090,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
                        }
                }
        } else {
-               status = perform_write(session, frame, timeout, io_flag);
+               status = perform_write(session, frame, timeout, io_flag, stream_id);
        }
        return status;
 }
@@ -1088,15 +1114,15 @@ SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_sessi
 
 }
 
-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;
                                }
                        }
@@ -1107,15 +1133,15 @@ SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_sessi
 
 }
 
-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;
                                }
                        }
@@ -1420,12 +1446,15 @@ static void switch_core_standard_on_loopback(switch_core_session *session)
 {
        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);
+                       }
                }
        }
 }