Changeset 3893 for pjproject/trunk/pjmedia/src/pjmedia/vid_port.c
- Timestamp:
- Dec 1, 2011 10:49:07 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/vid_port.c
r3758 r3893 62 62 pjmedia_conversion_param conv_param; 63 63 64 pjmedia_event_publisher epub;65 pjmedia_event_subscription esub_dev;66 pjmedia_event_subscription esub_client_port;67 68 64 pjmedia_clock *clock; 69 65 pjmedia_clock_src clocksrc; … … 95 91 void *user_data, 96 92 pjmedia_frame *frame); 97 static pj_status_t vidstream_event_cb(pjmedia_event _subscription *esub,98 pjmedia_event *event);99 static pj_status_t client_port_event_cb(pjmedia_event _subscription *esub,100 pjmedia_event *event);93 static pj_status_t vidstream_event_cb(pjmedia_event *event, 94 void *user_data); 95 static pj_status_t client_port_event_cb(pjmedia_event *event, 96 void *user_data); 101 97 102 98 static void enc_clock_cb(const pj_timestamp *ts, void *user_data); … … 207 203 vp->dir = prm->vidparam.dir; 208 204 // vp->cap_size = vfd->size; 209 pjmedia_event_publisher_init(&vp->epub, SIGNATURE);210 205 211 206 vparam = prm->vidparam; … … 273 268 274 269 /* Subscribe to device's events */ 275 pjmedia_event_subscription_init(&vp->esub_dev, vidstream_event_cb, vp); 276 pjmedia_event_subscribe( 277 pjmedia_vid_dev_stream_get_event_publisher(vp->strm), 278 &vp->esub_dev); 270 pjmedia_event_subscribe(NULL, vp->pool, &vidstream_event_cb, 271 vp, vp->strm); 279 272 280 273 if (vp->dir & PJMEDIA_DIR_CAPTURE) { … … 371 364 } 372 365 373 PJ_DEF(pjmedia_event_publisher*)374 pjmedia_vid_port_get_event_publisher(pjmedia_vid_port *vid_port)375 {376 PJ_ASSERT_RETURN(vid_port, NULL);377 return &vid_port->epub;378 }379 380 366 PJ_DEF(pjmedia_vid_dev_stream*) 381 367 pjmedia_vid_port_get_stream(pjmedia_vid_port *vp) … … 420 406 pj_bool_t destroy) 421 407 { 422 pjmedia_event_publisher *epub;423 424 408 PJ_ASSERT_RETURN(vp && vp->role==ROLE_ACTIVE, PJ_EINVAL); 425 409 vp->destroy_client_port = destroy; … … 427 411 428 412 /* Subscribe to client port's events */ 429 epub = pjmedia_port_get_event_publisher(port); 430 if (epub) { 431 pjmedia_event_subscription_init(&vp->esub_client_port, 432 &client_port_event_cb, 433 vp); 434 pjmedia_event_subscribe(epub, &vp->esub_client_port); 435 } 413 pjmedia_event_subscribe(NULL, vp->pool, &client_port_event_cb, vp, 414 vp->client_port); 415 436 416 return PJ_SUCCESS; 437 417 } … … 442 422 PJ_ASSERT_RETURN(vp && vp->role==ROLE_ACTIVE, PJ_EINVAL); 443 423 444 if (vp->client_port) {445 pjmedia_event_unsubscribe(&vp->esub_client_port);446 447 } 424 pjmedia_event_unsubscribe(NULL, &client_port_event_cb, vp, 425 vp->client_port); 426 vp->client_port = NULL; 427 448 428 return PJ_SUCCESS; 449 429 } … … 511 491 } 512 492 if (vp->strm) { 493 pjmedia_event_unsubscribe(NULL, &vidstream_event_cb, vp, vp->strm); 513 494 pjmedia_vid_dev_stream_destroy(vp->strm); 514 495 vp->strm = NULL; 515 496 } 516 497 if (vp->client_port) { 498 pjmedia_event_unsubscribe(NULL, &client_port_event_cb, vp, 499 vp->client_port); 517 500 if (vp->destroy_client_port) 518 501 pjmedia_port_destroy(vp->client_port); … … 561 544 562 545 /* Handle event from vidstream */ 563 static pj_status_t vidstream_event_cb(pjmedia_event _subscription *esub,564 pjmedia_event *event)565 { 566 pjmedia_vid_port *vp = (pjmedia_vid_port*) esub->user_data;546 static pj_status_t vidstream_event_cb(pjmedia_event *event, 547 void *user_data) 548 { 549 pjmedia_vid_port *vp = (pjmedia_vid_port*)user_data; 567 550 568 551 /* Just republish the event to our client */ 569 return pjmedia_event_publish( &vp->epub, event);570 } 571 572 static pj_status_t client_port_event_cb(pjmedia_event _subscription *esub,573 pjmedia_event *event)574 { 575 pjmedia_vid_port *vp = (pjmedia_vid_port*) esub->user_data;552 return pjmedia_event_publish(NULL, vp, event, 0); 553 } 554 555 static pj_status_t client_port_event_cb(pjmedia_event *event, 556 void *user_data) 557 { 558 pjmedia_vid_port *vp = (pjmedia_vid_port*)user_data; 576 559 577 560 if (event->type == PJMEDIA_EVENT_FMT_CHANGED) { … … 579 562 pj_status_t status; 580 563 581 ++event->proc_cnt;582 583 564 pjmedia_vid_port_stop(vp); 584 565 … … 634 615 } 635 616 636 /* Republish the event */ 637 return pjmedia_event_publish(&vp->epub, event); 617 /* Republish the event, post the event to the event manager 618 * to avoid deadlock if vidport is trying to stop the clock. 619 */ 620 return pjmedia_event_publish(NULL, vp, event, 621 PJMEDIA_EVENT_PUBLISH_POST_EVENT); 638 622 } 639 623
Note: See TracChangeset
for help on using the changeset viewer.