Skip to content

Commit

Permalink
Merge pull request #10 from k7k0/master
Browse files Browse the repository at this point in the history
CT-1237: start using the resolution parameter while capturing
  • Loading branch information
jacque006 authored Oct 11, 2016
2 parents 2dcbc1c + 908fc31 commit e4e5652
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
8 changes: 4 additions & 4 deletions OTKBasicVideoCapturer.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ - (id)initWithPreset:(NSString *)preset andDesiredFrameRate:(NSUInteger)frameRat
CGSize imageSize = [self sizeFromAVCapturePreset:self.sessionPreset];
_inputHeight = imageSize.height;
_inputWidth = imageSize.width;
_outputHeight = 480;
_outputWidth = 480;
_outputHeight = _inputHeight < _inputWidth ? _inputHeight : _inputWidth; //pick the smaller axis
_outputWidth = _outputHeight; //Should be square
_desiredFrameRate = frameRate;

_captureQueue = dispatch_queue_create("com.tokbox.OTKBasicVideoCapturer",DISPATCH_QUEUE_SERIAL);
Expand Down Expand Up @@ -158,8 +158,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
}

int inputBytesPerRow = (int) CVPixelBufferGetBytesPerRowOfPlane(imageBuffer, i);
int inputWidth = (int) CVPixelBufferGetWidthOfPlane(imageBuffer, i);
int bytesPerPixel = inputBytesPerRow / inputWidth; // 1 for Y, 2 for U/V
int inputPixelWidth = (int) CVPixelBufferGetWidthOfPlane(imageBuffer, i);
int bytesPerPixel = inputBytesPerRow / inputPixelWidth; // 1 for Y, 2 for U/V
int bytesToCopyPerRow = cropWidth * bytesPerPixel;

rowBaseAddress = CVPixelBufferGetBaseAddressOfPlane(imageBuffer, i);
Expand Down
18 changes: 16 additions & 2 deletions RCTOpenTokPublisherView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,22 @@ - (void)startPublishing {

[self attachPublisherView];

_publisher.videoCapture = [[OTKBasicVideoCapturer alloc] initWithPreset:AVCaptureSessionPreset640x480 // @TODO: Change!
andDesiredFrameRate:_cameraFrameRate];
_publisher.videoCapture = [[OTKBasicVideoCapturer alloc]
initWithPreset: [self getCapturePreset:_cameraResolution]
andDesiredFrameRate:_cameraFrameRate];
}

- (NSString *) getCapturePreset:(NSInteger) resolution
{
if (resolution == OTCameraCaptureResolutionLow) {
return AVCaptureSessionPreset352x288;
} else if (resolution == OTCameraCaptureResolutionMedium) {
return AVCaptureSessionPreset640x480;
} else if (resolution == OTCameraCaptureResolutionHigh) {
return AVCaptureSessionPreset1280x720;
}
[NSException raise:@"Invalid camera resolution value" format:@" %ld is invalid", (long)resolution];
return @"";
}

- (void)pausePublish{
Expand Down

0 comments on commit e4e5652

Please sign in to comment.