Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
35fe8f74
Commit
35fe8f74
authored
9 years ago
by
Matt Jordan
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "rtp_engine.c: Fix performance issue with several channel drivers that use RTP."
parents
12e6f5ac
f49bef08
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/rtp_engine.c
+57
-51
57 additions, 51 deletions
main/rtp_engine.c
with
57 additions
and
51 deletions
main/rtp_engine.c
+
57
−
51
View file @
35fe8f74
...
@@ -229,7 +229,7 @@ static int mime_types_len = 0;
...
@@ -229,7 +229,7 @@ static int mime_types_len = 0;
* See http://www.iana.org/assignments/rtp-parameters for a list of
* See http://www.iana.org/assignments/rtp-parameters for a list of
* assigned values
* assigned values
*/
*/
static
struct
ast_rtp_payload_type
static_RTP_PT
[
AST_RTP_MAX_PT
];
static
struct
ast_rtp_payload_type
*
static_RTP_PT
[
AST_RTP_MAX_PT
];
static
ast_rwlock_t
static_RTP_PT_lock
;
static
ast_rwlock_t
static_RTP_PT_lock
;
/*! \brief \ref stasis topic for RTP related messages */
/*! \brief \ref stasis topic for RTP related messages */
...
@@ -651,23 +651,23 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
...
@@ -651,23 +651,23 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
return
;
return
;
}
}
new_type
=
ast_rtp_engine_alloc_payload_type
();
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
new_type
=
ao2_bump
(
static_RTP_PT
[
payload
]);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
if
(
!
new_type
)
{
if
(
!
new_type
)
{
ast_debug
(
1
,
"Don't have a default tx payload type %d format for m type on %p
\n
"
,
payload
,
codecs
);
return
;
return
;
}
}
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
ast_debug
(
1
,
"Setting tx payload type %d based on m type on %p
\n
"
,
payload
,
codecs
);
ast_rwlock_wrlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_wrlock
(
&
codecs
->
codecs_lock
);
if
(
payload
<
AST_VECTOR_SIZE
(
&
codecs
->
payloads
))
{
if
(
payload
<
AST_VECTOR_SIZE
(
&
codecs
->
payloads
))
{
ao2_t_cleanup
(
AST_VECTOR_GET
(
&
codecs
->
payloads
,
payload
),
"cleaning up replaced payload type"
);
ao2_t_cleanup
(
AST_VECTOR_GET
(
&
codecs
->
payloads
,
payload
),
"cleaning up replaced payload type"
);
}
}
new_type
->
asterisk_format
=
static_RTP_PT
[
payload
].
asterisk_format
;
new_type
->
rtp_code
=
static_RTP_PT
[
payload
].
rtp_code
;
new_type
->
payload
=
payload
;
new_type
->
format
=
ao2_bump
(
static_RTP_PT
[
payload
].
format
);
ast_debug
(
1
,
"Setting payload %d (%p) based on m type on %p
\n
"
,
payload
,
new_type
,
codecs
);
AST_VECTOR_REPLACE
(
&
codecs
->
payloads
,
payload
,
new_type
);
AST_VECTOR_REPLACE
(
&
codecs
->
payloads
,
payload
,
new_type
);
if
(
instance
&&
instance
->
engine
&&
instance
->
engine
->
payload_set
)
{
if
(
instance
&&
instance
->
engine
&&
instance
->
engine
->
payload_set
)
{
...
@@ -675,7 +675,6 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
...
@@ -675,7 +675,6 @@ void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct as
}
}
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
}
}
int
ast_rtp_codecs_payloads_set_rtpmap_type_rate
(
struct
ast_rtp_codecs
*
codecs
,
struct
ast_rtp_instance
*
instance
,
int
pt
,
int
ast_rtp_codecs_payloads_set_rtpmap_type_rate
(
struct
ast_rtp_codecs
*
codecs
,
struct
ast_rtp_instance
*
instance
,
int
pt
,
...
@@ -791,15 +790,8 @@ struct ast_rtp_payload_type *ast_rtp_codecs_get_payload(struct ast_rtp_codecs *c
...
@@ -791,15 +790,8 @@ struct ast_rtp_payload_type *ast_rtp_codecs_get_payload(struct ast_rtp_codecs *c
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
if
(
!
type
)
{
if
(
!
type
)
{
type
=
ast_rtp_engine_alloc_payload_type
();
if
(
!
type
)
{
return
NULL
;
}
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
type
->
asterisk_format
=
static_RTP_PT
[
payload
].
asterisk_format
;
type
=
ao2_bump
(
static_RTP_PT
[
payload
]);
type
->
rtp_code
=
static_RTP_PT
[
payload
].
rtp_code
;
type
->
payload
=
payload
;
type
->
format
=
ao2_bump
(
static_RTP_PT
[
payload
].
format
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
}
}
...
@@ -810,17 +802,24 @@ int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int pay
...
@@ -810,17 +802,24 @@ int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int pay
{
{
struct
ast_rtp_payload_type
*
type
;
struct
ast_rtp_payload_type
*
type
;
if
(
payload
<
0
||
payload
>=
AST_RTP_MAX_PT
)
{
if
(
payload
<
0
||
payload
>=
AST_RTP_MAX_PT
||
!
format
)
{
return
-
1
;
}
type
=
ast_rtp_engine_alloc_payload_type
();
if
(
!
type
)
{
return
-
1
;
return
-
1
;
}
}
ao2_ref
(
format
,
+
1
);
type
->
format
=
format
;
type
->
asterisk_format
=
1
;
type
->
payload
=
payload
;
ast_rwlock_wrlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_wrlock
(
&
codecs
->
codecs_lock
);
if
(
payload
<
AST_VECTOR_SIZE
(
&
codecs
->
payloads
))
{
if
(
payload
<
AST_VECTOR_SIZE
(
&
codecs
->
payloads
))
{
type
=
AST_VECTOR_GET
(
&
codecs
->
payloads
,
payload
);
ao2_cleanup
(
AST_VECTOR_GET
(
&
codecs
->
payloads
,
payload
));
if
(
type
&&
type
->
asterisk_format
)
{
ao2_replace
(
type
->
format
,
format
);
}
}
}
AST_VECTOR_REPLACE
(
&
codecs
->
payloads
,
payload
,
type
);
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
ast_rwlock_unlock
(
&
codecs
->
codecs_lock
);
return
0
;
return
0
;
...
@@ -923,12 +922,15 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_form
...
@@ -923,12 +922,15 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_form
if
(
payload
<
0
)
{
if
(
payload
<
0
)
{
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
ast_rwlock_rdlock
(
&
static_RTP_PT_lock
);
for
(
i
=
0
;
i
<
AST_RTP_MAX_PT
;
i
++
)
{
for
(
i
=
0
;
i
<
AST_RTP_MAX_PT
;
i
++
)
{
if
(
static_RTP_PT
[
i
].
asterisk_format
&&
asterisk_format
&&
format
&&
if
(
!
static_RTP_PT
[
i
])
{
(
ast_format_cmp
(
format
,
static_RTP_PT
[
i
].
format
)
!=
AST_FORMAT_CMP_NOT_EQUAL
))
{
continue
;
}
if
(
static_RTP_PT
[
i
]
->
asterisk_format
&&
asterisk_format
&&
format
&&
(
ast_format_cmp
(
format
,
static_RTP_PT
[
i
]
->
format
)
!=
AST_FORMAT_CMP_NOT_EQUAL
))
{
payload
=
i
;
payload
=
i
;
break
;
break
;
}
else
if
(
!
static_RTP_PT
[
i
]
.
asterisk_format
&&
!
asterisk_format
&&
}
else
if
(
!
static_RTP_PT
[
i
]
->
asterisk_format
&&
!
asterisk_format
&&
(
static_RTP_PT
[
i
]
.
rtp_code
==
code
))
{
(
static_RTP_PT
[
i
]
->
rtp_code
==
code
))
{
payload
=
i
;
payload
=
i
;
break
;
break
;
}
}
...
@@ -1693,16 +1695,6 @@ void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
...
@@ -1693,16 +1695,6 @@ void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
dtls_cfg
->
capath
=
NULL
;
dtls_cfg
->
capath
=
NULL
;
}
}
/*! \internal
* \brief Small helper routine that cleans up entry i in
* \c static_RTP_PT.
*/
static
void
rtp_engine_static_RTP_PT_cleanup
(
int
i
)
{
ao2_cleanup
(
static_RTP_PT
[
i
].
format
);
memset
(
&
static_RTP_PT
[
i
],
0
,
sizeof
(
struct
ast_rtp_payload_type
));
}
/*! \internal
/*! \internal
* \brief Small helper routine that cleans up entry i in
* \brief Small helper routine that cleans up entry i in
* \c ast_rtp_mime_types.
* \c ast_rtp_mime_types.
...
@@ -1744,6 +1736,7 @@ static void set_next_mime_type(struct ast_format *format, int rtp_code, const ch
...
@@ -1744,6 +1736,7 @@ static void set_next_mime_type(struct ast_format *format, int rtp_code, const ch
static
void
add_static_payload
(
int
map
,
struct
ast_format
*
format
,
int
rtp_code
)
static
void
add_static_payload
(
int
map
,
struct
ast_format
*
format
,
int
rtp_code
)
{
{
int
x
;
int
x
;
struct
ast_rtp_payload_type
*
type
;
ast_assert
(
map
<
ARRAY_LEN
(
static_RTP_PT
));
ast_assert
(
map
<
ARRAY_LEN
(
static_RTP_PT
));
...
@@ -1751,24 +1744,36 @@ static void add_static_payload(int map, struct ast_format *format, int rtp_code)
...
@@ -1751,24 +1744,36 @@ static void add_static_payload(int map, struct ast_format *format, int rtp_code)
if
(
map
<
0
)
{
if
(
map
<
0
)
{
/* find next available dynamic payload slot */
/* find next available dynamic payload slot */
for
(
x
=
AST_RTP_PT_FIRST_DYNAMIC
;
x
<
AST_RTP_MAX_PT
;
++
x
)
{
for
(
x
=
AST_RTP_PT_FIRST_DYNAMIC
;
x
<
AST_RTP_MAX_PT
;
++
x
)
{
if
(
!
static_RTP_PT
[
x
]
.
asterisk_format
&&
!
static_RTP_PT
[
x
].
rtp_code
)
{
if
(
!
static_RTP_PT
[
x
])
{
map
=
x
;
map
=
x
;
break
;
break
;
}
}
}
}
if
(
map
<
0
)
{
if
(
map
<
0
)
{
ast_log
(
LOG_WARNING
,
"No Dynamic RTP mapping available for format %s
\n
"
,
if
(
format
)
{
ast_format_get_name
(
format
));
ast_log
(
LOG_WARNING
,
"No Dynamic RTP mapping available for format %s
\n
"
,
ast_format_get_name
(
format
));
}
else
{
ast_log
(
LOG_WARNING
,
"No Dynamic RTP mapping available for RTP code %d
\n
"
,
rtp_code
);
}
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
return
;
return
;
}
}
}
}
if
(
format
)
{
type
=
ast_rtp_engine_alloc_payload_type
();
static_RTP_PT
[
map
].
asterisk_format
=
1
;
if
(
type
)
{
static_RTP_PT
[
map
].
format
=
ao2_bump
(
format
);
if
(
format
)
{
}
else
{
ao2_ref
(
format
,
+
1
);
static_RTP_PT
[
map
].
rtp_code
=
rtp_code
;
type
->
format
=
format
;
type
->
asterisk_format
=
1
;
}
else
{
type
->
rtp_code
=
rtp_code
;
}
type
->
payload
=
map
;
ao2_cleanup
(
static_RTP_PT
[
map
]);
static_RTP_PT
[
map
]
=
type
;
}
}
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
}
}
...
@@ -1797,8 +1802,10 @@ int ast_rtp_engine_unload_format(struct ast_format *format)
...
@@ -1797,8 +1802,10 @@ int ast_rtp_engine_unload_format(struct ast_format *format)
ast_rwlock_wrlock
(
&
static_RTP_PT_lock
);
ast_rwlock_wrlock
(
&
static_RTP_PT_lock
);
/* remove everything pertaining to this format id from the lists */
/* remove everything pertaining to this format id from the lists */
for
(
x
=
0
;
x
<
AST_RTP_MAX_PT
;
x
++
)
{
for
(
x
=
0
;
x
<
AST_RTP_MAX_PT
;
x
++
)
{
if
(
ast_format_cmp
(
static_RTP_PT
[
x
].
format
,
format
)
==
AST_FORMAT_CMP_EQUAL
)
{
if
(
static_RTP_PT
[
x
]
rtp_engine_static_RTP_PT_cleanup
(
x
);
&&
ast_format_cmp
(
static_RTP_PT
[
x
]
->
format
,
format
)
==
AST_FORMAT_CMP_EQUAL
)
{
ao2_ref
(
static_RTP_PT
[
x
],
-
1
);
static_RTP_PT
[
x
]
=
NULL
;
}
}
}
}
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
...
@@ -2087,9 +2094,8 @@ static void rtp_engine_shutdown(void)
...
@@ -2087,9 +2094,8 @@ static void rtp_engine_shutdown(void)
ast_rwlock_wrlock
(
&
static_RTP_PT_lock
);
ast_rwlock_wrlock
(
&
static_RTP_PT_lock
);
for
(
x
=
0
;
x
<
AST_RTP_MAX_PT
;
x
++
)
{
for
(
x
=
0
;
x
<
AST_RTP_MAX_PT
;
x
++
)
{
if
(
static_RTP_PT
[
x
].
format
)
{
ao2_cleanup
(
static_RTP_PT
[
x
]);
rtp_engine_static_RTP_PT_cleanup
(
x
);
static_RTP_PT
[
x
]
=
NULL
;
}
}
}
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
ast_rwlock_unlock
(
&
static_RTP_PT_lock
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment