Commit 496b5b1f authored by Simon Morlat's avatar Simon Morlat

add to_string and from_string

parent d515df04
......@@ -119,6 +119,7 @@ typedef struct _RtpTransport
} RtpTransport;
typedef enum _OrtpNetworkSimulatorMode{
OrtpNetworkSimulatorInvalid=-1,
OrtpNetworkSimulatorInbound,/**<simulation is applied when receiving packets*/
OrtpNetworkSimulatorOutbound, /**<simulation is applied to sent packets*/
OrtpNetworkSimulatorOutboundControlled /**<simulation is applied to sent packets according to sent timestamp
......@@ -399,6 +400,10 @@ extern "C"
{
#endif
ORTP_PUBLIC const char *ortp_network_simulator_mode_to_string(OrtpNetworkSimulatorMode mode);
ORTP_PUBLIC OrtpNetworkSimulatorMode ortp_network_simulator_mode_from_string(const char *str);
/* public API */
ORTP_PUBLIC RtpSession *rtp_session_new(int mode);
ORTP_PUBLIC void rtp_session_set_scheduling_mode(RtpSession *session, int yesno);
......
......@@ -108,7 +108,7 @@ static void * outboud_simulator_thread(void *ctx){
return NULL;
}
static const char *simulator_mode_to_string(OrtpNetworkSimulatorMode mode){
const char *ortp_network_simulator_mode_to_string(OrtpNetworkSimulatorMode mode){
switch(mode){
case OrtpNetworkSimulatorInbound:
return "Inbound";
......@@ -116,10 +116,19 @@ static const char *simulator_mode_to_string(OrtpNetworkSimulatorMode mode){
return "Outbound";
case OrtpNetworkSimulatorOutboundControlled:
return "OutboundControlled";
case OrtpNetworkSimulatorInvalid:
return "Invalid";
}
return "invalid";
}
OrtpNetworkSimulatorMode ortp_network_simulator_mode_from_string(const char *str){
if (strcasecmp(str,"Inbound")==0) return OrtpNetworkSimulatorInbound;
if (strcasecmp(str,"Outbound")==0) return OrtpNetworkSimulatorOutbound;
if (strcasecmp(str,"OutboundControlled")==0) return OrtpNetworkSimulatorOutboundControlled;
return OrtpNetworkSimulatorInvalid;
}
void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetworkSimulatorParams *params){
OrtpNetworkSimulatorCtx *sim=session->net_sim_ctx;
if (params->enabled){
......@@ -158,7 +167,7 @@ void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetwor
params->max_buffer_size,
params->jitter_burst_density,
params->jitter_strength,
simulator_mode_to_string(params->mode)
ortp_network_simulator_mode_to_string(params->mode)
);
}else{
session->net_sim_ctx=NULL;
......
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