Ignore:
Timestamp:
Dec 1, 2011 10:49:07 AM (12 years ago)
Author:
ming
Message:

Closed #1420: Add support for event manager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c

    r3848 r3893  
    148148    pj_uint32_t              last_dec_ts;    /**< Last decoded timestamp.   */ 
    149149    int                      last_dec_seq;   /**< Last decoded sequence.    */ 
    150  
    151     pjmedia_event_subscription esub_codec;   /**< To subscribe codec events */ 
    152     pjmedia_event_publisher    epub;         /**< To publish events         */ 
    153150}; 
    154151 
     
    340337 * Handle events from stream components. 
    341338 */ 
    342 static pj_status_t stream_event_cb(pjmedia_event_subscription *esub, 
    343                                    pjmedia_event *event) 
    344 { 
    345     pjmedia_vid_stream *stream = (pjmedia_vid_stream*)esub->user_data; 
    346  
    347     if (esub == &stream->esub_codec) { 
     339static pj_status_t stream_event_cb(pjmedia_event *event, 
     340                                   void *user_data) 
     341{ 
     342    pjmedia_vid_stream *stream = (pjmedia_vid_stream*)user_data; 
     343 
     344    if (event->epub == stream->codec) { 
    348345        /* This is codec event */ 
    349346        switch (event->type) { 
    350347        case PJMEDIA_EVENT_FMT_CHANGED: 
    351             /* we process the event */ 
    352             ++event->proc_cnt; 
    353  
    354348            /* Copy the event to avoid deadlock if we publish the event 
    355349             * now. This happens because fmt_event may trigger restart 
     
    363357    } 
    364358 
    365     return pjmedia_event_publish(&stream->epub, event); 
    366 } 
    367  
    368 static pjmedia_event_publisher *port_get_epub(pjmedia_port *port) 
    369 { 
    370     pjmedia_vid_stream *stream = (pjmedia_vid_stream*) port->port_data.pdata; 
    371     return &stream->epub; 
     359    return pjmedia_event_publish(NULL, stream, event, 0); 
    372360} 
    373361 
     
    10321020 
    10331021                /* Publish PJMEDIA_EVENT_FMT_CHANGED event */ 
    1034                 if (pjmedia_event_publisher_has_sub(&stream->epub)) { 
     1022                { 
    10351023                    pjmedia_event event; 
    10361024 
     
    10381026 
    10391027                    pjmedia_event_init(&event, PJMEDIA_EVENT_FMT_CHANGED, 
    1040                                        &frame->timestamp, &stream->epub); 
     1028                                       &frame->timestamp, &stream); 
    10411029                    event.data.fmt_changed.dir = PJMEDIA_DIR_DECODING; 
    10421030                    pj_memcpy(&event.data.fmt_changed.new_fmt, 
    10431031                              &stream->info.codec_param->dec_fmt, 
    10441032                              sizeof(pjmedia_format)); 
    1045                     pjmedia_event_publish(&stream->epub, &event); 
     1033                    pjmedia_event_publish(NULL, stream, &event, 0); 
    10461034                } 
    10471035            } 
     
    10871075                      "changed"); 
    10881076 
    1089         pjmedia_event_publish(&stream->epub, &stream->fmt_event); 
     1077        pjmedia_event_publish(NULL, stream, &stream->fmt_event, 0); 
    10901078 
    10911079        stream->fmt_event.type = PJMEDIA_EVENT_NONE; 
     
    12121200    /* Init port. */ 
    12131201    channel->port.port_data.pdata = stream; 
    1214     channel->port.get_event_pub = &port_get_epub; 
    12151202 
    12161203    PJ_LOG(5, (name.ptr, 
     
    13461333        return status; 
    13471334 
    1348     /* Init event publisher and subscribe to codec events */ 
    1349     pjmedia_event_publisher_init(&stream->epub, SIGNATURE); 
    1350     pjmedia_event_subscription_init(&stream->esub_codec, &stream_event_cb, 
    1351                                     stream); 
    1352     pjmedia_event_subscribe(&stream->codec->epub, &stream->esub_codec); 
     1335    /* Subscribe to codec events */ 
     1336    pjmedia_event_subscribe(NULL, pool, &stream_event_cb, stream, 
     1337                            stream->codec); 
    13531338 
    13541339    /* Estimate the maximum frame size */ 
     
    15571542    /* Free codec. */ 
    15581543    if (stream->codec) { 
     1544        pjmedia_event_unsubscribe(NULL, &stream_event_cb, stream, 
     1545                                  stream->codec); 
    15591546        pjmedia_vid_codec_close(stream->codec); 
    15601547        pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec); 
Note: See TracChangeset for help on using the changeset viewer.