Commit a7736612 authored by Simon Morlat's avatar Simon Morlat

add ms_get_mtu() that can be used by streams and filters to adapt their buffers.

parent eb8a2ee0
......@@ -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
*/
......
......@@ -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;
}
......@@ -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);
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment