Ignore:
Timestamp:
Nov 6, 2013 8:05:11 AM (10 years ago)
Author:
bennylp
Message:

Re #1519: Added persistent API in pjsua2, with JSON as the format. The API is extensible to support more formats. All config structures are serializable now. Tested in Python.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp

    r4639 r4644  
    11/* $Id$ */ 
    22/*  
    3  * Copyright (C) 2012 Teluu Inc. (http://www.teluu.com) 
     3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 
    44 * 
    55 * This program is free software; you can redistribute it and/or modify 
     
    9999} 
    100100 
     101void UaConfig::readObject(const ContainerNode &node) throw(Error) 
     102{ 
     103    ContainerNode this_node = node.readContainer("UaConfig"); 
     104 
     105    NODE_READ_UNSIGNED( this_node, maxCalls); 
     106    NODE_READ_UNSIGNED( this_node, threadCnt); 
     107    NODE_READ_STRINGV ( this_node, nameserver); 
     108    NODE_READ_STRING  ( this_node, userAgent); 
     109    NODE_READ_STRINGV ( this_node, stunServer); 
     110    NODE_READ_BOOL    ( this_node, stunIgnoreFailure); 
     111    NODE_READ_INT     ( this_node, natTypeInSdp); 
     112    NODE_READ_BOOL    ( this_node, mwiUnsolicitedEnabled); 
     113} 
     114 
     115void UaConfig::writeObject(ContainerNode &node) const throw(Error) 
     116{ 
     117    ContainerNode this_node = node.writeNewContainer("UaConfig"); 
     118 
     119    NODE_WRITE_UNSIGNED( this_node, maxCalls); 
     120    NODE_WRITE_UNSIGNED( this_node, threadCnt); 
     121    NODE_WRITE_STRINGV ( this_node, nameserver); 
     122    NODE_WRITE_STRING  ( this_node, userAgent); 
     123    NODE_WRITE_STRINGV ( this_node, stunServer); 
     124    NODE_WRITE_BOOL    ( this_node, stunIgnoreFailure); 
     125    NODE_WRITE_INT     ( this_node, natTypeInSdp); 
     126    NODE_WRITE_BOOL    ( this_node, mwiUnsolicitedEnabled); 
     127} 
     128 
    101129/////////////////////////////////////////////////////////////////////////////// 
    102130 
     
    134162 
    135163    return lc; 
     164} 
     165 
     166void LogConfig::readObject(const ContainerNode &node) throw(Error) 
     167{ 
     168    ContainerNode this_node = node.readContainer("LogConfig"); 
     169 
     170    NODE_READ_UNSIGNED( this_node, msgLogging); 
     171    NODE_READ_UNSIGNED( this_node, level); 
     172    NODE_READ_UNSIGNED( this_node, consoleLevel); 
     173    NODE_READ_UNSIGNED( this_node, decor); 
     174    NODE_READ_STRING  ( this_node, filename); 
     175    NODE_READ_UNSIGNED( this_node, fileFlags); 
     176} 
     177 
     178void LogConfig::writeObject(ContainerNode &node) const throw(Error) 
     179{ 
     180    ContainerNode this_node = node.writeNewContainer("LogConfig"); 
     181 
     182    NODE_WRITE_UNSIGNED( this_node, msgLogging); 
     183    NODE_WRITE_UNSIGNED( this_node, level); 
     184    NODE_WRITE_UNSIGNED( this_node, consoleLevel); 
     185    NODE_WRITE_UNSIGNED( this_node, decor); 
     186    NODE_WRITE_STRING  ( this_node, filename); 
     187    NODE_WRITE_UNSIGNED( this_node, fileFlags); 
    136188} 
    137189 
     
    206258} 
    207259 
     260void MediaConfig::readObject(const ContainerNode &node) throw(Error) 
     261{ 
     262    ContainerNode this_node = node.readContainer("MediaConfig"); 
     263 
     264    NODE_READ_UNSIGNED( this_node, clockRate); 
     265    NODE_READ_UNSIGNED( this_node, sndClockRate); 
     266    NODE_READ_UNSIGNED( this_node, channelCount); 
     267    NODE_READ_UNSIGNED( this_node, audioFramePtime); 
     268    NODE_READ_UNSIGNED( this_node, maxMediaPorts); 
     269    NODE_READ_BOOL    ( this_node, hasIoqueue); 
     270    NODE_READ_UNSIGNED( this_node, threadCnt); 
     271    NODE_READ_UNSIGNED( this_node, quality); 
     272    NODE_READ_UNSIGNED( this_node, ptime); 
     273    NODE_READ_BOOL    ( this_node, noVad); 
     274    NODE_READ_UNSIGNED( this_node, ilbcMode); 
     275    NODE_READ_UNSIGNED( this_node, txDropPct); 
     276    NODE_READ_UNSIGNED( this_node, rxDropPct); 
     277    NODE_READ_UNSIGNED( this_node, ecOptions); 
     278    NODE_READ_UNSIGNED( this_node, ecTailLen); 
     279    NODE_READ_UNSIGNED( this_node, sndRecLatency); 
     280    NODE_READ_UNSIGNED( this_node, sndPlayLatency); 
     281    NODE_READ_INT     ( this_node, jbInit); 
     282    NODE_READ_INT     ( this_node, jbMinPre); 
     283    NODE_READ_INT     ( this_node, jbMaxPre); 
     284    NODE_READ_INT     ( this_node, jbMax); 
     285    NODE_READ_INT     ( this_node, sndAutoCloseTime); 
     286    NODE_READ_BOOL    ( this_node, vidPreviewEnableNative); 
     287} 
     288 
     289void MediaConfig::writeObject(ContainerNode &node) const throw(Error) 
     290{ 
     291    ContainerNode this_node = node.writeNewContainer("MediaConfig"); 
     292 
     293    NODE_WRITE_UNSIGNED( this_node, clockRate); 
     294    NODE_WRITE_UNSIGNED( this_node, sndClockRate); 
     295    NODE_WRITE_UNSIGNED( this_node, channelCount); 
     296    NODE_WRITE_UNSIGNED( this_node, audioFramePtime); 
     297    NODE_WRITE_UNSIGNED( this_node, maxMediaPorts); 
     298    NODE_WRITE_BOOL    ( this_node, hasIoqueue); 
     299    NODE_WRITE_UNSIGNED( this_node, threadCnt); 
     300    NODE_WRITE_UNSIGNED( this_node, quality); 
     301    NODE_WRITE_UNSIGNED( this_node, ptime); 
     302    NODE_WRITE_BOOL    ( this_node, noVad); 
     303    NODE_WRITE_UNSIGNED( this_node, ilbcMode); 
     304    NODE_WRITE_UNSIGNED( this_node, txDropPct); 
     305    NODE_WRITE_UNSIGNED( this_node, rxDropPct); 
     306    NODE_WRITE_UNSIGNED( this_node, ecOptions); 
     307    NODE_WRITE_UNSIGNED( this_node, ecTailLen); 
     308    NODE_WRITE_UNSIGNED( this_node, sndRecLatency); 
     309    NODE_WRITE_UNSIGNED( this_node, sndPlayLatency); 
     310    NODE_WRITE_INT     ( this_node, jbInit); 
     311    NODE_WRITE_INT     ( this_node, jbMinPre); 
     312    NODE_WRITE_INT     ( this_node, jbMaxPre); 
     313    NODE_WRITE_INT     ( this_node, jbMax); 
     314    NODE_WRITE_INT     ( this_node, sndAutoCloseTime); 
     315    NODE_WRITE_BOOL    ( this_node, vidPreviewEnableNative); 
     316} 
     317 
     318/////////////////////////////////////////////////////////////////////////////// 
     319 
     320void EpConfig::readObject(const ContainerNode &node) throw(Error) 
     321{ 
     322    ContainerNode this_node = node.readContainer("EpConfig"); 
     323    NODE_READ_OBJ( this_node, uaConfig); 
     324    NODE_READ_OBJ( this_node, logConfig); 
     325    NODE_READ_OBJ( this_node, medConfig); 
     326} 
     327 
     328void EpConfig::writeObject(ContainerNode &node) const throw(Error) 
     329{ 
     330    ContainerNode this_node = node.writeNewContainer("EpConfig"); 
     331    NODE_WRITE_OBJ( this_node, uaConfig); 
     332    NODE_WRITE_OBJ( this_node, logConfig); 
     333    NODE_WRITE_OBJ( this_node, medConfig); 
     334} 
    208335 
    209336/////////////////////////////////////////////////////////////////////////////// 
     
    783910 
    784911    tcfg = cfg.toPj(); 
    785     PJSUA2_CHECK_EXPR( pjsua_transport_create(type, &tcfg, &tid) ); 
     912    PJSUA2_CHECK_EXPR( pjsua_transport_create(type, 
     913                                              &tcfg, &tid) ); 
    786914 
    787915    return tid; 
Note: See TracChangeset for help on using the changeset viewer.