Changeset 5755 for pjproject/trunk/pjsip/src/pjsua2/account.cpp
- Timestamp:
- Mar 15, 2018 3:00:59 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/account.cpp
r5649 r5755 27 27 28 28 #define THIS_FILE "account.cpp" 29 30 /////////////////////////////////////////////////////////////////////////////// 31 32 void SrtpCrypto::fromPj(const pjmedia_srtp_crypto &prm) 33 { 34 this->key = pj2Str(prm.key); 35 this->name = pj2Str(prm.name); 36 this->flags = prm.flags; 37 } 38 39 pjmedia_srtp_crypto SrtpCrypto::toPj() const 40 { 41 pjmedia_srtp_crypto crypto; 42 43 crypto.key = str2Pj(this->key); 44 crypto.name = str2Pj(this->name); 45 crypto.flags = this->flags; 46 47 return crypto; 48 } 49 50 /////////////////////////////////////////////////////////////////////////////// 51 52 SrtpOpt::SrtpOpt() 53 { 54 pjsua_srtp_opt opt; 55 pjsua_srtp_opt_default(&opt); 56 fromPj(opt); 57 } 58 59 void SrtpOpt::fromPj(const pjsua_srtp_opt &prm) 60 { 61 this->cryptos.clear(); 62 for (unsigned i = 0; i < prm.crypto_count; ++i) { 63 SrtpCrypto crypto; 64 crypto.fromPj(prm.crypto[i]); 65 this->cryptos.push_back(crypto); 66 } 67 68 this->keyings.clear(); 69 for (unsigned i = 0; i < prm.keying_count; ++i) { 70 this->keyings.push_back(prm.keying[i]); 71 } 72 } 73 74 pjsua_srtp_opt SrtpOpt::toPj() const 75 { 76 pjsua_srtp_opt opt; 77 78 pj_bzero(&opt, sizeof(opt)); 79 80 opt.crypto_count = this->cryptos.size(); 81 for (unsigned i = 0; i < opt.crypto_count; ++i) { 82 opt.crypto[i] = this->cryptos[i].toPj(); 83 } 84 85 opt.keying_count = this->keyings.size(); 86 for (unsigned i = 0; i < opt.keying_count; ++i) { 87 opt.keying[i] = (pjmedia_srtp_keying_method)this->keyings[i]; 88 } 89 90 return opt; 91 } 92 93 void SrtpOpt::readObject(const ContainerNode &node) throw(Error) 94 { 95 ContainerNode this_node = node.readContainer("SrtpOpt"); 96 97 ContainerNode crypto_node = this_node.readArray("cryptos"); 98 this->cryptos.clear(); 99 while (crypto_node.hasUnread()) { 100 SrtpCrypto crypto; 101 NODE_READ_STRING (crypto_node, crypto.key); 102 NODE_READ_STRING (crypto_node, crypto.name); 103 NODE_READ_UNSIGNED (crypto_node, crypto.flags); 104 this->cryptos.push_back(crypto); 105 } 106 107 ContainerNode keying_node = this_node.readArray("keyings"); 108 this->keyings.clear(); 109 while (keying_node.hasUnread()) { 110 unsigned keying; 111 NODE_READ_UNSIGNED (keying_node, keying); 112 this->keyings.push_back(keying); 113 } 114 } 115 116 void SrtpOpt::writeObject(ContainerNode &node) const throw(Error) 117 { 118 ContainerNode this_node = node.writeNewContainer("SrtpOpt"); 119 120 ContainerNode crypto_node = this_node.writeNewArray("cryptos"); 121 for (unsigned i=0; i<this->cryptos.size(); ++i) { 122 NODE_WRITE_STRING (crypto_node, this->cryptos[i].key); 123 NODE_WRITE_STRING (crypto_node, this->cryptos[i].name); 124 NODE_WRITE_UNSIGNED (crypto_node, this->cryptos[i].flags); 125 } 126 127 ContainerNode keying_node = this_node.writeNewArray("keyings"); 128 for (unsigned i=0; i<this->keyings.size(); ++i) { 129 NODE_WRITE_UNSIGNED (keying_node, this->keyings[i]); 130 } 131 } 29 132 30 133 /////////////////////////////////////////////////////////////////////////////// … … 253 356 NODE_READ_NUM_T ( this_node, pjmedia_srtp_use, srtpUse); 254 357 NODE_READ_INT ( this_node, srtpSecureSignaling); 358 NODE_READ_OBJ ( this_node, srtpOpt); 255 359 NODE_READ_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 256 360 NODE_READ_OBJ ( this_node, transportConfig); … … 265 369 NODE_WRITE_NUM_T ( this_node, pjmedia_srtp_use, srtpUse); 266 370 NODE_WRITE_INT ( this_node, srtpSecureSignaling); 371 NODE_WRITE_OBJ ( this_node, srtpOpt); 267 372 NODE_WRITE_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 268 373 NODE_WRITE_OBJ ( this_node, transportConfig); … … 453 558 ret.use_srtp = mediaConfig.srtpUse; 454 559 ret.srtp_secure_signaling = mediaConfig.srtpSecureSignaling; 560 ret.srtp_opt = mediaConfig.srtpOpt.toPj(); 455 561 ret.ipv6_media_use = mediaConfig.ipv6Use; 456 562 … … 627 733 mediaConfig.srtpUse = prm.use_srtp; 628 734 mediaConfig.srtpSecureSignaling = prm.srtp_secure_signaling; 735 mediaConfig.srtpOpt.fromPj(prm.srtp_opt); 629 736 mediaConfig.ipv6Use = prm.ipv6_media_use; 630 737
Note: See TracChangeset
for help on using the changeset viewer.