iOS VideoEngine: move video_{capture,render} to ARC.

Replaces ye olde timey explicit release with teh hotness of automatic
reference counting.

This is the webrtc/ half; the talk/ half is in https://webrtc-codereview.appspot.com/10499005/

BUG=3054,3055
R=noahric@google.com

Review URL: https://webrtc-codereview.appspot.com/10539005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5770 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2014-03-25 05:15:44 +00:00
parent e42b8ab129
commit e68102e046
14 changed files with 74 additions and 45 deletions

View File

@ -8,6 +8,10 @@
* 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
#include "webrtc/modules/video_capture/ios/device_info_ios.h"
#include "webrtc/modules/video_capture/ios/device_info_ios_objc.h"
#include "webrtc/modules/video_capture/video_capture_impl.h"

View File

@ -8,6 +8,10 @@
* 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 <AVFoundation/AVFoundation.h>
#import "webrtc/modules/video_capture/ios/device_info_ios_objc.h"

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_IOS_VIDEO_CAPTURE_IOS_OBJC_H_
#define WEBRTC_MODULES_VIDEO_CAPTURE_IOS_VIDEO_CAPTURE_IOS_OBJC_H_
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include "webrtc/modules/video_capture/ios/video_capture_ios.h"
@ -20,7 +21,7 @@
// This notification must be posted in order for the capturer to reflect the
// orientation change in video w.r.t. the application orientation.
@interface RTCVideoCaptureIosObjC
: UIViewController<AVCaptureVideoDataOutputSampleBufferDelegate> {
: NSObject<AVCaptureVideoDataOutputSampleBufferDelegate> {
@private
webrtc::videocapturemodule::VideoCaptureIos* _owner;
webrtc::VideoCaptureCapability _capability;

View File

@ -8,6 +8,12 @@
* 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 <UIKit/UIKit.h>
#import "webrtc/modules/video_capture/ios/device_info_ios_objc.h"
#import "webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h"
@ -81,7 +87,6 @@ using namespace webrtc::videocapturemodule;
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (BOOL)setCaptureDeviceByUniqueId:(NSString*)uniqueId {
@ -174,8 +179,6 @@ using namespace webrtc::videocapturemodule;
[_captureSession startRunning];
[captureQuality release];
return YES;
}
@ -199,7 +202,8 @@ using namespace webrtc::videocapturemodule;
}
}
- (void)onVideoError {
- (void)onVideoError:(NSNotification*)notification {
NSLog(@"onVideoError: %@", notification);
// TODO(sjlee): make the specific error handling with this notification.
WEBRTC_TRACE(kTraceError,
kTraceVideoCapture,

View File

@ -8,6 +8,10 @@
* 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
#include "webrtc/modules/video_capture/ios/device_info_ios_objc.h"
#include "webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h"
#include "webrtc/system_wrappers/interface/ref_count.h"
@ -86,7 +90,6 @@ int32_t VideoCaptureIos::StopCapture() {
}
is_capturing_ = false;
return 0;
}

View File

@ -113,6 +113,9 @@
'ios/video_capture_ios.h',
'ios/video_capture_ios.mm',
],
'xcode_settings': {
'CLANG_ENABLE_OBJC_ARC': 'YES',
},
'all_dependent_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [

View File

@ -8,6 +8,10 @@
* 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
// This files is mostly copied from
// webrtc/modules/video_render/android/video_render_opengles20.h

View File

@ -8,6 +8,10 @@
* 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
#include "webrtc/modules/video_render/ios/video_render_ios_channel.h"
using namespace webrtc;

View File

@ -8,6 +8,10 @@
* 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
#include "webrtc/modules/video_render/ios/video_render_ios_gles20.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/event_wrapper.h"
@ -246,7 +250,7 @@ int VideoRenderIosGles20::GetWindowRect(Rect& rect) {
int VideoRenderIosGles20::ChangeWindow(void* new_window) {
CriticalSectionScoped cs(gles_crit_sec_.get());
view_ = (VideoRenderIosView*)new_window;
view_ = (__bridge VideoRenderIosView*)new_window;
return 0;
}

View File

@ -99,7 +99,7 @@ class VideoRenderIosImpl : IVideoRender {
bool full_screen_;
CriticalSectionWrapper* crit_sec_;
VideoRenderIosGles20* ptr_ios_render_;
webrtc::scoped_ptr<VideoRenderIosGles20> ptr_ios_render_;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_RENDER_IOS_VIDEO_RENDER_IOS_IMPL_H_

View File

@ -8,6 +8,10 @@
* 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
#include "webrtc/modules/video_render/ios/video_render_ios_impl.h"
#include "webrtc/modules/video_render/ios/video_render_ios_gles20.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
@ -33,18 +37,13 @@ VideoRenderIosImpl::VideoRenderIosImpl(const int32_t id,
VideoRenderIosImpl::~VideoRenderIosImpl() {
delete crit_sec_;
if (ptr_ios_render_) {
delete ptr_ios_render_;
ptr_ios_render_ = NULL;
}
}
int32_t VideoRenderIosImpl::Init() {
CriticalSectionScoped cs(crit_sec_);
ptr_ios_render_ = new VideoRenderIosGles20(
(VideoRenderIosView*)ptr_window_, full_screen_, id_);
ptr_ios_render_.reset(new VideoRenderIosGles20(
(__bridge VideoRenderIosView*)ptr_window_, full_screen_, id_));
return ptr_ios_render_->Init();
;

View File

@ -16,15 +16,7 @@
#include "webrtc/modules/video_render/ios/open_gles20.h"
@interface VideoRenderIosView : UIView {
@private // NOLINT
EAGLContext* context_;
webrtc::OpenGles20* gles_renderer20_;
int _frameBufferWidth;
int _frameBufferHeight;
unsigned int _defaultFrameBuffer;
unsigned int _colorRenderBuffer;
}
@interface VideoRenderIosView : UIView
- (BOOL)createContext;
- (BOOL)presentFramebuffer;

View File

@ -8,12 +8,23 @@
* 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
#include "webrtc/modules/video_render/ios/video_render_ios_view.h"
#include "webrtc/system_wrappers/interface/trace.h"
using namespace webrtc;
@implementation VideoRenderIosView
@implementation VideoRenderIosView {
EAGLContext* _context;
webrtc::scoped_ptr<webrtc::OpenGles20> _gles_renderer20;
int _frameBufferWidth;
int _frameBufferHeight;
unsigned int _defaultFrameBuffer;
unsigned int _colorRenderBuffer;
}
@synthesize context = context_;
@ -25,7 +36,7 @@ using namespace webrtc;
// init super class
self = [super initWithCoder:coder];
if (self) {
gles_renderer20_ = new OpenGles20();
_gles_renderer20.reset(new OpenGles20());
}
return self;
}
@ -34,7 +45,7 @@ using namespace webrtc;
// init super class
self = [super init];
if (self) {
gles_renderer20_ = new OpenGles20();
_gles_renderer20.reset(new OpenGles20());
}
return self;
}
@ -43,7 +54,7 @@ using namespace webrtc;
// init super class
self = [super initWithFrame:frame];
if (self) {
gles_renderer20_ = new OpenGles20();
_gles_renderer20.reset(new OpenGles20());
}
return self;
}
@ -59,13 +70,7 @@ using namespace webrtc;
_colorRenderBuffer = 0;
}
context_ = nil;
if (gles_renderer20_) {
delete gles_renderer20_;
}
[super dealloc];
[EAGLContext setCurrentContext:nil];
}
- (NSString*)description {
@ -84,14 +89,13 @@ using namespace webrtc;
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
context_ = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!context_) {
if (!_context) {
return NO;
}
// set current EAGLContext to self context_
if (![EAGLContext setCurrentContext:context_]) {
if (![EAGLContext setCurrentContext:_context]) {
return NO;
}
@ -102,7 +106,7 @@ using namespace webrtc;
// Create color render buffer and allocate backing store.
glGenRenderbuffers(1, &_colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer);
[context_ renderbufferStorage:GL_RENDERBUFFER
[_context renderbufferStorage:GL_RENDERBUFFER
fromDrawable:(CAEAGLLayer*)self.layer];
glGetRenderbufferParameteriv(
GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &_frameBufferWidth);
@ -121,12 +125,12 @@ using namespace webrtc;
glBindFramebuffer(GL_FRAMEBUFFER, _defaultFrameBuffer);
glViewport(0, 0, self.frame.size.width, self.frame.size.height);
return gles_renderer20_->Setup([self bounds].size.width,
return _gles_renderer20->Setup([self bounds].size.width,
[self bounds].size.height);
}
- (BOOL)presentFramebuffer {
if (![context_ presentRenderbuffer:GL_RENDERBUFFER]) {
if (![_context presentRenderbuffer:GL_RENDERBUFFER]) {
WEBRTC_TRACE(kTraceWarning,
kTraceVideoRenderer,
0,
@ -139,11 +143,11 @@ using namespace webrtc;
}
- (BOOL)renderFrame:(I420VideoFrame*)frameToRender {
if (![EAGLContext setCurrentContext:context_]) {
if (![EAGLContext setCurrentContext:_context]) {
return NO;
}
return gles_renderer20_->Render(*frameToRender);
return _gles_renderer20->Render(*frameToRender);
}
- (BOOL)setCoordinatesForZOrder:(const float)zOrder
@ -151,7 +155,7 @@ using namespace webrtc;
Top:(const float)top
Right:(const float)right
Bottom:(const float)bottom {
return gles_renderer20_->SetCoordinates(zOrder, left, top, right, bottom);
return _gles_renderer20->SetCoordinates(zOrder, left, top, right, bottom);
}
@end

View File

@ -130,6 +130,9 @@
],
}],
['OS=="ios"', {
'xcode_settings': {
'CLANG_ENABLE_OBJC_ARC': 'YES',
},
'all_dependent_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [