Skip to content

Commit 7c0258c

Browse files
authored
Merge pull request #1 from jrahaim/HardwareZoom
Enabled hardware zoom to support 7 Plus camera
2 parents 8e84e21 + 4fdaec0 commit 7c0258c

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

VideoCore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "VideoCore"
33
s.module_name = "VideoCore"
4-
s.version = "0.3.2"
4+
s.version = "0.4.0"
55
s.summary = "An audio and video manipulation and streaming pipeline with support for RTMP."
66
s.description = <<-DESC
77
This is a work-in-progress library with the

videocore/api/iOS/VCSimpleSession.mm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,12 @@ - (void) setVideoZoomFactor:(float)videoZoomFactor
289289
{
290290
_videoZoomFactor = videoZoomFactor;
291291
if(m_positionTransform) {
292-
// We could use AVCaptureConnection's zoom factor, but in reality it's
293-
// doing the exact same thing as this (in terms of the algorithm used),
294-
// but it is not clear how CoreVideo accomplishes it.
295-
// In this case this is just modifying the matrix
296-
// multiplication that is already happening once per frame.
297-
m_positionTransform->setSize(self.videoSize.width * videoZoomFactor,
298-
self.videoSize.height * videoZoomFactor);
292+
// Switched to Hardware zoom to better support iPhone 7 Plus
293+
m_cameraSource->setVideoZoomFactor(MAX(1.0, MIN(videoZoomFactor, 6.4)));
294+
295+
// Original VideoCore code:
296+
//m_positionTransform->setSize(self.videoSize.width * videoZoomFactor,
297+
// self.videoSize.height * videoZoomFactor);
299298
}
300299
}
301300
- (void) setAudioChannelCount:(int)channelCount

videocore/sources/iOS/CameraSource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ namespace videocore { namespace iOS {
114114

115115
bool setContinuousExposure(bool wantsContinuous);
116116

117+
bool setVideoZoomFactor(float zoomFactor);
117118

118119
public:
119120
/*! Used by Objective-C Capture Session */

videocore/sources/iOS/CameraSource.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,17 @@ - (void) orientationChanged: (NSNotification*) notification
503503
return ret;
504504
}
505505

506+
bool
507+
CameraSource::setVideoZoomFactor(float zoomFactor) {
508+
AVCaptureDevice* device = (AVCaptureDevice*)m_captureDevice;
509+
NSError* err = nil;
510+
if([device lockForConfiguration:&err]) {
511+
device.videoZoomFactor = zoomFactor;
512+
return YES;
513+
} else {
514+
return NO;
515+
}
516+
}
517+
506518
}
507519
}

0 commit comments

Comments
 (0)