Changeset 3459


Ignore:
Timestamp:
Mar 17, 2011 11:25:19 AM (13 years ago)
Author:
bennylp
Message:

Re #1213 (video devices):

  • fixed devices to correctly increment the frame timestamp
  • minor fix in video port to set default "active" value to 1 in the param
Location:
pjproject/branches/projects/2.0-dev/pjmedia
Files:
7 edited

Legend:

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

    r3431 r3459  
    5757     * calls pjmedia_port_put_frame() or pjmedia_port_get_frame() to that 
    5858     * media port. 
     59     * 
     60     * Default: PJ_TRUE 
    5961     */ 
    6062    pj_bool_t           active; 
     
    6971/** 
    7072 * Initialize the parameter with the default values. Note that this typically 
    71  * would only fill the structure to zeroes. 
     73 * would only fill the structure to zeroes unless they have different default 
     74 * values. 
    7275 * 
    7376 * @param prm   The parameter. 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/colorbar_dev.c

    r3420 r3459  
    9292    pjmedia_video_apply_fmt_param    vafp; 
    9393    pj_uint8_t                      *first_line[PJMEDIA_MAX_VIDEO_PLANES]; 
     94    pj_timestamp                     ts; 
     95    unsigned                         ts_inc; 
    9496}; 
    9597 
     
    186188    ddi = &cf->dev_info[0]; 
    187189    pj_bzero(ddi, sizeof(*ddi)); 
    188     strncpy(ddi->info.name, "Colorbar generator", 
    189             sizeof(ddi->info.name)); 
     190    pj_ansi_strncpy(ddi->info.name, "Colorbar generator", 
     191                    sizeof(ddi->info.name)); 
    190192    ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0'; 
    191     strncpy(ddi->info.driver, "Colorbar", sizeof(ddi->info.driver)); 
     193    pj_ansi_strncpy(ddi->info.driver, "Colorbar", sizeof(ddi->info.driver)); 
    192194    ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0'; 
    193195    ddi->info.dir = PJMEDIA_DIR_CAPTURE; 
     
    206208    } 
    207209 
    208     PJ_LOG(4, (THIS_FILE, "Colorbar video src initialized with %d devices:", 
     210    PJ_LOG(4, (THIS_FILE, "Colorbar video src initialized with %d device(s):", 
    209211               cf->dev_count)); 
     212    for (i = 0; i < cf->dev_count; i++) { 
     213        PJ_LOG(4, (THIS_FILE, "%2d: %s", i, cf->dev_info[i].info.name)); 
     214    } 
    210215 
    211216    return PJ_SUCCESS; 
     
    366371    pj_pool_t *pool; 
    367372    struct cbar_stream *strm; 
     373    const pjmedia_video_format_detail *vfd; 
    368374    const pjmedia_video_format_info *vfi; 
    369375    pjmedia_video_apply_fmt_param vafp; 
     
    378384    pj_bzero(&vafp, sizeof(vafp)); 
    379385 
     386    vfd = pjmedia_format_get_video_format_detail(&param->fmt, PJ_TRUE); 
    380387    vfi = pjmedia_get_video_format_info(NULL, param->fmt.id); 
    381388    cbfi = get_cbar_fmt_info(param->fmt.id); 
     
    399406    strm->cbfi = cbfi; 
    400407    pj_memcpy(&strm->vafp, &vafp, sizeof(vafp)); 
     408    strm->ts_inc = PJMEDIA_SPF2(param->clock_rate, &vfd->fps, 1); 
    401409 
    402410    for (i = 0; i < vfi->plane_cnt; ++i) { 
     
    560568    struct cbar_stream *stream = (struct cbar_stream*)strm; 
    561569 
     570    frame->timestamp = stream->ts; 
     571    stream->ts.u64 += stream->ts_inc; 
    562572    return spectrum_run(stream, frame->buf, frame->size); 
    563573} 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c

    r3420 r3459  
    6666    {PJMEDIA_FORMAT_RGB24, &MEDIASUBTYPE_RGB24} , 
    6767    {PJMEDIA_FORMAT_RGB32, &MEDIASUBTYPE_RGB32} , 
     68    //{PJMEDIA_FORMAT_IYUV, &MEDIASUBTYPE_IYUV} , 
    6869}; 
    6970 
     
    113114        AM_MEDIA_TYPE       *mediatype; 
    114115    } dgraph[2]; 
     116 
     117    pj_timestamp             cap_ts; 
     118    unsigned                 cap_ts_inc; 
    115119}; 
    116120 
     
    287291    ddi = &df->dev_info[df->dev_count++]; 
    288292    pj_bzero(ddi, sizeof(*ddi)); 
    289     strncpy(ddi->info.name,  "Video Mixing Renderer", 
    290             sizeof(ddi->info.name)); 
     293    pj_ansi_strncpy(ddi->info.name,  "Video Mixing Renderer", 
     294                    sizeof(ddi->info.name)); 
    291295    ddi->info.name[sizeof(ddi->info.name)-1] = '\0'; 
    292     strncpy(ddi->info.driver, "dshow", sizeof(ddi->info.driver)); 
     296    pj_ansi_strncpy(ddi->info.driver, "dshow", sizeof(ddi->info.driver)); 
    293297    ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0'; 
    294298    ddi->info.dir = PJMEDIA_DIR_RENDER; 
     
    410414    struct dshow_stream *strm = (struct dshow_stream*)user_data; 
    411415    unsigned char *buffer; 
    412     pjmedia_frame frame; 
     416    pjmedia_frame frame = {0}; 
    413417 
    414418    if (strm->quit_flag) { 
     
    435439    frame.size = IMediaSample_GetActualDataLength(pMediaSample); 
    436440    frame.bit_info = 0; 
     441    frame.timestamp = strm->cap_ts; 
     442    strm->cap_ts.u64 += strm->cap_ts_inc; 
    437443    if (strm->vid_cb.capture_cb) 
    438444        (*strm->vid_cb.capture_cb)(&strm->base, strm->user_data, &frame); 
     
    454460        if (stream->dgraph[i].csource_filter) { 
    455461            HRESULT hr = SourceFilter_Deliver(stream->dgraph[i].csource_filter, 
    456                 frame->buf, frame->size); 
     462                                              frame->buf, frame->size); 
    457463 
    458464            if (FAILED(hr)) { 
     
    727733    /* Create capture stream here */ 
    728734    if (param->dir & PJMEDIA_DIR_CAPTURE) { 
     735        const pjmedia_video_format_detail *vfd; 
     736 
    729737        status = create_filter_graph(PJMEDIA_DIR_CAPTURE, param->cap_id, 
    730738                                     df, strm, &strm->dgraph[ngraph++]); 
    731739        if (status != PJ_SUCCESS) 
    732740            goto on_error; 
     741         
     742        vfd = pjmedia_format_get_video_format_detail(&param->fmt, PJ_TRUE); 
     743        strm->cap_ts_inc = PJMEDIA_SPF2(param->clock_rate, &vfd->fps, 1); 
    733744    } 
    734745 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/ios_dev.m

    r3399 r3459  
    9393    UIImageView         *imgView; 
    9494    void                *buf; 
     95     
     96    pj_timestamp         frame_ts; 
     97    unsigned             ts_inc; 
    9598}; 
    9699 
     
    356359    frame.size = stream->frame_size; 
    357360    frame.bit_info = 0; 
     361    frame.timestamp.u64 = stream->frame_ts.u64; 
     362     
    358363    if (stream->vid_cb.capture_cb) 
    359364        (*stream->vid_cb.capture_cb)(&stream->base, stream->user_data, &frame); 
    360365 
     366    stream->frame_ts.u64 += stream->ts_inc; 
     367     
    361368    /* Unlock the pixel buffer */ 
    362369    CVPixelBufferUnlockBaseAddress(imageBuffer,0); 
     
    386393    pj_pool_t *pool; 
    387394    struct ios_stream *strm; 
    388     pjmedia_video_format_detail *vfd; 
     395    const pjmedia_video_format_detail *vfd; 
    389396    const pjmedia_video_format_info *vfi; 
    390397    pj_status_t status = PJ_SUCCESS; 
     
    419426    strm->bytes_per_row = strm->size.w * strm->bpp / 8; 
    420427    strm->frame_size = strm->bytes_per_row * strm->size.h; 
     428    strm->ts_inc = PJMEDIA_SPF2(param->clock_rate, &vfd->fps, 1); 
    421429 
    422430    /* Create capture stream here */ 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/qt_dev.m

    r3395 r3459  
    7777    pj_pool_t           *pool;              /**< Memory pool.          */ 
    7878 
     79    pj_timestamp         cap_frame_ts;      /**< Captured frame tstamp */ 
     80    unsigned             cap_ts_inc;        /**< Increment             */ 
     81     
    7982    pjmedia_vid_cb       vid_cb;            /**< Stream callback.      */ 
    8083    void                *user_data;         /**< Application data.     */ 
     
    322325    frame.size = size; 
    323326    frame.bit_info = 0; 
     327    frame.timestamp.u64 = stream->cap_frame_ts.u64; 
     328     
    324329    if (stream->vid_cb.capture_cb) 
    325330        (*stream->vid_cb.capture_cb)(&stream->base, stream->user_data, 
    326331                                     &frame); 
     332     
     333    stream->cap_frame_ts.u64 += stream->cap_ts_inc; 
    327334} 
    328335@end 
     
    380387    /* Create capture stream here */ 
    381388    if (param->dir & PJMEDIA_DIR_CAPTURE) { 
    382         pjmedia_video_format_detail *vfd; 
     389        const pjmedia_video_format_detail *vfd; 
    383390        qt_fmt_info *qfi = get_qt_format_info(param->fmt.id); 
    384391         
     
    438445 
    439446        pj_assert(vfd->fps.num); 
     447        strm->cap_ts_inc = PJMEDIA_SPF2(&strm->param.clock_rate, &vfd->fps, 1); 
     448         
    440449        [strm->video_output setMinimumVideoFrameInterval: 
    441450                            (1.0f * vfd->fps.denum / (double)vfd->fps.num)]; 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/v4l2_dev.c

    r3447 r3459  
    677677    frame->type = PJMEDIA_FRAME_TYPE_VIDEO; 
    678678    frame->size = buf.bytesused; 
    679     frame->timestamp.u64 = PJ_TIME_VAL_MSEC(time) * stream->param.clock_rate 
    680                            / PJ_UINT64(1000); 
     679    frame->timestamp.u64 = PJ_UINT64(1) * PJ_TIME_VAL_MSEC(time) * 
     680                           stream->param.clock_rate / PJ_UINT64(1000); 
    681681    pj_memcpy(frame->buf, stream->buffers[buf.index].start, buf.bytesused); 
    682682 
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/videoport.c

    r3431 r3459  
    101101{ 
    102102    pj_bzero(prm, sizeof(*prm)); 
     103    prm->active = PJ_TRUE; 
    103104} 
    104105 
Note: See TracChangeset for help on using the changeset viewer.