Merge "SDP: Add interface_address to specify our address to use."
This commit is contained in:
commit
f09e079294
4 changed files with 40 additions and 56 deletions
|
@ -124,6 +124,26 @@ void ast_sdp_options_set_media_address(struct ast_sdp_options *options,
|
||||||
*/
|
*/
|
||||||
const char *ast_sdp_options_get_media_address(const struct ast_sdp_options *options);
|
const char *ast_sdp_options_get_media_address(const struct ast_sdp_options *options);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \since 15.0.0
|
||||||
|
* \brief Set SDP Options interface_address
|
||||||
|
*
|
||||||
|
* \param options SDP Options
|
||||||
|
* \param interface_address
|
||||||
|
*/
|
||||||
|
void ast_sdp_options_set_interface_address(struct ast_sdp_options *options,
|
||||||
|
const char *interface_address);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \since 15.0.0
|
||||||
|
* \brief Get SDP Options interface_address
|
||||||
|
*
|
||||||
|
* \param options SDP Options
|
||||||
|
*
|
||||||
|
* \returns interface_address
|
||||||
|
*/
|
||||||
|
const char *ast_sdp_options_get_interface_address(const struct ast_sdp_options *options);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \since 15.0.0
|
* \since 15.0.0
|
||||||
* \brief Set SDP Options sdpowner
|
* \brief Set SDP Options sdpowner
|
||||||
|
@ -184,26 +204,6 @@ void ast_sdp_options_set_rtp_engine(struct ast_sdp_options *options,
|
||||||
*/
|
*/
|
||||||
const char *ast_sdp_options_get_rtp_engine(const struct ast_sdp_options *options);
|
const char *ast_sdp_options_get_rtp_engine(const struct ast_sdp_options *options);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \since 15.0.0
|
|
||||||
* \brief Set SDP Options bind_rtp_to_media_address
|
|
||||||
*
|
|
||||||
* \param options SDP Options
|
|
||||||
* \param bind_rtp_to_media_address
|
|
||||||
*/
|
|
||||||
void ast_sdp_options_set_bind_rtp_to_media_address(struct ast_sdp_options *options,
|
|
||||||
unsigned int bind_rtp_to_media_address);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \since 15.0.0
|
|
||||||
* \brief Get SDP Options bind_rtp_to_media_address
|
|
||||||
*
|
|
||||||
* \param options SDP Options
|
|
||||||
*
|
|
||||||
* \returns bind_rtp_to_media_address
|
|
||||||
*/
|
|
||||||
unsigned int ast_sdp_options_get_bind_rtp_to_media_address(const struct ast_sdp_options *options);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \since 15.0.0
|
* \since 15.0.0
|
||||||
* \brief Set SDP Options rtp_symmetric
|
* \brief Set SDP Options rtp_symmetric
|
||||||
|
@ -503,26 +503,6 @@ void ast_sdp_options_set_udptl_far_max_datagram(struct ast_sdp_options *options,
|
||||||
*/
|
*/
|
||||||
unsigned int ast_sdp_options_get_udptl_far_max_datagram(const struct ast_sdp_options *options);
|
unsigned int ast_sdp_options_get_udptl_far_max_datagram(const struct ast_sdp_options *options);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \since 15.0.0
|
|
||||||
* \brief Set SDP Options bind_udptl_to_media_address
|
|
||||||
*
|
|
||||||
* \param options SDP Options
|
|
||||||
* \param bind_udptl_to_media_address
|
|
||||||
*/
|
|
||||||
void ast_sdp_options_set_bind_udptl_to_media_address(struct ast_sdp_options *options,
|
|
||||||
unsigned int bind_udptl_to_media_address);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \since 15.0.0
|
|
||||||
* \brief Get SDP Options bind_udptl_to_media_address
|
|
||||||
*
|
|
||||||
* \param options SDP Options
|
|
||||||
*
|
|
||||||
* \returns bind_udptl_to_media_address
|
|
||||||
*/
|
|
||||||
unsigned int ast_sdp_options_get_bind_udptl_to_media_address(const struct ast_sdp_options *options);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \since 15.0.0
|
* \since 15.0.0
|
||||||
* \brief Enable setting SSRC level attributes on SDPs
|
* \brief Enable setting SSRC level attributes on SDPs
|
||||||
|
|
|
@ -55,12 +55,11 @@ type ast_sdp_options_get_##field(const struct ast_sdp_options *options) \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(media_address, 0);
|
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(media_address, 0);
|
||||||
|
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(interface_address, 0);
|
||||||
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpowner, 0);
|
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpowner, 0);
|
||||||
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpsession, 0);
|
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpsession, 0);
|
||||||
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(rtp_engine, 0);
|
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(rtp_engine, 0);
|
||||||
|
|
||||||
DEFINE_GETTERS_SETTERS_FOR(unsigned int, bind_rtp_to_media_address);
|
|
||||||
DEFINE_GETTERS_SETTERS_FOR(unsigned int, bind_udptl_to_media_address);
|
|
||||||
DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_symmetric);
|
DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_symmetric);
|
||||||
DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_symmetric);
|
DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_symmetric);
|
||||||
DEFINE_GETTERS_SETTERS_FOR(enum ast_t38_ec_modes, udptl_error_correction);
|
DEFINE_GETTERS_SETTERS_FOR(enum ast_t38_ec_modes, udptl_error_correction);
|
||||||
|
|
|
@ -24,8 +24,10 @@
|
||||||
|
|
||||||
struct ast_sdp_options {
|
struct ast_sdp_options {
|
||||||
AST_DECLARE_STRING_FIELDS(
|
AST_DECLARE_STRING_FIELDS(
|
||||||
/*! Optional media address to use in SDP */
|
/*! Media address to use in SDP */
|
||||||
AST_STRING_FIELD(media_address);
|
AST_STRING_FIELD(media_address);
|
||||||
|
/*! Optional address of the interface media should use. */
|
||||||
|
AST_STRING_FIELD(interface_address);
|
||||||
/*! SDP origin username */
|
/*! SDP origin username */
|
||||||
AST_STRING_FIELD(sdpowner);
|
AST_STRING_FIELD(sdpowner);
|
||||||
/*! SDP session name */
|
/*! SDP session name */
|
||||||
|
@ -34,8 +36,6 @@ struct ast_sdp_options {
|
||||||
AST_STRING_FIELD(rtp_engine);
|
AST_STRING_FIELD(rtp_engine);
|
||||||
);
|
);
|
||||||
struct {
|
struct {
|
||||||
unsigned int bind_rtp_to_media_address:1;
|
|
||||||
unsigned int bind_udptl_to_media_address:1;
|
|
||||||
unsigned int rtp_symmetric:1;
|
unsigned int rtp_symmetric:1;
|
||||||
unsigned int udptl_symmetric:1;
|
unsigned int udptl_symmetric:1;
|
||||||
unsigned int rtp_ipv6:1;
|
unsigned int rtp_ipv6:1;
|
||||||
|
|
|
@ -150,13 +150,15 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
|
||||||
{
|
{
|
||||||
struct ast_rtp_instance *rtp;
|
struct ast_rtp_instance *rtp;
|
||||||
struct ast_rtp_engine_ice *ice;
|
struct ast_rtp_engine_ice *ice;
|
||||||
struct ast_sockaddr temp_media_address;
|
|
||||||
static struct ast_sockaddr address_rtp;
|
static struct ast_sockaddr address_rtp;
|
||||||
struct ast_sockaddr *media_address = &address_rtp;
|
struct ast_sockaddr *media_address = &address_rtp;
|
||||||
|
|
||||||
if (options->bind_rtp_to_media_address && !ast_strlen_zero(options->media_address)) {
|
if (!ast_strlen_zero(options->interface_address)) {
|
||||||
ast_sockaddr_parse(&temp_media_address, options->media_address, 0);
|
if (!ast_sockaddr_parse(&address_rtp, options->interface_address, 0)) {
|
||||||
media_address = &temp_media_address;
|
ast_log(LOG_ERROR, "Attempted to bind RTP to invalid media address: %s\n",
|
||||||
|
options->interface_address);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ast_check_ipv6()) {
|
if (ast_check_ipv6()) {
|
||||||
ast_sockaddr_parse(&address_rtp, "::", 0);
|
ast_sockaddr_parse(&address_rtp, "::", 0);
|
||||||
|
@ -165,7 +167,8 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rtp = ast_rtp_instance_new(options->rtp_engine, sched, media_address, NULL))) {
|
rtp = ast_rtp_instance_new(options->rtp_engine, sched, media_address, NULL);
|
||||||
|
if (!rtp) {
|
||||||
ast_log(LOG_ERROR, "Unable to create RTP instance using RTP engine '%s'\n",
|
ast_log(LOG_ERROR, "Unable to create RTP instance using RTP engine '%s'\n",
|
||||||
options->rtp_engine);
|
options->rtp_engine);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -204,13 +207,15 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
|
||||||
static struct sdp_state_udptl *create_udptl(const struct ast_sdp_options *options)
|
static struct sdp_state_udptl *create_udptl(const struct ast_sdp_options *options)
|
||||||
{
|
{
|
||||||
struct sdp_state_udptl *udptl;
|
struct sdp_state_udptl *udptl;
|
||||||
struct ast_sockaddr temp_media_address;
|
|
||||||
static struct ast_sockaddr address_udptl;
|
static struct ast_sockaddr address_udptl;
|
||||||
struct ast_sockaddr *media_address = &address_udptl;
|
struct ast_sockaddr *media_address = &address_udptl;
|
||||||
|
|
||||||
if (options->bind_udptl_to_media_address && !ast_strlen_zero(options->media_address)) {
|
if (!ast_strlen_zero(options->interface_address)) {
|
||||||
ast_sockaddr_parse(&temp_media_address, options->media_address, 0);
|
if (!ast_sockaddr_parse(&address_udptl, options->interface_address, 0)) {
|
||||||
media_address = &temp_media_address;
|
ast_log(LOG_ERROR, "Attempted to bind UDPTL to invalid media address: %s\n",
|
||||||
|
options->interface_address);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ast_check_ipv6()) {
|
if (ast_check_ipv6()) {
|
||||||
ast_sockaddr_parse(&address_udptl, "::", 0);
|
ast_sockaddr_parse(&address_udptl, "::", 0);
|
||||||
|
|
Loading…
Reference in a new issue