Changeset 4838


Ignore:
Timestamp:
May 7, 2014 8:11:10 AM (11 years ago)
Author:
nanang
Message:

Re #1762: Support more capture sizes (was only 352x288) and automatically find the closest supported size from the requested size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_dev.m

    r4837 r4838  
    549549 
    550550    if (param->dir & PJMEDIA_DIR_CAPTURE) { 
     551        NSString *size_preset_str[] = { 
     552            AVCaptureSessionPreset352x288, 
     553            AVCaptureSessionPreset640x480, 
     554            AVCaptureSessionPreset1280x720, 
     555            AVCaptureSessionPreset1920x1080 
     556        }; 
     557        pj_size_t supported_size_w[] = { 352, 640, 1280, 1920 }; 
     558        pj_size_t supported_size_h[] = { 288, 480,  720, 1080 }; 
     559        pj_size_t supported_size[] = { 352*288, 640*480, 1280*720, 1920*1080 }; 
     560        pj_size_t requested_size = strm->size.w * strm->size.h; 
     561        int i; 
     562         
    551563        /* Create capture stream here */ 
    552564        strm->cap_session = [[AVCaptureSession alloc] init]; 
     
    556568        } 
    557569         
    558         /* Just hardcode to always capture 352x288 for now */ 
    559         strm->cap_session.sessionPreset = AVCaptureSessionPreset352x288; 
    560         vfd->size.w = 352; 
    561         vfd->size.h = 288; 
     570        /* Find the closest supported size */ 
     571        for(i = 0; i < PJ_ARRAY_SIZE(supported_size)-1; ++i) { 
     572            if (supported_size[i] >= requested_size) 
     573                break; 
     574        } 
     575        strm->cap_session.sessionPreset = size_preset_str[i]; 
     576        vfd->size.w = supported_size_w[i]; 
     577        vfd->size.h = supported_size_h[i]; 
    562578        strm->size = vfd->size; 
    563579        strm->bytes_per_row = strm->size.w * vfi->bpp / 8; 
Note: See TracChangeset for help on using the changeset viewer.