Index: webrtc/api/objc/RTCEAGLVideoView.m |
diff --git a/talk/app/webrtc/objc/RTCEAGLVideoView.m b/webrtc/api/objc/RTCEAGLVideoView.m |
similarity index 71% |
copy from talk/app/webrtc/objc/RTCEAGLVideoView.m |
copy to webrtc/api/objc/RTCEAGLVideoView.m |
index d19462c9d97576b841df86cd6f1872fc738de2ba..e664ede455492c339180c406eeeb9ff90b06d831 100644 |
--- a/talk/app/webrtc/objc/RTCEAGLVideoView.m |
+++ b/webrtc/api/objc/RTCEAGLVideoView.m |
@@ -1,39 +1,18 @@ |
/* |
- * libjingle |
- * Copyright 2014 Google Inc. |
+ * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
* |
- * Redistribution and use in source and binary forms, with or without |
- * modification, are permitted provided that the following conditions are met: |
- * |
- * 1. Redistributions of source code must retain the above copyright notice, |
- * this list of conditions and the following disclaimer. |
- * 2. Redistributions in binary form must reproduce the above copyright notice, |
- * this list of conditions and the following disclaimer in the documentation |
- * and/or other materials provided with the distribution. |
- * 3. The name of the author may not be used to endorse or promote products |
- * derived from this software without specific prior written permission. |
- * |
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
*/ |
-#if !defined(__has_feature) || !__has_feature(objc_arc) |
-#error "This file requires ARC support." |
-#endif |
- |
#import "RTCEAGLVideoView.h" |
#import <GLKit/GLKit.h> |
-#import "RTCI420Frame.h" |
+#import "RTCVideoFrame.h" |
#import "RTCOpenGLVideoRenderer.h" |
// RTCDisplayLinkTimer wraps a CADisplayLink and is set to fire every two screen |
@@ -50,7 +29,7 @@ |
@end |
@implementation RTCDisplayLinkTimer { |
- CADisplayLink* _displayLink; |
+ CADisplayLink *_displayLink; |
void (^_timerHandler)(void); |
} |
@@ -86,7 +65,7 @@ |
[_displayLink invalidate]; |
} |
-- (void)displayLinkDidFire:(CADisplayLink*)displayLink { |
+- (void)displayLinkDidFire:(CADisplayLink *)displayLink { |
_timerHandler(); |
} |
@@ -105,22 +84,25 @@ |
// its own |isDirty| flag. |
@interface RTCEAGLVideoView () <GLKViewDelegate> |
-// |i420Frame| is set when we receive a frame from a worker thread and is read |
+// |videoFrame| is set when we receive a frame from a worker thread and is read |
// from the display link callback so atomicity is required. |
-@property(atomic, strong) RTCI420Frame* i420Frame; |
-@property(nonatomic, readonly) GLKView* glkView; |
-@property(nonatomic, readonly) RTCOpenGLVideoRenderer* glRenderer; |
+@property(atomic, strong) RTCVideoFrame *videoFrame; |
+@property(nonatomic, readonly) GLKView *glkView; |
+@property(nonatomic, readonly) RTCOpenGLVideoRenderer *glRenderer; |
@end |
@implementation RTCEAGLVideoView { |
- RTCDisplayLinkTimer* _timer; |
- GLKView* _glkView; |
- RTCOpenGLVideoRenderer* _glRenderer; |
+ RTCDisplayLinkTimer *_timer; |
// This flag should only be set and read on the main thread (e.g. by |
// setNeedsDisplay) |
BOOL _isDirty; |
} |
+@synthesize delegate = _delegate; |
+@synthesize videoFrame = _videoFrame; |
+@synthesize glkView = _glkView; |
+@synthesize glRenderer = _glRenderer; |
+ |
- (instancetype)initWithFrame:(CGRect)frame { |
if (self = [super initWithFrame:frame]) { |
[self configure]; |
@@ -136,7 +118,7 @@ |
} |
- (void)configure { |
- EAGLContext* glContext = |
+ EAGLContext *glContext = |
[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; |
if (!glContext) { |
glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; |
@@ -157,7 +139,7 @@ |
// Listen to application state in order to clean up OpenGL before app goes |
// away. |
- NSNotificationCenter* notificationCenter = |
+ NSNotificationCenter *notificationCenter = |
[NSNotificationCenter defaultCenter]; |
[notificationCenter addObserver:self |
selector:@selector(willResignActive) |
@@ -171,9 +153,9 @@ |
// Frames are received on a separate thread, so we poll for current frame |
// using a refresh rate proportional to screen refresh frequency. This |
// occurs on the main thread. |
- __weak RTCEAGLVideoView* weakSelf = self; |
+ __weak RTCEAGLVideoView *weakSelf = self; |
_timer = [[RTCDisplayLinkTimer alloc] initWithTimerHandler:^{ |
- RTCEAGLVideoView* strongSelf = weakSelf; |
+ RTCEAGLVideoView *strongSelf = weakSelf; |
[strongSelf displayLinkTimerDidFire]; |
}]; |
[self setupGL]; |
@@ -210,25 +192,25 @@ |
// This method is called when the GLKView's content is dirty and needs to be |
// redrawn. This occurs on main thread. |
-- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { |
+- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { |
// The renderer will draw the frame to the framebuffer corresponding to the |
// one used by |view|. |
- [_glRenderer drawFrame:self.i420Frame]; |
+ [_glRenderer drawFrame:self.videoFrame]; |
} |
#pragma mark - RTCVideoRenderer |
// These methods may be called on non-main thread. |
- (void)setSize:(CGSize)size { |
- __weak RTCEAGLVideoView* weakSelf = self; |
+ __weak RTCEAGLVideoView *weakSelf = self; |
dispatch_async(dispatch_get_main_queue(), ^{ |
- RTCEAGLVideoView* strongSelf = weakSelf; |
+ RTCEAGLVideoView *strongSelf = weakSelf; |
[strongSelf.delegate videoView:strongSelf didChangeVideoSize:size]; |
}); |
} |
-- (void)renderFrame:(RTCI420Frame*)frame { |
- self.i420Frame = frame; |
+- (void)renderFrame:(RTCVideoFrame *)frame { |
+ self.videoFrame = frame; |
} |
#pragma mark - Private |
@@ -236,7 +218,7 @@ |
- (void)displayLinkTimerDidFire { |
// Don't render unless video frame have changed or the view content |
// has explicitly been marked dirty. |
- if (!_isDirty && _glRenderer.lastDrawnFrame == self.i420Frame) { |
+ if (!_isDirty && _glRenderer.lastDrawnFrame == self.videoFrame) { |
return; |
} |
@@ -254,13 +236,13 @@ |
} |
- (void)setupGL { |
- self.i420Frame = nil; |
+ self.videoFrame = nil; |
[_glRenderer setupGL]; |
_timer.isPaused = NO; |
} |
- (void)teardownGL { |
- self.i420Frame = nil; |
+ self.videoFrame = nil; |
_timer.isPaused = YES; |
[_glkView deleteDrawable]; |
[_glRenderer teardownGL]; |