Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
55973deb
Commit
55973deb
authored
Jan 17, 2015
by
Simon Morlat
Browse files
modularize payload type matching exceptions in offer/answer
parent
546b953c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
27 deletions
+94
-27
coreapi/offeranswer.c
coreapi/offeranswer.c
+93
-26
mediastreamer2
mediastreamer2
+1
-1
No files found.
coreapi/offeranswer.c
View file @
55973deb
...
@@ -31,9 +31,13 @@ static bool_t only_telephone_event(const MSList *l){
...
@@ -31,9 +31,13 @@ static bool_t only_telephone_event(const MSList *l){
return
TRUE
;
return
TRUE
;
}
}
static
PayloadType
*
find_payload_type_best_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
typedef
struct
_PayloadTypeMatcher
{
const
char
*
mime_type
;
PayloadType
*
(
*
match_func
)(
const
MSList
*
l
,
const
PayloadType
*
refpt
);
}
PayloadTypeMatcher
;
static
PayloadType
*
opus_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
PayloadType
*
pt
;
PayloadType
*
pt
;
char
value
[
10
];
const
MSList
*
elem
;
const
MSList
*
elem
;
PayloadType
*
candidate
=
NULL
;
PayloadType
*
candidate
=
NULL
;
...
@@ -41,38 +45,101 @@ static PayloadType * find_payload_type_best_match(const MSList *l, const Payload
...
@@ -41,38 +45,101 @@ static PayloadType * find_payload_type_best_match(const MSList *l, const Payload
pt
=
(
PayloadType
*
)
elem
->
data
;
pt
=
(
PayloadType
*
)
elem
->
data
;
/*workaround a bug in earlier versions of linphone where opus/48000/1 is offered, which is uncompliant with opus rtp draft*/
/*workaround a bug in earlier versions of linphone where opus/48000/1 is offered, which is uncompliant with opus rtp draft*/
if
(
refpt
->
mime_type
&&
strcasecmp
(
ref
pt
->
mime_type
,
"opus"
)
==
0
&&
refpt
->
channels
==
1
if
(
strcasecmp
(
pt
->
mime_type
,
"opus"
)
==
0
){
&&
strcasecmp
(
pt
->
mime_type
,
refpt
->
mime_type
)
==
0
){
if
(
refpt
->
channels
==
1
){
pt
->
channels
=
1
;
/*so that we respond with same number of channels */
pt
->
channels
=
1
;
/*so that we respond with same number of channels */
candidate
=
pt
;
candidate
=
pt
;
break
;
}
else
if
(
refpt
->
channels
==
2
){
return
pt
;
}
}
}
}
return
candidate
;
}
/* the reason for this matcher is for some stupid uncompliant phone that offer G729a mime type !*/
static
PayloadType
*
g729A_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
PayloadType
*
pt
;
const
MSList
*
elem
;
PayloadType
*
candidate
=
NULL
;
/* the compare between G729 and G729A is for some stupid uncompliant phone*/
for
(
elem
=
l
;
elem
!=
NULL
;
elem
=
elem
->
next
){
if
(
pt
->
mime_type
&&
refpt
->
mime_type
&&
pt
=
(
PayloadType
*
)
elem
->
data
;
(
strcasecmp
(
pt
->
mime_type
,
refpt
->
mime_type
)
==
0
||
(
strcasecmp
(
pt
->
mime_type
,
"G729"
)
==
0
&&
strcasecmp
(
refpt
->
mime_type
,
"G729A"
)
==
0
))
/*workaround a bug in earlier versions of linphone where opus/48000/1 is offered, which is uncompliant with opus rtp draft*/
&&
pt
->
clock_rate
==
refpt
->
clock_rate
&&
pt
->
channels
==
ref
pt
->
channels
){
if
(
strcasecmp
(
pt
->
mime_type
,
"G729"
)
==
0
&&
ref
pt
->
channels
==
pt
->
channels
){
candidate
=
pt
;
candidate
=
pt
;
/*good candidate, check fmtp for H264 */
if
(
strcasecmp
(
pt
->
mime_type
,
"H264"
)
==
0
){
if
(
pt
->
recv_fmtp
!=
NULL
&&
refpt
->
recv_fmtp
!=
NULL
){
int
mode1
=
0
,
mode2
=
0
;
if
(
fmtp_get_value
(
pt
->
recv_fmtp
,
"packetization-mode"
,
value
,
sizeof
(
value
))){
mode1
=
atoi
(
value
);
}
}
if
(
fmtp_get_value
(
refpt
->
recv_fmtp
,
"packetization-mode"
,
value
,
sizeof
(
value
))){
mode2
=
atoi
(
value
);
}
}
if
(
mode1
==
mode2
)
return
candidate
;
}
static
PayloadType
*
amr_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
PayloadType
*
pt
;
char
value
[
10
];
const
MSList
*
elem
;
PayloadType
*
candidate
=
NULL
;
for
(
elem
=
l
;
elem
!=
NULL
;
elem
=
elem
->
next
){
pt
=
(
PayloadType
*
)
elem
->
data
;
if
(
pt
->
mime_type
&&
refpt
->
mime_type
&&
strcasecmp
(
pt
->
mime_type
,
refpt
->
mime_type
)
==
0
&&
pt
->
clock_rate
==
refpt
->
clock_rate
&&
pt
->
channels
==
refpt
->
channels
)
{
int
octedalign1
=
0
,
octedalign2
=
0
;
if
(
pt
->
recv_fmtp
!=
NULL
&&
fmtp_get_value
(
pt
->
recv_fmtp
,
"octet-align"
,
value
,
sizeof
(
value
))){
octedalign1
=
atoi
(
value
);
}
if
(
refpt
->
send_fmtp
!=
NULL
&&
fmtp_get_value
(
refpt
->
send_fmtp
,
"octet-align"
,
value
,
sizeof
(
value
))){
octedalign2
=
atoi
(
value
);
}
if
(
octedalign1
==
octedalign2
)
{
candidate
=
pt
;
break
;
/*exact match */
break
;
/*exact match */
}
}
}
else
break
;
}
}
}
}
return
candidate
;
return
candidate
;
}
}
static
PayloadType
*
generic_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
PayloadType
*
pt
;
const
MSList
*
elem
;
for
(
elem
=
l
;
elem
!=
NULL
;
elem
=
elem
->
next
){
pt
=
(
PayloadType
*
)
elem
->
data
;
if
(
pt
->
mime_type
&&
refpt
->
mime_type
&&
strcasecmp
(
pt
->
mime_type
,
refpt
->
mime_type
)
==
0
&&
pt
->
clock_rate
==
refpt
->
clock_rate
&&
pt
->
channels
==
refpt
->
channels
)
return
pt
;
}
return
NULL
;
}
static
PayloadTypeMatcher
matchers
[]
=
{
{
"opus"
,
opus_match
},
{
"G729A"
,
g729A_match
},
{
"AMR"
,
amr_match
},
{
"AMR-WB"
,
amr_match
},
{
NULL
,
NULL
}
};
static
PayloadType
*
find_payload_type_best_match
(
const
MSList
*
l
,
const
PayloadType
*
refpt
){
PayloadTypeMatcher
*
m
;
for
(
m
=
matchers
;
m
->
mime_type
!=
NULL
;
++
m
){
if
(
refpt
->
mime_type
&&
strcasecmp
(
m
->
mime_type
,
refpt
->
mime_type
)
==
0
){
return
m
->
match_func
(
l
,
refpt
);
}
}
return
generic_match
(
l
,
refpt
);
}
static
MSList
*
match_payloads
(
const
MSList
*
local
,
const
MSList
*
remote
,
bool_t
reading_response
,
bool_t
one_matching_codec
){
static
MSList
*
match_payloads
(
const
MSList
*
local
,
const
MSList
*
remote
,
bool_t
reading_response
,
bool_t
one_matching_codec
){
const
MSList
*
e2
,
*
e1
;
const
MSList
*
e2
,
*
e1
;
MSList
*
res
=
NULL
;
MSList
*
res
=
NULL
;
...
...
mediastreamer2
@
81e6bd55
Subproject commit
0450c04a38ce2c78430208d90e41dbe23163b950
Subproject commit
81e6bd5511c16133df340e732807d64faac1f7b2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment