ObjC: RTCVideoSource cleanup

RTCVideoSource was recently added in
https://codereview.webrtc.org/2745193002/. This CL addresses some post
commit feedback.

BUG=webrtc:7177

Review-Url: https://codereview.webrtc.org/2812533003
Cr-Commit-Position: refs/heads/master@{#17649}
This commit is contained in:
magjed
2017-04-11 04:50:15 -07:00
committed by Commit bot
parent 29dbb1992a
commit 24da37b0bf
6 changed files with 19 additions and 18 deletions

View File

@ -89,9 +89,9 @@
}
- (RTCVideoSource *)videoSource {
rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objc_video_track_source(
rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objcVideoTrackSource(
new rtc::RefCountedObject<webrtc::ObjcVideoTrackSource>());
return [[RTCVideoSource alloc] initWithNativeVideoSource:objc_video_track_source];
return [[RTCVideoSource alloc] initWithNativeVideoSource:objcVideoTrackSource];
}
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source

View File

@ -10,19 +10,16 @@
#import "WebRTC/RTCVideoCapturer.h"
@implementation RTCVideoCapturer {
__weak id<RTCVideoCapturerDelegate> _delegate;
}
@implementation RTCVideoCapturer
@synthesize delegate = _delegate;
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate {
NSAssert(delegate != nil, @"delegate cannot be nil");
if (self = [super init]) {
_delegate = delegate;
}
return self;
}
- (id<RTCVideoCapturerDelegate>)delegate {
return _delegate;
}
@end

View File

@ -11,11 +11,12 @@
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_OBJCVIDEOTRACKSOURCE_H_
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_OBJCVIDEOTRACKSOURCE_H_
#import <WebRTC/RTCVideoFrame.h>
#include "WebRTC/RTCMacros.h"
#include "webrtc/base/timestampaligner.h"
#include "webrtc/media/base/adaptedvideotracksource.h"
RTC_FWD_DECL_OBJC_CLASS(RTCVideoFrame);
namespace webrtc {
class ObjcVideoTrackSource : public rtc::AdaptedVideoTrackSource {

View File

@ -46,6 +46,9 @@ RTC_EXPORT
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
(nullable RTCMediaConstraints *)constraints;
/** Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer
* implementation, e.g. RTCCameraVideoCapturer, in order to produce frames.
*/
- (RTCVideoSource *)videoSource;
/** Initialize an RTCVideoTrack with a source and an id. */

View File

@ -15,14 +15,17 @@ NS_ASSUME_NONNULL_BEGIN
@class RTCVideoCapturer;
RTC_EXPORT
@protocol RTCVideoCapturerDelegate
@protocol RTCVideoCapturerDelegate <NSObject>
- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame;
@end
RTC_EXPORT
@interface RTCVideoCapturer : NSObject
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate;
@property(nonatomic, readonly, weak) id<RTCVideoCapturerDelegate> delegate;
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@ -18,13 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
RTC_EXPORT
@interface RTCVideoSource : RTCMediaSource<RTCVideoCapturerDelegate>
@interface RTCVideoSource : RTCMediaSource <RTCVideoCapturerDelegate>
- (instancetype)init NS_UNAVAILABLE;
// RTCVideoCapturerDelegate protocol implementation.
- (void)capturer:(RTCVideoCapturer*)capturer didCaptureVideoFrame:(RTCVideoFrame*)frame;
/**
* Calling this function will cause frames to be scaled down to the
* requested resolution. Also, frames will be cropped to match the