提交 7dd872e9 authored 作者: Seven Du's avatar Seven Du 提交者: Anthony Minessale

FS-9575 #resolve [Add MRCP]

上级 c409499c
......@@ -296,6 +296,7 @@ library_include_HEADERS = \
src/include/switch_curl.h \
src/include/switch_json.h \
src/include/switch_utf8.h \
src/include/switch_msrp.h \
src/include/switch_vpx.h \
libs/libteletone/src/libteletone_detect.h \
libs/libteletone/src/libteletone_generate.h \
......@@ -376,6 +377,7 @@ libfreeswitch_la_SOURCES = \
src/switch_curl.c \
src/switch_hashtable.c\
src/switch_utf8.c \
src/switch_msrp.c \
src/switch_vpx.c \
libs/libtpl-1.5/src/tpl.c \
libs/libteletone/src/libteletone_detect.c \
......
<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_msrp.h>
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_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
#endif
/* For Emacs:
......
/*
* 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_IO_OVERRIDE,
CC_RTP_RTT,
CC_MSRP,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
CC_FLAG_MAX
} switch_channel_cap_t;
......@@ -1528,6 +1529,7 @@ typedef enum {
CF_TEXT_ECHO,
CF_TEXT_ACTIVE,
CF_TEXT_IDLE,
CF_MSRP,
/* 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() */
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 getcputime");
switch_msrp_load_apis_and_applications(module_interface);
/* indicate that the module should continue to be loaded */
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)
{
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);
}
......
......@@ -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_FS_RTP);
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);
......
......@@ -42,6 +42,7 @@
#include <switch_nat.h>
#include "private/switch_core_pvt.h"
#include <switch_curl.h>
#include <switch_msrp.h>
#ifndef WIN32
#include <switch_private.h>
#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_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, "Loading Modules.\n");
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_rtp_shutdown();
switch_msrp_destroy();
if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
switch_nat_shutdown();
......
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论