From 41875aa686138e7f18f935dd257641fe69e18938 Mon Sep 17 00:00:00 2001 From: CZ Theng Date: Fri, 20 Dec 2019 11:33:21 +0800 Subject: [PATCH] add rotationOverride for RTCEAGLVideoView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:11221 Change-Id: I105b93de21fd2faeaf072c947c08006857c7a654 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162460 Reviewed-by: Kári Helgason Commit-Queue: Kári Helgason Cr-Commit-Position: refs/heads/master@{#30117} --- sdk/objc/components/renderer/opengl/RTCEAGLVideoView.h | 3 +++ sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.h b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.h index 30764b54cd..73cd3a1a26 100644 --- a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.h +++ b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.h @@ -35,6 +35,9 @@ NS_EXTENSION_UNAVAILABLE_IOS("Rendering not available in app extensions.") - (instancetype)initWithCoder:(NSCoder *)aDecoder shader:(id)shader NS_DESIGNATED_INITIALIZER; +/** @abstract Wrapped RTCVideoRotation, or nil. + */ +@property(nonatomic, nullable) NSValue *rotationOverride; @end NS_ASSUME_NONNULL_END diff --git a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m index 0ccbf9dd6f..6a01d48f32 100644 --- a/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m +++ b/sdk/objc/components/renderer/opengl/RTCEAGLVideoView.m @@ -57,6 +57,7 @@ @synthesize delegate = _delegate; @synthesize videoFrame = _videoFrame; @synthesize glkView = _glkView; +@synthesize rotationOverride = _rotationOverride; - (instancetype)initWithFrame:(CGRect)frame { return [self initWithFrame:frame shader:[[RTCDefaultShader alloc] init]]; @@ -185,6 +186,10 @@ if (!frame || frame.timeStampNs == _lastDrawnFrameTimeStampNs) { return; } + RTCVideoRotation rotation = frame.rotation; + if(_rotationOverride != nil) { + [_rotationOverride getValue: &rotation]; + } [self ensureGLContext]; glClear(GL_COLOR_BUFFER_BIT); if ([frame.buffer isKindOfClass:[RTCCVPixelBuffer class]]) { @@ -195,7 +200,7 @@ [_nv12TextureCache uploadFrameToTextures:frame]; [_shader applyShadingForFrameWithWidth:frame.width height:frame.height - rotation:frame.rotation + rotation:rotation yPlane:_nv12TextureCache.yTexture uvPlane:_nv12TextureCache.uvTexture]; [_nv12TextureCache releaseTextures]; @@ -209,7 +214,7 @@ [_i420TextureCache uploadFrameToTextures:frame]; [_shader applyShadingForFrameWithWidth:frame.width height:frame.height - rotation:frame.rotation + rotation:rotation yPlane:_i420TextureCache.yTexture uPlane:_i420TextureCache.uTexture vPlane:_i420TextureCache.vTexture];