- Timestamp:
- Aug 23, 2018 4:45:13 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/vid_port.c
r5864 r5866 166 166 } 167 167 168 static pj_status_t get_vafp(const pjmedia_format *fmt, 169 pjmedia_video_apply_fmt_param *vafp) 170 { 171 const pjmedia_video_format_info *vfi; 172 173 vfi = pjmedia_get_video_format_info(NULL, fmt->id); 174 if (!vfi) 175 return PJMEDIA_EBADFMT; 176 177 pj_bzero(vafp, sizeof(*vafp)); 178 vafp->size = fmt->det.vid.size; 179 return vfi->apply_fmt(vfi, vafp); 180 } 181 168 182 static pj_status_t create_converter(pjmedia_vid_port *vp) 169 183 { … … 195 209 { 196 210 pj_status_t status; 197 const pjmedia_video_format_info *vfi;198 211 pjmedia_video_apply_fmt_param vafp; 199 212 200 213 /* Allocate buffer for conversion */ 201 vfi = pjmedia_get_video_format_info(NULL, vp->conv.conv_param.dst.id); 202 if (!vfi) 203 return PJMEDIA_EBADFMT; 204 205 pj_bzero(&vafp, sizeof(vafp)); 206 vafp.size = vp->conv.conv_param.dst.det.vid.size; 207 status = vfi->apply_fmt(vfi, &vafp); 214 status = get_vafp(&vp->conv.conv_param.dst, &vafp); 208 215 if (status != PJ_SUCCESS) 209 return PJMEDIA_EBADFMT;216 return status; 210 217 211 218 if (vafp.framebytes > vp->conv.conv_buf_size) { … … 647 654 648 655 if (need_frame_buf) { 649 const pjmedia_video_format_info *vfi;650 656 pjmedia_video_apply_fmt_param vafp; 651 const pjmedia_vid_dev_param *vparam_src; 652 653 vparam_src = (vp->dir & PJMEDIA_DIR_RENDER)? &prm->vidparam: 654 &vparam; 655 656 vfi = pjmedia_get_video_format_info(NULL, vparam_src->fmt.id); 657 if (!vfi) { 658 status = PJ_ENOTFOUND; 659 goto on_error; 660 } 661 662 pj_bzero(&vafp, sizeof(vafp)); 663 vafp.size = vparam_src->fmt.det.vid.size; 664 status = vfi->apply_fmt(vfi, &vafp); 657 658 status = get_vafp(&vp->conv.conv_param.src, &vafp); 665 659 if (status != PJ_SUCCESS) 666 660 goto on_error; … … 672 666 vp->frm_buf->type = PJMEDIA_FRAME_TYPE_NONE; 673 667 674 /* Black initial render screen for I420/YV12 format */675 if ((vp->dir & PJMEDIA_DIR_RENDER) &&676 (prm->vidparam.fmt.id == PJMEDIA_FORMAT_I420 ||677 prm->vidparam.fmt.id == PJMEDIA_FORMAT_YV12))678 {679 pj_memset(vp->frm_buf->buf, 16, vafp.plane_bytes[0]);680 pj_memset((pj_uint8_t*)vp->frm_buf->buf + vafp.plane_bytes[0],681 0x80, vafp.plane_bytes[1] * 2);682 }683 684 668 status = pj_mutex_create_simple(pool, vp->dev_name.ptr, 685 669 &vp->frm_mutex); … … 788 772 if (status != PJ_SUCCESS) 789 773 goto on_error; 774 775 if ((vp->dir & PJMEDIA_DIR_RENDER) && 776 (vp->conv.conv_param.dst.id == PJMEDIA_FORMAT_I420 || 777 vp->conv.conv_param.dst.id == PJMEDIA_FORMAT_YV12)) 778 { 779 pjmedia_video_apply_fmt_param vafp; 780 pj_status_t status; 781 pjmedia_frame frame; 782 783 pj_bzero(&frame, sizeof(pjmedia_frame)); 784 frame.buf = (vp->conv.conv? vp->conv.conv_buf: vp->frm_buf->buf); 785 frame.size = (vp->conv.conv? vp->conv.conv_buf_size: 786 vp->frm_buf_size); 787 788 status = get_vafp(&vp->conv.conv_param.dst, &vafp); 789 if (status == PJ_SUCCESS && frame.buf) { 790 frame.type = PJMEDIA_FRAME_TYPE_VIDEO; 791 pj_assert(frame.size >= vafp.framebytes); 792 frame.size = vafp.framebytes; 793 794 /* Black initial render screen for I420/YV12 format */ 795 pj_memset(frame.buf, 16, vafp.plane_bytes[0]); 796 pj_memset((pj_uint8_t*)frame.buf + vafp.plane_bytes[0], 797 0x80, vafp.plane_bytes[1] * 2); 798 799 pjmedia_vid_dev_stream_put_frame(vp->strm, &frame); 800 } 801 } 790 802 791 803 if (vp->clock) {
Note: See TracChangeset
for help on using the changeset viewer.