Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
62600b2
Inline mal placé
jpb-ives May 13, 2024
1b77fdf
Premiere étape pour un module WebRTC Datachannel et un second Websock…
jpb-ives May 13, 2024
c148f4e
Pour eviter d'avoir des warnings de compile qd le flag DONTOPTIMIZE e…
jpb-ives May 13, 2024
142a261
Module qui rajoute la gestion d'un websocket pour le texte provenant …
jpb-ives May 21, 2024
ad4a815
Avoir accès à la callback pour vérifier que l'url websocket est permise
jpb-ives May 27, 2024
4fc9aba
Ajout d'une pile de frame de type TEXT pour les échanges texte
jpb-ives May 28, 2024
f526114
Pour completer la description du SDP
jpb-ives Jun 12, 2024
e57dce9
Augmenter le nombre de média pour gerer le media 'texte'
jpb-ives Jun 12, 2024
8ab9bd8
Fixe orthographe
jpb-ives Jun 19, 2024
17495c9
ajout des capacités
jpb-ives Jun 19, 2024
16b7390
Deactive le TEXTE en mode sendtext via SIP/MESSAGE
jpb-ives Jun 20, 2024
71bb958
Ajout temporaire d'infos sur les traces
jpb-ives Jun 20, 2024
575acc1
Ajout et gestion du flag pour gerer le T.140/RED
jpb-ives Jun 25, 2024
fb50275
Debug end on T.140/RED
jpb-ives Jun 25, 2024
7da0a94
Removing datachannel impl
jpb-ives Jun 25, 2024
3e20f13
Version before deletion of implementation with list of frames
jpb-ives Jun 25, 2024
6e1afc7
Removing unnecessary files
jpb-ives Jun 25, 2024
4a0c670
Improving logs
jpb-ives Jun 25, 2024
61bc8e9
Improved communication via websocket exchange pipe with the asterisk …
jpb-ives Jun 25, 2024
e9f44d7
Suppression de traces inutiles
jpb-ives Jul 1, 2024
cd8cbc5
Premiere étape d'optimisation et de rationalistion
jpb-ives Jul 1, 2024
65e511a
IPv6 flag removed in configuration
jpb-ives Jul 12, 2024
24ee4a0
Consolidation of structures
jpb-ives Jul 12, 2024
b0e8275
For the text in the dialplan
jpb-ives Jul 18, 2024
35c177f
Fix pour avoir le bon nombre de generations RED
jpb-ives Aug 22, 2024
8a9cbc9
Doc du nouveau parametre ws_text d'un endpoint pjsip
jpb-ives Aug 22, 2024
47ba6d3
Optimise et limite à une taille de frame text de 396 octets
jpb-ives Aug 22, 2024
2c04e7f
Pouvoir personnaliser le nom hostname du service avec le fichier res_…
jpb-ives Sep 10, 2024
a567f44
Comments in English
jpb-ives Sep 10, 2024
ec096e9
Delete unnecessary function
jpb-ives Sep 11, 2024
566bf24
Fix of a badly managed pointer
jpb-ives Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bridges/bridge_native_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ static int native_rtp_bridge_compatible_check(struct ast_bridge *bridge, struct
RAII_VAR(struct rtp_glue_data *, glue0, NULL, rtp_glue_data_destroy);
RAII_VAR(struct rtp_glue_data *, glue1, NULL, rtp_glue_data_destroy);

ast_debug(1, "Bridge '%s'. Checking compatability for channels '%s' and '%s'\n",
ast_debug(1, "Bridge '%s'. Checking compatibility for channels '%s' and '%s'\n",
bridge->uniqueid, ast_channel_name(bc0->chan), ast_channel_name(bc1->chan));

if (!native_rtp_bridge_capable(bc0->chan)) {
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ AST_NO_STRINGOP_TRUNCATION
AST_NO_FORMAT_Y2K
AST_NO_FORMAT_TRUNCATION
AST_NO_STRICT_OVERFLOW
AST_FORTIFY_SOURCE
# AST_FORTIFY_SOURCE
AST_TRAMPOLINES
AST_DECLARATION_AFTER_STATEMENT
AST_UNDEFINED_SANITIZER
Expand Down
26 changes: 25 additions & 1 deletion include/asterisk/res_pjsip.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,26 @@ struct ast_sip_t38_configuration {
unsigned int bind_udptl_to_media_address;
};

/*!
* \brief WebRTC Datachannel configuration for SIP endpoints
*/
struct ast_sip_webrtc_datachannel_configuration
{
/*! Whether WebRTC Datachannel support is enabled or not */
unsigned int enabled;
/*! Whether to use IPv6 for WebRTC Datachannel or not */
unsigned int ipv6;
};

/*!
* \brief Websocket text configuration for SIP endpoints
*/
struct ast_sip_websocket_text_configuration
{
/*! Whether websocket text support is enabled or not */
unsigned int enabled;
};

/*!
* \brief Media configuration for SIP endpoints
*/
Expand All @@ -905,6 +925,10 @@ struct ast_sip_endpoint_media_configuration {
struct ast_sip_direct_media_configuration direct_media;
/*! T.38 (FoIP) options */
struct ast_sip_t38_configuration t38;
/*! WebRTC Datachannel configuration options */
struct ast_sip_webrtc_datachannel_configuration webrtc_datachannel_configuration;
/*! Websocket text configuration options */
struct ast_sip_websocket_text_configuration websocket_text_configuration;
/*! Configured codecs */
struct ast_format_cap *codecs;
/*! Capabilities in topology form */
Expand All @@ -921,7 +945,7 @@ struct ast_sip_endpoint_media_configuration {
unsigned int tos_text;
/*! Priority for text streams */
unsigned int cos_text;
/*! Indicate if text stream supports RED */
/*! Flag indicate if text stream supports RED */
unsigned int red_enabled;
/*! Is g.726 packed in a non standard way */
unsigned int g726_non_standard;
Expand Down
4 changes: 4 additions & 0 deletions include/asterisk/res_pjsip_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct pjmedia_sdp_media;
struct pjmedia_sdp_session;
struct ast_dsp;
struct ast_udptl;
struct ast_websocket_session_text;

/*! \brief T.38 states for a session */
enum ast_sip_session_t38state {
Expand Down Expand Up @@ -127,6 +128,9 @@ struct ast_sip_session_media {
char *remote_label;
/*! \brief Stream name */
char *stream_name;

/*! \brief Websocket session text instance itself */
struct ast_websocket_session_text *websocket_session_text;
};

/*!
Expand Down
4 changes: 2 additions & 2 deletions include/asterisk/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static force_inline int attribute_pure ast_strlen_zero(const char *s)
\retval 1 if \a str begins with \a prefix
\retval 0 otherwise.
*/
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
static force_inline int attribute_pure ast_begins_with(const char *str, const char *prefix)
{
ast_assert(str != NULL);
ast_assert(prefix != NULL);
Expand All @@ -113,7 +113,7 @@ static int force_inline attribute_pure ast_begins_with(const char *str, const ch
\retval 1 if \a str ends with \a suffix
\retval 0 otherwise.
*/
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
static force_inline int attribute_pure ast_ends_with(const char *str, const char *suffix)
{
size_t str_len;
size_t suffix_len;
Expand Down
1 change: 1 addition & 0 deletions main/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4818,6 +4818,7 @@ int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
f.datalen = body_len;
f.mallocd = AST_MALLOCD_DATA;
f.data.ptr = ast_strdup(body);
f.stream_num = ast_stream_get_position(ast_channel_get_default_stream(chan, AST_MEDIA_TYPE_TEXT));
if (f.data.ptr) {
res = ast_channel_tech(chan)->write_text(chan, &f);
} else {
Expand Down
7 changes: 5 additions & 2 deletions res/res_pjsip/pjsip_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@
<configOption name="tos_text">
<synopsis>DSCP TOS bits for text streams</synopsis>
<description><para>
See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
See https://docs.asterisk.org/Configuration/Channel-Drivers/IP-Quality-of-Service for more information about QoS settings
</para></description>
</configOption>
<configOption name="cos_audio">
Expand All @@ -1016,9 +1016,12 @@
<configOption name="cos_text">
<synopsis>Priority for text streams</synopsis>
<description><para>
See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
See https://docs.asterisk.org/Configuration/Channel-Drivers/IP-Quality-of-Service for more information about QoS settings
</para></description>
</configOption>
<configOption name="ws_text" default="no">
<synopsis>Allow use of websocket text for WebRTC traffic</synopsis>
</configOption>
<configOption name="allow_subscribe" default="yes">
<synopsis>Determines if endpoint is allowed to initiate subscriptions with Asterisk.</synopsis>
</configOption>
Expand Down
3 changes: 3 additions & 0 deletions res/res_pjsip/pjsip_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,9 @@ int ast_res_pjsip_initialize_configuration(void)
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "named_call_group", "", named_groups_handler, named_callgroups_to_str, NULL, 0, 0);
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "named_pickup_group", "", named_groups_handler, named_pickupgroups_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "device_state_busy_at", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, devicestate_busy_at));

ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ws_text", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.websocket_text_configuration.enabled));

ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.t38.enabled));
ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "t38_udptl_ec", "none", t38udptl_ec_handler, t38udptl_ec_to_str, NULL, 0, 0);
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "t38_udptl_maxdatagram", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.t38.maxdatagram));
Expand Down
3 changes: 3 additions & 0 deletions res/res_pjsip/pjsip_manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@
<parameter name="RewriteContact">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rewrite_contact']/synopsis/node())"/></para>
</parameter>
<parameter name="WsText">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='ws_text']/synopsis/node())"/></para>
</parameter>
<parameter name="Transport">
<para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='transport']/synopsis/node())"/></para>
</parameter>
Expand Down
28 changes: 22 additions & 6 deletions res/res_pjsip_sdp_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static void get_codecs(struct ast_sip_session *session, const struct pjmedia_sdp
red_cp = strtok_r(NULL, "/", &rest);
}

