| 1 | /* |
| 2 | * Copyright (C) 2012-2013 Teluu Inc. (http://www.teluu.com) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | #ifndef __PJSUA2_CALL_HPP__ |
| 19 | #define __PJSUA2_CALL_HPP__ |
| 20 | |
| 21 | /** |
| 22 | * @file pjsua2/call.hpp |
| 23 | * @brief PJSUA2 Call manipulation |
| 24 | */ |
| 25 | #include <pjsua-lib/pjsua.h> |
| 26 | #include <pjsua2/account.hpp> |
| 27 | #include <pjsua2/media.hpp> |
| 28 | |
| 29 | /** PJSUA2 API is inside pj namespace */ |
| 30 | namespace pj |
| 31 | { |
| 32 | |
| 33 | /** |
| 34 | * @defgroup PJSUA2_CALL Call |
| 35 | * @ingroup PJSUA2_Ref |
| 36 | */ |
| 37 | |
| 38 | /** |
| 39 | * @defgroup PJSUA2_Call_Data_Structure Call Related Types |
| 40 | * @ingroup PJSUA2_DS |
| 41 | * @{ |
| 42 | */ |
| 43 | |
| 44 | using std::string; |
| 45 | using std::vector; |
| 46 | |
| 47 | ////////////////////////////////////////////////////////////////////////////// |
| 48 | |
| 49 | /** |
| 50 | * Media stream, corresponds to pjmedia_stream |
| 51 | */ |
| 52 | typedef void *MediaStream; |
| 53 | |
| 54 | /** |
| 55 | * Media transport, corresponds to pjmedia_transport |
| 56 | */ |
| 57 | typedef void *MediaTransport; |
| 58 | |
| 59 | /** |
| 60 | * This structure describes statistics state. |
| 61 | */ |
| 62 | struct MathStat |
| 63 | { |
| 64 | int n; /**< number of samples */ |
| 65 | int max; /**< maximum value */ |
| 66 | int min; /**< minimum value */ |
| 67 | int last; /**< last value */ |
| 68 | int mean; /**< mean */ |
| 69 | |
| 70 | public: |
| 71 | /** |
| 72 | * Default constructor |
| 73 | */ |
| 74 | MathStat(); |
| 75 | |
| 76 | /** |
| 77 | * Convert from pjsip |
| 78 | */ |
| 79 | void fromPj(const pj_math_stat &prm); |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * Types of loss detected. |
| 84 | */ |
| 85 | struct LossType |
| 86 | { |
| 87 | unsigned burst; /**< Burst/sequential packet lost detected */ |
| 88 | unsigned random; /**< Random packet lost detected. */ |
| 89 | }; |
| 90 | |
| 91 | /** |
| 92 | * Unidirectional RTP stream statistics. |
| 93 | */ |
| 94 | struct RtcpStreamStat |
| 95 | { |
| 96 | TimeVal update; /**< Time of last update. */ |
| 97 | unsigned updateCount;/**< Number of updates (to calculate avg) */ |
| 98 | unsigned pkt; /**< Total number of packets */ |
| 99 | unsigned bytes; /**< Total number of payload/bytes */ |
| 100 | unsigned discard; /**< Total number of discarded packets. */ |
| 101 | unsigned loss; /**< Total number of packets lost */ |
| 102 | unsigned reorder; /**< Total number of out of order packets */ |
| 103 | unsigned dup; /**< Total number of duplicates packets */ |
| 104 | |
| 105 | MathStat lossPeriodUsec; /**< Loss period statistics */ |
| 106 | |
| 107 | LossType lossType; /**< Types of loss detected. */ |
| 108 | |
| 109 | MathStat jitterUsec; /**< Jitter statistics */ |
| 110 | |
| 111 | public: |
| 112 | /** |
| 113 | * Convert from pjsip |
| 114 | */ |
| 115 | void fromPj(const pjmedia_rtcp_stream_stat &prm); |
| 116 | }; |
| 117 | |
| 118 | /** |
| 119 | * RTCP SDES structure. |
| 120 | */ |
| 121 | struct RtcpSdes |
| 122 | { |
| 123 | string cname; /**< RTCP SDES type CNAME. */ |
| 124 | string name; /**< RTCP SDES type NAME. */ |
| 125 | string email; /**< RTCP SDES type EMAIL. */ |
| 126 | string phone; /**< RTCP SDES type PHONE. */ |
| 127 | string loc; /**< RTCP SDES type LOC. */ |
| 128 | string tool; /**< RTCP SDES type TOOL. */ |
| 129 | string note; /**< RTCP SDES type NOTE. */ |
| 130 | |
| 131 | public: |
| 132 | /** |
| 133 | * Convert from pjsip |
| 134 | */ |
| 135 | void fromPj(const pjmedia_rtcp_sdes &prm); |
| 136 | }; |
| 137 | |
| 138 | /** |
| 139 | * Bidirectional RTP stream statistics. |
| 140 | */ |
| 141 | struct RtcpStat |
| 142 | { |
| 143 | TimeVal start; /**< Time when session was created */ |
| 144 | |
| 145 | RtcpStreamStat txStat; /**< Encoder stream statistics. */ |
| 146 | RtcpStreamStat rxStat; /**< Decoder stream statistics. */ |
| 147 | |
| 148 | MathStat rttUsec; /**< Round trip delay statistic. */ |
| 149 | |
| 150 | pj_uint32_t rtpTxLastTs; /**< Last TX RTP timestamp. */ |
| 151 | pj_uint16_t rtpTxLastSeq; /**< Last TX RTP sequence. */ |
| 152 | |
| 153 | MathStat rxIpdvUsec; /**< Statistics of IP packet delay |
| 154 | variation in receiving |
| 155 | direction. It is only used when |
| 156 | PJMEDIA_RTCP_STAT_HAS_IPDV is |
| 157 | set to non-zero. */ |
| 158 | |
| 159 | MathStat rxRawJitterUsec;/**< Statistic of raw jitter in |
| 160 | receiving direction. It is only |
| 161 | used when |
| 162 | PJMEDIA_RTCP_STAT_HAS_RAW_JITTER |
| 163 | is set to non-zero. */ |
| 164 | |
| 165 | RtcpSdes peerSdes; /**< Peer SDES. */ |
| 166 | |
| 167 | public: |
| 168 | /** |
| 169 | * Convert from pjsip |
| 170 | */ |
| 171 | void fromPj(const pjmedia_rtcp_stat &prm); |
| 172 | }; |
| 173 | |
| 174 | /** |
| 175 | * This structure describes jitter buffer state. |
| 176 | */ |
| 177 | struct JbufState |
| 178 | { |
| 179 | /* Setting */ |
| 180 | unsigned frameSize; /**< Individual frame size, in bytes. */ |
| 181 | unsigned minPrefetch; /**< Minimum allowed prefetch, in frms. */ |
| 182 | unsigned maxPrefetch; /**< Maximum allowed prefetch, in frms. */ |
| 183 | |
| 184 | /* Status */ |
| 185 | unsigned burst; /**< Current burst level, in frames */ |
| 186 | unsigned prefetch; /**< Current prefetch value, in frames */ |
| 187 | unsigned size; /**< Current buffer size, in frames. */ |
| 188 | |
| 189 | /* Statistic */ |
| 190 | unsigned avgDelayMsec; /**< Average delay, in ms. */ |
| 191 | unsigned minDelayMsec; /**< Minimum delay, in ms. */ |
| 192 | unsigned maxDelayMsec; /**< Maximum delay, in ms. */ |
| 193 | unsigned devDelayMsec; /**< Standard deviation of delay, in ms.*/ |
| 194 | unsigned avgBurst; /**< Average burst, in frames. */ |
| 195 | unsigned lost; /**< Number of lost frames. */ |
| 196 | unsigned discard; /**< Number of discarded frames. */ |
| 197 | unsigned empty; /**< Number of empty on GET events. */ |
| 198 | |
| 199 | public: |
| 200 | /** |
| 201 | * Convert from pjsip |
| 202 | */ |
| 203 | void fromPj(const pjmedia_jb_state &prm); |
| 204 | }; |
| 205 | |
| 206 | /** |
| 207 | * This structure describes SDP session description. It corresponds to the |
| 208 | * pjmedia_sdp_session structure. |
| 209 | */ |
| 210 | struct SdpSession |
| 211 | { |
| 212 | /** |
| 213 | * The whole SDP as a string. |
| 214 | */ |
| 215 | string wholeSdp; |
| 216 | |
| 217 | /** |
| 218 | * Pointer to its original pjmedia_sdp_session. Only valid when the struct |
| 219 | * is converted from PJSIP's pjmedia_sdp_session. |
| 220 | */ |
| 221 | void *pjSdpSession; |
| 222 | |
| 223 | public: |
| 224 | /** |
| 225 | * Convert from pjsip |
| 226 | */ |
| 227 | void fromPj(const pjmedia_sdp_session &sdp); |
| 228 | }; |
| 229 | |
| 230 | |
| 231 | /** |
| 232 | * This structure describes media transport informations. It corresponds to the |
| 233 | * pjmedia_transport_info structure. The address name field can be empty string |
| 234 | * if the address in the pjmedia_transport_info is invalid. |
| 235 | */ |
| 236 | struct MediaTransportInfo |
| 237 | { |
| 238 | /** |
| 239 | * Address to be advertised as the local address for the RTP socket, |
| 240 | * which does not need to be equal as the bound address (for example, |
| 241 | * this address can be the address resolved with STUN). |
| 242 | */ |
| 243 | SocketAddress localRtpName; |
| 244 | |
| 245 | /** |
| 246 | * Address to be advertised as the local address for the RTCP socket, |
| 247 | * which does not need to be equal as the bound address (for example, |
| 248 | * this address can be the address resolved with STUN). |
| 249 | */ |
| 250 | SocketAddress localRtcpName; |
| 251 | |
| 252 | /** |
| 253 | * Remote address where RTP originated from. This can be empty string if |
| 254 | * no data is received from the remote. |
| 255 | */ |
| 256 | SocketAddress srcRtpName; |
| 257 | |
| 258 | /** |
| 259 | * Remote address where RTCP originated from. This can be empty string if |
| 260 | * no data is recevied from the remote. |
| 261 | */ |
| 262 | SocketAddress srcRtcpName; |
| 263 | |
| 264 | public: |
| 265 | /** |
| 266 | * Convert from pjsip |
| 267 | */ |
| 268 | void fromPj(const pjmedia_transport_info &info); |
| 269 | }; |
| 270 | |
| 271 | ////////////////////////////////////////////////////////////////////////////// |
| 272 | |
| 273 | /** Array of media direction */ |
| 274 | typedef IntVector MediaDirVector; |
| 275 | |
| 276 | |
| 277 | /** |
| 278 | * Call settings. |
| 279 | */ |
| 280 | struct CallSetting |
| 281 | { |
| 282 | /** |
| 283 | * Bitmask of pjsua_call_flag constants. |
| 284 | * |
| 285 | * Default: 0 |
| 286 | * (PJSUA_CALL_INCLUDE_DISABLED_MEDIA is the legacy default value). |
| 287 | */ |
| 288 | unsigned flag; |
| 289 | |
| 290 | /** |
| 291 | * This flag controls what methods to request keyframe are allowed on |
| 292 | * the call. Value is bitmask of pjsua_vid_req_keyframe_method. |
| 293 | * |
| 294 | * Default: PJSUA_VID_REQ_KEYFRAME_SIP_INFO | |
| 295 | * PJSUA_VID_REQ_KEYFRAME_RTCP_PLI |
| 296 | */ |
| 297 | unsigned reqKeyframeMethod; |
| 298 | |
| 299 | /** |
| 300 | * Number of simultaneous active audio streams for this call. Setting |
| 301 | * this to zero will disable audio in this call. |
| 302 | * |
| 303 | * Default: 1 |
| 304 | */ |
| 305 | unsigned audioCount; |
| 306 | |
| 307 | /** |
| 308 | * Number of simultaneous active video streams for this call. Setting |
| 309 | * this to zero will disable video in this call. |
| 310 | * |
| 311 | * Default: 1 (if video feature is enabled, otherwise it is zero) |
| 312 | */ |
| 313 | unsigned videoCount; |
| 314 | |
| 315 | /** |
| 316 | * Number of simultaneous active text streams for this call. Setting |
| 317 | * this to zero will disable text in this call. |
| 318 | * |
| 319 | * Default: 1 |
| 320 | */ |
| 321 | unsigned textCount; |
| 322 | |
| 323 | /** |
| 324 | * Media direction. This setting will only be used if the flag |
| 325 | * PJSUA_CALL_SET_MEDIA_DIR is set, and it will persist for subsequent |
| 326 | * offers or answers. |
| 327 | * For example, a media that is set as PJMEDIA_DIR_ENCODING can only |
| 328 | * mark the stream in the SDP as sendonly or inactive, but will not |
| 329 | * become sendrecv in subsequent offers and answers. |
| 330 | * Application can update the media direction in any API or callback |
| 331 | * that accepts CallSetting as a parameter, such as via |
| 332 | * Call::reinvite/update() or in onCallRxOffer/Reinvite() |
| 333 | * callback. |
| 334 | * |
| 335 | * The index of the media dir will correspond to the provisional media |
| 336 | * in CallInfo.provMedia. |
| 337 | * For offers that involve adding new medias (such as initial offer), |
| 338 | * the index will correspond to all new audio media first, then video. |
| 339 | * For example, for a new call with 2 audios and 1 video, mediaDir[0] |
| 340 | * and mediaDir[1] will be for the audios, and mediaDir[2] video. |
| 341 | * |
| 342 | * Default: empty vector |
| 343 | */ |
| 344 | MediaDirVector mediaDir; |
| 345 | |
| 346 | /** |
| 347 | * User defined Call-ID to be sent out with outgoing INVITE. |
| 348 | * |
| 349 | * Note: It is up to the developer to verify uniqueness of the |
| 350 | * Call-ID as there will be no verification. The developer must |
| 351 | * change the Call-ID between calls creating a unique id for each |
| 352 | * outgoing call. |
| 353 | * |
| 354 | * This setting will only be used when creating a new outgoing call |
| 355 | * via Call::makeCall(). |
| 356 | */ |
| 357 | string customCallId; |
| 358 | |
| 359 | |
| 360 | public: |
| 361 | /** |
| 362 | * Default constructor initializes with empty or default values. |
| 363 | */ |
| 364 | CallSetting(bool useDefaultValues = false); |
| 365 | |
| 366 | /** |
| 367 | * Check if the settings are set with empty values. |
| 368 | * |
| 369 | * @return True if the settings are empty. |
| 370 | */ |
| 371 | bool isEmpty() const; |
| 372 | |
| 373 | /** |
| 374 | * Convert from pjsip |
| 375 | */ |
| 376 | void fromPj(const pjsua_call_setting &prm); |
| 377 | |
| 378 | /** |
| 379 | * Convert to pjsip |
| 380 | */ |
| 381 | pjsua_call_setting toPj() const; |
| 382 | }; |
| 383 | |
| 384 | /** |
| 385 | * Call media information. |
| 386 | * |
| 387 | * Application can query conference bridge port of this media using |
| 388 | * Call::getAudioMedia() if the media type is audio, |
| 389 | * or Call::getEncodingVideoMedia() / Call::getDecodingVideoMedia() |
| 390 | * if the media type is video. |
| 391 | */ |
| 392 | struct CallMediaInfo |
| 393 | { |
| 394 | /** |
| 395 | * Media index in SDP. |
| 396 | */ |
| 397 | unsigned index; |
| 398 | |
| 399 | /** |
| 400 | * Media type. |
| 401 | */ |
| 402 | pjmedia_type type; |
| 403 | |
| 404 | /** |
| 405 | * Media direction. |
| 406 | */ |
| 407 | pjmedia_dir dir; |
| 408 | |
| 409 | /** |
| 410 | * Call media status. |
| 411 | */ |
| 412 | pjsua_call_media_status status; |
| 413 | |
| 414 | /** |
| 415 | * Warning: this is deprecated, application can query conference bridge |
| 416 | * port of this media using Call::getAudioMedia(). |
| 417 | * |
| 418 | * The conference port number for the call. Only valid if the media type |
| 419 | * is audio. |
| 420 | */ |
| 421 | int audioConfSlot; |
| 422 | |
| 423 | /** |
| 424 | * The window id for incoming video, if any, or |
| 425 | * PJSUA_INVALID_ID. Only valid if the media type is video. |
| 426 | */ |
| 427 | pjsua_vid_win_id videoIncomingWindowId; |
| 428 | |
| 429 | /** |
| 430 | * The video window instance for incoming video. Only valid if |
| 431 | * videoIncomingWindowId is not PJSUA_INVALID_ID and |
| 432 | * the media type is video. |
| 433 | */ |
| 434 | VideoWindow videoWindow; |
| 435 | |
| 436 | /** |
| 437 | * The video capture device for outgoing transmission, if any, |
| 438 | * or PJMEDIA_VID_INVALID_DEV. Only valid if the media type is video. |
| 439 | */ |
| 440 | pjmedia_vid_dev_index videoCapDev; |
| 441 | |
| 442 | public: |
| 443 | /** |
| 444 | * Default constructor |
| 445 | */ |
| 446 | CallMediaInfo(); |
| 447 | |
| 448 | /** |
| 449 | * Convert from pjsip |
| 450 | */ |
| 451 | void fromPj(const pjsua_call_media_info &prm); |
| 452 | }; |
| 453 | |
| 454 | /** Array of call media info */ |
| 455 | typedef std::vector<CallMediaInfo> CallMediaInfoVector; |
| 456 | |
| 457 | /** |
| 458 | * Call information. Application can query the call information |
| 459 | * by calling Call::getInfo(). |
| 460 | */ |
| 461 | struct CallInfo |
| 462 | { |
| 463 | /** |
| 464 | * Call identification. |
| 465 | */ |
| 466 | pjsua_call_id id; |
| 467 | |
| 468 | /** |
| 469 | * Initial call role (UAC == caller) |
| 470 | */ |
| 471 | pjsip_role_e role; |
| 472 | |
| 473 | /** |
| 474 | * The account ID where this call belongs. |
| 475 | */ |
| 476 | pjsua_acc_id accId; |
| 477 | |
| 478 | /** |
| 479 | * Local URI |
| 480 | */ |
| 481 | string localUri; |
| 482 | |
| 483 | /** |
| 484 | * Local Contact |
| 485 | */ |
| 486 | string localContact; |
| 487 | |
| 488 | /** |
| 489 | * Remote URI |
| 490 | */ |
| 491 | string remoteUri; |
| 492 | |
| 493 | /** |
| 494 | * Remote contact |
| 495 | */ |
| 496 | string remoteContact; |
| 497 | |
| 498 | /** |
| 499 | * Dialog Call-ID string. |
| 500 | */ |
| 501 | string callIdString; |
| 502 | |
| 503 | /** |
| 504 | * Call setting |
| 505 | */ |
| 506 | CallSetting setting; |
| 507 | |
| 508 | /** |
| 509 | * Call state |
| 510 | */ |
| 511 | pjsip_inv_state state; |
| 512 | |
| 513 | /** |
| 514 | * Text describing the state |
| 515 | */ |
| 516 | string stateText; |
| 517 | |
| 518 | /** |
| 519 | * Last status code heard, which can be used as cause code |
| 520 | */ |
| 521 | pjsip_status_code lastStatusCode; |
| 522 | |
| 523 | /** |
| 524 | * The reason phrase describing the last status. |
| 525 | */ |
| 526 | string lastReason; |
| 527 | |
| 528 | /** |
| 529 | * Array of active media information. |
| 530 | */ |
| 531 | CallMediaInfoVector media; |
| 532 | |
| 533 | /** |
| 534 | * Array of provisional media information. This contains the media info |
| 535 | * in the provisioning state, that is when the media session is being |
| 536 | * created/updated (SDP offer/answer is on progress). |
| 537 | */ |
| 538 | CallMediaInfoVector provMedia; |
| 539 | |
| 540 | /** |
| 541 | * Up-to-date call connected duration (zero when call is not |
| 542 | * established) |
| 543 | */ |
| 544 | TimeVal connectDuration; |
| 545 | |
| 546 | /** |
| 547 | * Total call duration, including set-up time |
| 548 | */ |
| 549 | TimeVal totalDuration; |
| 550 | |
| 551 | /** |
| 552 | * Flag if remote was SDP offerer |
| 553 | */ |
| 554 | bool remOfferer; |
| 555 | |
| 556 | /** |
| 557 | * Number of audio streams offered by remote |
| 558 | */ |
| 559 | unsigned remAudioCount; |
| 560 | |
| 561 | /** |
| 562 | * Number of video streams offered by remote |
| 563 | */ |
| 564 | unsigned remVideoCount; |
| 565 | |
| 566 | /** |
| 567 | * Number of text streams offered by remote |
| 568 | */ |
| 569 | unsigned remTextCount; |
| 570 | |
| 571 | public: |
| 572 | /** |
| 573 | * Default constructor |
| 574 | */ |
| 575 | CallInfo() : id(PJSUA_INVALID_ID), |
| 576 | role(PJSIP_ROLE_UAC), |
| 577 | accId(PJSUA_INVALID_ID), |
| 578 | state(PJSIP_INV_STATE_NULL), |
| 579 | lastStatusCode(PJSIP_SC_NULL), |
| 580 | remOfferer(false), |
| 581 | remAudioCount(0), |
| 582 | remVideoCount(0), |
| 583 | remTextCount(0) |
| 584 | {} |
| 585 | |
| 586 | /** |
| 587 | * Convert from pjsip |
| 588 | */ |
| 589 | void fromPj(const pjsua_call_info &pci); |
| 590 | }; |
| 591 | |
| 592 | /** |
| 593 | * Media stream info. |
| 594 | */ |
| 595 | struct StreamInfo |
| 596 | { |
| 597 | /** |
| 598 | * Media type of this stream. |
| 599 | */ |
| 600 | pjmedia_type type; |
| 601 | |
| 602 | /** |
| 603 | * Transport protocol (RTP/AVP, etc.) |
| 604 | */ |
| 605 | pjmedia_tp_proto proto; |
| 606 | |
| 607 | /** |
| 608 | * Media direction. |
| 609 | */ |
| 610 | pjmedia_dir dir; |
| 611 | |
| 612 | /** |
| 613 | * Remote RTP address |
| 614 | */ |
| 615 | SocketAddress remoteRtpAddress; |
| 616 | |
| 617 | /** |
| 618 | * Optional remote RTCP address |
| 619 | */ |
| 620 | SocketAddress remoteRtcpAddress; |
| 621 | |
| 622 | /** |
| 623 | * Outgoing codec payload type. |
| 624 | */ |
| 625 | unsigned txPt; |
| 626 | |
| 627 | /** |
| 628 | * Incoming codec payload type. |
| 629 | */ |
| 630 | unsigned rxPt; |
| 631 | |
| 632 | /** |
| 633 | * Outgoing pt for audio telephone-events. |
| 634 | */ |
| 635 | int audTxEventPt; |
| 636 | |
| 637 | /** |
| 638 | * Incoming pt for audio telephone-events. |
| 639 | */ |
| 640 | int audRxEventPt; |
| 641 | |
| 642 | /** |
| 643 | * Codec name. |
| 644 | */ |
| 645 | string codecName; |
| 646 | |
| 647 | /** |
| 648 | * Codec clock rate. |
| 649 | */ |
| 650 | unsigned codecClockRate; |
| 651 | |
| 652 | /** |
| 653 | * Optional audio codec param. |
| 654 | */ |
| 655 | CodecParam audCodecParam; |
| 656 | |
| 657 | /** |
| 658 | * Optional video codec param. |
| 659 | */ |
| 660 | VidCodecParam vidCodecParam; |
| 661 | |
| 662 | /** |
| 663 | * Jitter buffer init delay in msec. |
| 664 | */ |
| 665 | int jbInit; |
| 666 | |
| 667 | /** |
| 668 | * Jitter buffer minimum prefetch delay in msec. |
| 669 | */ |
| 670 | int jbMinPre; |
| 671 | |
| 672 | /** |
| 673 | * Jitter buffer maximum prefetch delay in msec. |
| 674 | */ |
| 675 | int jbMaxPre; |
| 676 | |
| 677 | /** |
| 678 | * Jitter buffer max delay in msec. |
| 679 | */ |
| 680 | int jbMax; |
| 681 | |
| 682 | /** |
| 683 | * Jitter buffer discard algorithm. |
| 684 | */ |
| 685 | pjmedia_jb_discard_algo jbDiscardAlgo; |
| 686 | |
| 687 | #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0 |
| 688 | /** |
| 689 | * Stream keep-alive and NAT hole punch (see #PJMEDIA_STREAM_ENABLE_KA) is |
| 690 | * enabled? |
| 691 | */ |
| 692 | bool useKa; |
| 693 | |
| 694 | /** |
| 695 | * Number of keepalive messages to be sent |
| 696 | */ |
| 697 | unsigned startCountKa; |
| 698 | |
| 699 | /** |
| 700 | * Keepalive interval after the stream is created. |
| 701 | */ |
| 702 | unsigned startIntervalKa; |
| 703 | |
| 704 | /** |
| 705 | * Keepalive sending interval. |
| 706 | */ |
| 707 | unsigned intervalKa; |
| 708 | #endif |
| 709 | |
| 710 | /** |
| 711 | * Disable automatic sending of RTCP SDES and BYE. |
| 712 | */ |
| 713 | bool rtcpSdesByeDisabled; |
| 714 | |
| 715 | public: |
| 716 | /** |
| 717 | * Default constructor |
| 718 | */ |
| 719 | StreamInfo() |
| 720 | : type(PJMEDIA_TYPE_NONE), |
| 721 | proto(PJMEDIA_TP_PROTO_NONE), |
| 722 | dir(PJMEDIA_DIR_NONE), |
| 723 | txPt(0), |
| 724 | rxPt(0), |
| 725 | audTxEventPt(0), |
| 726 | audRxEventPt(0), |
| 727 | codecClockRate(0), |
| 728 | jbInit(-1), |
| 729 | jbMinPre(-1), |
| 730 | jbMaxPre(-1), |
| 731 | jbMax(-1), |
| 732 | jbDiscardAlgo(PJMEDIA_JB_DISCARD_NONE), |
| 733 | #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0 |
| 734 | useKa(false), |
| 735 | #endif |
| 736 | rtcpSdesByeDisabled(false) |
| 737 | {} |
| 738 | |
| 739 | /** |
| 740 | * Convert from pjsip |
| 741 | */ |
| 742 | void fromPj(const pjsua_stream_info &info); |
| 743 | }; |
| 744 | |
| 745 | /** |
| 746 | * Media stream statistic. |
| 747 | */ |
| 748 | struct StreamStat |
| 749 | { |
| 750 | /** |
| 751 | * RTCP statistic. |
| 752 | */ |
| 753 | RtcpStat rtcp; |
| 754 | |
| 755 | /** |
| 756 | * Jitter buffer statistic. |
| 757 | */ |
| 758 | JbufState jbuf; |
| 759 | |
| 760 | public: |
| 761 | /** |
| 762 | * Convert from pjsip |
| 763 | */ |
| 764 | void fromPj(const pjsua_stream_stat &prm); |
| 765 | }; |
| 766 | |
| 767 | /** |
| 768 | * This structure contains parameters for Call::onCallState() callback. |
| 769 | */ |
| 770 | struct OnCallStateParam |
| 771 | { |
| 772 | /** |
| 773 | * Event which causes the call state to change. |
| 774 | */ |
| 775 | SipEvent e; |
| 776 | }; |
| 777 | |
| 778 | /** |
| 779 | * This structure contains parameters for Call::onCallTsxState() callback. |
| 780 | */ |
| 781 | struct OnCallTsxStateParam |
| 782 | { |
| 783 | /** |
| 784 | * Transaction event that caused the state change. |
| 785 | */ |
| 786 | SipEvent e; |
| 787 | }; |
| 788 | |
| 789 | /** |
| 790 | * This structure contains parameters for Call::onCallMediaState() callback. |
| 791 | */ |
| 792 | struct OnCallMediaStateParam |
| 793 | { |
| 794 | }; |
| 795 | |
| 796 | /** |
| 797 | * This structure contains parameters for Call::onCallSdpCreated() callback. |
| 798 | */ |
| 799 | struct OnCallSdpCreatedParam |
| 800 | { |
| 801 | /** |
| 802 | * The SDP has just been created. |
| 803 | */ |
| 804 | SdpSession sdp; |
| 805 | |
| 806 | /** |
| 807 | * The remote SDP, will be empty if local is SDP offerer. |
| 808 | */ |
| 809 | SdpSession remSdp; |
| 810 | }; |
| 811 | |
| 812 | /** |
| 813 | * This structure contains parameters for Call::onStreamPreCreate() |
| 814 | * callback. |
| 815 | */ |
| 816 | struct OnStreamPreCreateParam |
| 817 | { |
| 818 | /** |
| 819 | * Stream index in the media session, read-only. |
| 820 | */ |
| 821 | unsigned streamIdx; |
| 822 | |
| 823 | /** |
| 824 | * Parameters that the stream will be created from. |
| 825 | */ |
| 826 | StreamInfo streamInfo; |
| 827 | }; |
| 828 | |
| 829 | /** |
| 830 | * This structure contains parameters for Call::onStreamCreated() |
| 831 | * callback. |
| 832 | */ |
| 833 | struct OnStreamCreatedParam |
| 834 | { |
| 835 | /** |
| 836 | * Audio media stream, read-only. |
| 837 | */ |
| 838 | MediaStream stream; |
| 839 | |
| 840 | /** |
| 841 | * Stream index in the audio media session, read-only. |
| 842 | */ |
| 843 | unsigned streamIdx; |
| 844 | |
| 845 | /** |
| 846 | * Specify if PJSUA2 should take ownership of the port returned in |
| 847 | * the pPort parameter below. If set to true, |
| 848 | * pjmedia_port_destroy() will be called on the port when it is |
| 849 | * no longer needed. |
| 850 | * |
| 851 | * Default: false |
| 852 | */ |
| 853 | bool destroyPort; |
| 854 | |
| 855 | /** |
| 856 | * On input, it specifies the audio media port of the stream. Application |
| 857 | * may modify this pointer to point to different media port to be |
| 858 | * registered to the conference bridge. |
| 859 | */ |
| 860 | MediaPort pPort; |
| 861 | }; |
| 862 | |
| 863 | /** |
| 864 | * This structure contains parameters for Call::onStreamDestroyed() |
| 865 | * callback. |
| 866 | */ |
| 867 | struct OnStreamDestroyedParam |
| 868 | { |
| 869 | /** |
| 870 | * Audio media stream. |
| 871 | */ |
| 872 | MediaStream stream; |
| 873 | |
| 874 | /** |
| 875 | * Stream index in the audio media session. |
| 876 | */ |
| 877 | unsigned streamIdx; |
| 878 | }; |
| 879 | |
| 880 | /** |
| 881 | * This structure contains parameters for Call::onDtmfDigit() |
| 882 | * callback. |
| 883 | */ |
| 884 | struct OnDtmfDigitParam |
| 885 | { |
| 886 | /** |
| 887 | * DTMF sending method. |
| 888 | */ |
| 889 | pjsua_dtmf_method method; |
| 890 | |
| 891 | /** |
| 892 | * DTMF ASCII digit. |
| 893 | */ |
| 894 | string digit; |
| 895 | |
| 896 | /** |
| 897 | * DTMF signal duration. If the duration is unknown, this value is set to |
| 898 | * PJSUA_UNKNOWN_DTMF_DURATION. |
| 899 | */ |
| 900 | unsigned duration; |
| 901 | }; |
| 902 | |
| 903 | /** |
| 904 | * This structure contains parameters for Call::onDtmfEvent() |
| 905 | * callback. |
| 906 | */ |
| 907 | struct OnDtmfEventParam |
| 908 | { |
| 909 | /** |
| 910 | * DTMF sending method. |
| 911 | */ |
| 912 | pjsua_dtmf_method method; |
| 913 | |
| 914 | /** |
| 915 | * The timestamp identifying the begin of the event. Timestamp units are |
| 916 | * expressed in milliseconds. |
| 917 | * Note that this value should only be used to compare multiple events |
| 918 | * received via the same method relatively to each other, as the time-base |
| 919 | * is randomized. |
| 920 | */ |
| 921 | unsigned timestamp; |
| 922 | |
| 923 | /** |
| 924 | * DTMF ASCII digit. |
| 925 | */ |
| 926 | string digit; |
| 927 | |
| 928 | /** |
| 929 | * DTMF signal duration in milliseconds. Interpretation of the duration |
| 930 | * depends on the flag PJMEDIA_STREAM_DTMF_IS_END. |
| 931 | * depends on the method. |
| 932 | * If the method is PJSUA_DTMF_METHOD_SIP_INFO, this contains the total |
| 933 | * duration of the DTMF signal or PJSUA_UNKNOWN_DTMF_DURATION if no signal |
| 934 | * duration was indicated. |
| 935 | * If the method is PJSUA_DTMF_METHOD_RFC2833, this contains the total |
| 936 | * duration of the DTMF signal received up to this point in time. |
| 937 | */ |
| 938 | unsigned duration; |
| 939 | |
| 940 | /** |
| 941 | * Flags indicating additional information about the DTMF event. |
| 942 | * If PJMEDIA_STREAM_DTMF_IS_UPDATE is set, the event was already |
| 943 | * indicated earlier. The new indication contains an updated event |
| 944 | * duration. |
| 945 | * If PJMEDIA_STREAM_DTMF_IS_END is set, the event has ended and this |
| 946 | * indication contains the final event duration. Note that end |
| 947 | * indications might get lost. Hence it is not guaranteed to receive |
| 948 | * an event with PJMEDIA_STREAM_DTMF_IS_END for every event. |
| 949 | */ |
| 950 | unsigned flags; |
| 951 | }; |
| 952 | |
| 953 | /** |
| 954 | * This structure contains parameters for Call::onCallRxText() |
| 955 | * callback. |
| 956 | */ |
| 957 | struct OnCallRxTextParam |
| 958 | { |
| 959 | /** |
| 960 | * The sequence of the incoming text block data. |
| 961 | */ |
| 962 | int seq; |
| 963 | |
| 964 | /** |
| 965 | * The timestamp of the text block data. |
| 966 | */ |
| 967 | unsigned ts; |
| 968 | |
| 969 | /** |
| 970 | * The content of the text block. |
| 971 | * Note that the text can be empty. |
| 972 | */ |
| 973 | string text; |
| 974 | |
| 975 | public: |
| 976 | /** |
| 977 | * Convert from pjsip |
| 978 | */ |
| 979 | void fromPj(const pjsua_txt_stream_data &prm); |
| 980 | }; |
| 981 | |
| 982 | /** |
| 983 | * This structure contains parameters for Call::onCallTransferRequest() |
| 984 | * callback. |
| 985 | */ |
| 986 | struct OnCallTransferRequestParam |
| 987 | { |
| 988 | /** |
| 989 | * The destination where the call will be transferred to. |
| 990 | */ |
| 991 | string dstUri; |
| 992 | |
| 993 | /** |
| 994 | * Status code to be returned for the call transfer request. On input, |
| 995 | * it contains status code 202. |
| 996 | */ |
| 997 | pjsip_status_code statusCode; |
| 998 | |
| 999 | /** |
| 1000 | * The current call setting, application can update this setting |
| 1001 | * for the call being transferred. |
| 1002 | */ |
| 1003 | CallSetting opt; |
| 1004 | |
| 1005 | /** |
| 1006 | * New Call derived object instantiated by application when the call |
| 1007 | * transfer is about to be accepted. |
| 1008 | */ |
| 1009 | Call *newCall; |
| 1010 | }; |
| 1011 | |
| 1012 | /** |
| 1013 | * This structure contains parameters for Call::onCallTransferStatus() |
| 1014 | * callback. |
| 1015 | */ |
| 1016 | struct OnCallTransferStatusParam |
| 1017 | { |
| 1018 | /** |
| 1019 | * Status progress of the transfer request. |
| 1020 | */ |
| 1021 | pjsip_status_code statusCode; |
| 1022 | |
| 1023 | /** |
| 1024 | * Status progress reason. |
| 1025 | */ |
| 1026 | string reason; |
| 1027 | |
| 1028 | /** |
| 1029 | * If true, no further notification will be reported. The statusCode |
| 1030 | * specified in this callback is the final status. |
| 1031 | */ |
| 1032 | bool finalNotify; |
| 1033 | |
| 1034 | /** |
| 1035 | * Initially will be set to true, application can set this to false |
| 1036 | * if it no longer wants to receive further notification (for example, |
| 1037 | * after it hangs up the call). |
| 1038 | */ |
| 1039 | bool cont; |
| 1040 | }; |
| 1041 | |
| 1042 | /** |
| 1043 | * This structure contains parameters for Call::onCallReplaceRequest() |
| 1044 | * callback. |
| 1045 | */ |
| 1046 | struct OnCallReplaceRequestParam |
| 1047 | { |
| 1048 | /** |
| 1049 | * The incoming INVITE request to replace the call. |
| 1050 | */ |
| 1051 | SipRxData rdata; |
| 1052 | |
| 1053 | /** |
| 1054 | * Status code to be set by application. Application should only |
| 1055 | * return a final status (>= PJSIP_SC_OK (200)) |
| 1056 | */ |
| 1057 | pjsip_status_code statusCode; |
| 1058 | |
| 1059 | /** |
| 1060 | * Optional status text to be set by application. |
| 1061 | */ |
| 1062 | string reason; |
| 1063 | |
| 1064 | /** |
| 1065 | * The current call setting, application can update this setting for |
| 1066 | * the call being replaced. |
| 1067 | */ |
| 1068 | CallSetting opt; |
| 1069 | |
| 1070 | /** |
| 1071 | * New Call derived object instantiated by application. |
| 1072 | */ |
| 1073 | Call *newCall; |
| 1074 | }; |
| 1075 | |
| 1076 | /** |
| 1077 | * This structure contains parameters for Call::onCallReplaced() callback. |
| 1078 | */ |
| 1079 | struct OnCallReplacedParam |
| 1080 | { |
| 1081 | /** |
| 1082 | * The new call id. |
| 1083 | */ |
| 1084 | pjsua_call_id newCallId; |
| 1085 | |
| 1086 | /** |
| 1087 | * New Call derived object instantiated by application. |
| 1088 | */ |
| 1089 | Call *newCall; |
| 1090 | }; |
| 1091 | |
| 1092 | /** |
| 1093 | * This structure contains parameters for Call::onCallRxOffer() callback. |
| 1094 | */ |
| 1095 | struct OnCallRxOfferParam |
| 1096 | { |
| 1097 | /** |
| 1098 | * The new offer received. |
| 1099 | */ |
| 1100 | SdpSession offer; |
| 1101 | |
| 1102 | /** |
| 1103 | * Status code to be returned for answering the offer. On input, |
| 1104 | * it contains status code PJSIP_SC_OK (200). Currently, valid values are only |
| 1105 | * PJSIP_SC_OK (200) and PJSIP_SC_NOT_ACCEPTABLE_HERE (488). |
| 1106 | */ |
| 1107 | pjsip_status_code statusCode; |
| 1108 | |
| 1109 | /** |
| 1110 | * The current call setting, application can update this setting for |
| 1111 | * answering the offer. |
| 1112 | */ |
| 1113 | CallSetting opt; |
| 1114 | }; |
| 1115 | |
| 1116 | /** |
| 1117 | * This structure contains parameters for Call::onCallRxReinvite() callback. |
| 1118 | */ |
| 1119 | struct OnCallRxReinviteParam |
| 1120 | { |
| 1121 | /** |
| 1122 | * The new offer received. |
| 1123 | */ |
| 1124 | SdpSession offer; |
| 1125 | |
| 1126 | /** |
| 1127 | * The incoming re-INVITE. |
| 1128 | */ |
| 1129 | SipRxData rdata; |
| 1130 | |
| 1131 | /** |
| 1132 | * On input, it is false. Set to true if app wants to manually answer |
| 1133 | * the re-INVITE. |
| 1134 | */ |
| 1135 | bool isAsync; |
| 1136 | |
| 1137 | /** |
| 1138 | * Status code to be returned for answering the offer. On input, |
| 1139 | * it contains status code PJSIP_SC_OK (200). Currently, valid values are only |
| 1140 | * PJSIP_SC_OK (200) and PJSIP_SC_NOT_ACCEPTABLE_HERE (488). |
| 1141 | */ |
| 1142 | pjsip_status_code statusCode; |
| 1143 | |
| 1144 | /** |
| 1145 | * The current call setting, application can update this setting for |
| 1146 | * answering the offer. |
| 1147 | */ |
| 1148 | CallSetting opt; |
| 1149 | }; |
| 1150 | |
| 1151 | /** |
| 1152 | * This structure contains parameters for Call::onCallTxOffer() callback. |
| 1153 | */ |
| 1154 | struct OnCallTxOfferParam |
| 1155 | { |
| 1156 | /** |
| 1157 | * The current call setting, application can update this setting for |
| 1158 | * generating the offer. Note that application should maintain any |
| 1159 | * active media to avoid the need for the peer to reject the offer. |
| 1160 | */ |
| 1161 | CallSetting opt; |
| 1162 | }; |
| 1163 | |
| 1164 | /** |
| 1165 | * This structure contains parameters for Call::onCallRedirected() callback. |
| 1166 | */ |
| 1167 | struct OnCallRedirectedParam |
| 1168 | { |
| 1169 | /** |
| 1170 | * The current target to be tried. |
| 1171 | */ |
| 1172 | string targetUri; |
| 1173 | |
| 1174 | /** |
| 1175 | * The event that caused this callback to be called. |
| 1176 | * This could be the receipt of 3xx response, or 4xx/5xx response |
| 1177 | * received for the INVITE sent to subsequent targets, or empty |
| 1178 | * (e.type == PJSIP_EVENT_UNKNOWN) if this callback is called from |
| 1179 | * within Call::processRedirect() context. |
| 1180 | */ |
| 1181 | SipEvent e; |
| 1182 | }; |
| 1183 | |
| 1184 | /** |
| 1185 | * This structure contains parameters for Call::onCallMediaEvent() callback. |
| 1186 | */ |
| 1187 | struct OnCallMediaEventParam |
| 1188 | { |
| 1189 | /** |
| 1190 | * The media stream index. |
| 1191 | */ |
| 1192 | unsigned medIdx; |
| 1193 | |
| 1194 | /** |
| 1195 | * The media event. |
| 1196 | */ |
| 1197 | MediaEvent ev; |
| 1198 | }; |
| 1199 | |
| 1200 | /** |
| 1201 | * This structure contains parameters for Call::onCallMediaTransportState() |
| 1202 | * callback. |
| 1203 | */ |
| 1204 | struct OnCallMediaTransportStateParam |
| 1205 | { |
| 1206 | /** |
| 1207 | * The media index. |
| 1208 | */ |
| 1209 | unsigned medIdx; |
| 1210 | |
| 1211 | /** |
| 1212 | * The media transport state |
| 1213 | */ |
| 1214 | pjsua_med_tp_st state; |
| 1215 | |
| 1216 | /** |
| 1217 | * The last error code related to the media transport state. |
| 1218 | */ |
| 1219 | pj_status_t status; |
| 1220 | |
| 1221 | /** |
| 1222 | * Optional SIP error code. |
| 1223 | */ |
| 1224 | int sipErrorCode; |
| 1225 | }; |
| 1226 | |
| 1227 | /** |
| 1228 | * This structure contains parameters for Call::onCreateMediaTransport() |
| 1229 | * callback. |
| 1230 | */ |
| 1231 | struct OnCreateMediaTransportParam |
| 1232 | { |
| 1233 | /** |
| 1234 | * The media index in the SDP for which this media transport will be used. |
| 1235 | */ |
| 1236 | unsigned mediaIdx; |
| 1237 | |
| 1238 | /** |
| 1239 | * The media transport which otherwise will be used by the call has this |
| 1240 | * callback not been implemented. Application can change this to its own |
| 1241 | * instance of media transport to be used by the call. |
| 1242 | */ |
| 1243 | MediaTransport mediaTp; |
| 1244 | |
| 1245 | /** |
| 1246 | * Bitmask from pjsua_create_media_transport_flag. |
| 1247 | */ |
| 1248 | unsigned flags; |
| 1249 | }; |
| 1250 | |
| 1251 | /** |
| 1252 | * This structure contains parameters for Call::onCreateMediaTransportSrtp() |
| 1253 | * callback. |
| 1254 | */ |
| 1255 | struct OnCreateMediaTransportSrtpParam |
| 1256 | { |
| 1257 | /** |
| 1258 | * The media index in the SDP for which the SRTP media transport |
| 1259 | * will be used. |
| 1260 | */ |
| 1261 | unsigned mediaIdx; |
| 1262 | |
| 1263 | /** |
| 1264 | * Specify whether secure media transport should be used. Application |
| 1265 | * can modify this only for initial INVITE. |
| 1266 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 1267 | * PJMEDIA_SRTP_MANDATORY. |
| 1268 | */ |
| 1269 | pjmedia_srtp_use srtpUse; |
| 1270 | |
| 1271 | /** |
| 1272 | * Application can modify this to specify the cryptos and keys |
| 1273 | * which are going to be used. |
| 1274 | */ |
| 1275 | SrtpCryptoVector cryptos; |
| 1276 | }; |
| 1277 | |
| 1278 | /** |
| 1279 | * @} // PJSUA2_Call_Data_Structure |
| 1280 | */ |
| 1281 | |
| 1282 | /** |
| 1283 | * @addtogroup PJSUA2_CALL |
| 1284 | * @{ |
| 1285 | */ |
| 1286 | |
| 1287 | /** |
| 1288 | * This structure contains parameters for Call::answer(), Call::hangup(), |
| 1289 | * Call::reinvite(), Call::update(), Call::xfer(), Call::xferReplaces(), |
| 1290 | * Call::setHold(). |
| 1291 | */ |
| 1292 | struct CallOpParam |
| 1293 | { |
| 1294 | /** |
| 1295 | * The call setting. |
| 1296 | */ |
| 1297 | CallSetting opt; |
| 1298 | |
| 1299 | /** |
| 1300 | * Status code. |
| 1301 | */ |
| 1302 | pjsip_status_code statusCode; |
| 1303 | |
| 1304 | /** |
| 1305 | * Reason phrase. |
| 1306 | */ |
| 1307 | string reason; |
| 1308 | |
| 1309 | /** |
| 1310 | * Options. |
| 1311 | */ |
| 1312 | unsigned options; |
| 1313 | |
| 1314 | /** |
| 1315 | * List of headers etc to be added to outgoing response message. |
| 1316 | * Note that this message data will be persistent in all next |
| 1317 | * answers/responses for this INVITE request. |
| 1318 | */ |
| 1319 | SipTxOption txOption; |
| 1320 | |
| 1321 | /** |
| 1322 | * SDP answer. Currently only used for Call::answer(). |
| 1323 | */ |
| 1324 | SdpSession sdp; |
| 1325 | |
| 1326 | public: |
| 1327 | /** |
| 1328 | * Default constructor initializes with zero/empty values. |
| 1329 | * Setting useDefaultCallSetting to true will initialize opt with default |
| 1330 | * call setting values. |
| 1331 | */ |
| 1332 | CallOpParam(bool useDefaultCallSetting = false); |
| 1333 | }; |
| 1334 | |
| 1335 | /** |
| 1336 | * This structure contains parameters for Call::sendRequest() |
| 1337 | */ |
| 1338 | struct CallSendRequestParam |
| 1339 | { |
| 1340 | /** |
| 1341 | * SIP method of the request. |
| 1342 | */ |
| 1343 | string method; |
| 1344 | |
| 1345 | /** |
| 1346 | * Message body and/or list of headers etc to be included in |
| 1347 | * outgoing request. |
| 1348 | */ |
| 1349 | SipTxOption txOption; |
| 1350 | |
| 1351 | public: |
| 1352 | /** |
| 1353 | * Default constructor initializes with zero/empty values. |
| 1354 | */ |
| 1355 | CallSendRequestParam(); |
| 1356 | }; |
| 1357 | |
| 1358 | /** |
| 1359 | * This structure contains parameters for Call::vidSetStream() |
| 1360 | */ |
| 1361 | struct CallVidSetStreamParam |
| 1362 | { |
| 1363 | /** |
| 1364 | * Specify the media stream index. This can be set to -1 to denote |
| 1365 | * the default video stream in the call, which is the first active |
| 1366 | * video stream or any first video stream if none is active. |
| 1367 | * |
| 1368 | * This field is valid for all video stream operations, except |
| 1369 | * PJSUA_CALL_VID_STRM_ADD. |
| 1370 | * |
| 1371 | * Default: -1 (first active video stream, or any first video stream |
| 1372 | * if none is active) |
| 1373 | */ |
| 1374 | int medIdx; |
| 1375 | |
| 1376 | /** |
| 1377 | * Specify the media stream direction. |
| 1378 | * |
| 1379 | * This field is valid for the following video stream operations: |
| 1380 | * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR. |
| 1381 | * |
| 1382 | * Default: PJMEDIA_DIR_ENCODING_DECODING |
| 1383 | */ |
| 1384 | pjmedia_dir dir; |
| 1385 | |
| 1386 | /** |
| 1387 | * Specify the video capture device ID. This can be set to |
| 1388 | * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture |
| 1389 | * device as configured in the account. |
| 1390 | * |
| 1391 | * This field is valid for the following video stream operations: |
| 1392 | * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV. |
| 1393 | * |
| 1394 | * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV. |
| 1395 | */ |
| 1396 | pjmedia_vid_dev_index capDev; |
| 1397 | |
| 1398 | public: |
| 1399 | /** |
| 1400 | * Default constructor |
| 1401 | */ |
| 1402 | CallVidSetStreamParam(); |
| 1403 | }; |
| 1404 | |
| 1405 | /** |
| 1406 | * This structure contains parameters for Call::sendDtmf() |
| 1407 | */ |
| 1408 | struct CallSendDtmfParam |
| 1409 | { |
| 1410 | /** |
| 1411 | * The method used to send DTMF. |
| 1412 | * |
| 1413 | * Default: PJSUA_DTMF_METHOD_RFC2833 |
| 1414 | */ |
| 1415 | pjsua_dtmf_method method; |
| 1416 | |
| 1417 | /** |
| 1418 | * The signal duration used for the DTMF. |
| 1419 | * |
| 1420 | * Default: PJSUA_CALL_SEND_DTMF_DURATION_DEFAULT |
| 1421 | */ |
| 1422 | unsigned duration; |
| 1423 | |
| 1424 | /** |
| 1425 | * The DTMF digits to be sent. |
| 1426 | */ |
| 1427 | string digits; |
| 1428 | |
| 1429 | public: |
| 1430 | /** |
| 1431 | * Default constructor initialize with default value. |
| 1432 | */ |
| 1433 | CallSendDtmfParam(); |
| 1434 | |
| 1435 | /** |
| 1436 | * Convert to pjsip. |
| 1437 | */ |
| 1438 | pjsua_call_send_dtmf_param toPj() const; |
| 1439 | |
| 1440 | /** |
| 1441 | * Convert from pjsip. |
| 1442 | */ |
| 1443 | void fromPj(const pjsua_call_send_dtmf_param ¶m); |
| 1444 | }; |
| 1445 | |
| 1446 | /** |
| 1447 | * This structure contains parameters for Call::sendText() |
| 1448 | */ |
| 1449 | struct CallSendTextParam |
| 1450 | { |
| 1451 | /** |
| 1452 | * Specify the text media stream index. This can be set to -1 to denote |
| 1453 | * the first text stream in the call. |
| 1454 | * |
| 1455 | * Default: -1 (first text stream) |
| 1456 | */ |
| 1457 | int medIdx; |
| 1458 | |
| 1459 | /** |
| 1460 | * The text data to be sent. |
| 1461 | */ |
| 1462 | string text; |
| 1463 | |
| 1464 | public: |
| 1465 | /** |
| 1466 | * Default constructor initializes with default value. |
| 1467 | */ |
| 1468 | CallSendTextParam(); |
| 1469 | }; |
| 1470 | |
| 1471 | |
| 1472 | /** |
| 1473 | * Call. |
| 1474 | */ |
| 1475 | class Call |
| 1476 | { |
| 1477 | public: |
| 1478 | /** |
| 1479 | * Constructor. |
| 1480 | */ |
| 1481 | Call(Account& acc, int call_id = PJSUA_INVALID_ID); |
| 1482 | |
| 1483 | /** |
| 1484 | * Destructor. |
| 1485 | */ |
| 1486 | virtual ~Call(); |
| 1487 | |
| 1488 | /** |
| 1489 | * Obtain detail information about this call. |
| 1490 | * |
| 1491 | * @return Call info. |
| 1492 | */ |
| 1493 | CallInfo getInfo() const PJSUA2_THROW(Error); |
| 1494 | |
| 1495 | /** |
| 1496 | * Check if this call has active INVITE session and the INVITE |
| 1497 | * session has not been disconnected. |
| 1498 | * |
| 1499 | * @return True if call is active. |
| 1500 | */ |
| 1501 | bool isActive() const; |
| 1502 | |
| 1503 | /** |
| 1504 | * Get PJSUA-LIB call ID or index associated with this call. |
| 1505 | * |
| 1506 | * @return Integer greater than or equal to zero. |
| 1507 | */ |
| 1508 | int getId() const; |
| 1509 | |
| 1510 | /** |
| 1511 | * Get the Call class for the specified call Id. |
| 1512 | * |
| 1513 | * @param call_id The call ID to lookup |
| 1514 | * |
| 1515 | * @return The Call instance or NULL if not found. |
| 1516 | */ |
| 1517 | static Call *lookup(int call_id); |
| 1518 | |
| 1519 | /** |
| 1520 | * Check if call has an active media session. |
| 1521 | * |
| 1522 | * @return True if yes. |
| 1523 | */ |
| 1524 | bool hasMedia() const; |
| 1525 | |
| 1526 | /** |
| 1527 | * Warning: deprecated, use getAudioMedia() instead. This function is not |
| 1528 | * safe in multithreaded environment. |
| 1529 | * |
| 1530 | * Get media for the specified media index. |
| 1531 | * |
| 1532 | * @param med_idx Media index. |
| 1533 | * |
| 1534 | * @return The media or NULL if invalid or inactive. |
| 1535 | */ |
| 1536 | Media *getMedia(unsigned med_idx) const; |
| 1537 | |
| 1538 | /** |
| 1539 | * Get audio media for the specified media index. If the specified media |
| 1540 | * index is not audio or invalid or inactive, exception will be thrown. |
| 1541 | * |
| 1542 | * @param med_idx Media index, or -1 to specify any first audio |
| 1543 | * media registered in the conference bridge. |
| 1544 | * |
| 1545 | * @return The audio media. |
| 1546 | */ |
| 1547 | AudioMedia getAudioMedia(int med_idx) const PJSUA2_THROW(Error); |
| 1548 | |
| 1549 | /** |
| 1550 | * Get video media in encoding direction for the specified media index. |
| 1551 | * If the specified media index is not video or invalid or the direction |
| 1552 | * is receive only, exception will be thrown. |
| 1553 | * |
| 1554 | * @param med_idx Media index, or -1 to specify any first video |
| 1555 | * media with encoding direction registered in the |
| 1556 | * conference bridge. |
| 1557 | * |
| 1558 | * @return The video media. |
| 1559 | */ |
| 1560 | VideoMedia getEncodingVideoMedia(int med_idx) const PJSUA2_THROW(Error); |
| 1561 | |
| 1562 | /** |
| 1563 | * Get video media in decoding direction for the specified media index. |
| 1564 | * If the specified media index is not video or invalid or the direction |
| 1565 | * is send only, exception will be thrown. |
| 1566 | * |
| 1567 | * @param med_idx Media index, or -1 to specify any first video |
| 1568 | * media with decoding direction registered in the |
| 1569 | * conference bridge. |
| 1570 | * |
| 1571 | * @return The video media. |
| 1572 | */ |
| 1573 | VideoMedia getDecodingVideoMedia(int med_idx) const PJSUA2_THROW(Error); |
| 1574 | |
| 1575 | /** |
| 1576 | * Check if remote peer support the specified capability. |
| 1577 | * |
| 1578 | * @param htype The header type (pjsip_hdr_e) to be checked, which |
| 1579 | * value may be: |
| 1580 | * - PJSIP_H_ACCEPT |
| 1581 | * - PJSIP_H_ALLOW |
| 1582 | * - PJSIP_H_SUPPORTED |
| 1583 | * @param hname If htype specifies PJSIP_H_OTHER, then the header |
| 1584 | * name must be supplied in this argument. Otherwise |
| 1585 | * the value must be set to empty string (""). |
| 1586 | * @param token The capability token to check. For example, if \a |
| 1587 | * htype is PJSIP_H_ALLOW, then \a token specifies the |
| 1588 | * method names; if \a htype is PJSIP_H_SUPPORTED, then |
| 1589 | * \a token specifies the extension names such as |
| 1590 | * "100rel". |
| 1591 | * |
| 1592 | * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified |
| 1593 | * capability is explicitly supported, see |
| 1594 | * pjsip_dialog_cap_status for more info. |
| 1595 | */ |
| 1596 | pjsip_dialog_cap_status remoteHasCap(int htype, |
| 1597 | const string &hname, |
| 1598 | const string &token) const; |
| 1599 | |
| 1600 | /** |
| 1601 | * Attach application specific data to the call. Application can then |
| 1602 | * inspect this data by calling getUserData(). |
| 1603 | * |
| 1604 | * @param user_data Arbitrary data to be attached to the call. |
| 1605 | */ |
| 1606 | void setUserData(Token user_data); |
| 1607 | |
| 1608 | /** |
| 1609 | * Get user data attached to the call, which has been previously set with |
| 1610 | * setUserData(). |
| 1611 | * |
| 1612 | * @return The user data. |
| 1613 | */ |
| 1614 | Token getUserData() const; |
| 1615 | |
| 1616 | /** |
| 1617 | * Get the NAT type of remote's endpoint. This is a proprietary feature |
| 1618 | * of PJSUA-LIB which sends its NAT type in the SDP when \a natTypeInSdp |
| 1619 | * is set in UaConfig. |
| 1620 | * |
| 1621 | * This function can only be called after SDP has been received from remote, |
| 1622 | * which means for incoming call, this function can be called as soon as |
| 1623 | * call is received as long as incoming call contains SDP, and for outgoing |
| 1624 | * call, this function can be called only after SDP is received (normally in |
| 1625 | * PJSIP_SC_OK (200) response to INVITE). As a general case, application |
| 1626 | * should call this function after or in \a onCallMediaState() callback. |
| 1627 | * |
| 1628 | * @return The NAT type. |
| 1629 | * |
| 1630 | * @see Endpoint::natGetType(), natTypeInSdp |
| 1631 | */ |
| 1632 | pj_stun_nat_type getRemNatType() PJSUA2_THROW(Error); |
| 1633 | |
| 1634 | /** |
| 1635 | * Make outgoing call to the specified URI. |
| 1636 | * |
| 1637 | * @param dst_uri URI to be put in the To header (normally is the same |
| 1638 | * as the target URI). |
| 1639 | * @param prm.opt Optional call setting. |
| 1640 | * @param prm.txOption Optional headers etc to be added to outgoing INVITE |
| 1641 | * request. |
| 1642 | */ |
| 1643 | void makeCall(const string &dst_uri, const CallOpParam &prm) |
| 1644 | PJSUA2_THROW(Error); |
| 1645 | |
| 1646 | /** |
| 1647 | * Send response to incoming INVITE request with call setting param. |
| 1648 | * Depending on the status code specified as parameter, this function may |
| 1649 | * send provisional response, establish the call, or terminate the call. |
| 1650 | * Notes about call setting: |
| 1651 | * - if call setting is changed in the subsequent call to this function, |
| 1652 | * only the first call setting supplied will applied. So normally |
| 1653 | * application will not supply call setting before getting confirmation |
| 1654 | * from the user. |
| 1655 | * - if no call setting is supplied when SDP has to be sent, i.e: answer |
| 1656 | * with status code 183 or 2xx, the default call setting will be used, |
| 1657 | * check CallSetting for its default values. |
| 1658 | * |
| 1659 | * @param prm.opt Optional call setting. |
| 1660 | * @param prm.statusCode Status code, (>= PJSIP_SC_TRYING (100)). |
| 1661 | * @param prm.reason Optional reason phrase. If empty, default text |
| 1662 | * will be used. |
| 1663 | * @param prm.txOption Optional list of headers etc to be added to outgoing |
| 1664 | * response message. Note that this message data will |
| 1665 | * be persistent in all next answers/responses for this |
| 1666 | * INVITE request. |
| 1667 | */ |
| 1668 | void answer(const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1669 | |
| 1670 | /** |
| 1671 | * Hangup call by using method that is appropriate according to the |
| 1672 | * call state. This function is different than answering the call with |
| 1673 | * 3xx-6xx response (with answer()), in that this function |
| 1674 | * will hangup the call regardless of the state and role of the call, |
| 1675 | * while answer() only works with incoming calls on EARLY |
| 1676 | * state. |
| 1677 | * |
| 1678 | * @param prm.statusCode |
| 1679 | * Optional status code to be sent when we're rejecting |
| 1680 | * incoming call. If the value is zero, "603/Decline" |
| 1681 | * will be sent. |
| 1682 | * @param prm.reason Optional reason phrase to be sent when we're |
| 1683 | * rejecting incoming call. If empty, default text |
| 1684 | * will be used. |
| 1685 | * @param prm.txOption Optional list of headers etc to be added to outgoing |
| 1686 | * request/response message. |
| 1687 | */ |
| 1688 | void hangup(const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1689 | |
| 1690 | /** |
| 1691 | * Put the specified call on hold. This will send re-INVITE with the |
| 1692 | * appropriate SDP to inform remote that the call is being put on hold. |
| 1693 | * The final status of the request itself will be reported on the |
| 1694 | * \a onCallMediaState() callback, which inform the application that |
| 1695 | * the media state of the call has changed. |
| 1696 | * |
| 1697 | * @param prm.options Bitmask of pjsua_call_flag constants. Currently, |
| 1698 | * only the flag PJSUA_CALL_UPDATE_CONTACT can be used. |
| 1699 | * @param prm.txOption Optional message components to be sent with |
| 1700 | * the request. |
| 1701 | */ |
| 1702 | void setHold(const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1703 | |
| 1704 | /** |
| 1705 | * Send re-INVITE. |
| 1706 | * The final status of the request itself will be reported on the |
| 1707 | * \a onCallMediaState() callback, which inform the application that |
| 1708 | * the media state of the call has changed. |
| 1709 | * |
| 1710 | * @param prm.opt Optional call setting, if empty, the current call |
| 1711 | * setting will remain unchanged. |
| 1712 | * @param prm.opt.flag Bitmask of pjsua_call_flag constants. Specifying |
| 1713 | * PJSUA_CALL_UNHOLD here will release call hold. |
| 1714 | * @param prm.txOption Optional message components to be sent with |
| 1715 | * the request. |
| 1716 | */ |
| 1717 | void reinvite(const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1718 | |
| 1719 | /** |
| 1720 | * Send UPDATE request. |
| 1721 | * |
| 1722 | * @param prm.opt Optional call setting, if empty, the current call |
| 1723 | * setting will remain unchanged. |
| 1724 | * @param prm.txOption Optional message components to be sent with |
| 1725 | * the request. |
| 1726 | */ |
| 1727 | void update(const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1728 | |
| 1729 | /** |
| 1730 | * Initiate call transfer to the specified address. This function will send |
| 1731 | * REFER request to instruct remote call party to initiate a new INVITE |
| 1732 | * session to the specified destination/target. |
| 1733 | * |
| 1734 | * If application is interested to monitor the successfulness and |
| 1735 | * the progress of the transfer request, it can implement |
| 1736 | * \a onCallTransferStatus() callback which will report the progress |
| 1737 | * of the call transfer request. |
| 1738 | * |
| 1739 | * @param dest URI of new target to be contacted. The URI may be |
| 1740 | * in name address or addr-spec format. |
| 1741 | * @param prm.txOption Optional message components to be sent with |
| 1742 | * the request. |
| 1743 | */ |
| 1744 | void xfer(const string &dest, const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1745 | |
| 1746 | /** |
| 1747 | * Initiate attended call transfer. This function will send REFER request |
| 1748 | * to instruct remote call party to initiate new INVITE session to the URL |
| 1749 | * of \a destCall. The party at \a dest_call then should "replace" |
| 1750 | * the call with us with the new call from the REFER recipient. |
| 1751 | * |
| 1752 | * @param dest_call The call to be replaced. |
| 1753 | * @param prm.options Application may specify |
| 1754 | * PJSUA_XFER_NO_REQUIRE_REPLACES to suppress the |
| 1755 | * inclusion of "Require: replaces" in |
| 1756 | * the outgoing INVITE request created by the REFER |
| 1757 | * request. |
| 1758 | * @param prm.txOption Optional message components to be sent with |
| 1759 | * the request. |
| 1760 | */ |
| 1761 | void xferReplaces(const Call& dest_call, |
| 1762 | const CallOpParam &prm) PJSUA2_THROW(Error); |
| 1763 | |
| 1764 | /** |
| 1765 | * Accept or reject redirection response. Application MUST call this |
| 1766 | * function after it signaled PJSIP_REDIRECT_PENDING in the |
| 1767 | * \a onCallRedirected() callback, |
| 1768 | * to notify the call whether to accept or reject the redirection |
| 1769 | * to the current target. Application can use the combination of |
| 1770 | * PJSIP_REDIRECT_PENDING command in \a onCallRedirected() callback and |
| 1771 | * this function to ask for user permission before redirecting the call. |
| 1772 | * |
| 1773 | * Note that if the application chooses to reject or stop redirection (by |
| 1774 | * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the |
| 1775 | * call disconnection callback will be called before this function returns. |
| 1776 | * And if the application rejects the target, the \a onCallRedirected() |
| 1777 | * callback may also be called before this function returns if there is |
| 1778 | * another target to try. |
| 1779 | * |
| 1780 | * @param cmd Redirection operation to be applied to the current |
| 1781 | * target. The semantic of this argument is similar |
| 1782 | * to the description in the \a onCallRedirected() |
| 1783 | * callback, except that the PJSIP_REDIRECT_PENDING is |
| 1784 | * not accepted here. |
| 1785 | */ |
| 1786 | void processRedirect(pjsip_redirect_op cmd) PJSUA2_THROW(Error); |
| 1787 | |
| 1788 | /** |
| 1789 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 1790 | * |
| 1791 | * @param digits DTMF string digits to be sent. |
| 1792 | */ |
| 1793 | void dialDtmf(const string &digits) PJSUA2_THROW(Error); |
| 1794 | |
| 1795 | /** |
| 1796 | * Send DTMF digits to remote. |
| 1797 | * |
| 1798 | * @param param The send DTMF parameter. |
| 1799 | */ |
| 1800 | void sendDtmf(const CallSendDtmfParam ¶m) PJSUA2_THROW(Error); |
| 1801 | |
| 1802 | /** |
| 1803 | * Send real-time text to remote via RTP stream. This only works if |
| 1804 | * the call has text media. |
| 1805 | * |
| 1806 | * @param param The send text parameter. |
| 1807 | */ |
| 1808 | void sendText(const CallSendTextParam ¶m) PJSUA2_THROW(Error); |
| 1809 | |
| 1810 | /** |
| 1811 | * Send instant messaging inside INVITE session. |
| 1812 | * |
| 1813 | * @param prm.contentType |
| 1814 | * MIME type. |
| 1815 | * @param prm.content The message content. |
| 1816 | * @param prm.txOption Optional list of headers etc to be included in |
| 1817 | * outgoing request. The body descriptor in the |
| 1818 | * txOption is ignored. |
| 1819 | * @param prm.userData Optional user data, which will be given back when |
| 1820 | * the IM callback is called. |
| 1821 | */ |
| 1822 | void sendInstantMessage(const SendInstantMessageParam& prm) |
| 1823 | PJSUA2_THROW(Error); |
| 1824 | |
| 1825 | /** |
| 1826 | * Send IM typing indication inside INVITE session. |
| 1827 | * |
| 1828 | * @param prm.isTyping True to indicate to remote that local person is |
| 1829 | * currently typing an IM. |
| 1830 | * @param prm.txOption Optional list of headers etc to be included in |
| 1831 | * outgoing request. |
| 1832 | */ |
| 1833 | void sendTypingIndication(const SendTypingIndicationParam &prm) |
| 1834 | PJSUA2_THROW(Error); |
| 1835 | |
| 1836 | /** |
| 1837 | * Send arbitrary request with the call. This is useful for example to send |
| 1838 | * INFO request. Note that application should not use this function to send |
| 1839 | * requests which would change the invite session's state, such as |
| 1840 | * re-INVITE, UPDATE, PRACK, and BYE. |
| 1841 | * |
| 1842 | * @param prm.method SIP method of the request. |
| 1843 | * @param prm.txOption Optional message body and/or list of headers to be |
| 1844 | * included in outgoing request. |
| 1845 | */ |
| 1846 | void sendRequest(const CallSendRequestParam &prm) PJSUA2_THROW(Error); |
| 1847 | |
| 1848 | /** |
| 1849 | * Dump call and media statistics to string. |
| 1850 | * |
| 1851 | * @param with_media True to include media information too. |
| 1852 | * @param indent Spaces for left indentation. |
| 1853 | * |
| 1854 | * @return Call dump and media statistics string. |
| 1855 | */ |
| 1856 | string dump(bool with_media, const string indent) PJSUA2_THROW(Error); |
| 1857 | |
| 1858 | /** |
| 1859 | * Get the media stream index of the default video stream in the call. |
| 1860 | * Typically this will just retrieve the stream index of the first |
| 1861 | * activated video stream in the call. If none is active, it will return |
| 1862 | * the first inactive video stream. |
| 1863 | * |
| 1864 | * @return The media stream index or -1 if no video stream |
| 1865 | * is present in the call. |
| 1866 | */ |
| 1867 | int vidGetStreamIdx() const; |
| 1868 | |
| 1869 | /** |
| 1870 | * Determine if video stream for the specified call is currently running |
| 1871 | * (i.e. has been created, started, and not being paused) for the specified |
| 1872 | * direction. |
| 1873 | * |
| 1874 | * @param med_idx Media stream index, or -1 to specify default video |
| 1875 | * media. |
| 1876 | * @param dir The direction to be checked. |
| 1877 | * |
| 1878 | * @return True if stream is currently running for the |
| 1879 | * specified direction. |
| 1880 | */ |
| 1881 | bool vidStreamIsRunning(int med_idx, pjmedia_dir dir) const; |
| 1882 | |
| 1883 | /** |
| 1884 | * Add, remove, modify, and/or manipulate video media stream for the |
| 1885 | * specified call. This may trigger a re-INVITE or UPDATE to be sent |
| 1886 | * for the call. |
| 1887 | * |
| 1888 | * @param op The video stream operation to be performed, |
| 1889 | * possible values are pjsua_call_vid_strm_op. |
| 1890 | * @param param The parameters for the video stream operation |
| 1891 | * (see CallVidSetStreamParam). |
| 1892 | */ |
| 1893 | void vidSetStream(pjsua_call_vid_strm_op op, |
| 1894 | const CallVidSetStreamParam ¶m) PJSUA2_THROW(Error); |
| 1895 | |
| 1896 | /** |
| 1897 | * Modify the video stream's codec parameter after the codec is opened. |
| 1898 | * Note that not all codec backends support modifying parameters during |
| 1899 | * runtime and only certain parameters can be changed. |
| 1900 | * |
| 1901 | * Currently, only Video Toolbox and OpenH264 backends support runtime |
| 1902 | * adjustment of encoding bitrate (avg_bps and max_bps). |
| 1903 | * |
| 1904 | * @param med_idx Video stream index. |
| 1905 | * @param param The new codec parameter. |
| 1906 | * |
| 1907 | * @return PJ_SUCCESS on success. |
| 1908 | */ |
| 1909 | void vidStreamModifyCodecParam(int med_idx, const VidCodecParam ¶m) |
| 1910 | PJSUA2_THROW(Error); |
| 1911 | |
| 1912 | /** |
| 1913 | * Modify the audio stream's codec parameter after the codec is opened. |
| 1914 | * Note that not all codec parameters can be modified during run-time. |
| 1915 | * Currently, only Opus codec supports changing key codec parameters |
| 1916 | * such as bitrate and bandwidth, while other codecs may only be able to |
| 1917 | * modify minor settings such as VAD or PLC. |
| 1918 | * |
| 1919 | * @param med_idx Media stream index, or -1 to specify default audio |
| 1920 | * media. |
| 1921 | * @param param The new codec parameter. |
| 1922 | * |
| 1923 | * @return PJ_SUCCESS on success. |
| 1924 | */ |
| 1925 | void audStreamModifyCodecParam(int med_idx, const CodecParam ¶m) |
| 1926 | PJSUA2_THROW(Error); |
| 1927 | |
| 1928 | /** |
| 1929 | * Get media stream info for the specified media index. |
| 1930 | * |
| 1931 | * @param med_idx Media stream index. |
| 1932 | * |
| 1933 | * @return The stream info. |
| 1934 | */ |
| 1935 | StreamInfo getStreamInfo(unsigned med_idx) const PJSUA2_THROW(Error); |
| 1936 | |
| 1937 | /** |
| 1938 | * Get media stream statistic for the specified media index. |
| 1939 | * |
| 1940 | * @param med_idx Media stream index. |
| 1941 | * |
| 1942 | * @return The stream statistic. |
| 1943 | */ |
| 1944 | StreamStat getStreamStat(unsigned med_idx) const PJSUA2_THROW(Error); |
| 1945 | |
| 1946 | /** |
| 1947 | * Get media transport info for the specified media index. |
| 1948 | * |
| 1949 | * @param med_idx Media stream index. |
| 1950 | * |
| 1951 | * @return The transport info. |
| 1952 | */ |
| 1953 | MediaTransportInfo getMedTransportInfo(unsigned med_idx) const |
| 1954 | PJSUA2_THROW(Error); |
| 1955 | |
| 1956 | /** |
| 1957 | * Internal function (callled by Endpoint( to process update to call |
| 1958 | * medias when call media state changes. |
| 1959 | */ |
| 1960 | void processMediaUpdate(OnCallMediaStateParam &prm); |
| 1961 | |
| 1962 | /** |
| 1963 | * Internal function (called by Endpoint) to process call state change. |
| 1964 | */ |
| 1965 | void processStateChange(OnCallStateParam &prm); |
| 1966 | |
| 1967 | public: |
| 1968 | /* |
| 1969 | * Callbacks |
| 1970 | */ |
| 1971 | /** |
| 1972 | * Notify application when call state has changed. |
| 1973 | * Application may then query the call info to get the |
| 1974 | * detail call states by calling getInfo() function. |
| 1975 | * |
| 1976 | * @param prm Callback parameter. |
| 1977 | */ |
| 1978 | virtual void onCallState(OnCallStateParam &prm) |
| 1979 | { PJ_UNUSED_ARG(prm); } |
| 1980 | |
| 1981 | /** |
| 1982 | * This is a general notification callback which is called whenever |
| 1983 | * a transaction within the call has changed state. Application can |
| 1984 | * implement this callback for example to monitor the state of |
| 1985 | * outgoing requests, or to answer unhandled incoming requests |
| 1986 | * (such as INFO) with a final response. |
| 1987 | * |
| 1988 | * @param prm Callback parameter. |
| 1989 | */ |
| 1990 | virtual void onCallTsxState(OnCallTsxStateParam &prm) |
| 1991 | { PJ_UNUSED_ARG(prm); } |
| 1992 | |
| 1993 | /** |
| 1994 | * Notify application when media state in the call has changed. |
| 1995 | * Normal application would need to implement this callback, e.g. |
| 1996 | * to connect the call's media to sound device. When ICE is used, |
| 1997 | * this callback will also be called to report ICE negotiation |
| 1998 | * failure. |
| 1999 | * |
| 2000 | * @param prm Callback parameter. |
| 2001 | */ |
| 2002 | virtual void onCallMediaState(OnCallMediaStateParam &prm) |
| 2003 | { PJ_UNUSED_ARG(prm); } |
| 2004 | |
| 2005 | /** |
| 2006 | * Notify application when a call has just created a local SDP (for |
| 2007 | * initial or subsequent SDP offer/answer). Application can implement |
| 2008 | * this callback to modify the SDP, before it is being sent and/or |
| 2009 | * negotiated with remote SDP, for example to apply per account/call |
| 2010 | * basis codecs priority or to add custom/proprietary SDP attributes. |
| 2011 | * |
| 2012 | * @param prm Callback parameter. |
| 2013 | */ |
| 2014 | virtual void onCallSdpCreated(OnCallSdpCreatedParam &prm) |
| 2015 | { PJ_UNUSED_ARG(prm); } |
| 2016 | |
| 2017 | /** |
| 2018 | * Notify application when an audio media session is about to be created |
| 2019 | * (as opposed to onStreamCreated(), which is called *after* the session |
| 2020 | * has been created). The application may change |
| 2021 | * some stream info parameter values, i.e: jbInit, jbMinPre, jbMaxPre, |
| 2022 | * jbMax, useKa, startCountKa, startIntervalKa, intervalKa, |
| 2023 | * rtcpSdesByeDisabled, jbDiscardAlgo (audio), vidCodecParam.encFmt (video). |
| 2024 | * |
| 2025 | * @param prm Callback parameter. |
| 2026 | */ |
| 2027 | virtual void onStreamPreCreate(OnStreamPreCreateParam &prm) |
| 2028 | { PJ_UNUSED_ARG(prm); } |
| 2029 | |
| 2030 | /** |
| 2031 | * Notify application when audio media session is created and before it is |
| 2032 | * registered to the conference bridge. Application may return different |
| 2033 | * audio media port if it has added media processing port to the stream. |
| 2034 | * This media port then will be added to the conference bridge instead. |
| 2035 | * |
| 2036 | * @param prm Callback parameter. |
| 2037 | */ |
| 2038 | virtual void onStreamCreated(OnStreamCreatedParam &prm) |
| 2039 | { PJ_UNUSED_ARG(prm); } |
| 2040 | |
| 2041 | /** |
| 2042 | * Notify application when audio media session has been unregistered from |
| 2043 | * the conference bridge and about to be destroyed. |
| 2044 | * |
| 2045 | * @param prm Callback parameter. |
| 2046 | */ |
| 2047 | virtual void onStreamDestroyed(OnStreamDestroyedParam &prm) |
| 2048 | { PJ_UNUSED_ARG(prm); } |
| 2049 | |
| 2050 | /** |
| 2051 | * Notify application upon incoming DTMF digits. |
| 2052 | * |
| 2053 | * @param prm Callback parameter. |
| 2054 | */ |
| 2055 | virtual void onDtmfDigit(OnDtmfDigitParam &prm) |
| 2056 | { PJ_UNUSED_ARG(prm); } |
| 2057 | |
| 2058 | /** |
| 2059 | * Notify application upon incoming DTMF events. |
| 2060 | * |
| 2061 | * @param prm Callback parameter. |
| 2062 | */ |
| 2063 | virtual void onDtmfEvent(OnDtmfEventParam &prm) |
| 2064 | { PJ_UNUSED_ARG(prm); } |
| 2065 | |
| 2066 | /** |
| 2067 | * Notify application upon incoming text data from the text stream. |
| 2068 | * Note that the received text can be empty. |
| 2069 | * |
| 2070 | * @param prm Callback parameter. |
| 2071 | */ |
| 2072 | virtual void onCallRxText(OnCallRxTextParam &prm) |
| 2073 | { PJ_UNUSED_ARG(prm); } |
| 2074 | |
| 2075 | /** |
| 2076 | * Notify application on call being transferred (i.e. REFER is received). |
| 2077 | * Application can decide to accept/reject transfer request by setting |
| 2078 | * the code (default is 202). When this callback is not implemented, |
| 2079 | * the default behavior is to accept the transfer. |
| 2080 | * |
| 2081 | * If application decides to accept the transfer request, it must also |
| 2082 | * instantiate the new Call object for the transfer operation and return |
| 2083 | * this new Call object to prm.newCall. For the new Call instance, |
| 2084 | * the account should use the same account as this call and the call ID |
| 2085 | * must be set to PJSUA_INVALID_ID. |
| 2086 | * |
| 2087 | * If application does not specify new Call object, library will reuse the |
| 2088 | * existing Call object for initiating the new call (to the transfer |
| 2089 | * destination). In this case, any events from both calls (transferred and |
| 2090 | * transferring) will be delivered to the same Call object, where the call |
| 2091 | * ID will be switched back and forth between callbacks. Application must |
| 2092 | * be careful to not destroy the Call object when receiving disconnection |
| 2093 | * event of the transferred call after the transfer process is completed. |
| 2094 | * |
| 2095 | * @param prm Callback parameter. |
| 2096 | */ |
| 2097 | virtual void onCallTransferRequest(OnCallTransferRequestParam &prm) |
| 2098 | { PJ_UNUSED_ARG(prm); } |
| 2099 | |
| 2100 | /** |
| 2101 | * Notify application of the status of previously sent call |
| 2102 | * transfer request. Application can monitor the status of the |
| 2103 | * call transfer request, for example to decide whether to |
| 2104 | * terminate existing call. |
| 2105 | * |
| 2106 | * @param prm Callback parameter. |
| 2107 | */ |
| 2108 | virtual void onCallTransferStatus(OnCallTransferStatusParam &prm) |
| 2109 | { PJ_UNUSED_ARG(prm); } |
| 2110 | |
| 2111 | /** |
| 2112 | * Notify application about incoming INVITE with Replaces header. |
| 2113 | * Application may reject the request by setting non-2xx code. |
| 2114 | * |
| 2115 | * In this callback, application should create a new Call instance and |
| 2116 | * return the Call object via prm.newCall. In creating the new Call |
| 2117 | * instance, the account should use the same account as this call and |
| 2118 | * the call ID must be set to PJSUA_INVALID_ID. |
| 2119 | * |
| 2120 | * If application does not specify new Call object, library will reuse the |
| 2121 | * existing Call object for callbacks. In this case, any events from |
| 2122 | * both calls (replaced and new) will be delivered to the same Call object, |
| 2123 | * where the call ID will be switched back and forth between callbacks. |
| 2124 | * Application must be careful to not destroy the Call object when |
| 2125 | * receiving disconnection event of the replaced call after the transfer |
| 2126 | * process is completed. |
| 2127 | * |
| 2128 | * @param prm Callback parameter. |
| 2129 | */ |
| 2130 | virtual void onCallReplaceRequest(OnCallReplaceRequestParam &prm) |
| 2131 | { PJ_UNUSED_ARG(prm); } |
| 2132 | |
| 2133 | /** |
| 2134 | * Notify application that an existing call has been replaced with |
| 2135 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 2136 | * request with Replaces header. |
| 2137 | * |
| 2138 | * After this callback is called, normally PJSUA-API will disconnect |
| 2139 | * this call and establish a new call. |
| 2140 | * |
| 2141 | * If not yet done in onCallReplaceRequest(), application can create |
| 2142 | * the new Call instance and return the Call object via prm.newCall. |
| 2143 | * In creating the new Call instance, the account should use the same |
| 2144 | * account as this call and the call ID must be set to prm.newCallId. |
| 2145 | * |
| 2146 | * If the new Call instance has been setup in onCallReplaceRequest(), |
| 2147 | * the prm.newCall should contain the new Call instance and application |
| 2148 | * MUST not change it. |
| 2149 | * |
| 2150 | * If application does not specify new Call object, library will reuse the |
| 2151 | * existing Call object for callbacks. In this case, any events from |
| 2152 | * both calls (replaced and new) will be delivered to the same Call object, |
| 2153 | * where the call ID will be switched back and forth between callbacks. |
| 2154 | * Application must be careful to not destroy the Call object when |
| 2155 | * receiving disconnection event of the replaced call after the transfer |
| 2156 | * process is completed. |
| 2157 | * |
| 2158 | * @param prm Callback parameter. |
| 2159 | */ |
| 2160 | virtual void onCallReplaced(OnCallReplacedParam &prm) |
| 2161 | { PJ_UNUSED_ARG(prm); } |
| 2162 | |
| 2163 | /** |
| 2164 | * Notify application when call has received new offer from remote |
| 2165 | * (i.e. re-INVITE/UPDATE with SDP is received). Application can |
| 2166 | * decide to accept/reject the offer by setting the code (default |
| 2167 | * is PJSIP_SC_OK (200)). If the offer is accepted, application can update |
| 2168 | * the call setting to be applied in the answer. When this callback is |
| 2169 | * not implemented, the default behavior is to accept the offer using |
| 2170 | * current call setting. |
| 2171 | * |
| 2172 | * @param prm Callback parameter. |
| 2173 | */ |
| 2174 | virtual void onCallRxOffer(OnCallRxOfferParam &prm) |
| 2175 | { PJ_UNUSED_ARG(prm); } |
| 2176 | |
| 2177 | /** |
| 2178 | * Notify application when call has received a re-INVITE offer from |
| 2179 | * the peer. It allows more fine-grained control over the response to |
| 2180 | * a re-INVITE. If application sets prm.isAsync to true, it can send |
| 2181 | * the reply manually using the function #pj::Call::answer() and setting |
| 2182 | * the SDP answer. Otherwise, by default the re-INVITE will be |
| 2183 | * answered automatically after the callback returns. |
| 2184 | * |
| 2185 | * Currently, this callback is only called for re-INVITE with |
| 2186 | * SDP, but app should be prepared to handle the case of re-INVITE |
| 2187 | * without SDP. |
| 2188 | * |
| 2189 | * Remarks: If manually answering at a later timing, application may |
| 2190 | * need to monitor onCallTsxState() callback to check whether |
| 2191 | * the re-INVITE is already answered automatically with |
| 2192 | * PJSIP_SC_REQUEST_TERMINATED (487) due to being cancelled. |
| 2193 | * |
| 2194 | * Note: onCallRxOffer() will still be called after this callback, |
| 2195 | * but only if prm.isAsync is false and prm.statusCode is PJSIP_SC_OK |
| 2196 | * (200). |
| 2197 | * |
| 2198 | * @param prm Callback parameter. |
| 2199 | */ |
| 2200 | virtual void onCallRxReinvite(OnCallRxReinviteParam &prm) |
| 2201 | { PJ_UNUSED_ARG(prm); } |
| 2202 | |
| 2203 | |
| 2204 | /** |
| 2205 | * Notify application when call has received INVITE with no SDP offer. |
| 2206 | * Application can update the call setting (e.g: add audio/video), or |
| 2207 | * enable/disable codecs, or update other media session settings from |
| 2208 | * within the callback, however, as mandated by the standard (RFC3261 |
| 2209 | * section 14.2), it must ensure that the update overlaps with the |
| 2210 | * existing media session (in codecs, transports, or other parameters) |
| 2211 | * that require support from the peer, this is to avoid the need for |
| 2212 | * the peer to reject the offer. |
| 2213 | * |
| 2214 | * When this callback is not implemented, the default behavior is to send |
| 2215 | * SDP offer using current active media session (with all enabled codecs |
| 2216 | * on each media type). |
| 2217 | * |
| 2218 | * @param prm Callback parameter. |
| 2219 | */ |
| 2220 | virtual void onCallTxOffer(OnCallTxOfferParam &prm) |
| 2221 | { PJ_UNUSED_ARG(prm); } |
| 2222 | |
| 2223 | /** |
| 2224 | * Notify application on incoming MESSAGE request. |
| 2225 | * |
| 2226 | * @param prm Callback parameter. |
| 2227 | */ |
| 2228 | virtual void onInstantMessage(OnInstantMessageParam &prm) |
| 2229 | { PJ_UNUSED_ARG(prm); } |
| 2230 | |
| 2231 | /** |
| 2232 | * Notify application about the delivery status of outgoing MESSAGE |
| 2233 | * request. |
| 2234 | * |
| 2235 | * @param prm Callback parameter. |
| 2236 | */ |
| 2237 | virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm) |
| 2238 | { PJ_UNUSED_ARG(prm); } |
| 2239 | |
| 2240 | /** |
| 2241 | * Notify application about typing indication. |
| 2242 | * |
| 2243 | * @param prm Callback parameter. |
| 2244 | */ |
| 2245 | virtual void onTypingIndication(OnTypingIndicationParam &prm) |
| 2246 | { PJ_UNUSED_ARG(prm); } |
| 2247 | |
| 2248 | /** |
| 2249 | * This callback is called when the call is about to resend the |
| 2250 | * INVITE request to the specified target, following the previously |
| 2251 | * received redirection response. |
| 2252 | * |
| 2253 | * Application may accept the redirection to the specified target, |
| 2254 | * reject this target only and make the session continue to try the next |
| 2255 | * target in the list if such target exists, stop the whole |
| 2256 | * redirection process altogether and cause the session to be |
| 2257 | * disconnected, or defer the decision to ask for user confirmation. |
| 2258 | * |
| 2259 | * This callback is optional, |
| 2260 | * the default behavior is to NOT follow the redirection response. |
| 2261 | * |
| 2262 | * @param prm Callback parameter. |
| 2263 | * |
| 2264 | * @return Action to be performed for the target. Set this |
| 2265 | * parameter to one of the value below: |
| 2266 | * - PJSIP_REDIRECT_ACCEPT: immediately accept the |
| 2267 | * redirection. When set, the call will immediately |
| 2268 | * resend INVITE request to the target. |
| 2269 | * - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept |
| 2270 | * the redirection and replace the To header with the |
| 2271 | * current target. When set, the call will immediately |
| 2272 | * resend INVITE request to the target. |
| 2273 | * - PJSIP_REDIRECT_REJECT: immediately reject this |
| 2274 | * target. The call will continue retrying with |
| 2275 | * next target if present, or disconnect the call |
| 2276 | * if there is no more target to try. |
| 2277 | * - PJSIP_REDIRECT_STOP: stop the whole redirection |
| 2278 | * process and immediately disconnect the call. The |
| 2279 | * onCallState() callback will be called with |
| 2280 | * PJSIP_INV_STATE_DISCONNECTED state immediately |
| 2281 | * after this callback returns. |
| 2282 | * - PJSIP_REDIRECT_PENDING: set to this value if |
| 2283 | * no decision can be made immediately (for example |
| 2284 | * to request confirmation from user). Application |
| 2285 | * then MUST call processRedirect() |
| 2286 | * to either accept or reject the redirection upon |
| 2287 | * getting user decision. |
| 2288 | */ |
| 2289 | virtual pjsip_redirect_op onCallRedirected(OnCallRedirectedParam &prm) |
| 2290 | { |
| 2291 | PJ_UNUSED_ARG(prm); |
| 2292 | return PJSIP_REDIRECT_STOP; |
| 2293 | } |
| 2294 | |
| 2295 | /** |
| 2296 | * This callback is called when media transport state is changed. |
| 2297 | * |
| 2298 | * @param prm Callback parameter. |
| 2299 | */ |
| 2300 | virtual void onCallMediaTransportState(OnCallMediaTransportStateParam &prm) |
| 2301 | { PJ_UNUSED_ARG(prm); } |
| 2302 | |
| 2303 | /** |
| 2304 | * Notification about media events such as video notifications. This |
| 2305 | * callback will most likely be called from media threads, thus |
| 2306 | * application must not perform heavy processing in this callback. |
| 2307 | * Especially, application must not destroy the call or media in this |
| 2308 | * callback. If application needs to perform more complex tasks to |
| 2309 | * handle the event, it should post the task to another thread. |
| 2310 | * |
| 2311 | * @param prm Callback parameter. |
| 2312 | */ |
| 2313 | virtual void onCallMediaEvent(OnCallMediaEventParam &prm) |
| 2314 | { PJ_UNUSED_ARG(prm); } |
| 2315 | |
| 2316 | /** |
| 2317 | * This callback can be used by application to implement custom media |
| 2318 | * transport adapter for the call, or to replace the media transport |
| 2319 | * with something completely new altogether. |
| 2320 | * |
| 2321 | * This callback is called when a new call is created. The library has |
| 2322 | * created a media transport for the call, and it is provided as the |
| 2323 | * \a mediaTp argument of this callback. The callback may change it |
| 2324 | * with the instance of media transport to be used by the call. |
| 2325 | * |
| 2326 | * @param prm Callback parameter. |
| 2327 | */ |
| 2328 | virtual void |
| 2329 | onCreateMediaTransport(OnCreateMediaTransportParam &prm) |
| 2330 | { PJ_UNUSED_ARG(prm); } |
| 2331 | |
| 2332 | /** |
| 2333 | * Warning: deprecated and may be removed in future release. |
| 2334 | * Application can set SRTP crypto settings (including keys) and |
| 2335 | * keying methods via AccountConfig.mediaConfig.srtpOpt. |
| 2336 | * See also ticket #2100. |
| 2337 | * |
| 2338 | * This callback is called when SRTP media transport is created. |
| 2339 | * Application can modify the SRTP setting \a srtpOpt to specify |
| 2340 | * the cryptos and keys which are going to be used. Note that |
| 2341 | * application should not modify the field |
| 2342 | * \a pjmedia_srtp_setting.close_member_tp and can only modify |
| 2343 | * the field \a pjmedia_srtp_setting.use for initial INVITE. |
| 2344 | * |
| 2345 | * @param prm Callback parameter. |
| 2346 | */ |
| 2347 | virtual void |
| 2348 | onCreateMediaTransportSrtp(OnCreateMediaTransportSrtpParam &prm) |
| 2349 | { PJ_UNUSED_ARG(prm); } |
| 2350 | |
| 2351 | private: |
| 2352 | friend class Endpoint; |
| 2353 | |
| 2354 | Account *acc; |
| 2355 | pjsua_call_id id; |
| 2356 | Token userData; |
| 2357 | std::vector<Media *> medias; |
| 2358 | Call *child; /* New outgoing call in call transfer. */ |
| 2359 | }; |
| 2360 | |
| 2361 | /** |
| 2362 | * @} // PJSUA2_CALL |
| 2363 | */ |
| 2364 | |
| 2365 | } // namespace pj |
| 2366 | |
| 2367 | #endif /* __PJSUA2_CALL_HPP__ */ |
| 2368 |