- Timestamp:
- Sep 20, 2007 1:19:03 PM (17 years ago)
- Location:
- pjproject/branches/pjproject-0.5-stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/pjproject-0.5-stable/pjmedia/include/pjmedia/rtcp.h
r974 r1447 59 59 struct pjmedia_rtcp_sr 60 60 { 61 pj_uint32_t ssrc; /**< SSRC identification. */62 61 pj_uint32_t ntp_sec; /**< NTP time, seconds part. */ 63 62 pj_uint32_t ntp_frac; /**< NTP time, fractions part. */ … … 118 117 #endif 119 118 unsigned length:16; /**< packet length */ 119 pj_uint32_t ssrc; /**< SSRC identification */ 120 120 }; 121 121 … … 130 130 * manually by application. 131 131 */ 132 struct pjmedia_rtcp_pkt132 typedef struct pjmedia_rtcp_sr_pkt 133 133 { 134 134 pjmedia_rtcp_common common; /**< Common header. */ 135 135 pjmedia_rtcp_sr sr; /**< Sender report. */ 136 136 pjmedia_rtcp_rr rr; /**< variable-length list */ 137 }; 138 139 /** 140 * @see pjmedia_rtcp_pkt 141 */ 142 typedef struct pjmedia_rtcp_pkt pjmedia_rtcp_pkt; 137 } pjmedia_rtcp_sr_pkt; 138 139 /** 140 * This structure declares RTCP RR (Receiver Report) packet. 141 */ 142 typedef struct pjmedia_rtcp_rr_pkt 143 { 144 pjmedia_rtcp_common common; /**< Common header. */ 145 pjmedia_rtcp_rr rr; /**< variable-length list */ 146 } pjmedia_rtcp_rr_pkt; 143 147 144 148 … … 251 255 { 252 256 char *name; /**< Name identification. */ 253 pjmedia_rtcp_pkt rtcp_pkt; /**< Cached RTCP packet. */ 257 pjmedia_rtcp_sr_pkt rtcp_sr_pkt;/**< Cached RTCP packet. */ 258 pjmedia_rtcp_rr_pkt rtcp_rr_pkt;/**< Cached RTCP RR packet. */ 254 259 255 260 pjmedia_rtp_seq_session seq_ctrl; /**< RTCP sequence number control. */ … … 310 315 * @return PJ_SUCCESS on success. 311 316 */ 312 PJ_DE F(pj_status_t) pjmedia_rtcp_get_ntp_time(const pjmedia_rtcp_session *sess,313 pjmedia_rtcp_ntp_rec *ntp);317 PJ_DECL(pj_status_t) pjmedia_rtcp_get_ntp_time(const pjmedia_rtcp_session *sess, 318 pjmedia_rtcp_ntp_rec *ntp); 314 319 315 320 … … 364 369 365 370 /** 366 * Build a RTCP SR+RR packet to be transmitted to remote RTP peer. 371 * Build a RTCP packet to be transmitted to remote RTP peer. This will 372 * create RTCP Sender Report (SR) or Receiver Report (RR) depending on 373 * whether the endpoint has been transmitting RTP since the last interval. 367 374 * Note that this function will reset the interval counters (such as 368 375 * the ones to calculate fraction lost) in the session. … … 370 377 * @param session The RTCP session. 371 378 * @param rtcp_pkt Upon return, it will contain pointer to the 372 * RTCP packet .379 * RTCP packet, which can be RTCP SR or RR. 373 380 * @param len Upon return, it will indicate the size of 374 381 * the RTCP packet. 375 382 */ 376 383 PJ_DECL(void) pjmedia_rtcp_build_rtcp( pjmedia_rtcp_session *session, 377 pjmedia_rtcp_pkt **rtcp_pkt, 378 int *len); 384 void **rtcp_pkt, int *len); 379 385 380 386 -
pjproject/branches/pjproject-0.5-stable/pjmedia/src/pjmedia/rtcp.c
r974 r1447 131 131 pj_uint32_t ssrc) 132 132 { 133 pjmedia_rtcp_ pkt *rtcp_pkt = &sess->rtcp_pkt;133 pjmedia_rtcp_sr_pkt *sr_pkt = &sess->rtcp_sr_pkt; 134 134 pj_time_val now; 135 135 … … 141 141 142 142 /* Name */ 143 sess->name = name ? name : THIS_FILE,143 sess->name = name ? name : (char*)THIS_FILE, 144 144 145 145 /* Set clock rate */ … … 147 147 sess->pkt_size = samples_per_frame; 148 148 149 /* Init common RTCP header */ 150 rtcp_pkt->common.version = 2; 151 rtcp_pkt->common.count = 1; 152 rtcp_pkt->common.pt = RTCP_SR; 153 rtcp_pkt->common.length = pj_htons(12); 154 155 /* Init SR */ 156 rtcp_pkt->sr.ssrc = pj_htonl(ssrc); 157 149 /* Init common RTCP SR header */ 150 sr_pkt->common.version = 2; 151 sr_pkt->common.count = 1; 152 sr_pkt->common.pt = RTCP_SR; 153 sr_pkt->common.length = pj_htons(12); 154 sr_pkt->common.ssrc = pj_htonl(ssrc); 155 156 /* Copy to RTCP RR header */ 157 pj_memcpy(&sess->rtcp_rr_pkt.common, &sr_pkt->common, 158 sizeof(pjmedia_rtcp_common)); 159 sess->rtcp_rr_pkt.common.pt = RTCP_RR; 160 sess->rtcp_rr_pkt.common.length = pj_htons(7); 161 158 162 /* Get time and timestamp base and frequency */ 159 163 pj_gettimeofday(&now); … … 333 337 pj_size_t size) 334 338 { 335 const pjmedia_rtcp_common *common =pkt;339 pjmedia_rtcp_common *common = (pjmedia_rtcp_common*) pkt; 336 340 const pjmedia_rtcp_rr *rr = NULL; 337 341 const pjmedia_rtcp_sr *sr = NULL; … … 341 345 if (common->pt == RTCP_SR) { 342 346 sr = (pjmedia_rtcp_sr*) (((char*)pkt) + sizeof(pjmedia_rtcp_common)); 343 if (common->count > 0 && size >= (sizeof(pjmedia_rtcp_ pkt))) {347 if (common->count > 0 && size >= (sizeof(pjmedia_rtcp_sr_pkt))) { 344 348 rr = (pjmedia_rtcp_rr*)(((char*)pkt) + (sizeof(pjmedia_rtcp_common) 345 349 + sizeof(pjmedia_rtcp_sr))); 346 350 } 347 351 } else if (common->pt == RTCP_RR && common->count > 0) 348 rr = (pjmedia_rtcp_rr*)(((char*)pkt) + sizeof(pjmedia_rtcp_common) +4);352 rr = (pjmedia_rtcp_rr*)(((char*)pkt) + sizeof(pjmedia_rtcp_common)); 349 353 350 354 … … 530 534 531 535 PJ_DEF(void) pjmedia_rtcp_build_rtcp(pjmedia_rtcp_session *sess, 532 pjmedia_rtcp_pkt **ret_p_pkt, 533 int *len) 536 void **ret_p_pkt, int *len) 534 537 { 535 538 pj_uint32_t expected, expected_interval, received_interval, lost_interval; 536 pjmedia_rtcp_pkt *rtcp_pkt = &sess->rtcp_pkt; 539 pjmedia_rtcp_common *common; 540 pjmedia_rtcp_sr *sr; 541 pjmedia_rtcp_rr *rr; 537 542 pj_timestamp ts_now; 538 543 pjmedia_rtcp_ntp_rec ntp; 539 540 /* Packet count */ 541 rtcp_pkt->sr.sender_pcount = pj_htonl(sess->stat.tx.pkt); 542 543 /* Octets count */ 544 rtcp_pkt->sr.sender_bcount = pj_htonl(sess->stat.tx.bytes); 544 545 /* Get current NTP time. */ 546 pj_get_timestamp(&ts_now); 547 pjmedia_rtcp_get_ntp_time(sess, &ntp); 548 549 550 /* See if we have transmitted RTP packets since last time we 551 * sent RTCP SR. 552 */ 553 if (sess->stat.tx.pkt != pj_ntohl(sess->rtcp_sr_pkt.sr.sender_pcount)) { 554 555 /* So we should send RTCP SR */ 556 *ret_p_pkt = (void*) &sess->rtcp_sr_pkt; 557 *len = sizeof(pjmedia_rtcp_sr_pkt); 558 common = &sess->rtcp_sr_pkt.common; 559 rr = &sess->rtcp_sr_pkt.rr; 560 sr = &sess->rtcp_sr_pkt.sr; 561 562 /* Update packet count */ 563 sr->sender_pcount = pj_htonl(sess->stat.tx.pkt); 564 565 /* Update octets count */ 566 sr->sender_bcount = pj_htonl(sess->stat.tx.bytes); 567 568 /* Fill in NTP timestamp in SR. */ 569 sr->ntp_sec = pj_htonl(ntp.hi); 570 sr->ntp_frac = pj_htonl(ntp.lo); 571 572 TRACE_((sess->name, "TX RTCP SR: ntp_ts=%p", 573 ((ntp.hi & 0xFFFF) << 16) + ((ntp.lo & 0xFFFF0000) 574 >> 16))); 575 576 577 } else { 578 /* We should send RTCP RR then */ 579 *ret_p_pkt = (void*) &sess->rtcp_rr_pkt; 580 *len = sizeof(pjmedia_rtcp_rr_pkt); 581 common = &sess->rtcp_rr_pkt.common; 582 rr = &sess->rtcp_rr_pkt.rr; 583 sr = NULL; 584 } 545 585 546 586 /* SSRC and last_seq */ 547 rtcp_pkt->rr.ssrc = pj_htonl(sess->peer_ssrc); 548 rtcp_pkt->rr.last_seq = (sess->seq_ctrl.cycles & 0xFFFF0000L); 549 rtcp_pkt->rr.last_seq += sess->seq_ctrl.max_seq; 550 rtcp_pkt->rr.last_seq = pj_htonl(rtcp_pkt->rr.last_seq); 587 rr->ssrc = pj_htonl(sess->peer_ssrc); 588 rr->last_seq = (sess->seq_ctrl.cycles & 0xFFFF0000L); 589 /* Since this is an "+=" operation, make sure we update last_seq on 590 * both RR and SR. 591 */ 592 sess->rtcp_sr_pkt.rr.last_seq += sess->seq_ctrl.max_seq; 593 sess->rtcp_rr_pkt.rr.last_seq += sess->seq_ctrl.max_seq; 594 rr->last_seq = pj_htonl(rr->last_seq); 551 595 552 596 553 597 /* Jitter */ 554 r tcp_pkt->rr.jitter = pj_htonl(sess->jitter >> 4);598 rr->jitter = pj_htonl(sess->jitter >> 4); 555 599 556 600 557 601 /* Total lost. */ 558 expected = pj_ntohl(r tcp_pkt->rr.last_seq) - sess->seq_ctrl.base_seq;602 expected = pj_ntohl(rr->last_seq) - sess->seq_ctrl.base_seq; 559 603 560 604 /* This is bug: total lost already calculated on each incoming RTP! … … 565 609 */ 566 610 567 r tcp_pkt->rr.total_lost_2 = (sess->stat.rx.loss >> 16) & 0xFF;568 r tcp_pkt->rr.total_lost_1 = (sess->stat.rx.loss >> 8) & 0xFF;569 r tcp_pkt->rr.total_lost_0 = (sess->stat.rx.loss & 0xFF);611 rr->total_lost_2 = (sess->stat.rx.loss >> 16) & 0xFF; 612 rr->total_lost_1 = (sess->stat.rx.loss >> 8) & 0xFF; 613 rr->total_lost_0 = (sess->stat.rx.loss & 0xFF); 570 614 571 615 /* Fraction lost calculation */ … … 576 620 sess->rx_prior = sess->received; 577 621 578 lost_interval = expected_interval - received_interval; 622 if (expected_interval >= received_interval) 623 lost_interval = expected_interval - received_interval; 624 else 625 lost_interval = 0; 579 626 580 627 if (expected_interval==0 || lost_interval == 0) { 581 r tcp_pkt->rr.fract_lost = 0;628 rr->fract_lost = 0; 582 629 } else { 583 rtcp_pkt->rr.fract_lost = (lost_interval << 8) / expected_interval; 584 } 585 586 /* Get current NTP time. */ 587 pj_get_timestamp(&ts_now); 588 pjmedia_rtcp_get_ntp_time(sess, &ntp); 589 590 /* Fill in NTP timestamp in SR. */ 591 rtcp_pkt->sr.ntp_sec = pj_htonl(ntp.hi); 592 rtcp_pkt->sr.ntp_frac = pj_htonl(ntp.lo); 593 594 TRACE_((sess->name, "TX RTCP SR: ntp_ts=%p", 595 ((ntp.hi & 0xFFFF) << 16) + ((ntp.lo & 0xFFFF0000) 596 >> 16))); 597 630 rr->fract_lost = (lost_interval << 8) / expected_interval; 631 } 632 598 633 if (sess->rx_lsr_time.u64 == 0 || sess->rx_lsr == 0) { 599 r tcp_pkt->rr.lsr = 0;600 r tcp_pkt->rr.dlsr = 0;634 rr->lsr = 0; 635 rr->dlsr = 0; 601 636 } else { 602 637 pj_timestamp ts; … … 611 646 LSR is the middle 32bit of the last SR NTP time received. 612 647 */ 613 r tcp_pkt->rr.lsr = pj_htonl(lsr);648 rr->lsr = pj_htonl(lsr); 614 649 615 650 /* Fill in DLSR. … … 623 658 /* Get DLSR */ 624 659 dlsr = (pj_uint32_t)(ts.u64 - lsr_time); 625 r tcp_pkt->rr.dlsr = pj_htonl(dlsr);660 rr->dlsr = pj_htonl(dlsr); 626 661 627 662 TRACE_((sess->name,"Tx RTCP RR: lsr=%p, lsr_time=%p, now=%p, dlsr=%p" … … 638 673 pj_gettimeofday(&sess->stat.rx.update); 639 674 sess->stat.rx.update_cnt++; 640 641 642 /* Return pointer. */643 *ret_p_pkt = rtcp_pkt;644 *len = sizeof(pjmedia_rtcp_pkt);645 675 } 646 676 -
pjproject/branches/pjproject-0.5-stable/pjmedia/src/pjmedia/stream.c
r1047 r1447 63 63 { 64 64 int event; 65 pj_uint32_t start_ts;65 pj_uint32_t duration; 66 66 }; 67 67 … … 167 167 static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame) 168 168 { 169 pjmedia_stream *stream = port->port_data.pdata;169 pjmedia_stream *stream = (pjmedia_stream*) port->port_data.pdata; 170 170 pjmedia_channel *channel = stream->dec; 171 171 unsigned samples_count, samples_per_frame, samples_required; … … 192 192 stream->codec_param.info.channel_cnt / 193 193 1000; 194 p_out_samp = frame->buf;194 p_out_samp = (pj_int16_t*) frame->buf; 195 195 196 196 for (samples_count=0; samples_count < samples_required; … … 374 374 */ 375 375 static void create_dtmf_payload(pjmedia_stream *stream, 376 struct pjmedia_frame *frame_out) 376 struct pjmedia_frame *frame_out, 377 int *first, int *last) 377 378 { 378 379 pjmedia_rtp_dtmf_event *event; 379 380 struct dtmf *digit = &stream->tx_dtmf_buf[0]; 380 unsigned duration;381 381 pj_uint32_t cur_ts; 382 382 383 383 pj_assert(sizeof(pjmedia_rtp_dtmf_event) == 4); 384 384 385 event = frame_out->buf; 385 *first = *last = 0; 386 387 event = (pjmedia_rtp_dtmf_event*) frame_out->buf; 386 388 cur_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts); 387 duration = cur_ts - digit->start_ts; 389 390 if (digit->duration == 0) { 391 PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c", 392 digitmap[digit->event])); 393 *first = 1; 394 } 395 396 digit->duration += stream->port.info.samples_per_frame; 388 397 389 398 event->event = (pj_uint8_t)digit->event; 390 399 event->e_vol = 10; 391 event->duration = pj_htons((pj_uint16_t)duration); 392 393 if (duration >= PJMEDIA_DTMF_DURATION) { 400 event->duration = pj_htons((pj_uint16_t)digit->duration); 401 402 403 if (digit->duration >= PJMEDIA_DTMF_DURATION) { 404 394 405 event->e_vol |= 0x80; 406 *last = 1; 395 407 396 408 /* Prepare next digit. */ 397 409 pj_mutex_lock(stream->jb_mutex); 410 398 411 pj_array_erase(stream->tx_dtmf_buf, sizeof(stream->tx_dtmf_buf[0]), 399 412 stream->tx_dtmf_count, 0); 400 413 --stream->tx_dtmf_count; 401 414 402 stream->tx_dtmf_buf[0].start_ts = cur_ts;403 415 pj_mutex_unlock(stream->jb_mutex); 404 405 if (stream->tx_dtmf_count) { 406 PJ_LOG(5,(stream->port.info.name.ptr, 407 "Sending DTMF digit id %c", 408 digitmap[stream->tx_dtmf_buf[0].event])); 409 } 410 411 } else if (duration == 0) { 412 PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c", 413 digitmap[digit->event])); 414 } 415 416 } 416 417 417 418 frame_out->size = 4; … … 439 440 } else if (timestamp - stream->rtcp_last_tx >= stream->rtcp_interval) { 440 441 441 pjmedia_rtcp_pkt*rtcp_pkt;442 void *rtcp_pkt; 442 443 int len; 443 444 … … 515 516 const pjmedia_frame *frame ) 516 517 { 517 pjmedia_stream *stream = port->port_data.pdata;518 pjmedia_stream *stream = (pjmedia_stream*) port->port_data.pdata; 518 519 pjmedia_channel *channel = stream->enc; 519 520 pj_status_t status = 0; … … 522 523 void *rtphdr; 523 524 int rtphdrlen; 524 525 int inc_timestamp = 0; 525 526 526 527 /* Don't do anything if stream is paused */ … … 551 552 */ 552 553 if (stream->tx_dtmf_count) { 553 554 create_dtmf_payload(stream, &frame_out); 555 556 /* Encapsulate. */ 554 int first=0, last=0; 555 556 create_dtmf_payload(stream, &frame_out, &first, &last); 557 558 /* Encapsulate into RTP packet. Note that: 559 * - RTP marker should be set on the beginning of a new event 560 * - RTP timestamp is constant for the same packet. 561 */ 557 562 status = pjmedia_rtp_encode_rtp( &channel->rtp, 558 stream->tx_event_pt, 0,559 frame_out.size, ts_len,563 stream->tx_event_pt, first, 564 frame_out.size, (first?ts_len:0), 560 565 (const void**)&rtphdr, 561 566 &rtphdrlen); 567 568 if (last) { 569 /* This is the last packet for the event. 570 * Increment the RTP timestamp of the RTP session, for next 571 * RTP packets. 572 */ 573 inc_timestamp = PJMEDIA_DTMF_DURATION - ts_len; 574 } 562 575 563 576 } else if (frame->type != PJMEDIA_FRAME_TYPE_NONE) { … … 663 676 pj_memcpy(channel->out_pkt, rtphdr, sizeof(pjmedia_rtp_hdr)); 664 677 678 /* Special case for DTMF: timestamp remains constant for 679 * the same event, and is only updated after a complete event 680 * has been transmitted. 681 */ 682 if (inc_timestamp) { 683 pjmedia_rtp_encode_rtp( &channel->rtp, stream->tx_event_pt, 0, 684 0, inc_timestamp, NULL, NULL); 685 } 665 686 666 687 /* Set RTP marker bit if currently not streaming */ 667 688 if (stream->is_streaming == PJ_FALSE) { 668 pjmedia_rtp_hdr *rtp = channel->out_pkt;689 pjmedia_rtp_hdr *rtp = (pjmedia_rtp_hdr*) channel->out_pkt; 669 690 670 691 rtp->m = 1; … … 698 719 const pjmedia_frame *frame ) 699 720 { 700 pjmedia_stream *stream = port->port_data.pdata;721 pjmedia_stream *stream = (pjmedia_stream*) port->port_data.pdata; 701 722 pjmedia_frame tmp_zero_frame; 702 723 unsigned samples_per_frame; … … 831 852 const void *payload, unsigned payloadlen) 832 853 { 833 const pjmedia_rtp_dtmf_event *event =payload;854 pjmedia_rtp_dtmf_event *event = (pjmedia_rtp_dtmf_event*) payload; 834 855 835 856 /* Check compiler packing. */ … … 903 924 904 925 { 905 pjmedia_stream *stream = data;926 pjmedia_stream *stream = (pjmedia_stream*) data; 906 927 pjmedia_channel *channel = stream->dec; 907 928 const pjmedia_rtp_hdr *hdr; … … 919 940 920 941 /* Ignore keep-alive packets */ 921 if (bytes_read < sizeof(pjmedia_rtp_hdr))942 if (bytes_read < (pj_ssize_t) sizeof(pjmedia_rtp_hdr)) 922 943 return; 923 944 … … 1053 1074 pj_ssize_t bytes_read) 1054 1075 { 1055 pjmedia_stream *stream = data;1076 pjmedia_stream *stream = (pjmedia_stream*) data; 1056 1077 1057 1078 /* Check for errors */ … … 1081 1102 /* Allocate memory for channel descriptor */ 1082 1103 1083 channel = pj_pool_zalloc(pool, sizeof(pjmedia_channel));1104 channel = (pjmedia_channel*) pj_pool_zalloc(pool, sizeof(pjmedia_channel)); 1084 1105 PJ_ASSERT_RETURN(channel != NULL, PJ_ENOMEM); 1085 1106 … … 1147 1168 /* Allocate the media stream: */ 1148 1169 1149 stream = pj_pool_zalloc(pool, sizeof(pjmedia_stream));1170 stream = (pjmedia_stream*) pj_pool_zalloc(pool, sizeof(pjmedia_stream)); 1150 1171 PJ_ASSERT_RETURN(stream != NULL, PJ_ENOMEM); 1151 1172 1152 1173 /* Init stream/port name */ 1153 name.ptr = pj_pool_alloc(pool, M);1174 name.ptr = (char*) pj_pool_alloc(pool, M); 1154 1175 name.slen = pj_ansi_snprintf(name.ptr, M, "strm%p", stream); 1155 1176 … … 1263 1284 /* Allocate buffer */ 1264 1285 stream->enc_buf_size = stream->port.info.clock_rate * ptime / 1000; 1265 stream->enc_buf = pj_pool_alloc(pool, stream->enc_buf_size * 2); 1286 stream->enc_buf = (pj_int16_t*) 1287 pj_pool_alloc(pool, stream->enc_buf_size * 2); 1266 1288 1267 1289 } else { … … 1536 1558 1537 1559 if (stream->tx_dtmf_count+digit_char->slen >= 1538 PJ_ARRAY_SIZE(stream->tx_dtmf_buf))1560 (long)PJ_ARRAY_SIZE(stream->tx_dtmf_buf)) 1539 1561 { 1540 1562 status = PJ_ETOOMANY; … … 1572 1594 1573 1595 stream->tx_dtmf_buf[stream->tx_dtmf_count+i].event = pt; 1596 stream->tx_dtmf_buf[stream->tx_dtmf_count+i].duration = 0; 1574 1597 } 1575 1598 … … 1577 1600 goto on_return; 1578 1601 1579 /* Init start_ts and end_ts only for the first digit.1580 * Subsequent digits are initialized on the fly.1581 */1582 if (stream->tx_dtmf_count ==0) {1583 pj_uint32_t start_ts;1584 1585 start_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts);1586 stream->tx_dtmf_buf[0].start_ts = start_ts;1587 }1588 1589 1602 /* Increment digit count only if all digits are valid. */ 1590 1603 stream->tx_dtmf_count += digit_char->slen; 1591 1592 1604 } 1593 1605 … … 1646 1658 * Set callback to be called upon receiving DTMF digits. 1647 1659 */ 1648 PJ_DEF(pj_status_t) 1649 pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream, 1660 PJ_DEF(pj_status_t) pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream, 1650 1661 void (*cb)(pjmedia_stream*, 1651 1662 void *user_data, -
pjproject/branches/pjproject-0.5-stable/pjsip-apps/src/samples/siprtp.c
r974 r1447 75 75 #include <stdlib.h> 76 76 77 /* Uncomment these to disable threads. 78 * NOTE: 79 * when threading is disabled, siprtp won't transmit any 80 * RTP packets. 81 */ 82 /* 83 #undef PJ_HAS_THREADS 84 #define PJ_HAS_THREADS 0 85 */ 86 77 87 78 88 #if PJ_HAS_HIGH_RES_TIMER==0 … … 402 412 * initialized. 403 413 */ 414 #if PJ_HAS_THREADS 404 415 status = pjmedia_endpt_create(&app.cp.factory, NULL, 1, &app.med_endpt); 416 #else 417 status = pjmedia_endpt_create(&app.cp.factory, 418 pjsip_endpt_get_ioqueue(app.sip_endpt), 419 0, &app.med_endpt); 420 #endif 405 421 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 406 422 … … 1327 1343 * Time to send RTCP packet. 1328 1344 */ 1329 pjmedia_rtcp_pkt*rtcp_pkt;1345 void *rtcp_pkt; 1330 1346 int rtcp_len; 1331 1347 pj_ssize_t size; … … 1436 1452 /* Start media thread. */ 1437 1453 audio->thread_quit_flag = 0; 1454 #if PJ_HAS_THREADS 1438 1455 status = pj_thread_create( inv->pool, "media", &media_thread, audio, 1439 1456 0, 0, &audio->thread); … … 1442 1459 return; 1443 1460 } 1461 #endif 1444 1462 1445 1463 /* Set the media as active */ … … 2071 2089 2072 2090 /* Start worker threads */ 2091 #if PJ_HAS_THREADS 2073 2092 for (i=0; i<app.thread_count; ++i) { 2074 2093 pj_thread_create( app.pool, "app", &sip_worker_thread, NULL, 2075 2094 0, 0, &app.sip_thread[i]); 2076 2095 } 2096 #endif 2077 2097 2078 2098 /* If URL is specified, then make call immediately */ … … 2097 2117 pj_thread_sleep(200); 2098 2118 } else { 2119 #if PJ_HAS_THREADS 2099 2120 /* Start user interface loop */ 2100 2121 console_main(); 2122 #endif 2101 2123 } 2102 2124 … … 2106 2128 app.max_calls)); 2107 2129 2130 #if PJ_HAS_THREADS 2108 2131 /* Start user interface loop */ 2109 2132 console_main(); 2110 2111 } 2112 2133 #endif 2134 } 2135 2136 #if !PJ_HAS_THREADS 2137 PJ_LOG(3,(THIS_FILE, "Press Ctrl-C to quit")); 2138 for (;;) { 2139 pj_time_val t = {0, 10}; 2140 pjsip_endpt_handle_events(app.sip_endpt, &t); 2141 } 2142 #endif 2113 2143 2114 2144 /* Shutting down... */
Note: See TracChangeset
for help on using the changeset viewer.