FS-9575 #resolve [Add MRCP]
This commit is contained in:
parent
c409499cd9
commit
7dd872e9b8
|
@ -296,6 +296,7 @@ library_include_HEADERS = \
|
||||||
src/include/switch_curl.h \
|
src/include/switch_curl.h \
|
||||||
src/include/switch_json.h \
|
src/include/switch_json.h \
|
||||||
src/include/switch_utf8.h \
|
src/include/switch_utf8.h \
|
||||||
|
src/include/switch_msrp.h \
|
||||||
src/include/switch_vpx.h \
|
src/include/switch_vpx.h \
|
||||||
libs/libteletone/src/libteletone_detect.h \
|
libs/libteletone/src/libteletone_detect.h \
|
||||||
libs/libteletone/src/libteletone_generate.h \
|
libs/libteletone/src/libteletone_generate.h \
|
||||||
|
@ -376,6 +377,7 @@ libfreeswitch_la_SOURCES = \
|
||||||
src/switch_curl.c \
|
src/switch_curl.c \
|
||||||
src/switch_hashtable.c\
|
src/switch_hashtable.c\
|
||||||
src/switch_utf8.c \
|
src/switch_utf8.c \
|
||||||
|
src/switch_msrp.c \
|
||||||
src/switch_vpx.c \
|
src/switch_vpx.c \
|
||||||
libs/libtpl-1.5/src/tpl.c \
|
libs/libtpl-1.5/src/tpl.c \
|
||||||
libs/libteletone/src/libteletone_detect.c \
|
libs/libteletone/src/libteletone_detect.c \
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<configuration name="msrp.conf" description="MSRP">
|
||||||
|
<settings>
|
||||||
|
<param name="listen-ip" value="$${local_ip_v4}"/>
|
||||||
|
<param name="listen-port" value="2855"/>
|
||||||
|
<param name="listen-ssl-port" value="2856"/>
|
||||||
|
<!-- <param name="message-buffer-size" value="50"/> -->
|
||||||
|
<!-- <param name="debug" value="true"/> -->
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
#include <switch_msrp.h>
|
||||||
|
|
||||||
SWITCH_BEGIN_EXTERN_C
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
|
||||||
|
@ -371,7 +372,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_text_factory_destroy(switch_rtp_text_
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_print(switch_core_session_t *session, const char *data);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_print(switch_core_session_t *session, const char *data);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_printf(switch_core_session_t *session, const char *fmt, ...);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_printf(switch_core_session_t *session, const char *fmt, ...);
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_msrp_session_t *) switch_core_media_get_msrp_session(switch_core_session_t *session);
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
|
* Copyright (C) 2011-2016, Seven Du <dujinfang@gmail.com>
|
||||||
|
*
|
||||||
|
* Version: MPL 1.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Seven Du <dujinfang@gmail.com>
|
||||||
|
* Portions created by the Initial Developer are Copyright (C)
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* msrp.h -- MSRP lib
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MSRP_H
|
||||||
|
#define _MSRP_H
|
||||||
|
|
||||||
|
#include <switch.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
#define MSRP_LISTEN_PORT 2855
|
||||||
|
#define MSRP_SSL_LISTEN_PORT 2856
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MSRP_ST_WAIT_HEADER,
|
||||||
|
MSRP_ST_PARSE_HEADER,
|
||||||
|
MSRP_ST_WAIT_BODY,
|
||||||
|
MSRP_ST_DONE,
|
||||||
|
MSRP_ST_ERROR,
|
||||||
|
|
||||||
|
MSRP_METHOD_REPLY,
|
||||||
|
MSRP_METHOD_SEND,
|
||||||
|
MSRP_METHOD_AUTH,
|
||||||
|
MSRP_METHOD_REPORT,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MSRP_H_FROM_PATH,
|
||||||
|
MSRP_H_TO_PATH,
|
||||||
|
MSRP_H_MESSAGE_ID,
|
||||||
|
MSRP_H_CONTENT_TYPE,
|
||||||
|
MSRP_H_SUCCESS_REPORT,
|
||||||
|
MSRP_H_FAILURE_REPORT,
|
||||||
|
MSRP_H_STATUS,
|
||||||
|
MSRP_H_KEEPALIVE,
|
||||||
|
MSRP_H_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct msrp_msg_s {
|
||||||
|
int state;
|
||||||
|
int method;
|
||||||
|
char *headers[12];
|
||||||
|
int last_header;
|
||||||
|
char *transaction_id;
|
||||||
|
char *delimiter;
|
||||||
|
int code_number;
|
||||||
|
char *code_description;
|
||||||
|
switch_size_t byte_start;
|
||||||
|
switch_size_t byte_end;
|
||||||
|
switch_size_t bytes;
|
||||||
|
switch_size_t payload_bytes;
|
||||||
|
int range_star; /* range-end is '*' */
|
||||||
|
char *last_p;
|
||||||
|
char *payload;
|
||||||
|
struct msrp_msg_s *next;
|
||||||
|
} msrp_msg_t;
|
||||||
|
|
||||||
|
typedef struct msrp_msg_s switch_msrp_msg_t;
|
||||||
|
|
||||||
|
typedef struct msrp_socket_s {
|
||||||
|
switch_port_t port;
|
||||||
|
switch_socket_t *sock;
|
||||||
|
switch_thread_t *thread;
|
||||||
|
int secure;
|
||||||
|
} msrp_socket_t;
|
||||||
|
|
||||||
|
typedef struct msrp_client_socket_s {
|
||||||
|
switch_socket_t *sock;
|
||||||
|
int secure;
|
||||||
|
} msrp_client_socket_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
switch_memory_pool_t *pool;
|
||||||
|
int secure;
|
||||||
|
char *remote_path;
|
||||||
|
char *remote_accept_types;
|
||||||
|
char *remote_accept_wrapped_types;
|
||||||
|
char *remote_setup;
|
||||||
|
char *remote_file_selector;
|
||||||
|
char *local_path;
|
||||||
|
char *local_accept_types;
|
||||||
|
char *local_accept_wrapped_types;
|
||||||
|
char *local_setup;
|
||||||
|
char *local_file_selector;
|
||||||
|
int local_port;
|
||||||
|
char *call_id;
|
||||||
|
msrp_msg_t *msrp_msg;
|
||||||
|
msrp_msg_t *last_msg;
|
||||||
|
switch_mutex_t *mutex;
|
||||||
|
switch_size_t msrp_msg_buffer_size;
|
||||||
|
switch_size_t msrp_msg_count;
|
||||||
|
msrp_socket_t *msock;
|
||||||
|
msrp_client_socket_t *csock;
|
||||||
|
switch_frame_t frame;
|
||||||
|
uint8_t frame_data[SWITCH_RTP_MAX_BUF_LEN];
|
||||||
|
} switch_msrp_session_t;
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_msrp_init();
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_msrp_destroy();
|
||||||
|
SWITCH_DECLARE(switch_msrp_session_t *)switch_msrp_session_new(switch_memory_pool_t *pool, switch_bool_t secure);
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_msrp_session_destroy(switch_msrp_session_t **ms);
|
||||||
|
// switch_status_t switch_msrp_session_push_msg(switch_msrp_session_t *ms, msrp_msg_t *msg);
|
||||||
|
SWITCH_DECLARE(switch_msrp_msg_t *)switch_msrp_session_pop_msg(switch_msrp_session_t *ms);
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_msrp_send(switch_msrp_session_t *ms, msrp_msg_t *msg);
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_msrp_load_apis_and_applications(switch_loadable_module_interface_t **moudle_interface);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* For Emacs:
|
||||||
|
* Local Variables:
|
||||||
|
* mode:c
|
||||||
|
* indent-tabs-mode:t
|
||||||
|
* tab-width:4
|
||||||
|
* c-basic-offset:4
|
||||||
|
* End:
|
||||||
|
* For VIM:
|
||||||
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
|
||||||
|
*/
|
|
@ -1376,6 +1376,7 @@ typedef enum {
|
||||||
CC_QUEUEABLE_DTMF_DELAY,
|
CC_QUEUEABLE_DTMF_DELAY,
|
||||||
CC_IO_OVERRIDE,
|
CC_IO_OVERRIDE,
|
||||||
CC_RTP_RTT,
|
CC_RTP_RTT,
|
||||||
|
CC_MSRP,
|
||||||
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
||||||
CC_FLAG_MAX
|
CC_FLAG_MAX
|
||||||
} switch_channel_cap_t;
|
} switch_channel_cap_t;
|
||||||
|
@ -1528,6 +1529,7 @@ typedef enum {
|
||||||
CF_TEXT_ECHO,
|
CF_TEXT_ECHO,
|
||||||
CF_TEXT_ACTIVE,
|
CF_TEXT_ACTIVE,
|
||||||
CF_TEXT_IDLE,
|
CF_TEXT_IDLE,
|
||||||
|
CF_MSRP,
|
||||||
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
||||||
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
|
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
|
||||||
CF_FLAG_MAX
|
CF_FLAG_MAX
|
||||||
|
|
|
@ -7498,6 +7498,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
||||||
switch_console_set_complete("add file_exists");
|
switch_console_set_complete("add file_exists");
|
||||||
switch_console_set_complete("add getcputime");
|
switch_console_set_complete("add getcputime");
|
||||||
|
|
||||||
|
switch_msrp_load_apis_and_applications(module_interface);
|
||||||
|
|
||||||
/* indicate that the module should continue to be loaded */
|
/* indicate that the module should continue to be loaded */
|
||||||
return SWITCH_STATUS_NOUNLOAD;
|
return SWITCH_STATUS_NOUNLOAD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -927,6 +927,23 @@ static switch_status_t sofia_read_text_frame(switch_core_session_t *session, swi
|
||||||
|
|
||||||
static switch_status_t sofia_write_text_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
|
static switch_status_t sofia_write_text_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
|
||||||
{
|
{
|
||||||
|
if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_MSRP)) {
|
||||||
|
switch_msrp_session_t *msrp_session = switch_core_media_get_msrp_session(session);
|
||||||
|
|
||||||
|
if (frame && msrp_session) {
|
||||||
|
switch_msrp_msg_t msrp_msg = { 0 };
|
||||||
|
|
||||||
|
msrp_msg.headers[MSRP_H_CONTENT_TYPE] = "message/cpim";
|
||||||
|
// msrp_msg.headers[MSRP_H_CONTENT_TYPE] = "text/plain";
|
||||||
|
msrp_msg.payload = frame->data;
|
||||||
|
msrp_msg.payload_bytes = frame->datalen;
|
||||||
|
|
||||||
|
return switch_msrp_send(msrp_session, &msrp_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return switch_core_media_write_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_TEXT);
|
return switch_core_media_write_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
||||||
switch_channel_set_cap(tech_pvt->channel, CC_JITTERBUFFER);
|
switch_channel_set_cap(tech_pvt->channel, CC_JITTERBUFFER);
|
||||||
switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP);
|
switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP);
|
||||||
switch_channel_set_cap(tech_pvt->channel, CC_RTP_RTT);
|
switch_channel_set_cap(tech_pvt->channel, CC_RTP_RTT);
|
||||||
|
switch_channel_set_cap(tech_pvt->channel, CC_MSRP);
|
||||||
switch_channel_set_cap(tech_pvt->channel, CC_QUEUEABLE_DTMF_DELAY);
|
switch_channel_set_cap(tech_pvt->channel, CC_QUEUEABLE_DTMF_DELAY);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <switch_nat.h>
|
#include <switch_nat.h>
|
||||||
#include "private/switch_core_pvt.h"
|
#include "private/switch_core_pvt.h"
|
||||||
#include <switch_curl.h>
|
#include <switch_curl.h>
|
||||||
|
#include <switch_msrp.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <switch_private.h>
|
#include <switch_private.h>
|
||||||
#ifdef HAVE_SETRLIMIT
|
#ifdef HAVE_SETRLIMIT
|
||||||
|
@ -2391,6 +2392,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
|
||||||
switch_core_set_signal_handlers();
|
switch_core_set_signal_handlers();
|
||||||
switch_load_network_lists(SWITCH_FALSE);
|
switch_load_network_lists(SWITCH_FALSE);
|
||||||
|
|
||||||
|
switch_msrp_init();
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n");
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n");
|
||||||
if (switch_loadable_module_init(SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
if (switch_loadable_module_init(SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -2905,6 +2908,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
|
||||||
switch_scheduler_task_thread_stop();
|
switch_scheduler_task_thread_stop();
|
||||||
|
|
||||||
switch_rtp_shutdown();
|
switch_rtp_shutdown();
|
||||||
|
switch_msrp_destroy();
|
||||||
|
|
||||||
if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
|
if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
|
||||||
switch_nat_shutdown();
|
switch_nat_shutdown();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*
|
*
|
||||||
* Anthony Minessale II <anthm@freeswitch.org>
|
* Anthony Minessale II <anthm@freeswitch.org>
|
||||||
|
* Seven Du <dujinfang@gmail.com>
|
||||||
*
|
*
|
||||||
* switch_core_media.c -- Core Media
|
* switch_core_media.c -- Core Media
|
||||||
*
|
*
|
||||||
|
@ -56,7 +57,6 @@ static void gen_ice(switch_core_session_t *session, switch_media_type_t type, co
|
||||||
#define MAX_RED_FRAMES 25
|
#define MAX_RED_FRAMES 25
|
||||||
#define RED_PACKET_SIZE 100
|
#define RED_PACKET_SIZE 100
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SMF_INIT = (1 << 0),
|
SMF_INIT = (1 << 0),
|
||||||
SMF_READY = (1 << 1),
|
SMF_READY = (1 << 1),
|
||||||
|
@ -217,6 +217,7 @@ struct switch_media_handle_s {
|
||||||
switch_core_media_flag_t media_flags[SCMF_MAX];
|
switch_core_media_flag_t media_flags[SCMF_MAX];
|
||||||
smh_flag_t flags;
|
smh_flag_t flags;
|
||||||
switch_rtp_engine_t engines[SWITCH_MEDIA_TYPE_TOTAL];
|
switch_rtp_engine_t engines[SWITCH_MEDIA_TYPE_TOTAL];
|
||||||
|
switch_msrp_session_t *msrp_session;
|
||||||
switch_mutex_t *read_mutex[SWITCH_MEDIA_TYPE_TOTAL];
|
switch_mutex_t *read_mutex[SWITCH_MEDIA_TYPE_TOTAL];
|
||||||
switch_mutex_t *write_mutex[SWITCH_MEDIA_TYPE_TOTAL];
|
switch_mutex_t *write_mutex[SWITCH_MEDIA_TYPE_TOTAL];
|
||||||
char *codec_order[SWITCH_MAX_CODECS];
|
char *codec_order[SWITCH_MAX_CODECS];
|
||||||
|
@ -1702,8 +1703,7 @@ SWITCH_DECLARE(void) switch_media_handle_destroy(switch_core_session_t *session)
|
||||||
switch_core_session_unset_write_codec(session);
|
switch_core_session_unset_write_codec(session);
|
||||||
switch_core_media_deactivate_rtp(session);
|
switch_core_media_deactivate_rtp(session);
|
||||||
|
|
||||||
|
if (smh->msrp_session) switch_msrp_session_destroy(&smh->msrp_session);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2417,6 +2417,42 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == SWITCH_MEDIA_TYPE_TEXT && smh->msrp_session) {
|
||||||
|
switch_msrp_session_t *msrp_session = smh->msrp_session;
|
||||||
|
switch_frame_t *rframe = &msrp_session->frame;
|
||||||
|
|
||||||
|
msrp_msg_t *msrp_msg = switch_msrp_session_pop_msg(msrp_session);
|
||||||
|
|
||||||
|
if (0 && msrp_msg && msrp_msg->method == MSRP_METHOD_SEND) { /*echo back*/
|
||||||
|
char *p;
|
||||||
|
p = msrp_msg->headers[MSRP_H_TO_PATH];
|
||||||
|
msrp_msg->headers[MSRP_H_TO_PATH] = msrp_msg->headers[MSRP_H_FROM_PATH];
|
||||||
|
msrp_msg->headers[MSRP_H_FROM_PATH] = p;
|
||||||
|
switch_msrp_send(msrp_session, msrp_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msrp_msg && msrp_msg->method == MSRP_METHOD_SEND) {
|
||||||
|
rframe->data = msrp_session->frame_data;
|
||||||
|
rframe->datalen = msrp_msg->payload_bytes;
|
||||||
|
rframe->packetlen = msrp_msg->payload_bytes;
|
||||||
|
memcpy(rframe->data, msrp_msg->payload, msrp_msg->payload_bytes);
|
||||||
|
rframe->m = 1;
|
||||||
|
|
||||||
|
*frame = rframe;
|
||||||
|
|
||||||
|
switch_safe_free(msrp_msg);
|
||||||
|
msrp_msg = NULL;
|
||||||
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*frame = NULL;
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
engine = &smh->engines[type];
|
engine = &smh->engines[type];
|
||||||
|
|
||||||
if (type != SWITCH_MEDIA_TYPE_TEXT && (!engine->read_codec.implementation || !switch_core_codec_ready(&engine->read_codec))) {
|
if (type != SWITCH_MEDIA_TYPE_TEXT && (!engine->read_codec.implementation || !switch_core_codec_ready(&engine->read_codec))) {
|
||||||
|
@ -4051,7 +4087,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
const char *val;
|
const char *val;
|
||||||
const char *crypto = NULL;
|
const char *crypto = NULL;
|
||||||
int got_crypto = 0, got_video_crypto = 0, got_audio = 0, saw_audio = 0, got_avp = 0, got_video_avp = 0, got_video_savp = 0, got_savp = 0, got_udptl = 0, got_webrtc = 0, got_text = 0, got_text_crypto = 0;
|
int got_crypto = 0, got_video_crypto = 0, got_audio = 0, saw_audio = 0, got_avp = 0, got_video_avp = 0, got_video_savp = 0, got_savp = 0, got_udptl = 0, got_webrtc = 0, got_text = 0, got_text_crypto = 0, got_msrp = 0;
|
||||||
int scrooge = 0;
|
int scrooge = 0;
|
||||||
sdp_parser_t *parser = NULL;
|
sdp_parser_t *parser = NULL;
|
||||||
sdp_session_t *sdp;
|
sdp_session_t *sdp;
|
||||||
|
@ -4231,6 +4267,97 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||||
}
|
}
|
||||||
} else if (m->m_proto == sdp_proto_udptl) {
|
} else if (m->m_proto == sdp_proto_udptl) {
|
||||||
got_udptl++;
|
got_udptl++;
|
||||||
|
} else if (m->m_proto == sdp_proto_msrp || m->m_proto == sdp_proto_msrps){
|
||||||
|
got_msrp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(got_msrp && m->m_type == sdp_media_message) {
|
||||||
|
if (!smh->msrp_session) {
|
||||||
|
smh->msrp_session = switch_msrp_session_new(switch_core_session_get_pool(session), m->m_proto == sdp_proto_msrps);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!smh->msrp_session) {
|
||||||
|
goto endmsrp;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "MSRP session created\n");
|
||||||
|
|
||||||
|
for (attr = m->m_attributes; attr; attr = attr->a_next) {
|
||||||
|
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[%s]=[%s]\n", attr->a_name, attr->a_value);
|
||||||
|
if (!strcasecmp(attr->a_name, "path") && attr->a_value) {
|
||||||
|
smh->msrp_session->remote_path = switch_core_session_strdup(session, attr->a_value);
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_remote_path", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "accept-types") && attr->a_value) {
|
||||||
|
smh->msrp_session->remote_accept_types = switch_core_session_strdup(session, attr->a_value);
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_remote_accept_types", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "accept-wrapped-types") && attr->a_value) {
|
||||||
|
smh->msrp_session->remote_accept_wrapped_types = switch_core_session_strdup(session, attr->a_value);
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_remote_accept_wrapped_types", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "setup") && attr->a_value) {
|
||||||
|
smh->msrp_session->remote_setup = switch_core_session_strdup(session, attr->a_value);
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_remote_setup", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-selector") && attr->a_value) {
|
||||||
|
char *tmp = switch_mprintf("%s", attr->a_value);
|
||||||
|
char *argv[4] = { 0 };
|
||||||
|
int argc;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
smh->msrp_session->remote_file_selector = switch_core_session_strdup(session, attr->a_value);
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_remote_file_selector", attr->a_value);
|
||||||
|
|
||||||
|
argc = switch_separate_string(tmp, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||||
|
|
||||||
|
for(i = 0; i<argc; i++) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "::::%s\n", switch_str_nil(argv[i]));
|
||||||
|
if (zstr(argv[i])) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERRRRRRR\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!strncasecmp(argv[i], "name:", 5)) {
|
||||||
|
char *p = argv[i] + 5;
|
||||||
|
int len = strlen(p);
|
||||||
|
|
||||||
|
if (*p == '"') {
|
||||||
|
*(p + len - 1) = '\0';
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_name", p);
|
||||||
|
} else if (!strncasecmp(argv[i], "type:", 5)) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_type", argv[i] + 5);
|
||||||
|
}
|
||||||
|
if (!strncasecmp(argv[i], "size:", 5)) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_size", argv[i] + 5);
|
||||||
|
}
|
||||||
|
if (!strncasecmp(argv[i], "hash:", 5)) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_hash", argv[i] + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_safe_free(tmp);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-transfer-id") && attr->a_value) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_transfer_id", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-disposition") && attr->a_value) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_disposition", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-date") && attr->a_value) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_date", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-icon") && attr->a_value) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_icon", attr->a_value);
|
||||||
|
} else if (!strcasecmp(attr->a_name, "file-range") && attr->a_value) {
|
||||||
|
switch_channel_set_variable(session->channel, "sip_msrp_file_range", attr->a_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
smh->msrp_session->call_id = switch_core_session_get_uuid(session);
|
||||||
|
smh->msrp_session->local_accept_types = smh->msrp_session->remote_accept_types;
|
||||||
|
smh->msrp_session->local_accept_wrapped_types = smh->msrp_session->remote_accept_types;
|
||||||
|
smh->msrp_session->local_setup = smh->msrp_session->remote_setup;
|
||||||
|
|
||||||
|
switch_channel_set_flag(session->channel, CF_TEXT);
|
||||||
|
switch_channel_set_flag(session->channel, CF_TEXT_POSSIBLE);
|
||||||
|
switch_channel_set_flag(session->channel, CF_MSRP);
|
||||||
|
|
||||||
|
switch_core_session_start_text_thread(session);
|
||||||
|
|
||||||
|
endmsrp:;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_udptl && m->m_type == sdp_media_image) {
|
if (got_udptl && m->m_type == sdp_media_image) {
|
||||||
|
@ -6748,8 +6875,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_choose_port(switch_core_sessio
|
||||||
if (!zstr(smh->mparams->extrtpip)) { /* and we've got an ext-rtp-ip, eg, from verto config */
|
if (!zstr(smh->mparams->extrtpip)) { /* and we've got an ext-rtp-ip, eg, from verto config */
|
||||||
use_ip = smh->mparams->extrtpip; /* let's use it for composing local sdp to send to client */
|
use_ip = smh->mparams->extrtpip; /* let's use it for composing local sdp to send to client */
|
||||||
/*
|
/*
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
|
||||||
"%s will use %s instead of %s in SDP, because we're originating and we have an ext-rtp-ip setting\n",
|
"%s will use %s instead of %s in SDP, because we're originating and we have an ext-rtp-ip setting\n",
|
||||||
switch_channel_get_name(smh->session->channel), smh->mparams->extrtpip, smh->mparams->rtpip);
|
switch_channel_get_name(smh->session->channel), smh->mparams->extrtpip, smh->mparams->rtpip);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -7508,7 +7635,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
|
||||||
|
|
||||||
text:
|
text:
|
||||||
|
|
||||||
|
if (switch_channel_test_flag(session->channel, CF_MSRP)) { // skip RTP RTT
|
||||||
|
goto video;
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE) && t_engine->cur_payload_map->rm_encoding && t_engine->cur_payload_map->remote_sdp_port) {
|
if (switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE) && t_engine->cur_payload_map->rm_encoding && t_engine->cur_payload_map->remote_sdp_port) {
|
||||||
/******************************************************************************************/
|
/******************************************************************************************/
|
||||||
|
@ -9729,7 +9858,85 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///TEXT
|
msrp:
|
||||||
|
|
||||||
|
if (smh->msrp_session) {
|
||||||
|
switch_msrp_session_t *msrp_session = smh->msrp_session;
|
||||||
|
|
||||||
|
if (!zstr(msrp_session->remote_path)) {
|
||||||
|
if (zstr(msrp_session->local_path)) {
|
||||||
|
msrp_session->local_path = switch_core_session_sprintf(session,
|
||||||
|
"msrp%s://%s:%d/%s;tcp",
|
||||||
|
msrp_session->secure ? "s" : "",
|
||||||
|
ip, msrp_session->local_port, msrp_session->call_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
|
||||||
|
"m=message %d TCP/%sMSRP *\n"
|
||||||
|
"a=path:%s\n"
|
||||||
|
"a=accept-types:%s\n"
|
||||||
|
"a=accept-wrapped-types:%s\n"
|
||||||
|
"a=setup:passive\n",
|
||||||
|
msrp_session->local_port,
|
||||||
|
msrp_session->secure ? "TLS/" : "",
|
||||||
|
msrp_session->local_path,
|
||||||
|
msrp_session->local_accept_types,
|
||||||
|
msrp_session->local_accept_wrapped_types);
|
||||||
|
} else {
|
||||||
|
char *uuid = switch_core_session_get_uuid(session);
|
||||||
|
const char *file_selector = switch_channel_get_variable(session->channel, "sip_msrp_local_file_selector");
|
||||||
|
|
||||||
|
if (zstr(msrp_session->local_path)) {
|
||||||
|
msrp_session->local_path = switch_core_session_sprintf(session,
|
||||||
|
"msrp%s://%s:%d/%s;tcp",
|
||||||
|
msrp_session->secure ? "s" : "",
|
||||||
|
ip, msrp_session->local_port, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
|
||||||
|
"m=message %d TCP/%sMSRP *\n"
|
||||||
|
"a=path:%s\n"
|
||||||
|
"a=accept-types:message/cpim text/* application/im-iscomposing+xml\n"
|
||||||
|
"a=accept-wrapped-types:*\n"
|
||||||
|
"a=setup:passive\n",
|
||||||
|
msrp_session->local_port,
|
||||||
|
msrp_session->secure ? "TLS/" : "",
|
||||||
|
msrp_session->local_path);
|
||||||
|
|
||||||
|
if (!zstr(file_selector)) {
|
||||||
|
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
|
||||||
|
"a=sendonly\na=file-selector:%s\n", file_selector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goto no_rtt;
|
||||||
|
} else if (switch_channel_test_cap(session->channel, CC_RTP_RTT) && (
|
||||||
|
// switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE) ||
|
||||||
|
switch_channel_var_true(session->channel, "sip_enable_msrp") ||
|
||||||
|
switch_channel_var_true(session->channel, "sip_enable_msrps"))) {
|
||||||
|
|
||||||
|
smh->msrp_session = switch_msrp_session_new(switch_core_session_get_pool(session), switch_channel_var_true(session->channel, "sip_enable_msrps"));
|
||||||
|
|
||||||
|
if (!smh->msrp_session) {
|
||||||
|
goto endmsrp;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "MSRP session created\n");
|
||||||
|
|
||||||
|
smh->msrp_session->call_id = switch_core_session_get_uuid(session);
|
||||||
|
|
||||||
|
switch_channel_set_flag(session->channel, CF_TEXT);
|
||||||
|
switch_channel_set_flag(session->channel, CF_TEXT_POSSIBLE);
|
||||||
|
switch_channel_set_flag(session->channel, CF_MSRP);
|
||||||
|
|
||||||
|
switch_core_session_start_text_thread(session);
|
||||||
|
|
||||||
|
goto msrp;
|
||||||
|
|
||||||
|
endmsrp: ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RTP TEXT
|
||||||
|
|
||||||
if (sdp_type == SDP_TYPE_RESPONSE && !switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE)) {
|
if (sdp_type == SDP_TYPE_RESPONSE && !switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE)) {
|
||||||
if (switch_channel_test_flag(session->channel, CF_TEXT_SDP_RECVD)) {
|
if (switch_channel_test_flag(session->channel, CF_TEXT_SDP_RECVD)) {
|
||||||
|
@ -9993,9 +10200,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
no_rtt:
|
||||||
|
|
||||||
if (map) {
|
if (map) {
|
||||||
switch_event_destroy(&map);
|
switch_event_destroy(&map);
|
||||||
|
@ -10767,7 +10973,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_reset_jb(switch_core_session_t
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||||
{
|
{
|
||||||
switch_media_handle_t *smh;
|
switch_media_handle_t *smh;
|
||||||
switch_rtp_engine_t *a_engine, *v_engine;//, *t_engine;
|
switch_rtp_engine_t *a_engine, *v_engine, *t_engine;
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
switch_assert(session);
|
switch_assert(session);
|
||||||
|
@ -10782,7 +10988,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
|
||||||
|
|
||||||
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
|
a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
|
||||||
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
|
v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
|
||||||
//t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
|
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
|
||||||
|
|
||||||
switch (msg->message_id) {
|
switch (msg->message_id) {
|
||||||
|
|
||||||
|
@ -10925,6 +11131,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
|
||||||
if (direction && *direction == 'v') {
|
if (direction && *direction == 'v') {
|
||||||
direction++;
|
direction++;
|
||||||
rtp = v_engine->rtp_session;
|
rtp = v_engine->rtp_session;
|
||||||
|
} else if (direction && *direction == 't' && t_engine) {
|
||||||
|
direction++;
|
||||||
|
rtp = t_engine->rtp_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_rtp_ready(rtp) && !zstr(direction) && !zstr(msg->string_array_arg[1])) {
|
if (switch_rtp_ready(rtp) && !zstr(direction) && !zstr(msg->string_array_arg[1])) {
|
||||||
|
@ -13427,6 +13636,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_text_frame(switch_core
|
||||||
switch_io_event_hook_text_write_frame_t *ptr;
|
switch_io_event_hook_text_write_frame_t *ptr;
|
||||||
switch_rtp_engine_t *t_engine;
|
switch_rtp_engine_t *t_engine;
|
||||||
switch_io_write_text_frame_t write_text_frame = NULL;
|
switch_io_write_text_frame_t write_text_frame = NULL;
|
||||||
|
int is_msrp = switch_channel_test_flag(session->channel, CF_MSRP);
|
||||||
|
|
||||||
switch_assert(session);
|
switch_assert(session);
|
||||||
|
|
||||||
|
@ -13456,7 +13666,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_text_frame(switch_core
|
||||||
|
|
||||||
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
|
t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT];
|
||||||
|
|
||||||
if (switch_channel_test_cap(session->channel, CC_RTP_RTT)) {
|
if (!is_msrp && switch_channel_test_cap(session->channel, CC_RTP_RTT)) {
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
char *str = (char *) frame->data;
|
char *str = (char *) frame->data;
|
||||||
|
@ -13522,7 +13732,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_text_frame(switch_core
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_channel_test_cap(session->channel, CC_RTP_RTT)) {
|
if (!is_msrp && switch_channel_test_cap(session->channel, CC_RTP_RTT)) {
|
||||||
if (t_engine->red_pt) {
|
if (t_engine->red_pt) {
|
||||||
t_engine->tf->red_pos++;
|
t_engine->tf->red_pos++;
|
||||||
if (t_engine->tf->red_pos == t_engine->tf->red_max) {
|
if (t_engine->tf->red_pos == t_engine->tf->red_max) {
|
||||||
|
@ -13538,7 +13748,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_text_frame(switch_core
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_printf(switch_core_session_t *session, const char *fmt, ...)
|
SWITCH_DECLARE(switch_status_t) switch_core_session_printf(switch_core_session_t *session, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -13615,6 +13825,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_print(switch_core_session_t
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_msrp_session_t *) switch_core_media_get_msrp_session(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
if (!session->media_handle) return NULL;
|
||||||
|
|
||||||
|
return session->media_handle->msrp_session;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue