OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import "RTCEAGLVideoView.h" | 11 #import "webrtc/api/objc/RTCEAGLVideoView.h" |
12 | 12 |
13 #import <GLKit/GLKit.h> | 13 #import <GLKit/GLKit.h> |
14 | 14 |
15 #import "RTCVideoFrame.h" | 15 #import "webrtc/api/objc/RTCOpenGLVideoRenderer.h" |
16 #import "RTCOpenGLVideoRenderer.h" | 16 #import "webrtc/api/objc/RTCVideoFrame.h" |
17 | 17 |
18 // RTCDisplayLinkTimer wraps a CADisplayLink and is set to fire every two screen | 18 // RTCDisplayLinkTimer wraps a CADisplayLink and is set to fire every two screen |
19 // refreshes, which should be 30fps. We wrap the display link in order to avoid | 19 // refreshes, which should be 30fps. We wrap the display link in order to avoid |
20 // a retain cycle since CADisplayLink takes a strong reference onto its target. | 20 // a retain cycle since CADisplayLink takes a strong reference onto its target. |
21 // The timer is paused by default. | 21 // The timer is paused by default. |
22 @interface RTCDisplayLinkTimer : NSObject | 22 @interface RTCDisplayLinkTimer : NSObject |
23 | 23 |
24 @property(nonatomic) BOOL isPaused; | 24 @property(nonatomic) BOOL isPaused; |
25 | 25 |
26 - (instancetype)initWithTimerHandler:(void (^)(void))timerHandler; | 26 - (instancetype)initWithTimerHandler:(void (^)(void))timerHandler; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // These methods may be called on non-main thread. | 203 // These methods may be called on non-main thread. |
204 - (void)setSize:(CGSize)size { | 204 - (void)setSize:(CGSize)size { |
205 __weak RTCEAGLVideoView *weakSelf = self; | 205 __weak RTCEAGLVideoView *weakSelf = self; |
206 dispatch_async(dispatch_get_main_queue(), ^{ | 206 dispatch_async(dispatch_get_main_queue(), ^{ |
207 RTCEAGLVideoView *strongSelf = weakSelf; | 207 RTCEAGLVideoView *strongSelf = weakSelf; |
208 [strongSelf.delegate videoView:strongSelf didChangeVideoSize:size]; | 208 [strongSelf.delegate videoView:strongSelf didChangeVideoSize:size]; |
209 }); | 209 }); |
210 } | 210 } |
211 | 211 |
212 - (void)renderFrame:(RTCVideoFrame *)frame { | 212 - (void)renderFrame:(RTCVideoFrame *)frame { |
| 213 // Generate the i420 frame on video send thread instead of main thread. |
| 214 // TODO(tkchin): Remove this once RTCEAGLVideoView supports uploading |
| 215 // CVPixelBuffer textures. |
| 216 [frame convertBufferIfNeeded]; |
213 self.videoFrame = frame; | 217 self.videoFrame = frame; |
214 } | 218 } |
215 | 219 |
216 #pragma mark - Private | 220 #pragma mark - Private |
217 | 221 |
218 - (void)displayLinkTimerDidFire { | 222 - (void)displayLinkTimerDidFire { |
219 // Don't render unless video frame have changed or the view content | 223 // Don't render unless video frame have changed or the view content |
220 // has explicitly been marked dirty. | 224 // has explicitly been marked dirty. |
221 if (!_isDirty && _glRenderer.lastDrawnFrame == self.videoFrame) { | 225 if (!_isDirty && _glRenderer.lastDrawnFrame == self.videoFrame) { |
222 return; | 226 return; |
(...skipping 27 matching lines...) Expand all Loading... |
250 | 254 |
251 - (void)didBecomeActive { | 255 - (void)didBecomeActive { |
252 [self setupGL]; | 256 [self setupGL]; |
253 } | 257 } |
254 | 258 |
255 - (void)willResignActive { | 259 - (void)willResignActive { |
256 [self teardownGL]; | 260 [self teardownGL]; |
257 } | 261 } |
258 | 262 |
259 @end | 263 @end |
OLD | NEW |