Changeset 3622


Ignore:
Timestamp:
Jul 12, 2011 9:08:56 AM (13 years ago)
Author:
bennylp
Message:

More on re #1284:

  • Replaced bit_info mechanism to report format change in codec with event
  • Updated vid_port, vid_codec_test, etc.
  • Add event publisher to vid_codec
  • Add event publisher to pjmedia_port
  • Add event publisher to vid_stream
Location:
pjproject/branches/projects/2.0-dev/pjmedia
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/event.h

    r3617 r3622  
    103103typedef struct pjmedia_event_fmt_changed_data 
    104104{ 
    105     /** 
    106      * The new media format. 
    107      */ 
     105    /** The media flow direction */ 
     106    pjmedia_dir         dir; 
     107 
     108    /** The new media format. */ 
    108109    pjmedia_format      new_fmt; 
    109110} pjmedia_event_fmt_changed_data; 
     
    337338PJ_DECL(pj_status_t) pjmedia_event_unsubscribe(pjmedia_event_publisher *epub, 
    338339                                               pjmedia_event_subscription *esub); 
     340 
     341/** 
     342 * Check if the specified publisher has subscribers. 
     343 * 
     344 * @param epub          The event publisher. 
     345 * 
     346 * @return              PJ_TRUE if the publisher has at least one subscriber. 
     347 */ 
     348PJ_DECL(pj_bool_t) 
     349pjmedia_event_publisher_has_sub(pjmedia_event_publisher *epub); 
    339350 
    340351/** 
  • pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/port.h

    r3402 r3622  
    2626 */ 
    2727#include <pjmedia/clock.h> 
     28#include <pjmedia/event.h> 
    2829#include <pjmedia/format.h> 
    2930#include <pjmedia/frame.h> 
     
    399400    pj_status_t (*on_destroy)(struct pjmedia_port *this_port); 
    400401 
     402    /** 
     403     * Get event publisher for this media port, if any. 
     404     */ 
     405    pjmedia_event_publisher *(*get_event_pub)(struct pjmedia_port *this_port); 
     406 
    401407} pjmedia_port; 
    402408 
     
    478484                                             pjmedia_frame *frame ); 
    479485 
     486/** 
     487 * Get the event publisher for the media port, if any. 
     488 * 
     489 * @param port      The media port. 
     490 * 
     491 * @return          The event publisher, or NULL if the port does not publish 
     492 *                  events. 
     493 */ 
     494PJ_DECL(pjmedia_event_publisher*) 
     495pjmedia_port_get_event_publisher(pjmedia_port *port); 
    480496 
    481497/** 
  • pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/vid_codec.h

    r3613 r3622  
    2828 
    2929#include <pjmedia/codec.h> 
     30#include <pjmedia/event.h> 
    3031#include <pjmedia/format.h> 
    3132#include <pjmedia/types.h> 
     
    99100 
    100101/** 
    101  * Enumeration of video codec events. 
    102  */ 
    103 typedef enum pjmedia_vid_codec_event 
    104 { 
    105     /** 
    106      * Format changed event. The decoder output format is not really 
    107      * configurable, so that the output format setting configured in the 
    108      * initialization may be changed. Application can catch this event 
    109      * by checking the bit_info field of the pjmedia_frame of the decoder 
    110      * output frame. 
    111      */ 
    112     PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED = 1, 
    113  
    114 } pjmedia_vid_codec_event; 
    115  
    116  
    117 /** 
    118102 * Forward declaration for video codec. 
    119103 */ 
     
    269253     * format may different to the current setting, e.g: the format specified 
    270254     * in the #pjmedia_vid_codec_param when opening the codec, in this case the 
    271      * PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED flag will be set in the bit_info 
    272      * field of the output frame and application can query the new format 
     255     * PJMEDIA_EVENT_FMT_CHANGED event will be emitted by the codec. The codec 
     256     * parameter will also be updated, and application can query the format by 
    273257     * using #get_param(). 
    274258     * 
     
    310294 
    311295/** 
    312  * This structure describes a video codec instance.  
     296 * This structure describes a video codec instance. Codec implementers 
     297 * should use #pjmedia_vid_codec_init() to initialize this structure with 
     298 * default values. 
    313299 */ 
    314300struct pjmedia_vid_codec 
     
    325311    /** Operations to codec. */ 
    326312    pjmedia_vid_codec_op        *op; 
     313 
     314    /** Event publisher object */ 
     315    pjmedia_event_publisher      epub; 
    327316}; 
    328317 
     
    438427 
    439428 
     429/** 
     430 * Initialize pjmedia_vid_codec structure with default values. 
     431 * 
     432 * @param codec     The codec to be initialized. 
     433 */ 
     434PJ_DECL(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec); 
    440435 
    441436/** 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-codec/ffmpeg_codecs.c

    r3563 r3622  
    879879    /* Create pool for codec instance */ 
    880880    pool = pj_pool_create(ffmpeg_factory.pf, "ffmpeg codec", 512, 512, NULL); 
    881     codec = PJ_POOL_ZALLOC_T(pool, pjmedia_vid_codec); 
     881    codec = PJ_POOL_ALLOC_T(pool, pjmedia_vid_codec); 
    882882    if (!codec) { 
    883883        status = PJ_ENOMEM; 
    884884        goto on_error; 
    885885    } 
     886    pjmedia_vid_codec_init(codec); 
    886887    codec->op = &ffmpeg_op; 
    887888    codec->factory = factory; 
     
    14041405                return status; 
    14051406 
    1406             /* Notify application via the bit_info field of pjmedia_frame */ 
    1407             output->bit_info = PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED; 
     1407            /* Broadcast event */ 
     1408            if (pjmedia_event_publisher_has_sub(&codec->epub)) { 
     1409                pjmedia_event event; 
     1410 
     1411                pjmedia_event_init(&event, PJMEDIA_EVENT_FMT_CHANGED, 
     1412                                   &input->timestamp, &codec->epub); 
     1413                event.data.fmt_changed.dir = PJMEDIA_DIR_DECODING; 
     1414                pj_memcpy(&event.data.fmt_changed.new_fmt, &ff->param.dec_fmt, 
     1415                          sizeof(ff->param.dec_fmt)); 
     1416                pjmedia_event_publish(&codec->epub, &event); 
     1417            } 
    14081418        } 
    14091419 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/event.c

    r3617 r3622  
    5858} 
    5959 
     60PJ_DEF(pj_bool_t) 
     61pjmedia_event_publisher_has_sub(pjmedia_event_publisher *epub) 
     62{ 
     63    PJ_ASSERT_RETURN(epub, PJ_FALSE); 
     64    return epub->subscription_list.next && 
     65            (!pj_list_empty(&epub->subscription_list)); 
     66} 
     67 
    6068PJ_DEF(pj_status_t) pjmedia_event_subscribe( pjmedia_event_publisher *epub, 
    6169                                             pjmedia_event_subscription *esub) 
     
    8896 
    8997    esub = epub->subscription_list.next; 
     98    if (!esub) 
     99        return err; 
     100 
    90101    while (esub != &epub->subscription_list) { 
    91102        pjmedia_event_subscription *next; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/port.c

    r3402 r3622  
    118118} 
    119119 
     120/* 
     121 * Get event publisher 
     122 */ 
     123PJ_DEF(pjmedia_event_publisher*) 
     124pjmedia_port_get_event_publisher(pjmedia_port *port) 
     125{ 
     126    PJ_ASSERT_RETURN(port, NULL); 
     127 
     128    if (port->get_event_pub) 
     129        return (*port->get_event_pub)(port); 
     130 
     131    return NULL; 
     132} 
    120133 
    121134/** 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_codec.c

    r3613 r3622  
    6767static void sort_codecs(pjmedia_vid_codec_mgr *mgr); 
    6868 
     69/* 
     70 * Initialize pjmedia_vid_codec structure with default values. 
     71 */ 
     72PJ_DEF(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec) 
     73{ 
     74    pj_bzero(codec, sizeof(*codec)); 
     75    pj_list_init(&codec->epub); 
     76} 
    6977 
    7078/* 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_port.c

    r3617 r3622  
    5757    pjmedia_conversion_param conv_param; 
    5858 
    59     pjmedia_event_publisher  epub; 
     59    pjmedia_event_publisher    epub; 
    6060    pjmedia_event_subscription esub_dev; 
     61    pjmedia_event_subscription esub_client_port; 
    6162 
    6263    pjmedia_clock           *clock; 
     
    9192static pj_status_t vidstream_event_cb(pjmedia_event_subscription *esub, 
    9293                                      pjmedia_event *event); 
     94static pj_status_t client_port_event_cb(pjmedia_event_subscription *esub, 
     95                                        pjmedia_event *event); 
    9396 
    9497static void enc_clock_cb(const pj_timestamp *ts, void *user_data); 
     
    398401                                              pj_bool_t destroy) 
    399402{ 
     403    pjmedia_event_publisher *epub; 
     404 
    400405    PJ_ASSERT_RETURN(vp && vp->role==ROLE_ACTIVE, PJ_EINVAL); 
    401406    vp->destroy_client_port = destroy; 
    402407    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    } 
    403417    return PJ_SUCCESS; 
    404418} 
     
    408422{ 
    409423    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    } 
    411436    return PJ_SUCCESS; 
    412437} 
     
    513538*/ 
    514539 
     540/* Handle event from vidstream */ 
    515541static pj_status_t vidstream_event_cb(pjmedia_event_subscription *esub, 
    516542                                      pjmedia_event *event) 
     
    538564} 
    539565 
    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) { 
     566static 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) { 
    544572        const pjmedia_video_format_detail *vfd; 
    545         pjmedia_event pevent; 
    546573        pj_status_t status; 
     574 
     575        ++event->proc_cnt; 
    547576 
    548577        pjmedia_vid_port_stop(vp); 
     
    605634        } 
    606635 
    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  
    613636        pjmedia_vid_port_start(vp); 
    614637    } 
    615638 
    616     return PJ_SUCCESS; 
     639    /* Republish the event */ 
     640    return pjmedia_event_publish(&vp->epub, event); 
    617641} 
    618642 
     
    752776                    } 
    753777 
    754                     status = detect_fmt_change(vp, vp->frm_buf); 
    755                     if (status != PJ_SUCCESS) 
    756                         return; 
    757  
    758778                    pj_add_timestamp32(&vp->clocksrc.timestamp, 
    759779                                       frame_ts); 
     
    771791    pj_add_timestamp32(&vp->clocksrc.timestamp, frame_ts); 
    772792    pjmedia_clock_src_update(&vp->clocksrc, NULL); 
    773  
    774     status = detect_fmt_change(vp, vp->frm_buf); 
    775     if (status != PJ_SUCCESS) 
    776         return; 
    777793 
    778794    if (convert_frame(vp, vp->frm_buf, &frame) != PJ_SUCCESS) 
     
    821837    if (vp->role==ROLE_ACTIVE) { 
    822838        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); 
    830840        } 
    831841    } else { 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/vid_stream.c

    r3534 r3622  
    1919#include <pjmedia/vid_stream.h> 
    2020#include <pjmedia/errno.h> 
     21#include <pjmedia/event.h> 
    2122#include <pjmedia/rtp.h> 
    2223#include <pjmedia/rtcp.h> 
     
    135136    pj_uint32_t              last_dec_ts;    /**< Last decoded timestamp.   */ 
    136137    int                      last_dec_seq;   /**< Last decoded sequence.    */ 
     138 
     139    pjmedia_event_subscription esub_codec;   /**< To subscribe codec events */ 
     140    pjmedia_event_publisher    epub;         /**< To publish events         */ 
    137141}; 
    138142 
     
    301305#endif /* TRACE_JB */ 
    302306 
     307static void dump_port_info(const pjmedia_vid_channel *chan, 
     308                           const char *event_name) 
     309{ 
     310    const pjmedia_port_info *pi = &chan->port.info; 
     311 
     312    PJ_LOG(5, (pi->name.ptr, 
     313               " %s format %s: %dx%d %c%c%c%c%s %d/%d(~%d)fps", 
     314               (chan->dir==PJMEDIA_DIR_DECODING? "Decoding":"Encoding"), 
     315               event_name, 
     316               pi->fmt.det.vid.size.w, pi->fmt.det.vid.size.h, 
     317               ((pi->fmt.id & 0x000000FF) >> 0), 
     318               ((pi->fmt.id & 0x0000FF00) >> 8), 
     319               ((pi->fmt.id & 0x00FF0000) >> 16), 
     320               ((pi->fmt.id & 0xFF000000) >> 24), 
     321               (chan->dir==PJMEDIA_DIR_ENCODING?"->":"<-"), 
     322               pi->fmt.det.vid.fps.num, pi->fmt.det.vid.fps.denum, 
     323               pi->fmt.det.vid.fps.num/pi->fmt.det.vid.fps.denum)); 
     324} 
     325 
     326/* 
     327 * Handle events from stream components. 
     328 */ 
     329static pj_status_t stream_event_cb(pjmedia_event_subscription *esub, 
     330                                   pjmedia_event *event) 
     331{ 
     332    pjmedia_vid_stream *stream = (pjmedia_vid_stream*)esub->user_data; 
     333 
     334    if (esub == &stream->esub_codec) { 
     335        /* This is codec event */ 
     336        switch (event->type) { 
     337        case PJMEDIA_EVENT_FMT_CHANGED: 
     338            /* Update param from codec */ 
     339            stream->codec->op->get_param(stream->codec, stream->info.codec_param); 
     340 
     341            /* Update decoding channel port info */ 
     342            pjmedia_format_copy(&stream->dec->port.info.fmt, 
     343                                &stream->info.codec_param->dec_fmt); 
     344 
     345            /* we process the event */ 
     346            ++event->proc_cnt; 
     347 
     348            dump_port_info(event->data.fmt_changed.dir==PJMEDIA_DIR_DECODING ? 
     349                            stream->dec : stream->enc, 
     350                          "changed"); 
     351            break; 
     352        default: 
     353            break; 
     354        } 
     355    } 
     356 
     357    return pjmedia_event_publish(&stream->epub, event); 
     358} 
     359 
     360static pjmedia_event_publisher *port_get_epub(pjmedia_port *port) 
     361{ 
     362    pjmedia_vid_stream *stream = (pjmedia_vid_stream*) port->port_data.pdata; 
     363    return &stream->epub; 
     364} 
    303365 
    304366#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA != 0 
     
    795857    return PJ_SUCCESS; 
    796858} 
    797  
    798859 
    799860static pj_status_t get_frame(pjmedia_port *port, 
     
    915976    } 
    916977 
    917     /* Check if the decoder format is changed */ 
    918     if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) { 
    919         /* Update param from codec */ 
    920         stream->codec->op->get_param(stream->codec, stream->info.codec_param); 
    921  
    922         /* Update decoding channel port info */ 
    923         pjmedia_format_copy(&channel->port.info.fmt, 
    924                             &stream->info.codec_param->dec_fmt); 
    925     } 
    926  
    927978    /* Learn remote frame rate after successful decoding */ 
    928979    if (0 && frame->type == PJMEDIA_FRAME_TYPE_VIDEO && frame->size) 
     
    9501001                stream->info.codec_param->dec_fmt.det.vid.fps = vfd->fps; 
    9511002 
    952                 /* Set bit_info */ 
    953                 frame->bit_info |= PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED; 
    954  
    955                 PJ_LOG(5, (channel->port.info.name.ptr, "Frame rate changed to %.2ffps", 
    956                            (1.0 * vfd->fps.num / vfd->fps.denum))); 
     1003                PJ_LOG(5, (channel->port.info.name.ptr, 
     1004                           "Frame rate changed to %d/%d(~%d)fps", 
     1005                           vfd->fps.num, vfd->fps.denum, 
     1006                           vfd->fps.num / vfd->fps.denum)); 
     1007 
     1008                /* Publish PJMEDIA_EVENT_FMT_CHANGED event */ 
     1009                if (pjmedia_event_publisher_has_sub(&stream->epub)) { 
     1010                    pjmedia_event event; 
     1011 
     1012                    dump_port_info(stream->dec, "changed"); 
     1013 
     1014                    pjmedia_event_init(&event, PJMEDIA_EVENT_FMT_CHANGED, 
     1015                                       &frame_in.timestamp, &stream->epub); 
     1016                    event.data.fmt_changed.dir = PJMEDIA_DIR_DECODING; 
     1017                    pj_memcpy(&event.data.fmt_changed.new_fmt, 
     1018                              &stream->info.codec_param->dec_fmt, 
     1019                              sizeof(pjmedia_format)); 
     1020                    pjmedia_event_publish(&stream->epub, &event); 
     1021                } 
    9571022            } 
    9581023        } 
     
    9621027        stream->last_dec_ts = last_ts; 
    9631028    } 
    964  
    965 #if PJ_LOG_MAX_LEVEL >= 5 
    966     if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) { 
    967         pjmedia_port_info *pi = &channel->port.info; 
    968  
    969         PJ_LOG(5, (channel->port.info.name.ptr, 
    970                    "Decoding format changed to %dx%d %c%c%c%c %.2ffps", 
    971                    pi->fmt.det.vid.size.w, pi->fmt.det.vid.size.h, 
    972                    ((pi->fmt.id & 0x000000FF) >> 0), 
    973                    ((pi->fmt.id & 0x0000FF00) >> 8), 
    974                    ((pi->fmt.id & 0x00FF0000) >> 16), 
    975                    ((pi->fmt.id & 0xFF000000) >> 24), 
    976                    (1.0*pi->fmt.det.vid.fps.num/pi->fmt.det.vid.fps.denum))); 
    977     } 
    978 #endif 
    9791029 
    9801030    return PJ_SUCCESS; 
     
    10701120    /* Init port. */ 
    10711121    channel->port.port_data.pdata = stream; 
    1072  
    1073     PJ_LOG(5, (name.ptr, "%s channel created %dx%d %c%c%c%c%s%.*s %.2ffps", 
     1122    channel->port.get_event_pub = &port_get_epub; 
     1123 
     1124    PJ_LOG(5, (name.ptr, 
     1125               "%s channel created %dx%d %c%c%c%c%s%.*s %d/%d(~%d)fps", 
    10741126               (dir==PJMEDIA_DIR_ENCODING?"Encoding":"Decoding"), 
    10751127               pi->fmt.det.vid.size.w, pi->fmt.det.vid.size.h, 
     
    10811133               info->codec_info.encoding_name.slen, 
    10821134               info->codec_info.encoding_name.ptr, 
    1083                (1.0*pi->fmt.det.vid.fps.num/pi->fmt.det.vid.fps.denum))); 
     1135               pi->fmt.det.vid.fps.num, pi->fmt.det.vid.fps.denum, 
     1136               pi->fmt.det.vid.fps.num/pi->fmt.det.vid.fps.denum)); 
    10841137 
    10851138    /* Done. */ 
     
    11981251    if (status != PJ_SUCCESS) 
    11991252        return status; 
     1253 
     1254    /* Init event publisher and subscribe to codec events */ 
     1255    pjmedia_event_publisher_init(&stream->epub); 
     1256    pjmedia_event_subscription_init(&stream->esub_codec, &stream_event_cb, 
     1257                                    stream); 
     1258    pjmedia_event_subscribe(&stream->codec->epub, &stream->esub_codec); 
    12001259 
    12011260    /* Estimate the maximum frame size */ 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_codec_test.c

    r3579 r3622  
    2929} codec_port_data_t; 
    3030 
     31static pj_status_t codec_on_event(pjmedia_event_subscription *esub, 
     32                                  pjmedia_event *event) 
     33{ 
     34    codec_port_data_t *port_data = (codec_port_data_t*)esub->user_data; 
     35 
     36    if (event->type == PJMEDIA_EVENT_FMT_CHANGED) { 
     37        pjmedia_vid_codec *codec = port_data->codec; 
     38        pjmedia_vid_codec_param codec_param; 
     39        pj_status_t status; 
     40 
     41        ++event->proc_cnt; 
     42 
     43        status = codec->op->get_param(codec, &codec_param); 
     44        if (status != PJ_SUCCESS) 
     45            return status; 
     46 
     47        status = pjmedia_vid_dev_stream_set_cap( 
     48                        pjmedia_vid_port_get_stream(port_data->rdr_port), 
     49                        PJMEDIA_VID_DEV_CAP_FORMAT, 
     50                        &codec_param.dec_fmt); 
     51        if (status != PJ_SUCCESS) 
     52            return status; 
     53    } 
     54 
     55    return PJ_SUCCESS; 
     56} 
     57 
    3158static pj_status_t codec_put_frame(pjmedia_port *port, 
    3259                                   pjmedia_frame *frame) 
     
    4875#if !BYPASS_PACKETIZER 
    4976        if (enc_frame.size) { 
    50             unsigned pos = 0, i = 0; 
     77            unsigned pos = 0; 
    5178            pj_bool_t packetized = PJ_FALSE; 
    5279            unsigned unpack_pos = 0; 
     
    5986                                              (pj_uint8_t*)enc_frame.buf, 
    6087                                              enc_frame.size, &pos, 
    61                                               &payload, &payload_len); 
     88                                              (const pj_uint8_t**)&payload, 
     89                                              &payload_len); 
    6290                if (status == PJ_ENOTSUP) 
    6391                    break; 
     
    87115        status = codec->op->decode(codec, &enc_frame, frame->size, frame); 
    88116        if (status != PJ_SUCCESS) goto on_error; 
    89  
    90         /* Detect format change */ 
    91         if (frame->bit_info & PJMEDIA_VID_CODEC_EVENT_FMT_CHANGED) { 
    92             pjmedia_vid_codec_param codec_param; 
    93  
    94             status = codec->op->get_param(codec, &codec_param); 
    95             if (status != PJ_SUCCESS) goto on_error; 
    96  
    97             status = pjmedia_vid_dev_stream_set_cap( 
    98                             pjmedia_vid_port_get_stream(port_data->rdr_port), 
    99                             PJMEDIA_VID_DEV_CAP_FORMAT, 
    100                             &codec_param.dec_fmt); 
    101             if (status != PJ_SUCCESS) goto on_error; 
    102         } 
    103117    } 
    104118#endif 
     
    170184    pjmedia_vid_port_param vport_param; 
    171185    pjmedia_video_format_detail *vfd; 
     186    pjmedia_event_subscription esub; 
    172187    pj_status_t status; 
    173188    int rc = 0; 
     
    277292        codec_param.dec_fmt.det = codec_param.enc_fmt.det; 
    278293 
     294        /* Subscribe to codec events */ 
     295        pjmedia_event_subscription_init(&esub, &codec_on_event, 
     296                                        &codec_port_data); 
     297        pjmedia_event_subscribe(&codec->epub, &esub); 
    279298#endif /* !BYPASS_CODEC */ 
    280299    } 
    281  
    282300 
    283301    pjmedia_vid_port_param_default(&vport_param); 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/vid_dev_test.c

    r3617 r3622  
    9090    pjmedia_vid_port_param param; 
    9191    pjmedia_video_format_detail *vfd; 
    92     pjmedia_vid_cb cb; 
    9392    pjmedia_event_subscription esub; 
    9493    pj_status_t status; 
Note: See TracChangeset for help on using the changeset viewer.