summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2016-06-30 03:18:47 +0000
committerLiong Sauw Ming <ming@teluu.com>2016-06-30 03:18:47 +0000
commita55e13c20239b8c174dbaa40ab8809a5510985d4 (patch)
treec145ae3647abe0fe13d3a7fdc1bee304c80c9abb /pjmedia
parentad4c05bd3f16f4a70e81cdf253d4a1e5c7fc50f1 (diff)
Fixed #1931: Support more resolutions when opening the video capture and properly set the buffer's width and height as well.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5370 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia-videodev/darwin_dev.m38
1 files changed, 24 insertions, 14 deletions
diff --git a/pjmedia/src/pjmedia-videodev/darwin_dev.m b/pjmedia/src/pjmedia-videodev/darwin_dev.m
index b531474c..7e7d0d59 100644
--- a/pjmedia/src/pjmedia-videodev/darwin_dev.m
+++ b/pjmedia/src/pjmedia-videodev/darwin_dev.m
@@ -77,13 +77,14 @@ typedef struct darwin_supported_size
/* Set the preset_str on set_preset_str method. */
static darwin_supported_size darwin_sizes[] =
{
-#if TARGET_OS_IPHONE
+#if !TARGET_OS_IPHONE
+ { 320, 240, NULL },
+#endif
{ 352, 288, NULL },
{ 640, 480, NULL },
- { 1280, 720, NULL },
- { 1920, 1080, NULL }
-#else
{ 1280, 720, NULL }
+#if TARGET_OS_IPHONE
+ ,{ 1920, 1080, NULL }
#endif
};
@@ -215,13 +216,15 @@ static pjmedia_vid_dev_stream_op stream_op =
static void set_preset_str()
{
+ int idx = 0;
+#if !TARGET_OS_IPHONE
+ darwin_sizes[idx++].preset_str = AVCaptureSessionPreset320x240;
+#endif
+ darwin_sizes[idx++].preset_str = AVCaptureSessionPreset352x288;
+ darwin_sizes[idx++].preset_str = AVCaptureSessionPreset640x480;
+ darwin_sizes[idx++].preset_str = AVCaptureSessionPreset1280x720;
#if TARGET_OS_IPHONE
- darwin_sizes[0].preset_str = AVCaptureSessionPreset352x288;
- darwin_sizes[1].preset_str = AVCaptureSessionPreset640x480;
- darwin_sizes[2].preset_str = AVCaptureSessionPreset1280x720;
- darwin_sizes[3].preset_str = AVCaptureSessionPreset1920x1080;
-#else
- darwin_sizes[0].preset_str = AVCaptureSessionPreset1280x720;
+ darwin_sizes[idx++].preset_str = AVCaptureSessionPreset1920x1080;
#endif
}
@@ -503,10 +506,6 @@ static pj_status_t darwin_factory_default_param(pj_pool_t *pool,
[stream->frame_lock lock];
- // TODO: on Mac, nearly all frames, regardless of video format,
- // have extra padding. So we may need to create a util function to
- // remove the stride.
-
if (stream->is_planar && stream->capture_buf) {
if (stream->param.fmt.id == PJMEDIA_FORMAT_I420) {
/* kCVPixelFormatType_420YpCbCr8BiPlanar* is NV12 */
@@ -794,6 +793,17 @@ static pj_status_t darwin_factory_create_stream(
strm->video_output.alwaysDiscardsLateVideoFrames = YES;
strm->video_output.videoSettings =
[NSDictionary dictionaryWithObjectsAndKeys:
+#if !TARGET_OS_IPHONE
+ /* On Mac, we need to set the buffer's dimension
+ * to avoid extra padding.
+ */
+ [NSNumber numberWithDouble:
+ darwin_sizes[i].supported_size_w],
+ (id)kCVPixelBufferWidthKey,
+ [NSNumber numberWithDouble:
+ darwin_sizes[i].supported_size_h],
+ (id)kCVPixelBufferHeightKey,
+#endif
[NSNumber numberWithInt:ifi->darwin_format],
kCVPixelBufferPixelFormatTypeKey, nil];