Changeset 633 for pjproject/trunk
- Timestamp:
- Jul 29, 2006 11:14:47 AM (18 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/conference.h
r622 r633 173 173 174 174 /** 175 * Add stream port to the conference bridge. By default, the new conference 176 * port will have both TX and RX enabled, but it is not connected to any 177 * other ports. 178 * 179 * Application SHOULD call #pjmedia_conf_connect_port() to enable audio 180 * transmission and receipt to/from this port. 175 * Add media port to the conference bridge. 176 * 177 * By default, the new conference port will have both TX and RX enabled, 178 * but it is not connected to any other ports. Application SHOULD call 179 * #pjmedia_conf_connect_port() to enable audio transmission and receipt 180 * to/from this port. 181 * 182 * Once the media port is connected to other port(s) in the bridge, 183 * the bridge will continuosly call get_frame() and put_frame() to the 184 * port, allowing media to flow to/from the port. 181 185 * 182 186 * @param conf The conference bridge. … … 198 202 199 203 204 /** 205 * Create and add a passive media port to the conference bridge. Unlike 206 * "normal" media port that is added with #pjmedia_conf_add_port(), media 207 * port created with this function will not have its get_frame() and 208 * put_frame() called by the bridge; instead, application MUST continuosly 209 * call these functions to the port, to allow media to flow from/to the 210 * port. 211 * 212 * Upon return of this function, application will be given two objects: 213 * the slot number of the port in the bridge, and pointer to the media 214 * port where application MUST start calling get_frame() and put_frame() 215 * to the port. 216 * 217 * @param conf The conference bridge. 218 * @param pool Pool to allocate buffers etc for this port. 219 * @param name Name to be assigned to the port. 220 * @param clock_rate Clock rate/sampling rate. 221 * @param channel_count Number of channels. 222 * @param samples_per_frame Number of samples per frame. 223 * @param bits_per_sample Number of bits per sample. 224 * @param options Options (should be zero at the moment). 225 * @param p_slot Pointer to receive the slot index of the port in 226 * the conference bridge. 227 * @param p_port Pointer to receive the port instance. 228 * 229 * @return PJ_SUCCESS on success, or the appropriate error 230 * code. 231 */ 232 PJ_DECL(pj_status_t) pjmedia_conf_add_passive_port( pjmedia_conf *conf, 233 pj_pool_t *pool, 234 const pj_str_t *name, 235 unsigned clock_rate, 236 unsigned channel_count, 237 unsigned samples_per_frame, 238 unsigned bits_per_sample, 239 unsigned options, 240 unsigned *p_slot, 241 pjmedia_port **p_port ); 242 200 243 201 244 /** -
pjproject/trunk/pjmedia/include/pjmedia/port.h
r631 r633 292 292 { 293 293 PJMEDIA_FRAME_TYPE_NONE, /**< No frame. */ 294 PJMEDIA_FRAME_TYPE_CNG, /**< Silence audio frame. */295 294 PJMEDIA_FRAME_TYPE_AUDIO /**< Normal audio frame. */ 296 295 … … 333 332 { 334 333 pjmedia_port_info info; /**< Port information. */ 335 void *user_data; /**< User data. */ 334 335 /** Port data can be used by the port creator to attach arbitrary 336 * value to be associated with the port. 337 */ 338 struct port_data { 339 void *pdata; /**< Pointer data. */ 340 long ldata; /**< Long data. */ 341 } port_data; 336 342 337 343 /** -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r582 r633 30 30 #include <pj/string.h> 31 31 32 32 33 /* CONF_DEBUG enables detailed operation of the conference bridge. 33 34 * Beware that it prints large amounts of logs (several lines per frame). … … 58 59 #define BYTES_PER_SAMPLE 2 59 60 61 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'F') 62 #define SIGNATURE_PORT PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'P') 60 63 #define NORMAL_LEVEL 128 61 64 #define SLOT_TYPE unsigned … … 197 200 static pj_status_t get_frame(pjmedia_port *this_port, 198 201 pjmedia_frame *frame); 202 static pj_status_t get_frame_pasv(pjmedia_port *this_port, 203 pjmedia_frame *frame); 199 204 static pj_status_t destroy_port(pjmedia_port *this_port); 200 205 … … 329 334 } 330 335 331 /* 332 * Create port zero for the sound device. 333 */ 334 static pj_status_t create_sound_port( pj_pool_t *pool, 335 pjmedia_conf *conf ) 336 337 /* 338 * Add passive port. 339 */ 340 static pj_status_t create_pasv_port( pjmedia_conf *conf, 341 pj_pool_t *pool, 342 const pj_str_t *name, 343 pjmedia_port *port, 344 struct conf_port **p_conf_port) 336 345 { 337 346 struct conf_port *conf_port; 338 pj_str_t name = { "Master/sound", 12 };339 347 unsigned i; 340 348 pj_status_t status; 341 349 342 343 344 350 /* Create port */ 345 status = create_conf_port(pool, conf, NULL, &name, &conf_port);351 status = create_conf_port(pool, conf, port, name, &conf_port); 346 352 if (status != PJ_SUCCESS) 347 goto on_error;348 349 /* Sound devicehas rx buffers. */353 return status; 354 355 /* Passive port has rx buffers. */ 350 356 for (i=0; i<RX_BUF_COUNT; ++i) { 351 357 conf_port->snd_buf[i] = pj_pool_zalloc(pool, conf->samples_per_frame * 352 358 sizeof(conf_port->snd_buf[0][0])); 353 359 if (conf_port->snd_buf[i] == NULL) { 354 status = PJ_ENOMEM; 355 goto on_error; 360 return PJ_ENOMEM; 356 361 } 357 362 } … … 359 364 conf_port->snd_read_pos = 0; 360 365 361 362 /* Set to port zero */ 363 conf->ports[0] = conf_port; 364 conf->port_cnt++; 366 *p_conf_port = conf_port; 367 368 return PJ_SUCCESS; 369 } 370 371 372 /* 373 * Create port zero for the sound device. 374 */ 375 static pj_status_t create_sound_port( pj_pool_t *pool, 376 pjmedia_conf *conf ) 377 { 378 struct conf_port *conf_port; 379 pj_str_t name = { "Master/sound", 12 }; 380 pj_status_t status; 381 382 383 status = create_pasv_port(conf, pool, &name, NULL, &conf_port); 384 if (status != PJ_SUCCESS) 385 return status; 365 386 366 387 … … 395 416 396 417 418 /* Add the port to the bridge */ 419 conf->ports[0] = conf_port; 420 conf->port_cnt++; 421 422 397 423 PJ_LOG(5,(THIS_FILE, "Sound device successfully created for port 0")); 398 424 return PJ_SUCCESS; 399 400 on_error:401 return status;402 403 425 } 404 426 … … 416 438 { 417 439 pjmedia_conf *conf; 440 const pj_str_t name = { "Conf", 4 }; 418 441 pj_status_t status; 419 442 … … 443 466 PJ_ASSERT_RETURN(conf->master_port, PJ_ENOMEM); 444 467 445 conf->master_port->info.bits_per_sample = bits_per_sample; 446 conf->master_port->info.bytes_per_frame = samples_per_frame * 447 bits_per_sample / 8; 448 conf->master_port->info.channel_count = channel_count; 449 conf->master_port->info.encoding_name = pj_str("pcm"); 450 conf->master_port->info.has_info = 1; 451 conf->master_port->info.name = pj_str("sound-dev"); 452 conf->master_port->info.need_info = 0; 453 conf->master_port->info.pt = 0xFF; 454 conf->master_port->info.clock_rate = clock_rate; 455 conf->master_port->info.samples_per_frame = samples_per_frame; 456 conf->master_port->info.signature = 0; 457 conf->master_port->info.type = PJMEDIA_TYPE_AUDIO; 468 pjmedia_port_info_init(&conf->master_port->info, &name, SIGNATURE, 469 clock_rate, channel_count, bits_per_sample, 470 samples_per_frame); 471 472 conf->master_port->port_data.pdata = conf; 473 conf->master_port->port_data.ldata = 0; 458 474 459 475 conf->master_port->get_frame = &get_frame; 460 476 conf->master_port->put_frame = &put_frame; 461 477 conf->master_port->on_destroy = &destroy_port; 462 463 conf->master_port->user_data = conf;464 478 465 479 … … 545 559 static pj_status_t destroy_port(pjmedia_port *this_port) 546 560 { 547 pjmedia_conf *conf = this_port-> user_data;561 pjmedia_conf *conf = this_port->port_data.pdata; 548 562 return pjmedia_conf_destroy(conf); 549 563 } … … 630 644 return PJ_SUCCESS; 631 645 } 646 647 648 /* 649 * Add passive port. 650 */ 651 PJ_DEF(pj_status_t) pjmedia_conf_add_passive_port( pjmedia_conf *conf, 652 pj_pool_t *pool, 653 const pj_str_t *name, 654 unsigned clock_rate, 655 unsigned channel_count, 656 unsigned samples_per_frame, 657 unsigned bits_per_sample, 658 unsigned options, 659 unsigned *p_slot, 660 pjmedia_port **p_port ) 661 { 662 struct conf_port *conf_port; 663 pjmedia_port *port; 664 unsigned index; 665 pj_str_t tmp; 666 pj_status_t status; 667 668 PJ_ASSERT_RETURN(conf && pool, PJ_EINVAL); 669 670 /* For this version of PJMEDIA, port MUST have the same number of 671 * PCM channels. 672 */ 673 if (channel_count != conf->channel_count) { 674 pj_assert(!"Number of channels mismatch"); 675 return PJMEDIA_ENCCHANNEL; 676 } 677 678 /* For this version, options must be zero */ 679 PJ_ASSERT_RETURN(options == 0, PJ_EINVAL); 680 PJ_UNUSED_ARG(options); 681 682 pj_mutex_lock(conf->mutex); 683 684 if (conf->port_cnt >= conf->max_ports) { 685 pj_assert(!"Too many ports"); 686 pj_mutex_unlock(conf->mutex); 687 return PJ_ETOOMANY; 688 } 689 690 /* Find empty port in the conference bridge. */ 691 for (index=0; index < conf->max_ports; ++index) { 692 if (conf->ports[index] == NULL) 693 break; 694 } 695 696 pj_assert(index != conf->max_ports); 697 698 if (name == NULL) { 699 name = &tmp; 700 701 tmp.ptr = pj_pool_alloc(pool, 20); 702 tmp.slen = pj_ansi_sprintf(tmp.ptr, "ConfPort#%d", index); 703 } 704 705 /* Create and initialize the media port structure. */ 706 port = pj_pool_zalloc(pool, sizeof(pjmedia_port)); 707 PJ_ASSERT_RETURN(port, PJ_ENOMEM); 708 709 pjmedia_port_info_init(&port->info, name, SIGNATURE_PORT, 710 clock_rate, channel_count, bits_per_sample, 711 samples_per_frame); 712 713 port->port_data.pdata = conf; 714 port->port_data.ldata = index; 715 716 port->get_frame = &get_frame_pasv; 717 port->put_frame = &put_frame; 718 port->on_destroy = NULL; 719 720 721 /* Create conf port structure. */ 722 status = create_pasv_port(conf, pool, name, port, &conf_port); 723 if (status != PJ_SUCCESS) { 724 pj_mutex_unlock(conf->mutex); 725 return status; 726 } 727 728 729 /* Put the port. */ 730 conf->ports[index] = conf_port; 731 conf->port_cnt++; 732 733 /* Done. */ 734 if (p_slot) 735 *p_slot = index; 736 if (p_port) 737 *p_port = port; 738 739 pj_mutex_unlock(conf->mutex); 740 741 return PJ_SUCCESS; 742 } 743 632 744 633 745 … … 1363 1475 pjmedia_frame *frame) 1364 1476 { 1365 pjmedia_conf *conf = this_port-> user_data;1477 pjmedia_conf *conf = this_port->port_data.pdata; 1366 1478 unsigned ci, cj, i, j; 1367 1479 … … 1419 1531 1420 1532 /* Get frame from this port. 1421 * For port zero (sound port) , get the frame from the rx_buffer1422 * instead.1533 * For port zero (sound port) and passive ports, get the frame from 1534 * the rx_buffer instead. 1423 1535 */ 1424 if ( i==0) {1536 if (conf_port->port == NULL) { 1425 1537 pj_int16_t *snd_buf; 1426 1538 … … 1616 1728 1617 1729 /* 1730 * get_frame() for passive port 1731 */ 1732 static pj_status_t get_frame_pasv(pjmedia_port *this_port, 1733 pjmedia_frame *frame) 1734 { 1735 pj_assert(0); 1736 return -1; 1737 } 1738 1739 1740 /* 1618 1741 * Recorder callback. 1619 1742 */ … … 1621 1744 const pjmedia_frame *frame) 1622 1745 { 1623 pjmedia_conf *conf = this_port-> user_data;1624 struct conf_port * snd_port = conf->ports[0];1746 pjmedia_conf *conf = this_port->port_data.pdata; 1747 struct conf_port *port = conf->ports[this_port->port_data.ldata]; 1625 1748 const pj_int16_t *input = frame->buf; 1626 1749 pj_int16_t *target_snd_buf; … … 1632 1755 1633 1756 /* Skip if this port is muted/disabled. */ 1634 if ( snd_port->rx_setting != PJMEDIA_PORT_ENABLE) {1757 if (port->rx_setting != PJMEDIA_PORT_ENABLE) { 1635 1758 return PJ_SUCCESS; 1636 1759 } 1637 1760 1638 1761 /* Skip if no port is listening to the microphone */ 1639 if ( snd_port->listener_cnt == 0) {1762 if (port->listener_cnt == 0) { 1640 1763 return PJ_SUCCESS; 1641 1764 } … … 1643 1766 1644 1767 /* Determine which rx_buffer to fill in */ 1645 target_snd_buf = snd_port->snd_buf[snd_port->snd_write_pos];1768 target_snd_buf = port->snd_buf[port->snd_write_pos]; 1646 1769 1647 1770 /* Copy samples from audio device to target rx_buffer */ … … 1649 1772 1650 1773 /* Switch buffer */ 1651 snd_port->snd_write_pos = (snd_port->snd_write_pos+1)%RX_BUF_COUNT;1652 1653 1654 return PJ_SUCCESS; 1655 } 1656 1774 port->snd_write_pos = (port->snd_write_pos+1)%RX_BUF_COUNT; 1775 1776 1777 return PJ_SUCCESS; 1778 } 1779 -
pjproject/trunk/pjmedia/src/pjmedia/mem_capture.c
r532 r633 58 58 { 59 59 struct mem_rec *rec; 60 const pj_str_t name = { "memrec", 6 }; 60 61 61 62 /* Sanity check */ … … 72 73 73 74 /* Create the rec */ 74 rec->base.info.name = pj_str("memrec"); 75 rec->base.info.signature = SIGNATURE; 76 rec->base.info.type = PJMEDIA_TYPE_AUDIO; 77 rec->base.info.has_info = PJ_TRUE; 78 rec->base.info.need_info = PJ_FALSE; 79 rec->base.info.pt = 0xFF; 80 rec->base.info.encoding_name = pj_str("pcm"); 75 pjmedia_port_info_init(&rec->base.info, &name, SIGNATURE, 76 clock_rate, channel_count, bits_per_sample, 77 samples_per_frame); 78 81 79 82 80 rec->base.put_frame = &rec_put_frame; … … 84 82 rec->base.on_destroy = &rec_on_destroy; 85 83 86 rec->base.info.clock_rate = clock_rate;87 rec->base.info.channel_count = channel_count;88 rec->base.info.bits_per_sample = bits_per_sample;89 rec->base.info.samples_per_frame = samples_per_frame;90 rec->base.info.bytes_per_frame = samples_per_frame * bits_per_sample / 2;91 84 92 85 /* Save the buffer */ -
pjproject/trunk/pjmedia/src/pjmedia/mem_player.c
r532 r633 59 59 { 60 60 struct mem_player *port; 61 pj_str_t name = pj_str("memplayer"); 61 62 62 63 /* Sanity check */ … … 73 74 74 75 /* Create the port */ 75 port->base.info.name = pj_str("memplayer"); 76 port->base.info.signature = SIGNATURE; 77 port->base.info.type = PJMEDIA_TYPE_AUDIO; 78 port->base.info.has_info = PJ_TRUE; 79 port->base.info.need_info = PJ_FALSE; 80 port->base.info.pt = 0xFF; 81 port->base.info.encoding_name = pj_str("pcm"); 76 pjmedia_port_info_init(&port->base.info, &name, SIGNATURE, clock_rate, 77 channel_count, bits_per_sample, samples_per_frame); 82 78 83 79 port->base.put_frame = &mem_put_frame; … … 85 81 port->base.on_destroy = &mem_on_destroy; 86 82 87 port->base.info.clock_rate = clock_rate;88 port->base.info.channel_count = channel_count;89 port->base.info.bits_per_sample = bits_per_sample;90 port->base.info.samples_per_frame = samples_per_frame;91 port->base.info.bytes_per_frame = samples_per_frame * bits_per_sample / 2;92 83 93 84 /* Save the buffer */ -
pjproject/trunk/pjmedia/src/pjmedia/null_port.c
r506 r633 24 24 25 25 26 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('N', 'U', 'L', 'L') 27 26 28 static pj_status_t null_get_frame(pjmedia_port *this_port, 27 29 pjmedia_frame *frame); … … 39 41 { 40 42 pjmedia_port *port; 43 const pj_str_t name = pj_str("null-port"); 41 44 42 45 PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL); … … 45 48 PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM); 46 49 47 port->info.bits_per_sample = bits_per_sample; 48 port->info.bytes_per_frame = samples_per_frame * bits_per_sample / 8; 49 port->info.encoding_name = pj_str("pcm"); 50 port->info.has_info = 1; 51 port->info.name = pj_str("null-port"); 52 port->info.need_info = 0; 53 port->info.pt = 0xFF; 54 port->info.clock_rate = sampling_rate; 55 port->info.samples_per_frame = samples_per_frame; 56 port->info.channel_count = channel_count; 57 port->info.signature = 0x2411; 58 port->info.type = PJMEDIA_TYPE_AUDIO; 50 pjmedia_port_info_init(&port->info, &name, SIGNATURE, sampling_rate, 51 channel_count, bits_per_sample, samples_per_frame); 59 52 60 53 port->get_frame = &null_get_frame; -
pjproject/trunk/pjmedia/src/pjmedia/resample_port.c
r582 r633 25 25 26 26 #define BYTES_PER_SAMPLE 2 27 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('R','S','M','P') 28 27 29 28 30 struct resample_port … … 53 55 pjmedia_port **p_port ) 54 56 { 57 const pj_str_t name = pj_str("resample"); 55 58 struct resample_port *rport; 56 59 unsigned ptime; … … 70 73 PJ_ASSERT_RETURN(rport != NULL, PJ_ENOMEM); 71 74 72 rport->base.info.clock_rate = clock_rate; 73 rport->base.info.samples_per_frame = clock_rate * ptime / 1000; 74 rport->base.info.bytes_per_frame = rport->base.info.samples_per_frame * 75 BYTES_PER_SAMPLE; 76 rport->base.info.bits_per_sample = BYTES_PER_SAMPLE * 8; 77 rport->base.info.channel_count = dn_port->info.channel_count; 78 rport->base.info.encoding_name = pj_str("pcm"); 79 rport->base.info.has_info = 1; 80 rport->base.info.name = pj_str("resample"); 81 rport->base.info.need_info = 0; 82 rport->base.info.pt = 0xFF; 83 rport->base.info.signature = PJMEDIA_PORT_SIGNATURE('R','S','M','P'); 84 rport->base.info.type = PJMEDIA_TYPE_AUDIO; 75 pjmedia_port_info_init(&rport->base.info, &name, SIGNATURE, clock_rate, 76 dn_port->info.channel_count, BYTES_PER_SAMPLE * 8, 77 clock_rate * ptime / 1000); 85 78 86 79 rport->dn_port = dn_port; -
pjproject/trunk/pjmedia/src/pjmedia/splitcomb.c
r631 r633 25 25 26 26 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('S', 'p', 'C', 'b') 27 #define SIGNATURE_PORT PJMEDIA_PORT_SIGNATURE('S', 'p', 'C', 'P') 27 28 #define THIS_FILE "splitcomb.c" 28 29 #define TMP_SAMP_TYPE pj_int16_t … … 129 130 pjmedia_port **p_splitcomb) 130 131 { 132 const pj_str_t name = pj_str("splitcomb"); 131 133 struct splitcomb *sc; 132 134 … … 161 163 162 164 /* Initialize port */ 163 sc->base.info.name = pj_str("splitcomb"); 164 sc->base.info.signature = SIGNATURE; 165 sc->base.info.type = PJMEDIA_TYPE_AUDIO; 166 sc->base.info.has_info = PJ_TRUE; 167 sc->base.info.need_info = PJ_FALSE; 168 sc->base.info.pt = 0xFF; 169 sc->base.info.encoding_name = pj_str("pcm"); 170 sc->base.info.clock_rate = clock_rate; 171 sc->base.info.channel_count = channel_count; 172 sc->base.info.bits_per_sample = bits_per_sample; 173 sc->base.info.samples_per_frame = samples_per_frame; 174 sc->base.info.bytes_per_frame = samples_per_frame * bits_per_sample / 8; 165 pjmedia_port_info_init(&sc->base.info, &name, SIGNATURE, clock_rate, 166 channel_count, bits_per_sample, samples_per_frame); 175 167 176 168 sc->base.put_frame = &put_frame; … … 227 219 pjmedia_port **p_chport) 228 220 { 221 const pj_str_t name = pj_str("splitcomb-ch"); 229 222 struct splitcomb *sc = (struct splitcomb*) splitcomb; 230 223 struct reverse_port *rport; … … 251 244 /* Initialize port info... */ 252 245 port = &rport->base; 253 port->info.name = pj_str("splitcomb-ch"); 254 port->info.signature = 0; 255 port->info.type = PJMEDIA_TYPE_AUDIO; 256 port->info.has_info = PJ_TRUE; 257 port->info.need_info = PJ_FALSE; 258 port->info.pt = 0xFF; 259 port->info.encoding_name = pj_str("pcm"); 260 port->info.clock_rate = splitcomb->info.clock_rate; 261 port->info.channel_count = 1; 262 port->info.bits_per_sample = splitcomb->info.bits_per_sample; 263 port->info.samples_per_frame = splitcomb->info.samples_per_frame / 264 splitcomb->info.channel_count; 265 port->info.bytes_per_frame = port->info.samples_per_frame * 266 port->info.bits_per_sample / 8; 246 pjmedia_port_info_init(&port->info, &name, SIGNATURE_PORT, 247 splitcomb->info.clock_rate, 1, 248 splitcomb->info.bits_per_sample, 249 splitcomb->info.samples_per_frame / 250 splitcomb->info.channel_count); 267 251 268 252 /* ... and the callbacks */ -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r569 r633 144 144 static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame) 145 145 { 146 pjmedia_stream *stream = port-> user_data;146 pjmedia_stream *stream = port->port_data.pdata; 147 147 pjmedia_channel *channel = stream->dec; 148 148 unsigned samples_count, samples_per_frame, samples_required; … … 439 439 const pjmedia_frame *frame ) 440 440 { 441 pjmedia_stream *stream = port-> user_data;441 pjmedia_stream *stream = port->port_data.pdata; 442 442 pjmedia_channel *channel = stream->enc; 443 443 pj_status_t status = 0; … … 914 914 { 915 915 pjmedia_stream *stream; 916 pj_str_t name; 916 917 unsigned jb_init, jb_max, jb_min_pre, jb_max_pre; 917 918 pj_status_t status; … … 926 927 927 928 /* Init stream/port name */ 928 stream->port.info.name.ptr = pj_pool_alloc(pool, 24); 929 pj_ansi_sprintf(stream->port.info.name.ptr, 930 "strm%p", stream); 931 stream->port.info.name.slen = pj_ansi_strlen(stream->port.info.name.ptr); 929 name.ptr = pj_pool_alloc(pool, 24); 930 name.slen = pj_ansi_snprintf(name.ptr, 24, "strm%p", stream); 931 932 933 /* Init some port-info. Some parts of the info will be set later 934 * once we have more info about the codec. 935 */ 936 pjmedia_port_info_init(&stream->port.info, &name, 937 PJMEDIA_PORT_SIGNATURE('S', 'T', 'R', 'M'), 938 info->fmt.clock_rate, info->fmt.channel_cnt, 939 16, 80); 932 940 933 941 /* Init port. */ 934 stream->port.info.signature = ('S'<<3 | 'T'<<2 | 'R'<<1 | 'M'); 935 stream->port.info.type = PJMEDIA_TYPE_AUDIO; 936 stream->port.info.has_info = 1; 937 stream->port.info.need_info = 0; 938 stream->port.info.pt = info->fmt.pt; 942 939 943 pj_strdup(pool, &stream->port.info.encoding_name, &info->fmt.encoding_name); 940 944 stream->port.info.clock_rate = info->fmt.clock_rate; 941 945 stream->port.info.channel_count = info->fmt.channel_cnt; 942 stream->port. user_data = stream;946 stream->port.port_data.pdata = stream; 943 947 stream->port.put_frame = &put_frame; 944 948 stream->port.get_frame = &get_frame; -
pjproject/trunk/pjmedia/src/pjmedia/wav_player.c
r582 r633 78 78 static struct file_port *create_file_port(pj_pool_t *pool) 79 79 { 80 const pj_str_t name = pj_str("file"); 80 81 struct file_port *port; 81 82 … … 84 85 return NULL; 85 86 86 port->base.info.name = pj_str("file"); 87 port->base.info.signature = SIGNATURE; 88 port->base.info.type = PJMEDIA_TYPE_AUDIO; 89 port->base.info.has_info = PJ_TRUE; 90 port->base.info.need_info = PJ_FALSE; 91 port->base.info.pt = 0xFF; 92 port->base.info.encoding_name = pj_str("pcm"); 87 /* Put in default values. 88 * These will be overriden once the file is read. 89 */ 90 pjmedia_port_info_init(&port->base.info, &name, SIGNATURE, 91 8000, 1, 16, 80); 93 92 94 93 port->base.put_frame = &file_put_frame; … … 96 95 port->base.on_destroy = &file_on_destroy; 97 96 98 99 /* Put in default values.100 * These will be overriden once the file is read.101 */102 port->base.info.clock_rate = 8000;103 port->base.info.bits_per_sample = 16;104 port->base.info.samples_per_frame = 160;105 port->base.info.bytes_per_frame = 320;106 97 107 98 return port; … … 151 142 152 143 fport->eof = PJ_TRUE; 153 status = (*fport->cb)(&fport->base, fport->base.user_data);144 status=(*fport->cb)(&fport->base,fport->base.port_data.pdata); 154 145 if (status != PJ_SUCCESS) { 155 146 /* This will crash if file port is destroyed in the … … 425 416 fport = (struct file_port*) port; 426 417 427 fport->base. user_data = user_data;418 fport->base.port_data.pdata = user_data; 428 419 fport->cb = cb; 429 420 -
pjproject/trunk/pjmedia/src/pjmedia/wav_writer.c
r582 r633 70 70 pjmedia_wave_hdr wave_hdr; 71 71 pj_ssize_t size; 72 pj_str_t name; 72 73 pj_status_t status; 73 74 … … 87 88 88 89 /* Initialize port info. */ 89 fport->base.info.bits_per_sample = bits_per_sample; 90 fport->base.info.bytes_per_frame = samples_per_frame * bits_per_sample * 91 channel_count / 8; 92 fport->base.info.channel_count = channel_count; 93 fport->base.info.encoding_name = pj_str("pom"); 94 fport->base.info.has_info = 1; 95 pj_strdup2(pool, &fport->base.info.name, filename); 96 fport->base.info.need_info = 0; 97 fport->base.info.pt = 0xFF; 98 fport->base.info.clock_rate = sampling_rate; 99 fport->base.info.samples_per_frame = samples_per_frame; 100 fport->base.info.signature = SIGNATURE; 101 fport->base.info.type = PJMEDIA_TYPE_AUDIO; 102 90 pj_strdup2(pool, &name, filename); 91 pjmedia_port_info_init(&fport->base.info, &name, SIGNATURE, 92 sampling_rate, channel_count, bits_per_sample, 93 samples_per_frame); 94 103 95 fport->base.get_frame = &file_get_frame; 104 96 fport->base.put_frame = &file_put_frame; … … 221 213 222 214 fport->cb_size = pos; 223 fport->base. user_data = user_data;215 fport->base.port_data.pdata = user_data; 224 216 fport->cb = cb; 225 217 … … 294 286 fport->cb = NULL; 295 287 296 status = (*cb)(this_port, this_port-> user_data);288 status = (*cb)(this_port, this_port->port_data.pdata); 297 289 return status; 298 290 }
Note: See TracChangeset
for help on using the changeset viewer.