- Timestamp:
- Feb 7, 2006 12:34:58 PM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/errno.h
r129 r140 150 150 /** 151 151 * @hideinitializer 152 * No initial local SDP. 153 */ 154 #define PJMEDIA_SDPNEG_ENOINITIAL (PJMEDIA_ERRNO_START+41) /* 220041 */ 155 /** 156 * @hideinitializer 152 157 * No currently active SDP. 153 158 */ 154 #define PJMEDIA_SDPNEG_ENOACTIVE (PJMEDIA_ERRNO_START+41) /* 220041 */ 159 #define PJMEDIA_SDPNEG_ENOACTIVE (PJMEDIA_ERRNO_START+42) /* 220042 */ 160 /** 161 * @hideinitializer 162 * No current offer or answer. 163 */ 164 #define PJMEDIA_SDPNEG_ENONEG (PJMEDIA_ERRNO_START+43) /* 220043 */ 155 165 /** 156 166 * @hideinitializer 157 167 * Media count mismatch in offer and answer. 158 168 */ 159 #define PJMEDIA_SDPNEG_EMISMEDIA (PJMEDIA_ERRNO_START+4 2) /* 220042*/169 #define PJMEDIA_SDPNEG_EMISMEDIA (PJMEDIA_ERRNO_START+44) /* 220044 */ 160 170 /** 161 171 * @hideinitializer 162 172 * Media type is different in the remote answer. 163 173 */ 164 #define PJMEDIA_SDPNEG_EINVANSMEDIA (PJMEDIA_ERRNO_START+4 3) /* 220043*/174 #define PJMEDIA_SDPNEG_EINVANSMEDIA (PJMEDIA_ERRNO_START+45) /* 220045 */ 165 175 /** 166 176 * @hideinitializer 167 177 * Transport type is different in the remote answer. 168 178 */ 169 #define PJMEDIA_SDPNEG_EINVANSTP (PJMEDIA_ERRNO_START+4 4) /* 220044*/179 #define PJMEDIA_SDPNEG_EINVANSTP (PJMEDIA_ERRNO_START+46) /* 220046 */ 170 180 /** 171 181 * @hideinitializer 172 182 * No common media payload is provided in the answer. 173 183 */ 174 #define PJMEDIA_SDPNEG_EANSNOMEDIA (PJMEDIA_ERRNO_START+45) /* 220045 */ 184 #define PJMEDIA_SDPNEG_EANSNOMEDIA (PJMEDIA_ERRNO_START+47) /* 220047 */ 185 /** 186 * @hideinitializer 187 * No media is active after negotiation. 188 */ 189 #define PJMEDIA_SDPNEG_ENOMEDIA (PJMEDIA_ERRNO_START+48) /* 220048 */ 175 190 176 191 -
pjproject/trunk/pjmedia/include/pjmedia/sdp_neg.h
r129 r140 40 40 41 41 /** 42 * This enumeration describes SDP negotiation state. 42 * This enumeration describes SDP negotiation state. The negotiator state 43 * is illustrated in the following diagram. 44 * 45 * <pre> 46 * reinit_local_offer() 47 * modify_local_offer() 48 * create_w_local_offer() +-------------+ send_local_offer() 49 * ----------------------->| LOCAL_OFFER |<----------------------- 50 * | +-------------+ | 51 * | | | 52 * | set_remote_answer() | | 53 * | V | 54 * +--+---+ +-----------+ negotiate() +------+ 55 * | NULL | | WAIT_NEGO |-------------------->| DONE | 56 * +------+ +-----------+ +------+ 57 * | A | 58 * | set_local_answer() | | 59 * | | | 60 * | +--------------+ set_remote_offer() | 61 * ----------------------->| REMOTE_OFFER |<---------------------- 62 * create_w_remote_offer() +--------------+ 63 * 64 * </pre> 43 65 */ 44 66 enum pjmedia_sdp_neg_state … … 51 73 /** 52 74 * This state occurs when SDP negotiator has sent our offer to remote and 53 * it is waiting for answer. 75 * it is waiting for answer. 54 76 */ 55 77 PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, 78 79 /** 80 * This state occurs when SDP negotiator has received offer from remote 81 * and currently waiting for local answer. 82 */ 83 PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER, 56 84 57 85 /** 58 86 * This state occurs when an offer (either local or remote) has been 59 87 * provided with answer. The SDP negotiator is ready to negotiate both 60 * session descriptors. 88 * session descriptors. Application can call #pjmedia_sdp_neg_negotiate() 89 * immediately to begin negotiation process. 61 90 */ 62 91 PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, … … 69 98 }; 70 99 71 /* Negotiator state:72 *73 * reinit_local_offer()74 * modify_local_offer()75 * create_w_local_offer() +-------------+ tx_local_offer()76 * /------------------------->| LOCAL_OFFER |<----------------------\77 * | +-------------+ |78 * | | |79 * | rx_remote_answer() | |80 * | V |81 * +--+---+ +-----------+ negotiate() +------+82 * + NULL |------------------------>| WAIT_NEGO |-------------------->| DONE |83 * +------+ create_w_remote_offer() +-----------+ +------+84 * A |85 * | rx_remote_offer() |86 * \-----------------------------/87 */88 89 100 /** 90 101 * Create the SDP negotiator with local offer. The SDP negotiator then 91 102 * will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER state, where it waits 92 103 * until it receives answer from remote. When SDP answer from remote is 93 * received, application should call #pjmedia_sdp_neg_ rx_remote_answer().104 * received, application should call #pjmedia_sdp_neg_set_remote_answer(). 94 105 * 95 106 * After calling this function, application should send the local SDP offer 96 * to remote party and wait for SDP answer. 107 * to remote party using higher layer signaling protocol (e.g. SIP) and 108 * wait for SDP answer. 109 * 110 * @param pool Pool to allocate memory. The pool's lifetime needs 111 * to be valid for the duration of the negotiator. 112 * @param local The initial local capability. 113 * @param p_neg Pointer to receive the negotiator instance. 114 * 115 * @return PJ_SUCCESS on success, or the appropriate error 116 * code. 97 117 */ 98 118 PJ_DECL(pj_status_t) … … 102 122 103 123 /** 104 * Initialize the SDP negotiator with both local and remote offer. 105 * Application normally calls this function when it receives initial offer 106 * from remote. Application must also provide initial local offer when 107 * calling this function. After this function is called, the SDP negotiator 108 * state will move to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and the negotiation 109 * function can be called. 124 * Initialize the SDP negotiator with remote offer, and optionally 125 * specify the initial local capability, if known. Application normally 126 * calls this function when it receives initial offer 127 * from remote. 128 * 129 * If local media capability is specified, this capability will be set as 130 * initial local capability of the negotiator, and after this function is 131 * called, the SDP negotiator state will move to state 132 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and the negotiation function can be 133 * called. 134 * 135 * If local SDP is not specified, the negotiator will not have initial local 136 * capability, and after this function is called the negotiator state will 137 * move to PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER state. Application MUST supply 138 * local answer later with #pjmedia_sdp_neg_set_local_answer(), before 139 * calling the negotiation function. 140 * 141 * @param pool Pool to allocate memory. The pool's lifetime needs 142 * to be valid for the duration of the negotiator. 143 * @param initial Optional initial local capability. 144 * @param remote The remote offer. 145 * @param p_neg Pointer to receive the negotiator instance. 146 * 147 * @return PJ_SUCCESS on success, or the appropriate error 148 * code. 110 149 */ 111 150 PJ_DECL(pj_status_t) 112 151 pjmedia_sdp_neg_create_w_remote_offer(pj_pool_t *pool, 113 const pjmedia_sdp_session * local,152 const pjmedia_sdp_session *initial, 114 153 const pjmedia_sdp_session *remote, 115 154 pjmedia_sdp_neg **p_neg); … … 117 156 /** 118 157 * Get SDP negotiator state. 158 * 159 * @param neg The SDP negotiator instance. 160 * 161 * @return The negotiator state. 119 162 */ 120 163 PJ_DECL(pjmedia_sdp_neg_state) … … 126 169 * active SDPs. Calling this function will not change the state of the 127 170 * negotiator. 128 */ 129 PJ_DECL(pj_status_t) 130 pjmedia_sdp_neg_get_local( pjmedia_sdp_neg *neg, 131 const pjmedia_sdp_session **local); 171 * 172 * @param neg The SDP negotiator instance. 173 * @param local Pointer to receive the local active SDP. 174 * 175 * @return PJ_SUCCESS if local active SDP is present. 176 */ 177 PJ_DECL(pj_status_t) 178 pjmedia_sdp_neg_get_active_local( pjmedia_sdp_neg *neg, 179 const pjmedia_sdp_session **local); 132 180 133 181 /** … … 136 184 * active SDPs. Calling this function will not change the state of the 137 185 * negotiator. 138 */ 139 PJ_DECL(pj_status_t) 140 pjmedia_sdp_neg_get_remote( pjmedia_sdp_neg *neg, 141 const pjmedia_sdp_session **remote); 142 186 * 187 * @param neg The SDP negotiator instance. 188 * @param remote Pointer to receive the remote active SDP. 189 * 190 * @return PJ_SUCCESS if remote active SDP is present. 191 */ 192 PJ_DECL(pj_status_t) 193 pjmedia_sdp_neg_get_active_remote( pjmedia_sdp_neg *neg, 194 const pjmedia_sdp_session **remote); 195 196 /** 197 * Get the current remote SDP offer or answer. Application can only 198 * call this function in state PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER or 199 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, or otherwise there won't be remote 200 * SDP offer/answer. Calling this function will not change the state 201 * of the negotiator. 202 * 203 * @param neg The SDP negotiator instance. 204 * @param remote Pointer to receive the current remote offer or 205 * answer. 206 * 207 * @return PJ_SUCCESS if the negotiator currently has 208 * remote offer or answer. 209 */ 210 PJ_DECL(pj_status_t) 211 pjmedia_sdp_neg_get_neg_remote( pjmedia_sdp_neg *neg, 212 const pjmedia_sdp_session **remote); 213 214 215 /** 216 * Get the current local SDP offer or answer. Application can only 217 * call this function in state PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER or 218 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, or otherwise there won't be local 219 * SDP offer/answer. Calling this function will not change the state 220 * of the negotiator. 221 * 222 * @param neg The SDP negotiator instance. 223 * @param local Pointer to receive the current local offer or 224 * answer. 225 * 226 * @return PJ_SUCCESS if the negotiator currently has 227 * local offer or answer. 228 */ 229 PJ_DECL(pj_status_t) 230 pjmedia_sdp_neg_get_neg_local( pjmedia_sdp_neg *neg, 231 const pjmedia_sdp_session **local); 143 232 144 233 /** … … 148 237 * The negotiator state will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, 149 238 * where it waits for SDP answer from remote. 239 * 240 * @param pool Pool to allocate memory. The pool's lifetime needs 241 * to be valid for the duration of the negotiator. 242 * @param neg The SDP negotiator instance. 243 * @param local The new local SDP. 244 * 245 * @return PJ_SUCCESS on success, or the appropriate 246 * error code. 150 247 */ 151 248 PJ_DECL(pj_status_t) … … 158 255 * SDP negotiator must be in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO state. 159 256 * After calling this function, the negotiator state will move to 160 * PJMEDIA_SDP_NEG_STATE_DONE. 257 * PJMEDIA_SDP_NEG_STATE_DONE regardless whether the negotiation has 258 * been successfull or not. 259 * 260 * If the negotiation succeeds (i.e. the return value is PJ_SUCCESS), 261 * the active local and remote SDP will be replaced with the new SDP 262 * from the negotiation process. 263 * 264 * If the negotiation fails, the active local and remote SDP will not 265 * change. 266 * 267 * @param pool Pool to allocate memory. The pool's lifetime needs 268 * to be valid for the duration of the negotiator. 269 * @param neg The SDP negotiator instance. 270 * @param allow_asym Should be zero. 271 * 272 * @return PJ_SUCCESS when there is at least one media 273 * is actuve common in both offer and answer, or 274 * failure code when negotiation has failed. 161 275 */ 162 276 PJ_DECL(pj_status_t) pjmedia_sdp_neg_negotiate( pj_pool_t *pool, … … 170 284 * local SDP to be sent to remote. The negotiator state will then move 171 285 * to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it waits for SDP answer 172 * from remote. 173 */ 174 PJ_DECL(pj_status_t) 175 pjmedia_sdp_neg_tx_local_offer( pj_pool_t *pool, 176 pjmedia_sdp_neg *neg, 177 const pjmedia_sdp_session **offer); 286 * from remote. When SDP answer has been received from remote, application 287 * must call #pjmedia_sdp_neg_set_remote_answer(). 288 * 289 * @param pool Pool to allocate memory. The pool's lifetime needs 290 * to be valid for the duration of the negotiator. 291 * @param neg The SDP negotiator instance. 292 * @param offer Pointer to receive active local SDP to be 293 * offered to remote. 294 * 295 * @return PJ_SUCCESS if local offer can be created. 296 */ 297 PJ_DECL(pj_status_t) 298 pjmedia_sdp_neg_send_local_offer( pj_pool_t *pool, 299 pjmedia_sdp_neg *neg, 300 const pjmedia_sdp_session **offer); 301 302 /** 303 * This function can only be called in PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER 304 * state, i.e. after application calls #pjmedia_sdp_neg_send_local_offer() 305 * function. Application calls this function when it receives SDP answer 306 * from remote. After this function is called, the negotiator state will 307 * move to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and application can call the 308 * negotiation function #pjmedia_sdp_neg_negotiate(). 309 * 310 * @param pool Pool to allocate memory. The pool's lifetime needs 311 * to be valid for the duration of the negotiator. 312 * @param neg The SDP negotiator instance. 313 * @param remote The remote answer. 314 * 315 * @return PJ_SUCCESS on success. 316 */ 317 PJ_DECL(pj_status_t) 318 pjmedia_sdp_neg_set_remote_answer( pj_pool_t *pool, 319 pjmedia_sdp_neg *neg, 320 const pjmedia_sdp_session *remote); 321 322 178 323 179 324 /** … … 181 326 * Application calls this function when it receives SDP offer from remote. 182 327 * After this function is called, the negotiator state will move to 183 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and application can call the 184 * negotiation function #pjmedia_sdp_neg_negotiate(). 185 */ 186 PJ_DECL(pj_status_t) 187 pjmedia_sdp_neg_rx_remote_offer( pj_pool_t *pool, 188 pjmedia_sdp_neg *neg, 189 const pjmedia_sdp_session *remote); 190 191 192 /** 193 * This function can only be called in PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER 194 * state. Application calls this function when it receives SDP answer 195 * from remote. After this function is called, the negotiator state will 328 * PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER, and application MUST call the 329 * #pjmedia_sdp_neg_set_local_answer() to set local answer before it can 330 * call the negotiation function. 331 * 332 * @param pool Pool to allocate memory. The pool's lifetime needs 333 * to be valid for the duration of the negotiator. 334 * @param neg The SDP negotiator instance. 335 * @param remote The remote offer. 336 * 337 * @return PJ_SUCCESS on success. 338 */ 339 PJ_DECL(pj_status_t) 340 pjmedia_sdp_neg_set_remote_offer( pj_pool_t *pool, 341 pjmedia_sdp_neg *neg, 342 const pjmedia_sdp_session *remote); 343 344 345 346 /** 347 * This function can only be called in PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER 348 * state, i.e. after application calls #pjmedia_sdp_neg_set_remote_offer() 349 * function. After this function is called, the negotiator state will 196 350 * move to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, and application can call the 197 351 * negotiation function #pjmedia_sdp_neg_negotiate(). 198 */ 199 PJ_DECL(pj_status_t) 200 pjmedia_sdp_neg_rx_remote_answer( pj_pool_t *pool, 352 * 353 * @param pool Pool to allocate memory. The pool's lifetime needs 354 * to be valid for the duration of the negotiator. 355 * @param neg The SDP negotiator instance. 356 * @param local Optional local answer. If negotiator has initial 357 * local capability, application can specify NULL on 358 * this argument; in this case, the negotiator will 359 * create answer by by negotiating remote offer with 360 * initial local capability. If negotiator doesn't have 361 * initial local capability, application MUST specify 362 * local answer here. 363 * 364 * @return PJ_SUCCESS on success. 365 */ 366 PJ_DECL(pj_status_t) 367 pjmedia_sdp_neg_set_local_answer( pj_pool_t *pool, 201 368 pjmedia_sdp_neg *neg, 202 const pjmedia_sdp_session *remote); 369 const pjmedia_sdp_session *local); 370 203 371 204 372 -
pjproject/trunk/pjmedia/src/pjmedia/errno.c
r129 r140 54 54 /* SDP negotiator errors. */ 55 55 { PJMEDIA_SDPNEG_EINSTATE, "Invalid SDP negotiator state for operation" }, 56 { PJMEDIA_SDPNEG_ENOINITIAL, "No initial local SDP in SDP negotiator" }, 56 57 { PJMEDIA_SDPNEG_ENOACTIVE, "No active SDP in SDP negotiator" }, 58 { PJMEDIA_SDPNEG_ENONEG, "No current local/remote offer/answer" }, 57 59 { PJMEDIA_SDPNEG_EMISMEDIA, "SDP media count mismatch in offer/answer" }, 58 60 { PJMEDIA_SDPNEG_EINVANSMEDIA, "SDP media type mismatch in offer/answer" }, 59 61 { PJMEDIA_SDPNEG_EINVANSTP, "SDP media transport type mismatch in offer/answer" }, 60 62 { PJMEDIA_SDPNEG_EANSNOMEDIA, "No common SDP media payload in answer" }, 63 { PJMEDIA_SDPNEG_ENOMEDIA, "No active media stream after negotiation" }, 61 64 62 65 /* SDP comparison results */ -
pjproject/trunk/pjmedia/src/pjmedia/sdp.c
r129 r140 1094 1094 { 1095 1095 unsigned i; 1096 const pj_str_t STR_RTPMAP = { "rtpmap", 6 }; 1096 1097 1097 1098 CHECK( sdp != NULL, PJ_EINVAL); … … 1156 1157 const pjmedia_sdp_attr *a; 1157 1158 1158 a = pjmedia_sdp_media_find_attr 2(m, "rtpmap",&m->desc.fmt[j]);1159 a = pjmedia_sdp_media_find_attr(m,&STR_RTPMAP,&m->desc.fmt[j]); 1159 1160 CHECK( a != NULL, PJMEDIA_SDP_EMISSINGRTPMAP); 1160 1161 } -
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r129 r140 78 78 PJ_DEF(pj_status_t) 79 79 pjmedia_sdp_neg_create_w_remote_offer(pj_pool_t *pool, 80 const pjmedia_sdp_session * local,80 const pjmedia_sdp_session *initial, 81 81 const pjmedia_sdp_session *remote, 82 82 pjmedia_sdp_neg **p_neg) … … 86 86 87 87 /* Check arguments are valid. */ 88 PJ_ASSERT_RETURN(pool && local &&remote && p_neg, PJ_EINVAL);88 PJ_ASSERT_RETURN(pool && remote && p_neg, PJ_EINVAL); 89 89 90 90 *p_neg = NULL; 91 91 92 /* Validate remote offer and local answer */92 /* Validate remote offer and initial answer */ 93 93 status = pjmedia_sdp_validate(remote); 94 94 if (status != PJ_SUCCESS) 95 95 return status; 96 PJ_ASSERT_RETURN((status=pjmedia_sdp_validate(local))==PJ_SUCCESS, status);97 96 98 97 /* Create and initialize negotiator. */ … … 100 99 PJ_ASSERT_RETURN(neg != NULL, PJ_ENOMEM); 101 100 102 neg->state = PJMEDIA_SDP_NEG_STATE_WAIT_NEGO;103 neg->initial_sdp = pjmedia_sdp_session_clone(pool, local);104 PJ_ASSERT_RETURN((status=pjmedia_sdp_validate(neg->initial_sdp))==PJ_SUCCESS,105 status);106 107 neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local);108 101 neg->neg_remote_sdp = pjmedia_sdp_session_clone(pool, remote); 109 PJ_ASSERT_RETURN((status=pjmedia_sdp_validate(neg->neg_remote_sdp))==PJ_SUCCESS, 110 status); 102 103 if (initial) { 104 PJ_ASSERT_RETURN((status=pjmedia_sdp_validate(initial))==PJ_SUCCESS, 105 status); 106 107 neg->initial_sdp = pjmedia_sdp_session_clone(pool, initial); 108 neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, initial); 109 110 neg->state = PJMEDIA_SDP_NEG_STATE_WAIT_NEGO; 111 112 } else { 113 114 neg->state = PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER; 115 116 } 111 117 112 118 *p_neg = neg; … … 127 133 128 134 PJ_DEF(pj_status_t) 129 pjmedia_sdp_neg_get_ local( pjmedia_sdp_neg *neg,130 135 pjmedia_sdp_neg_get_active_local( pjmedia_sdp_neg *neg, 136 const pjmedia_sdp_session **local) 131 137 { 132 138 PJ_ASSERT_RETURN(neg && local, PJ_EINVAL); … … 139 145 140 146 PJ_DEF(pj_status_t) 141 pjmedia_sdp_neg_get_ remote( pjmedia_sdp_neg *neg,142 147 pjmedia_sdp_neg_get_active_remote( pjmedia_sdp_neg *neg, 148 const pjmedia_sdp_session **remote) 143 149 { 144 150 PJ_ASSERT_RETURN(neg && remote, PJ_EINVAL); … … 146 152 147 153 *remote = neg->active_remote_sdp; 154 return PJ_SUCCESS; 155 } 156 157 PJ_DEF(pj_status_t) 158 pjmedia_sdp_neg_get_neg_remote( pjmedia_sdp_neg *neg, 159 const pjmedia_sdp_session **remote) 160 { 161 PJ_ASSERT_RETURN(neg && remote, PJ_EINVAL); 162 PJ_ASSERT_RETURN(neg->neg_remote_sdp, PJMEDIA_SDPNEG_ENONEG); 163 164 *remote = neg->neg_remote_sdp; 165 return PJ_SUCCESS; 166 } 167 168 PJ_DEF(pj_status_t) 169 pjmedia_sdp_neg_get_neg_local( pjmedia_sdp_neg *neg, 170 const pjmedia_sdp_session **local) 171 { 172 PJ_ASSERT_RETURN(neg && local, PJ_EINVAL); 173 PJ_ASSERT_RETURN(neg->neg_local_sdp, PJMEDIA_SDPNEG_ENONEG); 174 175 *local = neg->neg_local_sdp; 148 176 return PJ_SUCCESS; 149 177 } … … 175 203 176 204 PJ_DEF(pj_status_t) 177 pjmedia_sdp_neg_ tx_local_offer( pj_pool_t *pool,178 pjmedia_sdp_neg *neg,179 const pjmedia_sdp_session **offer)205 pjmedia_sdp_neg_send_local_offer( pj_pool_t *pool, 206 pjmedia_sdp_neg *neg, 207 const pjmedia_sdp_session **offer) 180 208 { 181 209 /* Check arguments are valid. */ … … 211 239 212 240 PJ_DEF(pj_status_t) 213 pjmedia_sdp_neg_rx_remote_offer( pj_pool_t *pool, 214 pjmedia_sdp_neg *neg, 215 const pjmedia_sdp_session *remote) 241 pjmedia_sdp_neg_set_remote_answer( pj_pool_t *pool, 242 pjmedia_sdp_neg *neg, 243 const pjmedia_sdp_session *remote) 244 { 245 /* Check arguments are valid. */ 246 PJ_ASSERT_RETURN(pool && neg && remote, PJ_EINVAL); 247 248 /* Can only do this in STATE_LOCAL_OFFER. 249 * If we haven't provided local offer, then rx_remote_offer() should 250 * be called instead of this function. 251 */ 252 PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, 253 PJMEDIA_SDPNEG_EINSTATE); 254 255 /* We're ready to negotiate. */ 256 neg->state = PJMEDIA_SDP_NEG_STATE_WAIT_NEGO; 257 neg->has_remote_answer = 1; 258 neg->neg_remote_sdp = pjmedia_sdp_session_clone(pool, remote); 259 260 return PJ_SUCCESS; 261 } 262 263 PJ_DEF(pj_status_t) 264 pjmedia_sdp_neg_set_remote_offer( pj_pool_t *pool, 265 pjmedia_sdp_neg *neg, 266 const pjmedia_sdp_session *remote) 216 267 { 217 268 /* Check arguments are valid. */ … … 225 276 PJMEDIA_SDPNEG_EINSTATE); 226 277 227 /* We're ready to negotiate. */228 neg->state = PJMEDIA_SDP_NEG_STATE_ WAIT_NEGO;278 /* State now is STATE_REMOTE_OFFER. */ 279 neg->state = PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER; 229 280 neg->neg_remote_sdp = pjmedia_sdp_session_clone(pool, remote); 230 281 … … 233 284 234 285 PJ_DEF(pj_status_t) 235 pjmedia_sdp_neg_ rx_remote_answer( pj_pool_t *pool,286 pjmedia_sdp_neg_set_local_answer( pj_pool_t *pool, 236 287 pjmedia_sdp_neg *neg, 237 const pjmedia_sdp_session * remote)288 const pjmedia_sdp_session *local) 238 289 { 239 290 /* Check arguments are valid. */ 240 PJ_ASSERT_RETURN(pool && neg && remote, PJ_EINVAL);241 242 /* Can only do this in STATE_ LOCAL_OFFER.243 * If we haven't provided local offer, then rx_remote_offer() should291 PJ_ASSERT_RETURN(pool && neg && local, PJ_EINVAL); 292 293 /* Can only do this in STATE_REMOTE_OFFER. 294 * If we already provide local offer, then rx_remote_answer() should 244 295 * be called instead of this function. 245 296 */ 246 PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_ LOCAL_OFFER,297 PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER, 247 298 PJMEDIA_SDPNEG_EINSTATE); 248 299 249 /* We're ready to negotiate. */300 /* State now is STATE_WAIT_NEGO. */ 250 301 neg->state = PJMEDIA_SDP_NEG_STATE_WAIT_NEGO; 251 neg->has_remote_answer = 1; 252 neg->neg_remote_sdp = pjmedia_sdp_session_clone(pool, remote); 253 302 if (local) 303 neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, local); 304 else { 305 PJ_ASSERT_RETURN(neg->initial_sdp, PJMEDIA_SDPNEG_ENOINITIAL); 306 neg->neg_local_sdp = pjmedia_sdp_session_clone(pool, neg->initial_sdp); 307 } 308 254 309 return PJ_SUCCESS; 255 310 } … … 464 519 { 465 520 unsigned mi; 521 pj_bool_t has_active = PJ_FALSE; 466 522 pj_status_t status; 467 523 … … 479 535 if (status != PJ_SUCCESS) 480 536 return status; 537 538 if (offer->media[mi]->desc.port != 0) 539 has_active = PJ_TRUE; 481 540 } 482 541 483 542 *p_active = offer; 484 return PJ_SUCCESS; 543 544 return has_active ? PJ_SUCCESS : PJMEDIA_SDPNEG_ENOMEDIA; 485 545 } 486 546 … … 675 735 { 676 736 pj_status_t status; 737 pj_bool_t has_active = PJ_FALSE; 677 738 pjmedia_sdp_session *answer; 678 739 char media_used[PJSDP_MAX_MEDIA]; … … 749 810 /* Add the media answer */ 750 811 answer->media[answer->media_count++] = am; 812 813 /* Check if this media is active.*/ 814 if (am->desc.port != 0) 815 has_active = PJ_TRUE; 751 816 } 752 817 753 818 *p_answer = answer; 754 return PJ_SUCCESS; 819 820 return has_active ? PJ_SUCCESS : PJMEDIA_SDPNEG_ENOMEDIA; 755 821 } 756 822 … … 785 851 pjmedia_sdp_session *answer; 786 852 787 status = create_answer(pool, neg-> initial_sdp, neg->neg_remote_sdp,853 status = create_answer(pool, neg->neg_local_sdp, neg->neg_remote_sdp, 788 854 &answer); 789 855 if (status == PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.