Changeset 1111 for pjproject/trunk/pjnath/include/pjnath/ice_session.h
- Timestamp:
- Mar 28, 2007 3:49:48 PM (17 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/ice_session.h
r1110 r1111 21 21 22 22 /** 23 * @file ice .h23 * @file ice_session.h 24 24 * @brief ICE session management 25 25 */ … … 44 44 * @{ 45 45 * 46 * This module describes #pj_ice , a transport independent ICE session,46 * This module describes #pj_ice_sess, a transport independent ICE session, 47 47 * part of PJNATH - the Open Source NAT helper library. 48 48 * 49 * An ICE session, represented by #pj_ice structure, is the lowest49 * An ICE session, represented by #pj_ice_sess structure, is the lowest 50 50 * abstraction of ICE in PJNATH, and it is used to perform and manage 51 51 * connectivity checks of transport address candidates <b>within a … … 70 70 typedef enum pj_ice_cand_type 71 71 { 72 PJ_ICE_CAND_TYPE_HOST, /**< ICE host candidate. */ 73 PJ_ICE_CAND_TYPE_SRFLX, /**< ICE server reflexive candidate. */ 74 PJ_ICE_CAND_TYPE_PRFLX, /**< ICE peer reflexive candidate. */ 75 PJ_ICE_CAND_TYPE_RELAYED /**< ICE relayed candidate. */ 72 /** 73 * ICE host candidate. A host candidate represents the actual local 74 * transport address in the host. 75 */ 76 PJ_ICE_CAND_TYPE_HOST, 77 78 /** 79 * ICE server reflexive candidate, which represents the public mapped 80 * address of the local address, and is obtained by sending STUN 81 * Binding request from the host candidate to a STUN server. 82 */ 83 PJ_ICE_CAND_TYPE_SRFLX, 84 85 /** 86 * ICE peer reflexive candidate, which is the address as seen by peer 87 * agent during connectivity check. 88 */ 89 PJ_ICE_CAND_TYPE_PRFLX, 90 91 /** 92 * ICE relayed candidate, which represents the address allocated in 93 * TURN server. 94 */ 95 PJ_ICE_CAND_TYPE_RELAYED 96 76 97 } pj_ice_cand_type; 77 98 … … 89 110 }; 90 111 91 /** Forward declaration for pj_ice */92 typedef struct pj_ice pj_ice;93 94 /** Forward declaration for pj_ice_ check */95 typedef struct pj_ice_ check pj_ice_check;112 /** Forward declaration for pj_ice_sess */ 113 typedef struct pj_ice_sess pj_ice_sess; 114 115 /** Forward declaration for pj_ice_sess_check */ 116 typedef struct pj_ice_sess_check pj_ice_sess_check; 96 117 97 118 … … 103 124 * and one for RTCP. 104 125 */ 105 typedef struct pj_ice_ comp126 typedef struct pj_ice_sess_comp 106 127 { 107 128 /** … … 110 131 * for this component. 111 132 */ 112 pj_ice_ check *valid_check;113 114 } pj_ice_ comp;133 pj_ice_sess_check *valid_check; 134 135 } pj_ice_sess_comp; 115 136 116 137 … … 123 144 * base. 124 145 */ 125 typedef struct pj_ice_ cand146 typedef struct pj_ice_sess_cand 126 147 { 127 148 /** … … 185 206 pj_stun_session *stun_sess; 186 207 187 } pj_ice_ cand;208 } pj_ice_sess_cand; 188 209 189 210 … … 191 212 * This enumeration describes the state of ICE check. 192 213 */ 193 typedef enum pj_ice_ check_state214 typedef enum pj_ice_sess_check_state 194 215 { 195 216 /** … … 198 219 * pair to unfreeze and move into the Waiting state. 199 220 */ 200 PJ_ICE_ CHECK_STATE_FROZEN,221 PJ_ICE_SESS_CHECK_STATE_FROZEN, 201 222 202 223 /** … … 205 226 * the check list. 206 227 */ 207 PJ_ICE_ CHECK_STATE_WAITING,228 PJ_ICE_SESS_CHECK_STATE_WAITING, 208 229 209 230 /** … … 212 233 * the check list. 213 234 */ 214 PJ_ICE_ CHECK_STATE_IN_PROGRESS,235 PJ_ICE_SESS_CHECK_STATE_IN_PROGRESS, 215 236 216 237 /** … … 219 240 * the check list. 220 241 */ 221 PJ_ICE_ CHECK_STATE_SUCCEEDED,242 PJ_ICE_SESS_CHECK_STATE_SUCCEEDED, 222 243 223 244 /** … … 226 247 * response. 227 248 */ 228 PJ_ICE_ CHECK_STATE_FAILED229 230 } pj_ice_ check_state;249 PJ_ICE_SESS_CHECK_STATE_FAILED 250 251 } pj_ice_sess_check_state; 231 252 232 253 … … 238 259 * of a candidate pair. 239 260 */ 240 struct pj_ice_ check261 struct pj_ice_sess_check 241 262 { 242 263 /** 243 264 * Pointer to local candidate entry of this check. 244 265 */ 245 pj_ice_ cand*lcand;266 pj_ice_sess_cand *lcand; 246 267 247 268 /** 248 269 * Pointer to remote candidate entry of this check. 249 270 */ 250 pj_ice_ cand*rcand;271 pj_ice_sess_cand *rcand; 251 272 252 273 /** … … 258 279 * Connectivity check state. 259 280 */ 260 pj_ice_ check_state state;281 pj_ice_sess_check_state state; 261 282 262 283 /** … … 285 306 * This enumeration describes ICE checklist state. 286 307 */ 287 typedef enum pj_ice_ checklist_state308 typedef enum pj_ice_sess_checklist_state 288 309 { 289 310 /** 290 311 * The checklist is not yet running. 291 312 */ 292 PJ_ICE_ CHECKLIST_ST_IDLE,313 PJ_ICE_SESS_CHECKLIST_ST_IDLE, 293 314 294 315 /** … … 296 317 * media stream. 297 318 */ 298 PJ_ICE_ CHECKLIST_ST_RUNNING,319 PJ_ICE_SESS_CHECKLIST_ST_RUNNING, 299 320 300 321 /** … … 302 323 * either successfully or with failure. 303 324 */ 304 PJ_ICE_ CHECKLIST_ST_COMPLETED305 306 } pj_ice_ checklist_state;325 PJ_ICE_SESS_CHECKLIST_ST_COMPLETED 326 327 } pj_ice_sess_checklist_state; 307 328 308 329 … … 311 332 * candidate pairs that an agent will use to generate checks. 312 333 */ 313 typedef struct pj_ice_ checklist334 typedef struct pj_ice_sess_checklist 314 335 { 315 336 /** 316 337 * The checklist state. 317 338 */ 318 pj_ice_ checklist_state state;339 pj_ice_sess_checklist_state state; 319 340 320 341 /** … … 326 347 * Array of candidate pairs (checks). 327 348 */ 328 pj_ice_ check checks[PJ_ICE_MAX_CHECKS];349 pj_ice_sess_check checks[PJ_ICE_MAX_CHECKS]; 329 350 330 351 /** … … 333 354 pj_timer_entry timer; 334 355 335 } pj_ice_ checklist;356 } pj_ice_sess_checklist; 336 357 337 358 … … 340 361 * session. 341 362 */ 342 typedef struct pj_ice_ cb363 typedef struct pj_ice_sess_cb 343 364 { 344 365 /** … … 350 371 * successful, or some error code. 351 372 */ 352 void (*on_ice_complete)(pj_ice *ice, pj_status_t status);373 void (*on_ice_complete)(pj_ice_sess *ice, pj_status_t status); 353 374 354 375 /** … … 364 385 * @param dst_addr_len Length of destination address. 365 386 */ 366 pj_status_t (*on_tx_pkt)(pj_ice *ice, unsigned comp_id,387 pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id, 367 388 unsigned cand_id, 368 389 const void *pkt, pj_size_t size, … … 382 403 * @param src_addr_len The length of source address. 383 404 */ 384 void (*on_rx_data)(pj_ice *ice, unsigned comp_id,405 void (*on_rx_data)(pj_ice_sess *ice, unsigned comp_id, 385 406 void *pkt, pj_size_t size, 386 407 const pj_sockaddr_t *src_addr, 387 408 unsigned src_addr_len); 388 } pj_ice_ cb;389 390 391 /** 392 * This enumeration describes ICE role.393 */ 394 typedef enum pj_ice_ role409 } pj_ice_sess_cb; 410 411 412 /** 413 * This enumeration describes the role of the ICE agent. 414 */ 415 typedef enum pj_ice_sess_role 395 416 { 396 417 /** 397 418 * The ICE agent is in controlled role. 398 419 */ 399 PJ_ICE_ ROLE_CONTROLLED,420 PJ_ICE_SESS_ROLE_CONTROLLED, 400 421 401 422 /** 402 423 * The ICE agent is in controlling role. 403 424 */ 404 PJ_ICE_ ROLE_CONTROLLING405 406 } pj_ice_ role;425 PJ_ICE_SESS_ROLE_CONTROLLING 426 427 } pj_ice_sess_role; 407 428 408 429 … … 416 437 * creating multiple ICE sessions, one for each media stream. 417 438 */ 418 struct pj_ice 439 struct pj_ice_sess 419 440 { 420 441 char obj_name[PJ_MAX_OBJ_NAME]; /**< Object name. */ … … 423 444 void *user_data; /**< App. data. */ 424 445 pj_mutex_t *mutex; /**< Mutex. */ 425 pj_ice_ rolerole; /**< ICE role. */446 pj_ice_sess_role role; /**< ICE role. */ 426 447 pj_bool_t is_complete; /**< Complete? */ 427 448 pj_status_t ice_status; /**< Error status. */ 428 pj_ice_ cbcb; /**< Callback. */449 pj_ice_sess_cb cb; /**< Callback. */ 429 450 430 451 pj_stun_config stun_cfg; /**< STUN settings. */ … … 440 461 /* Components */ 441 462 unsigned comp_cnt; /**< # of components. */ 442 pj_ice_ compcomp[PJ_ICE_MAX_COMP]; /**< Component array */463 pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]; /**< Component array */ 443 464 444 465 /* Local candidates */ 445 466 unsigned lcand_cnt; /**< # of local cand. */ 446 pj_ice_ candlcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */467 pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ 447 468 448 469 /* Remote candidates */ 449 470 unsigned rcand_cnt; /**< # of remote cand. */ 450 pj_ice_ candrcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */471 pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]; /**< Array of cand. */ 451 472 452 473 /* Checklist */ 453 pj_ice_ checklist clist;/**< Active checklist */474 pj_ice_sess_checklist clist; /**< Active checklist */ 454 475 455 476 /* Valid list */ 456 pj_ice_ checklistvalid_list; /**< Valid list. */477 pj_ice_sess_checklist valid_list; /**< Valid list. */ 457 478 }; 458 479 … … 462 483 * particular candidate type. 463 484 * 464 * @param type 465 * 466 * @return 485 * @param type Candidate type. 486 * 487 * @return The string representation of the candidate type. 467 488 */ 468 489 PJ_DECL(const char*) pj_ice_get_cand_type_name(pj_ice_cand_type type); 490 491 492 /** 493 * This is a utility function to calculate the foundation identification 494 * for a candidate. 495 * 496 * @param pool Pool to allocate the foundation string. 497 * @param foundation Pointer to receive the foundation string. 498 * @param type Candidate type. 499 * @param base_addr Base address of the candidate. 500 */ 501 PJ_DECL(void) pj_ice_calc_foundation(pj_pool_t *pool, 502 pj_str_t *foundation, 503 pj_ice_cand_type type, 504 const pj_sockaddr *base_addr); 469 505 470 506 … … 474 510 * sending an offer or upon receiving one. After the session is created, 475 511 * application can register candidates to the ICE session by calling 476 * #pj_ice_ add_cand() function.512 * #pj_ice_sess_add_cand() function. 477 513 * 478 514 * @param stun_cfg The STUN configuration settings, containing among … … 493 529 * @return PJ_SUCCESS if ICE session is created successfully. 494 530 */ 495 PJ_DECL(pj_status_t) pj_ice_create(pj_stun_config *stun_cfg, 496 const char *name, 497 pj_ice_role role, 498 unsigned comp_cnt, 499 const pj_ice_cb *cb, 500 const pj_str_t *local_ufrag, 501 const pj_str_t *local_passwd, 502 pj_ice **p_ice); 503 504 /** 505 * Destroy ICE session. 531 PJ_DECL(pj_status_t) pj_ice_sess_create(pj_stun_config *stun_cfg, 532 const char *name, 533 pj_ice_sess_role role, 534 unsigned comp_cnt, 535 const pj_ice_sess_cb *cb, 536 const pj_str_t *local_ufrag, 537 const pj_str_t *local_passwd, 538 pj_ice_sess **p_ice); 539 540 /** 541 * Destroy ICE session. This will cancel any connectivity checks currently 542 * running, if any, and any other events scheduled by this session, as well 543 * as all memory resources. 506 544 * 507 545 * @param ice ICE session instance. … … 509 547 * @return PJ_SUCCESS on success. 510 548 */ 511 PJ_DECL(pj_status_t) pj_ice_destroy(pj_ice *ice); 512 513 514 /** 515 * Add a candidate to this ICE session. 549 PJ_DECL(pj_status_t) pj_ice_sess_destroy(pj_ice_sess *ice); 550 551 552 /** 553 * Add a candidate to this ICE session. Application must add candidates for 554 * each components ID before it can start pairing the candidates and 555 * performing connectivity checks. 516 556 * 517 557 * @param ice ICE session instance. … … 529 569 * @return PJ_SUCCESS if candidate is successfully added. 530 570 */ 531 PJ_DECL(pj_status_t) pj_ice_ add_cand(pj_ice*ice,532 533 534 535 536 537 538 539 540 571 PJ_DECL(pj_status_t) pj_ice_sess_add_cand(pj_ice_sess *ice, 572 unsigned comp_id, 573 pj_ice_cand_type type, 574 pj_uint16_t local_pref, 575 const pj_str_t *foundation, 576 const pj_sockaddr_t *addr, 577 const pj_sockaddr_t *base_addr, 578 const pj_sockaddr_t *rel_addr, 579 int addr_len, 580 unsigned *p_cand_id); 541 581 542 582 /** … … 554 594 * @return PJ_SUCCESS if a candidate has been selected. 555 595 */ 556 PJ_DECL(pj_status_t) pj_ice_ find_default_cand(pj_ice*ice,557 558 596 PJ_DECL(pj_status_t) pj_ice_sess_find_default_cand(pj_ice_sess *ice, 597 unsigned comp_id, 598 int *p_cand_id); 559 599 560 600 /** … … 565 605 * 566 606 * Note that ICE connectivity check will not start until application calls 567 * #pj_ice_s tart_check().607 * #pj_ice_sess_start_check(). 568 608 * 569 609 * @param ice ICE session instance. … … 579 619 * @return PJ_SUCCESS or the appropriate error code. 580 620 */ 581 PJ_DECL(pj_status_t) pj_ice_create_check_list(pj_ice *ice, 582 const pj_str_t *rem_ufrag, 583 const pj_str_t *rem_passwd, 584 unsigned rem_cand_cnt, 585 const pj_ice_cand rem_cand[]); 621 PJ_DECL(pj_status_t) 622 pj_ice_sess_create_check_list(pj_ice_sess *ice, 623 const pj_str_t *rem_ufrag, 624 const pj_str_t *rem_passwd, 625 unsigned rem_cand_cnt, 626 const pj_ice_sess_cand rem_cand[]); 586 627 587 628 /** 588 629 * Start ICE periodic check. This function will return immediately, and 589 630 * application will be notified about the connectivity check status in 590 * #pj_ice_ cb callback.631 * #pj_ice_sess_cb callback. 591 632 * 592 633 * @param ice The ICE session instance. … … 594 635 * @return PJ_SUCCESS or the appropriate error code. 595 636 */ 596 PJ_DECL(pj_status_t) pj_ice_s tart_check(pj_ice*ice);637 PJ_DECL(pj_status_t) pj_ice_sess_start_check(pj_ice_sess *ice); 597 638 598 639 … … 604 645 * component. 605 646 * 647 * This function will in turn call \a on_tx_pkt function in 648 * #pj_ice_sess_cb callback to actually send the packet to the wire. 649 * 606 650 * @param ice The ICE session. 607 651 * @param comp_id Component ID. … … 611 655 * @return PJ_SUCCESS if data is sent successfully. 612 656 */ 613 PJ_DECL(pj_status_t) pj_ice_se nd_data(pj_ice*ice,614 615 616 657 PJ_DECL(pj_status_t) pj_ice_sess_send_data(pj_ice_sess *ice, 658 unsigned comp_id, 659 const void *data, 660 pj_size_t data_len); 617 661 618 662 /** … … 621 665 * higher layer component to give incoming packets to the ICE session. 622 666 * If the packet is not a STUN packet, this packet will be given back 623 * to application via \a on_rx_data() callback in #pj_ice_ cb.667 * to application via \a on_rx_data() callback in #pj_ice_sess_cb. 624 668 * 625 669 * @param ice The ICE session. … … 633 677 * @return PJ_SUCCESS or the appropriate error code. 634 678 */ 635 PJ_DECL(pj_status_t) pj_ice_ on_rx_pkt(pj_ice*ice,636 637 638 639 640 641 679 PJ_DECL(pj_status_t) pj_ice_sess_on_rx_pkt(pj_ice_sess *ice, 680 unsigned comp_id, 681 unsigned cand_id, 682 void *pkt, 683 pj_size_t pkt_size, 684 const pj_sockaddr_t *src_addr, 685 int src_addr_len); 642 686 643 687
Note: See TracChangeset
for help on using the changeset viewer.