Index: webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
index 1fb03bc909e27305eee7eb41bd9f6066983f7e3e..0cccbface2122d3bb1c85eb872007610db778dc9 100644 |
--- a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
+++ b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m |
@@ -12,7 +12,9 @@ |
#import <GLKit/GLKit.h> |
-#import "RTCShader+Private.h" |
+#import "RTCI420TextureCache.h" |
+#import "RTCNV12TextureCache.h" |
+#import "RTCDefaultShaderDelegate.h" |
#import "WebRTC/RTCLogging.h" |
#import "WebRTC/RTCVideoFrame.h" |
@@ -97,8 +99,10 @@ |
// This flag should only be set and read on the main thread (e.g. by |
// setNeedsDisplay) |
BOOL _isDirty; |
- id<RTCShader> _i420Shader; |
- id<RTCShader> _nv12Shader; |
+ RTCDefaultShaderDelegate *_defaultShaderDelegate; |
daniela-webrtc
2017/05/11 17:31:20
I find this slightly confusing. When is the defau
magjed_webrtc
2017/05/25 14:26:45
I added a comment:
|_defaultShaderDelegate| is use
|
+ __weak id<RTCVideoViewShaderDelegate> _shaderDelegate; |
+ RTCNV12TextureCache* _nv12TextureCache; |
+ RTCI420TextureCache* _i420TextureCache; |
RTCVideoFrame *_lastDrawnFrame; |
} |
@@ -107,14 +111,28 @@ |
@synthesize glkView = _glkView; |
- (instancetype)initWithFrame:(CGRect)frame { |
+ _defaultShaderDelegate = [[RTCDefaultShaderDelegate alloc] init]; |
+ return [self initWithFrame:frame shaderDelegate:_defaultShaderDelegate]; |
+} |
+ |
+- (instancetype)initWithCoder:(NSCoder *)aDecoder { |
+ _defaultShaderDelegate = [[RTCDefaultShaderDelegate alloc] init]; |
+ return [self initWithCoder:aDecoder shaderDelegate:_defaultShaderDelegate]; |
+} |
+ |
+- (instancetype)initWithFrame:(CGRect)frame |
+ shaderDelegate:(id<RTCVideoViewShaderDelegate>)shaderDelegate { |
if (self = [super initWithFrame:frame]) { |
+ _shaderDelegate = shaderDelegate; |
[self configure]; |
} |
return self; |
} |
-- (instancetype)initWithCoder:(NSCoder *)aDecoder { |
+- (instancetype)initWithCoder:(NSCoder *)aDecoder |
+ shaderDelegate:(id<RTCVideoViewShaderDelegate>)shaderDelegate { |
if (self = [super initWithCoder:aDecoder]) { |
+ _shaderDelegate = shaderDelegate; |
[self configure]; |
} |
return self; |
@@ -207,22 +225,28 @@ |
} |
[self ensureGLContext]; |
glClear(GL_COLOR_BUFFER_BIT); |
- id<RTCShader> shader = nil; |
if (frame.nativeHandle) { |
- if (!_nv12Shader) { |
- _nv12Shader = [[RTCNativeNV12Shader alloc] initWithContext:_glContext]; |
+ if (!_nv12TextureCache) { |
+ _nv12TextureCache = [[RTCNV12TextureCache alloc] initWithContext:_glContext]; |
} |
- shader = _nv12Shader; |
- } else { |
- if (!_i420Shader) { |
- _i420Shader = [[RTCI420Shader alloc] initWithContext:_glContext]; |
+ if (_nv12TextureCache) { |
+ [_nv12TextureCache uploadFrameToTextures:frame]; |
+ [_shaderDelegate videoView:self |
daniela-webrtc
2017/05/11 17:31:20
What if this is nil? Shouldn't the defaultDelegate
|
+ didReceiveFrameWithRotation:frame.rotation |
+ yPlane:_nv12TextureCache.yTexture |
+ uvPlane:_nv12TextureCache.uvTexture]; |
+ [_nv12TextureCache releaseTextures]; |
} |
- shader = _i420Shader; |
- } |
- if (shader && [shader drawFrame:frame]) { |
- _lastDrawnFrame = frame; |
} else { |
- RTCLog(@"Failed to draw frame."); |
+ if (!_i420TextureCache) { |
+ _i420TextureCache = [[RTCI420TextureCache alloc] initWithContext:_glContext]; |
+ } |
+ [_i420TextureCache uploadFrameToTextures:frame]; |
+ [_shaderDelegate videoView:self |
+ didReceiveFrameWithRotation:frame.rotation |
+ yPlane:_i420TextureCache.yTexture |
+ uPlane:_i420TextureCache.uTexture |
+ vPlane:_i420TextureCache.vTexture]; |
} |
} |
@@ -275,8 +299,9 @@ |
_timer.isPaused = YES; |
[_glkView deleteDrawable]; |
[self ensureGLContext]; |
- _i420Shader = nil; |
- _nv12Shader = nil; |
+ _nv12TextureCache = nil; |
+ _i420TextureCache = nil; |
+ _defaultShaderDelegate = nil; |
} |
- (void)didBecomeActive { |