Skip to content

Commit

Permalink
Re #1762: Support more capture sizes (was only 352x288) and automatic…
Browse files Browse the repository at this point in the history
…ally find the closest supported size from the requested size.

git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4838 74dad513-b988-da41-8d7b-12977e46ad98
  • Loading branch information
nanang committed May 7, 2014
1 parent f52f892 commit 6743083
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pjmedia/src/pjmedia-videodev/ios_dev.m
Original file line number Diff line number Diff line change
Expand Up @@ -548,17 +548,33 @@ static pj_status_t ios_factory_create_stream(
strm->is_planar = vfi->plane_cnt > 1;

if (param->dir & PJMEDIA_DIR_CAPTURE) {
NSString *size_preset_str[] = {
AVCaptureSessionPreset352x288,
AVCaptureSessionPreset640x480,
AVCaptureSessionPreset1280x720,
AVCaptureSessionPreset1920x1080
};
pj_size_t supported_size_w[] = { 352, 640, 1280, 1920 };
pj_size_t supported_size_h[] = { 288, 480, 720, 1080 };
pj_size_t supported_size[] = { 352*288, 640*480, 1280*720, 1920*1080 };
pj_size_t requested_size = strm->size.w * strm->size.h;
int i;

/* Create capture stream here */
strm->cap_session = [[AVCaptureSession alloc] init];
if (!strm->cap_session) {
status = PJ_ENOMEM;
goto on_error;
}

/* Just hardcode to always capture 352x288 for now */
strm->cap_session.sessionPreset = AVCaptureSessionPreset352x288;
vfd->size.w = 352;
vfd->size.h = 288;
/* Find the closest supported size */
for(i = 0; i < PJ_ARRAY_SIZE(supported_size)-1; ++i) {
if (supported_size[i] >= requested_size)
break;
}
strm->cap_session.sessionPreset = size_preset_str[i];
vfd->size.w = supported_size_w[i];
vfd->size.h = supported_size_h[i];
strm->size = vfd->size;
strm->bytes_per_row = strm->size.w * vfi->bpp / 8;
strm->frame_size = strm->bytes_per_row * strm->size.h;
Expand Down

0 comments on commit 6743083

Please sign in to comment.