if (++red_num_gen > 0) {
if (red_num_gen > 0) {
ast_log(AST_LOG_NOTICE, "T.140/RED enabled (pt=%d) with %d generations\n", num, red_num_gen);
session->endpoint->media.red_enabled = 1;
ast_rtp_red_init(session_media->rtp, 300, red_data_pt, red_num_gen);
Expand Down Expand Up @@ -975,7 +975,7 @@ static enum ast_sip_session_media_encryption get_media_encryption_type(pj_str_t

*optimistic = 0;

if (!transport_str) {
if (!transport_str || !strstr(transport_str, "AVP")) {
return AST_SIP_MEDIA_TRANSPORT_INVALID;
}
if (strstr(transport_str, "UDP/TLS")) {
Expand Down Expand Up @@ -1536,6 +1536,12 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session,
SCOPE_EXIT_RTN_VALUE(0, "Endpoint has no codecs\n");
}

RAII_VAR(char *, transport_str, ast_strndup(stream->desc.transport.ptr, stream->desc.transport.slen), ast_free);

if (!transport_str || !strstr(transport_str, "AVP")) {
SCOPE_EXIT_RTN_VALUE(0, "Incompatible transport\n");
}

/* Ensure incoming transport is compatible with the endpoint's configuration */
if (!session->endpoint->media.rtp.use_received_transport) {
encryption = check_endpoint_media_transport(session->endpoint, stream);
Expand Down Expand Up @@ -1974,6 +1980,10 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
media->attr[media->attr_count++] = attr;
}

if (media_type == AST_MEDIA_TYPE_TEXT) {
ast_debug(3, "SDP generate RTP frame text %d %s\n", rtp_code, ast_format_get_codec_name(format));
}

if (media_type == AST_MEDIA_TYPE_TEXT && !strcasecmp(ast_format_get_codec_name(format), "red")) {
// TODO jpb: En attendant de faire mieux.
if (rtp_code == 105 || rtp_code == 96) {
Expand Down Expand Up @@ -2150,6 +2160,12 @@ static int apply_negotiated_sdp_stream(struct ast_sip_session *session,
SCOPE_EXIT_RTN_VALUE(1, "No channel\n");
}

RAII_VAR(char *, transport_str, ast_strndup(remote_stream->desc.transport.ptr, remote_stream->desc.transport.slen), ast_free);

if (!transport_str || !strstr(transport_str, "AVP")) {
SCOPE_EXIT_RTN_VALUE(0, "Incompatible transport\n");
}

/* Ensure incoming transport is compatible with the endpoint's configuration */
if (!session->endpoint->media.rtp.use_received_transport &&
check_endpoint_media_transport(session->endpoint, remote_stream) == AST_SIP_MEDIA_TRANSPORT_INVALID) {
Expand Down Expand Up @@ -2347,7 +2363,7 @@ static void stream_destroy(struct ast_sip_session_media *session_media)

/*! \brief SDP handler for 'audio' media stream */
static struct ast_sip_session_sdp_handler audio_sdp_handler = {
.id = STR_AUDIO,
.id = "audio_rtp", //STR_AUDIO,
.negotiate_incoming_sdp_stream = negotiate_incoming_sdp_stream,
.create_outgoing_sdp_stream = create_outgoing_sdp_stream,
.apply_negotiated_sdp_stream = apply_negotiated_sdp_stream,
Expand All @@ -2358,7 +2374,7 @@ static struct ast_sip_session_sdp_handler audio_sdp_handler = {

/*! \brief SDP handler for 'video' media stream */
static struct ast_sip_session_sdp_handler video_sdp_handler = {
.id = STR_VIDEO,
.id = "video_rtp", //STR_VIDEO,
.negotiate_incoming_sdp_stream = negotiate_incoming_sdp_stream,
.create_outgoing_sdp_stream = create_outgoing_sdp_stream,
.apply_negotiated_sdp_stream = apply_negotiated_sdp_stream,
Expand All @@ -2370,7 +2386,7 @@ static struct ast_sip_session_sdp_handler video_sdp_handler = {

/*! \brief SDP handler for 'text' media stream */
static struct ast_sip_session_sdp_handler text_sdp_handler = {
.id = STR_TEXT,
.id = "test_rtp", //STR_TEXT,
.negotiate_incoming_sdp_stream = negotiate_incoming_sdp_stream,
.create_outgoing_sdp_stream = create_outgoing_sdp_stream,
.apply_negotiated_sdp_stream = apply_negotiated_sdp_stream,
Expand Down Expand Up @@ -2458,7 +2474,7 @@ static int load_module(void)
ast_log(LOG_ERROR, "Unable to register SDP handler for %s stream type\n", STR_VIDEO);
goto end;
}

if (ast_sip_session_register_sdp_handler(&text_sdp_handler, STR_TEXT)) {
ast_log(LOG_ERROR, "Unable to register SDP handler for %s stream type\n", STR_TEXT);
goto end;
Expand Down
4 changes: 2 additions & 2 deletions res/res_pjsip_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
#define MOD_DATA_ON_RESPONSE "on_response"
#define MOD_DATA_NAT_HOOK "nat_hook"

/* Most common case is one audio and one video stream */
#define DEFAULT_NUM_SESSION_MEDIA 2
/* Most common case is one audio, one video stream and one text stream */
#define DEFAULT_NUM_SESSION_MEDIA 3

/* Some forward declarations */
static void handle_session_begin(struct ast_sip_session *session);
Expand Down
Loading