- Timestamp:
- Jul 12, 2011 9:08:56 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_port.c
r3617 r3622 57 57 pjmedia_conversion_param conv_param; 58 58 59 pjmedia_event_publisher epub;59 pjmedia_event_publisher epub; 60 60 pjmedia_event_subscription esub_dev; 61 pjmedia_event_subscription esub_client_port; 61 62 62 63 pjmedia_clock *clock; … … 91 92 static pj_status_t vidstream_event_cb(pjmedia_event_subscription *esub, 92 93 pjmedia_event *event); 94 static pj_status_t client_port_event_cb(pjmedia_event_subscription *esub, 95 pjmedia_event *event); 93 96 94 97 static void enc_clock_cb(const pj_timestamp *ts, void *user_data); … … 398 401 pj_bool_t destroy) 399 402 { 403 pjmedia_event_publisher *epub; 404 400 405 PJ_ASSERT_RETURN(vp && vp->role==ROLE_ACTIVE, PJ_EINVAL); 401 406 vp->destroy_client_port = destroy; 402 407 vp->client_port = port; 408 409 /* Subscribe to client port's events */ 410 epub = pjmedia_port_get_event_publisher(port); 411 if (epub) { 412 pjmedia_event_subscription_init(&vp->esub_client_port, 413 &client_port_event_cb, 414 vp); 415 pjmedia_event_subscribe(epub, &vp->esub_client_port); 416 } 403 417 return PJ_SUCCESS; 404 418 } … … 408 422 { 409 423 PJ_ASSERT_RETURN(vp && vp->role==ROLE_ACTIVE, PJ_EINVAL); 410 vp->client_port = NULL; 424 425 if (vp->client_port) { 426 pjmedia_event_publisher *epub; 427 428 /* Unsubscribe event */ 429 epub = pjmedia_port_get_event_publisher(vp->client_port); 430 if (epub && vp->esub_client_port.user_data) { 431 pjmedia_event_unsubscribe(epub, &vp->esub_client_port); 432 pj_bzero(&vp->esub_client_port, sizeof(vp->esub_client_port)); 433 } 434 vp->client_port = NULL; 435 } 411 436 return PJ_SUCCESS; 412 437 } … … 513 538 */ 514 539 540 /* Handle event from vidstream */ 515 541 static pj_status_t vidstream_event_cb(pjmedia_event_subscription *esub, 516 542 pjmedia_event *event) … … 538 564 } 539 565 540 static pj_status_t detect_fmt_change(pjmedia_vid_port *vp, 541 pjmedia_frame *frame) 542 { 543 if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) { 566 static pj_status_t client_port_event_cb(pjmedia_event_subscription *esub, 567 pjmedia_event *event) 568 { 569 pjmedia_vid_port *vp = (pjmedia_vid_port*)esub->user_data; 570 571 if (event->type == PJMEDIA_EVENT_FMT_CHANGED) { 544 572 const pjmedia_video_format_detail *vfd; 545 pjmedia_event pevent;546 573 pj_status_t status; 574 575 ++event->proc_cnt; 547 576 548 577 pjmedia_vid_port_stop(vp); … … 605 634 } 606 635 607 /* Notify application of the format change. */608 pjmedia_event_init(&pevent, PJMEDIA_EVENT_FMT_CHANGED, NULL, &vp->epub);609 pjmedia_format_copy(&pevent.data.fmt_changed.new_fmt,610 &vp->client_port->info.fmt);611 pjmedia_event_publish(&vp->epub, &pevent);612 613 636 pjmedia_vid_port_start(vp); 614 637 } 615 638 616 return PJ_SUCCESS; 639 /* Republish the event */ 640 return pjmedia_event_publish(&vp->epub, event); 617 641 } 618 642 … … 752 776 } 753 777 754 status = detect_fmt_change(vp, vp->frm_buf);755 if (status != PJ_SUCCESS)756 return;757 758 778 pj_add_timestamp32(&vp->clocksrc.timestamp, 759 779 frame_ts); … … 771 791 pj_add_timestamp32(&vp->clocksrc.timestamp, frame_ts); 772 792 pjmedia_clock_src_update(&vp->clocksrc, NULL); 773 774 status = detect_fmt_change(vp, vp->frm_buf);775 if (status != PJ_SUCCESS)776 return;777 793 778 794 if (convert_frame(vp, vp->frm_buf, &frame) != PJ_SUCCESS) … … 821 837 if (vp->role==ROLE_ACTIVE) { 822 838 if (vp->client_port) { 823 pj_status_t status; 824 825 status = pjmedia_port_get_frame(vp->client_port, frame); 826 if (status != PJ_SUCCESS) 827 return status; 828 829 return detect_fmt_change(vp, frame); 839 return pjmedia_port_get_frame(vp->client_port, frame); 830 840 } 831 841 } else {
Note: See TracChangeset
for help on using the changeset viewer.