Changeset 1702
- Timestamp:
- Jan 18, 2008 12:30:18 PM (17 years ago)
- Location:
- pjproject/branches/users/nanang/pjmedia
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjmedia/include/pjmedia/transport.h
r1698 r1702 255 255 pj_pool_t *pool, 256 256 pjmedia_sdp_session *sdp_local, 257 const pjmedia_sdp_session *sdp_remote); 257 const pjmedia_sdp_session *sdp_remote, 258 unsigned media_index); 258 259 259 260 /** … … 471 472 pj_pool_t *pool, 472 473 pjmedia_sdp_session *sdp_local, 473 const pjmedia_sdp_session *sdp_remote) 474 { 475 return (*tp->op->media_create)(tp, pool, sdp_local, sdp_remote); 474 const pjmedia_sdp_session *sdp_remote, 475 unsigned media_index) 476 { 477 return (*tp->op->media_create)(tp, pool, sdp_local, sdp_remote, 478 media_index); 476 479 } 477 480 -
pjproject/branches/users/nanang/pjmedia/include/pjmedia/transport_srtp.h
r1698 r1702 30 30 PJ_BEGIN_DECL 31 31 32 /** 33 * Options that can be specified when creating SRTP transport. 34 */ 35 enum pjmedia_transport_srtp_options 36 { 37 /** 38 * This option will make the underlying transport to be closed whenever 39 * the SRTP transport is closed. 40 */ 41 PJMEDIA_SRTP_AUTO_CLOSE_UNDERLYING_TRANSPORT = 1 42 }; 43 44 /** 45 * SRTP session parameters. 46 */ 47 typedef struct pjmedia_srtp_stream_policy 48 { 49 pj_str_t key; /**< Key string. */ 50 pj_str_t crypto_suite; /**< SRTP parameter for RTP. */ 51 } pjmedia_srtp_stream_policy; 32 33 /** 34 * Crypto option. 35 */ 36 typedef enum pjmedia_srtp_crypto_option 37 { 38 /** When this flag is specified, encryption will be disabled. */ 39 PJMEDIA_SRTP_NO_ENCRYPTION = 1, 40 41 /** When this flag is specified, authentication will be disabled. */ 42 PJMEDIA_SRTP_NO_AUTHENTICATION = 2 43 44 } pjmedia_srtp_crypto_option; 45 46 47 /** 48 * This structure describes an individual crypto setting. 49 */ 50 typedef struct pjmedia_srtp_crypto 51 { 52 /** Optional key. If empty, a random key will be autogenerated. */ 53 pj_str_t key; 54 55 /** Crypto name. */ 56 pj_str_t crypto; 57 58 /* Flags, bitmask from #pjmedia_srtp_crypto_option */ 59 unsigned flags; 60 61 } pjmedia_srtp_crypto; 62 63 64 /** 65 * This enumeration specifies the behavior of the SRTP transport regarding 66 * media security offer and answer. 67 */ 68 typedef enum pjmedia_srtp_use 69 { 70 /** 71 * When this flag is specified, SRTP will be disabled, and the transport 72 * will reject RTP/SAVP offer. 73 */ 74 PJMEDIA_SRTP_DISABLED, 75 76 /** 77 * When this flag is specified, SRTP will be advertised as optional and 78 * incoming SRTP offer will be accepted. 79 */ 80 PJMEDIA_SRTP_OPTIONAL, 81 82 /** 83 * When this flag is specified, the transport will require that RTP/SAVP 84 * media shall be used. 85 */ 86 PJMEDIA_SRTP_MANDATORY 87 88 } pjmedia_srtp_use; 89 90 91 /** 92 * Settings to be given when creating SRTP transport. Application should call 93 * #pjmedia_srtp_setting_default() to initialize this structure with its 94 * default values. 95 */ 96 typedef struct pjmedia_srtp_setting 97 { 98 /** 99 * Specify the usage policy. Default is PJMEDIA_SRTP_OPTIONAL. 100 */ 101 pjmedia_srtp_use use; 102 103 /** 104 * Specify whether the SRTP transport should close the member transport 105 * when it is destroyed. Default: PJ_TRUE. 106 */ 107 pj_bool_t close_member_tp; 108 109 /** 110 * Specify the number of crypto suite settings. 111 */ 112 unsigned crypto_count; 113 114 /** 115 * Specify individual crypto suite setting. 116 */ 117 pjmedia_srtp_crypto crypto[8]; 118 119 } pjmedia_srtp_setting; 120 121 122 /** 123 * Initialize SRTP setting with its default values. 124 * 125 * @param opt SRTP setting to be initialized. 126 */ 127 PJ_DECL(void) pjmedia_srtp_setting_default(pjmedia_srtp_setting *opt); 52 128 53 129 … … 55 131 * Create an SRTP media transport. 56 132 * 57 * @param endpt The media endpoint instance. 58 * @param tp The actual media transport 59 * to send and receive RTP/RTCP packets. 60 * @param p_tp_srtp Pointer to receive the transport SRTP instance. 61 * 62 * @return PJ_SUCCESS on success. 63 */ 64 PJ_DECL(pj_status_t) pjmedia_transport_srtp_create(pjmedia_endpt *endpt, 65 pjmedia_transport *tp, 66 unsigned options, 67 pjmedia_transport **p_tp_srtp); 68 69 /** 70 * Initialize and start SRTP session with the given parameters. 71 * Please note: 72 * 1. pjmedia_transport_srtp_init_session() and 73 * pjmedia_transport_srtp_deinit_session() is automatic called by 74 * SRTP pjmedia_transport_media_start() and pjmedia_transport_media_stop(), 75 * application needs to call these functions directly only if the application 76 * is not intended to call SRTP pjmedia_transport_media_start. 77 * 2. Even if an RTP stream is only one direction, you might need to provide 78 * both policies, because it is needed by RTCP, which is usually two 79 * directions. 80 * 3. Key for transmit and receive direction MUST be different, this is 81 * specified by libsrtp. 133 * @param endpt The media endpoint instance. 134 * @param tp The actual media transport to send and receive 135 * RTP/RTCP packets. This media transport will be 136 * kept as member transport of this SRTP instance. 137 * @param opt Optional settings. If NULL is given, default 138 * settings will be used. 139 * @param p_tp Pointer to receive the transport SRTP instance. 140 * 141 * @return PJ_SUCCESS on success. 142 */ 143 PJ_DECL(pj_status_t) pjmedia_transport_srtp_create( 144 pjmedia_endpt *endpt, 145 pjmedia_transport *tp, 146 const pjmedia_srtp_setting *opt, 147 pjmedia_transport **p_tp); 148 149 150 /** 151 * Manually start SRTP session with the given parameters. Application only 152 * needs to call this function when the SRTP transport is used without SDP 153 * offer/answer. When SDP offer/answer framework is used, the SRTP transport 154 * will be started/stopped by #pjmedia_transport_media_start() and 155 * #pjmedia_transport_media_stop() respectively. 156 * 157 * Please note that even if an RTP stream is only one direction, application 158 * will still need to provide both crypto suites, because it is needed by 159 * RTCP. 160 161 * If application specifies the crypto keys, the keys for transmit and receive 162 * direction MUST be different. 82 163 * 83 164 * @param srtp The SRTP transport. 84 * @param prm Session parameters. 165 * @param tx Crypto suite setting for transmit direction. 166 * @param rx Crypto suite setting for receive direction. 85 167 * 86 168 * @return PJ_SUCCESS on success. 87 169 */ 88 PJ_DECL(pj_status_t) pjmedia_transport_srtp_ init_session(89 90 const pjmedia_srtp_stream_policy *policy_tx,91 const pjmedia_srtp_stream_policy *policy_rx);92 93 /** 94 * Stop SRTP se ession.170 PJ_DECL(pj_status_t) pjmedia_transport_srtp_start( 171 pjmedia_transport *srtp, 172 const pjmedia_srtp_crypto *tx, 173 const pjmedia_srtp_crypto *rx); 174 175 /** 176 * Stop SRTP session. 95 177 * 96 178 * @param srtp The SRTP media transport. … … 98 180 * @return PJ_SUCCESS on success. 99 181 * 100 * @see pjmedia_transport_srtp_init_session() 101 */ 102 PJ_DECL(pj_status_t) pjmedia_transport_srtp_deinit_session( 103 pjmedia_transport *srtp); 104 105 106 /** 107 * Query real transport of SRTP. 182 * @see #pjmedia_transport_srtp_start() 183 */ 184 PJ_DECL(pj_status_t) pjmedia_transport_srtp_stop(pjmedia_transport *srtp); 185 186 187 /** 188 * Query member transport of SRTP. 108 189 * 109 190 * @param srtp The SRTP media transport. 110 191 * 111 * @return realmedia transport.112 */ 113 PJ_DECL(pjmedia_transport*) pjmedia_transport_srtp_get_ real_transport(114 pjmedia_transport *srtp);192 * @return member media transport. 193 */ 194 PJ_DECL(pjmedia_transport*) pjmedia_transport_srtp_get_member( 195 pjmedia_transport *srtp); 115 196 116 197 -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_ice.c
r1698 r1702 76 76 pj_pool_t *pool, 77 77 pjmedia_sdp_session *sdp_local, 78 const pjmedia_sdp_session *sdp_remote); 78 const pjmedia_sdp_session *sdp_remote, 79 unsigned media_index); 79 80 static pj_status_t transport_media_start (pjmedia_transport *tp, 80 81 pj_pool_t *pool, … … 259 260 pj_pool_t *pool, 260 261 pjmedia_sdp_session *sdp_local, 261 const pjmedia_sdp_session *sdp_remote) 262 const pjmedia_sdp_session *sdp_remote, 263 unsigned media_index) 262 264 { 263 265 struct transport_ice *tp_ice = (struct transport_ice*)tp; -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_srtp.c
r1700 r1702 78 78 unsigned options; /**< Transport options. */ 79 79 80 pjmedia_srtp_setting setting; 80 81 /* SRTP policy */ 81 82 pj_bool_t session_inited; … … 83 84 char tx_key[MAX_KEY_LEN]; 84 85 char rx_key[MAX_KEY_LEN]; 85 pjmedia_srtp_stream_ policytx_policy;86 pjmedia_srtp_stream_ policyrx_policy;86 pjmedia_srtp_stream_crypto tx_policy; 87 pjmedia_srtp_stream_crypto rx_policy; 87 88 88 89 /* libSRTP contexts */ … … 245 246 * Initialize and start SRTP session with the given parameters. 246 247 */ 247 PJ_DEF(pj_status_t) pjmedia_transport_srtp_ init_session(248 PJ_DEF(pj_status_t) pjmedia_transport_srtp_start( 248 249 pjmedia_transport *srtp, 249 const pjmedia_srtp_stream_ policy*policy_tx,250 const pjmedia_srtp_stream_ policy*policy_rx)250 const pjmedia_srtp_stream_crypto *policy_tx, 251 const pjmedia_srtp_stream_crypto *policy_rx) 251 252 { 252 253 transport_srtp *p_srtp = (transport_srtp*) srtp; … … 344 345 * Stop SRTP session. 345 346 */ 346 PJ_DEF(pj_status_t) pjmedia_transport_srtp_deinit_session( 347 pjmedia_transport *srtp) 347 PJ_DEF(pj_status_t) pjmedia_transport_srtp_stop(pjmedia_transport *srtp) 348 348 { 349 349 transport_srtp *p_srtp = (transport_srtp*) srtp; … … 367 367 } 368 368 369 PJ_DEF(pjmedia_transport *) pjmedia_transport_srtp_get_ real_transport(370 369 PJ_DEF(pjmedia_transport *) pjmedia_transport_srtp_get_member( 370 pjmedia_transport *tp) 371 371 { 372 372 transport_srtp *srtp = (transport_srtp*) tp; … … 506 506 pjmedia_transport_detach(tp, NULL); 507 507 508 if (srtp-> options && PJMEDIA_SRTP_AUTO_CLOSE_UNDERLYING_TRANSPORT) {508 if (srtp->setting.close_member_tp) { 509 509 pjmedia_transport_close(srtp->real_tp); 510 510 } 511 511 512 status = pjmedia_transport_srtp_ deinit_session(tp);512 status = pjmedia_transport_srtp_stop(tp); 513 513 514 514 pj_pool_release(srtp->pool); … … 692 692 static pj_status_t parse_attr_crypto(pj_pool_t *pool, 693 693 const pjmedia_sdp_attr *attr, 694 pjmedia_srtp_stream_ policy*policy,694 pjmedia_srtp_stream_crypto *policy, 695 695 int *tag) 696 696 { … … 749 749 pjmedia_sdp_media *media_local = sdp_local->media[media_index]; 750 750 pjmedia_sdp_attr *attr; 751 pjmedia_srtp_stream_ policypolicy_remote;752 pjmedia_srtp_stream_ policypolicy_local;751 pjmedia_srtp_stream_crypto policy_remote; 752 pjmedia_srtp_stream_crypto policy_local; 753 753 pj_status_t status; 754 754 unsigned cs_cnt = sizeof(crypto_suites)/sizeof(crypto_suites[0]); … … 970 970 971 971 /* Got policy_local & policy_remote, let's initalize the SRTP */ 972 status = pjmedia_transport_srtp_init_session(tp, 973 &policy_local, &policy_remote); 972 status = pjmedia_transport_srtp_start(tp, &policy_local, &policy_remote); 974 973 if (status != PJ_SUCCESS) 975 974 return status; … … 985 984 pj_status_t status; 986 985 987 status = pjmedia_transport_srtp_ deinit_session(tp);986 status = pjmedia_transport_srtp_stop(tp); 988 987 if (status != PJ_SUCCESS) 989 988 PJ_LOG(4, (THIS_FILE, "Failed deinit session.")); -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_udp.c
r1698 r1702 122 122 pj_pool_t *pool, 123 123 pjmedia_sdp_session *sdp_local, 124 const pjmedia_sdp_session *sdp_remote); 124 const pjmedia_sdp_session *sdp_remote, 125 unsigned media_index); 125 126 static pj_status_t transport_media_start (pjmedia_transport *tp, 126 127 pj_pool_t *pool, … … 741 742 pj_pool_t *pool, 742 743 pjmedia_sdp_session *sdp_local, 743 const pjmedia_sdp_session *sdp_remote) 744 const pjmedia_sdp_session *sdp_remote, 745 unsigned media_index) 744 746 { 745 747 PJ_UNUSED_ARG(tp);
Note: See TracChangeset
for help on using the changeset viewer.