Add method on AVFoundation capturer to adapt output format.
This CL makes a method available on the AVFoundationVideoCapturer that adapts the output format of captured video to the specified width and height. BUG=webrtc:6753 Review-Url: https://codereview.webrtc.org/2528493004 Cr-Commit-Position: refs/heads/master@{#15351}
This commit is contained in:
@ -32,6 +32,12 @@
|
||||
return [super initWithNativeVideoSource:source];
|
||||
}
|
||||
|
||||
- (void)adaptOutputFormatToWidth:(int)width
|
||||
height:(int)height
|
||||
fps:(int)fps {
|
||||
self.capturer->AdaptOutputFormat(width, height, fps);
|
||||
}
|
||||
|
||||
- (BOOL)canUseBackCamera {
|
||||
return self.capturer->CanUseBackCamera();
|
||||
}
|
||||
|
||||
@ -58,6 +58,10 @@ class AVFoundationVideoCapturer : public cricket::VideoCapturer {
|
||||
void CaptureSampleBuffer(CMSampleBufferRef sample_buffer,
|
||||
webrtc::VideoRotation rotation);
|
||||
|
||||
// Called to adjust the size of output frames to supplied |width| and
|
||||
// |height|. Also drops frames to make the output match |fps|.
|
||||
void AdaptOutputFormat(int width, int height, int fps);
|
||||
|
||||
private:
|
||||
RTCAVFoundationVideoCapturerInternal *_capturer;
|
||||
webrtc::I420BufferPool _buffer_pool;
|
||||
|
||||
@ -113,6 +113,11 @@ bool AVFoundationVideoCapturer::GetUseBackCamera() const {
|
||||
return _capturer.useBackCamera;
|
||||
}
|
||||
|
||||
void AVFoundationVideoCapturer::AdaptOutputFormat(int width, int height, int fps) {
|
||||
cricket::VideoFormat format(width, height, cricket::VideoFormat::FpsToInterval(fps), 0);
|
||||
video_adapter()->OnOutputFormatRequest(format);
|
||||
}
|
||||
|
||||
void AVFoundationVideoCapturer::CaptureSampleBuffer(
|
||||
CMSampleBufferRef sample_buffer, VideoRotation rotation) {
|
||||
if (CMSampleBufferGetNumSamples(sample_buffer) != 1 ||
|
||||
|
||||
Reference in New Issue
Block a user