Ignore:
Timestamp:
Aug 6, 2015 7:10:33 AM (9 years ago)
Author:
nanang
Message:

Fix #1876: Don't restart renderer when only fps is changing, just modify the clock instead.

File:
1 edited

Legend:

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

    r5057 r5149  
    888888    if (event->type == PJMEDIA_EVENT_FMT_CHANGED) { 
    889889        const pjmedia_video_format_detail *vfd; 
     890        const pjmedia_video_format_detail *vfd_cur; 
    890891        pjmedia_vid_dev_param vid_param; 
    891892        pj_status_t status; 
    892893         
     894        /* Retrieve the current video format detail */ 
     895        pjmedia_vid_dev_stream_get_param(vp->strm, &vid_param); 
     896        vfd_cur = pjmedia_format_get_video_format_detail( 
     897                  &vid_param.fmt, PJ_TRUE); 
     898        if (!vfd_cur) 
     899            return PJMEDIA_EVID_BADFORMAT; 
     900 
     901        /* Retrieve the new video format detail */ 
     902        vfd = pjmedia_format_get_video_format_detail( 
     903                  &event->data.fmt_changed.new_fmt, PJ_TRUE); 
     904        if (!vfd || !vfd->fps.num || !vfd->fps.denum) 
     905            return PJMEDIA_EVID_BADFORMAT; 
     906 
     907        /* Ticket #1876: if this is a passive renderer and only frame rate is 
     908         * changing, simply modify the clock. 
     909         */ 
     910        if (vp->dir == PJMEDIA_DIR_RENDER && 
     911            vp->stream_role == ROLE_PASSIVE && vp->role == ROLE_ACTIVE) 
     912        { 
     913            pj_bool_t fps_only; 
     914            pjmedia_video_format_detail tmp_vfd; 
     915             
     916            tmp_vfd = *vfd_cur; 
     917            tmp_vfd.fps = vfd->fps; 
     918            fps_only = pj_memcmp(vfd, &tmp_vfd, sizeof(*vfd)) == 0; 
     919            if (fps_only) { 
     920                pjmedia_clock_param clock_param; 
     921                clock_param.usec_interval = PJMEDIA_PTIME(&vfd->fps); 
     922                clock_param.clock_rate = vid_param.clock_rate; 
     923                pjmedia_clock_modify(vp->clock, &clock_param); 
     924 
     925                return pjmedia_event_publish(NULL, vp, event, 
     926                                             PJMEDIA_EVENT_PUBLISH_POST_EVENT); 
     927            } 
     928        } 
     929 
    893930        /* Ticket #1827: 
    894931         * Stopping video port should not be necessary here because 
     
    900937        pjmedia_vid_dev_stream_stop(vp->strm); 
    901938         
    902         /* Retrieve the video format detail */ 
    903         vfd = pjmedia_format_get_video_format_detail( 
    904                   &event->data.fmt_changed.new_fmt, PJ_TRUE); 
    905         if (!vfd || !vfd->fps.num || !vfd->fps.denum) 
    906             return PJMEDIA_EVID_BADFORMAT; 
    907          
    908939        /* Change the destination format to the new format */ 
    909940        pjmedia_format_copy(&vp->conv.conv_param.src, 
     
    919950        } 
    920951 
    921         pjmedia_vid_dev_stream_get_param(vp->strm, &vid_param); 
    922952        if (vid_param.fmt.id != vp->conv.conv_param.dst.id || 
    923953            (vid_param.fmt.det.vid.size.h != 
Note: See TracChangeset for help on using the changeset viewer.