mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
Merge topic 'misc_rtp_tweaks' into 13
* changes: rtp_engine.c: Must protect mime_types_len with mime_types_lock. res_pjsip_sdp_rtp.c: Fixup some whitespace.
This commit is contained in:
@@ -603,6 +603,7 @@ void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
|
|||||||
void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
|
void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
|
||||||
{
|
{
|
||||||
ast_rtp_codecs_payloads_destroy(codecs);
|
ast_rtp_codecs_payloads_destroy(codecs);
|
||||||
|
ast_rtp_codecs_payloads_initialize(codecs);
|
||||||
|
|
||||||
if (instance && instance->engine && instance->engine->payload_set) {
|
if (instance && instance->engine && instance->engine->payload_set) {
|
||||||
int i;
|
int i;
|
||||||
@@ -610,8 +611,6 @@ void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp
|
|||||||
instance->engine->payload_set(instance, i, 0, NULL, 0);
|
instance->engine->payload_set(instance, i, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_rtp_codecs_payloads_initialize(codecs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
|
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
|
||||||
@@ -1716,12 +1715,16 @@ static void rtp_engine_mime_type_cleanup(int i)
|
|||||||
|
|
||||||
static void set_next_mime_type(struct ast_format *format, int rtp_code, const char *type, const char *subtype, unsigned int sample_rate)
|
static void set_next_mime_type(struct ast_format *format, int rtp_code, const char *type, const char *subtype, unsigned int sample_rate)
|
||||||
{
|
{
|
||||||
int x = mime_types_len;
|
int x;
|
||||||
if (ARRAY_LEN(ast_rtp_mime_types) == mime_types_len) {
|
|
||||||
|
ast_rwlock_wrlock(&mime_types_lock);
|
||||||
|
|
||||||
|
x = mime_types_len;
|
||||||
|
if (ARRAY_LEN(ast_rtp_mime_types) <= x) {
|
||||||
|
ast_rwlock_unlock(&mime_types_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_rwlock_wrlock(&mime_types_lock);
|
|
||||||
/* Make sure any previous value in ast_rtp_mime_types is cleaned up */
|
/* Make sure any previous value in ast_rtp_mime_types is cleaned up */
|
||||||
memset(&ast_rtp_mime_types[x], 0, sizeof(struct ast_rtp_mime_type));
|
memset(&ast_rtp_mime_types[x], 0, sizeof(struct ast_rtp_mime_type));
|
||||||
if (format) {
|
if (format) {
|
||||||
@@ -1734,6 +1737,7 @@ static void set_next_mime_type(struct ast_format *format, int rtp_code, const ch
|
|||||||
ast_copy_string(ast_rtp_mime_types[x].subtype, subtype, sizeof(ast_rtp_mime_types[x].subtype));
|
ast_copy_string(ast_rtp_mime_types[x].subtype, subtype, sizeof(ast_rtp_mime_types[x].subtype));
|
||||||
ast_rtp_mime_types[x].sample_rate = sample_rate;
|
ast_rtp_mime_types[x].sample_rate = sample_rate;
|
||||||
mime_types_len++;
|
mime_types_len++;
|
||||||
|
|
||||||
ast_rwlock_unlock(&mime_types_lock);
|
ast_rwlock_unlock(&mime_types_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2095,6 +2099,7 @@ static void rtp_engine_shutdown(void)
|
|||||||
rtp_engine_mime_type_cleanup(x);
|
rtp_engine_mime_type_cleanup(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mime_types_len = 0;
|
||||||
ast_rwlock_unlock(&mime_types_lock);
|
ast_rwlock_unlock(&mime_types_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,13 +237,13 @@ static void get_codecs(struct ast_sip_session *session, const struct pjmedia_sdp
|
|||||||
}
|
}
|
||||||
|
|
||||||
ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
|
ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
|
||||||
if (strcmp(name,"telephone-event") == 0) {
|
if (strcmp(name, "telephone-event") == 0) {
|
||||||
tel_event++;
|
tel_event++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_copy_pj_str(media, (pj_str_t*)&stream->desc.media, sizeof(media));
|
ast_copy_pj_str(media, (pj_str_t*)&stream->desc.media, sizeof(media));
|
||||||
ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, NULL, pj_strtoul(&stream->desc.fmt[i]),
|
ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, NULL,
|
||||||
media, name, options, rtpmap->clock_rate);
|
pj_strtoul(&stream->desc.fmt[i]), media, name, options, rtpmap->clock_rate);
|
||||||
/* Look for an optional associated fmtp attribute */
|
/* Look for an optional associated fmtp attribute */
|
||||||
if (!(attr = pjmedia_sdp_media_find_attr2(stream, "fmtp", &rtpmap->pt))) {
|
if (!(attr = pjmedia_sdp_media_find_attr2(stream, "fmtp", &rtpmap->pt))) {
|
||||||
continue;
|
continue;
|
||||||
@@ -270,7 +270,7 @@ static void get_codecs(struct ast_sip_session *session, const struct pjmedia_sdp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tel_event==0) && (session->endpoint->dtmf == AST_SIP_DTMF_AUTO)) {
|
if (!tel_event && (session->endpoint->dtmf == AST_SIP_DTMF_AUTO)) {
|
||||||
ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
|
ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
|
||||||
}
|
}
|
||||||
/* Get the packetization, if it exists */
|
/* Get the packetization, if it exists */
|
||||||
@@ -1137,8 +1137,12 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
|
|||||||
/* Add non-codec formats */
|
/* Add non-codec formats */
|
||||||
if (media_type != AST_MEDIA_TYPE_VIDEO) {
|
if (media_type != AST_MEDIA_TYPE_VIDEO) {
|
||||||
for (index = 1LL; index <= AST_RTP_MAX; index <<= 1) {
|
for (index = 1LL; index <= AST_RTP_MAX; index <<= 1) {
|
||||||
if (!(noncodec & index) || (rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session_media->rtp),
|
if (!(noncodec & index)) {
|
||||||
0, NULL, index)) == -1) {
|
continue;
|
||||||
|
}
|
||||||
|
rtp_code = ast_rtp_codecs_payload_code(
|
||||||
|
ast_rtp_instance_get_codecs(session_media->rtp), 0, NULL, index);
|
||||||
|
if (rtp_code == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user