Changeset 5370


Ignore:
Timestamp:
Jun 30, 2016 3:18:47 AM (8 years ago)
Author:
ming
Message:

Fixed #1931: Support more resolutions when opening the video capture and properly set the buffer's width and height as well.

File:
1 edited

Legend:

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

    r5348 r5370  
    7878static darwin_supported_size darwin_sizes[] = 
    7979{ 
    80 #if TARGET_OS_IPHONE 
     80#if !TARGET_OS_IPHONE 
     81    { 320, 240, NULL }, 
     82#endif 
    8183    { 352, 288, NULL }, 
    8284    { 640, 480, NULL }, 
    83     { 1280, 720, NULL }, 
    84     { 1920, 1080, NULL } 
    85 #else 
    8685    { 1280, 720, NULL } 
     86#if TARGET_OS_IPHONE 
     87    ,{ 1920, 1080, NULL } 
    8788#endif 
    8889}; 
     
    216217static void set_preset_str() 
    217218{ 
    218 #if TARGET_OS_IPHONE 
    219     darwin_sizes[0].preset_str = AVCaptureSessionPreset352x288; 
    220     darwin_sizes[1].preset_str = AVCaptureSessionPreset640x480; 
    221     darwin_sizes[2].preset_str = AVCaptureSessionPreset1280x720; 
    222     darwin_sizes[3].preset_str = AVCaptureSessionPreset1920x1080; 
    223 #else 
    224     darwin_sizes[0].preset_str = AVCaptureSessionPreset1280x720; 
     219    int idx = 0; 
     220#if !TARGET_OS_IPHONE 
     221    darwin_sizes[idx++].preset_str = AVCaptureSessionPreset320x240; 
     222#endif 
     223    darwin_sizes[idx++].preset_str = AVCaptureSessionPreset352x288; 
     224    darwin_sizes[idx++].preset_str = AVCaptureSessionPreset640x480; 
     225    darwin_sizes[idx++].preset_str = AVCaptureSessionPreset1280x720; 
     226#if TARGET_OS_IPHONE 
     227    darwin_sizes[idx++].preset_str = AVCaptureSessionPreset1920x1080; 
    225228#endif 
    226229} 
     
    504507    [stream->frame_lock lock]; 
    505508     
    506     // TODO: on Mac, nearly all frames, regardless of video format, 
    507     // have extra padding. So we may need to create a util function to 
    508     // remove the stride. 
    509      
    510509    if (stream->is_planar && stream->capture_buf) { 
    511510        if (stream->param.fmt.id == PJMEDIA_FORMAT_I420) { 
     
    795794        strm->video_output.videoSettings = 
    796795            [NSDictionary dictionaryWithObjectsAndKeys: 
     796#if !TARGET_OS_IPHONE 
     797                          /* On Mac, we need to set the buffer's dimension 
     798                           * to avoid extra padding. 
     799                           */ 
     800                          [NSNumber numberWithDouble: 
     801                                    darwin_sizes[i].supported_size_w], 
     802                          (id)kCVPixelBufferWidthKey, 
     803                          [NSNumber numberWithDouble: 
     804                                    darwin_sizes[i].supported_size_h], 
     805                          (id)kCVPixelBufferHeightKey, 
     806#endif 
    797807                          [NSNumber numberWithInt:ifi->darwin_format], 
    798808                          kCVPixelBufferPixelFormatTypeKey, nil]; 
Note: See TracChangeset for help on using the changeset viewer.