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
mediastreamer2
Commits
a7736612
Commit
a7736612
authored
Mar 05, 2013
by
Simon Morlat
Browse files
add ms_get_mtu() that can be used by streams and filters to adapt their buffers.
parent
eb8a2ee0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
4 deletions
+32
-4
include/mediastreamer2/mscommon.h
include/mediastreamer2/mscommon.h
+6
-0
src/base/mtu.c
src/base/mtu.c
+15
-2
src/voip/mediastream.c
src/voip/mediastream.c
+1
-1
tools/mediastream.c
tools/mediastream.c
+10
-1
No files found.
include/mediastreamer2/mscommon.h
View file @
a7736612
...
...
@@ -258,6 +258,12 @@ MS2_PUBLIC int ms_discover_mtu(const char *destination_host);
**/
MS2_PUBLIC
void
ms_set_mtu
(
int
mtu
);
/**
* Get mediastreamer default mtu, used to compute the default RTP max payload size.
**/
MS2_PUBLIC
int
ms_get_mtu
(
void
);
/**
* Declare how many cpu (cores) are available on the platform
*/
...
...
src/base/mtu.c
View file @
a7736612
...
...
@@ -274,11 +274,24 @@ int ms_discover_mtu(const char*host){
#endif
#define MS_MTU_DEFAULT 1500
static
int
ms_mtu
=
MS_MTU_DEFAULT
;
void
ms_set_mtu
(
int
mtu
){
/*60= IPv6+UDP+RTP overhead */
if
(
mtu
>
60
){
if
(
mtu
>
1500
)
mtu
=
1500
;
/*limit to 1500, the mediastreamer2 buffer are not large enough anyway*/
ms_mtu
=
mtu
;
ms_set_payload_max_size
(
mtu
-
60
);
}
else
ms_set_payload_max_size
(
0
);
}
else
{
if
(
mtu
>
0
){
ms_warning
(
"MTU is too short: %i bytes, using default value instead."
,
mtu
);
}
ms_set_mtu
(
MS_MTU_DEFAULT
);
}
}
int
ms_get_mtu
(
void
){
return
ms_mtu
;
}
src/voip/mediastream.c
View file @
a7736612
...
...
@@ -120,7 +120,7 @@ RtpSession * create_duplex_rtpsession(int loc_rtp_port, int loc_rtcp_port, bool_
RtpSession
*
rtpr
;
rtpr
=
rtp_session_new
(
RTP_SESSION_SENDRECV
);
rtp_session_set_recv_buf_size
(
rtpr
,
MAX_RTP_SIZE
);
rtp_session_set_recv_buf_size
(
rtpr
,
ms_get_mtu
()
);
rtp_session_set_scheduling_mode
(
rtpr
,
0
);
rtp_session_set_blocking_mode
(
rtpr
,
0
);
rtp_session_enable_adaptive_jitter_compensation
(
rtpr
,
TRUE
);
...
...
tools/mediastream.c
View file @
a7736612
...
...
@@ -85,6 +85,7 @@ typedef struct _MediastreamDatas {
char
*
fmtp
;
int
jitter
;
int
bitrate
;
int
mtu
;
MSVideoSize
vs
;
bool_t
ec
;
bool_t
agc
;
...
...
@@ -198,6 +199,7 @@ const char *usage="mediastream --local <port> --remote <ip:port> \n"
"[ --zoom zoomfactor]
\n
"
"[ --ice-local-candidate <ip:port:[host|srflx|prflx|relay]> ]
\n
"
"[ --ice-remote-candidate <ip:port:[host|srflx|prflx|relay]> ]
\n
"
"[ --mtu <mtu> (specify MTU)]
\n
"
;
#if TARGET_OS_IPHONE
...
...
@@ -492,7 +494,13 @@ bool_t parse_args(int argc, char** argv, MediastreamDatas* out) {
ms_error
(
"Invalid zoom triplet"
);
return
FALSE
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
){
}
else
if
(
strcmp
(
argv
[
i
],
"--mtu"
)
==
0
){
i
++
;
if
(
sscanf
(
argv
[
i
],
"%i"
,
&
out
->
mtu
)
!=
1
)
{
ms_error
(
"Invalid mtu value"
);
return
FALSE
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
){
printf
(
"%s"
,
usage
);
return
FALSE
;
}
...
...
@@ -549,6 +557,7 @@ void setup_media_streams(MediastreamDatas* args) {
args
->
q
=
ortp_ev_queue_new
();
ms_init
();
if
(
args
->
mtu
)
ms_set_mtu
(
args
->
mtu
);
ms_filter_enable_statistics
(
TRUE
);
ms_filter_reset_statistics
();
args
->
ice_session
=
ice_session_new
();
...
...
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