Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 24da37b

Browse files
Hnoo112233Commit bot
authored andcommitted
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}
1 parent 29dbb19 commit 24da37b

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
8989
}
9090

9191
- (RTCVideoSource *)videoSource {
92-
rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objc_video_track_source(
92+
rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objcVideoTrackSource(
9393
new rtc::RefCountedObject<webrtc::ObjcVideoTrackSource>());
94-
return [[RTCVideoSource alloc] initWithNativeVideoSource:objc_video_track_source];
94+
return [[RTCVideoSource alloc] initWithNativeVideoSource:objcVideoTrackSource];
9595
}
9696

9797
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source

webrtc/sdk/objc/Framework/Classes/RTCVideoCapturer.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@
1010

1111
#import "WebRTC/RTCVideoCapturer.h"
1212

13-
@implementation RTCVideoCapturer {
14-
__weak id<RTCVideoCapturerDelegate> _delegate;
15-
}
13+
@implementation RTCVideoCapturer
14+
15+
@synthesize delegate = _delegate;
1616

1717
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate {
18+
NSAssert(delegate != nil, @"delegate cannot be nil");
1819
if (self = [super init]) {
1920
_delegate = delegate;
2021
}
2122
return self;
2223
}
2324

24-
- (id<RTCVideoCapturerDelegate>)delegate {
25-
return _delegate;
26-
}
27-
2825
@end

webrtc/sdk/objc/Framework/Classes/objcvideotracksource.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_OBJCVIDEOTRACKSOURCE_H_
1212
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_OBJCVIDEOTRACKSOURCE_H_
1313

14-
#import <WebRTC/RTCVideoFrame.h>
15-
14+
#include "WebRTC/RTCMacros.h"
1615
#include "webrtc/base/timestampaligner.h"
1716
#include "webrtc/media/base/adaptedvideotracksource.h"
1817

18+
RTC_FWD_DECL_OBJC_CLASS(RTCVideoFrame);
19+
1920
namespace webrtc {
2021

2122
class ObjcVideoTrackSource : public rtc::AdaptedVideoTrackSource {

webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ RTC_EXPORT
4646
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
4747
(nullable RTCMediaConstraints *)constraints;
4848

49+
/** Initialize a generic RTCVideoSource. The RTCVideoSource should be passed to a RTCVideoCapturer
50+
* implementation, e.g. RTCCameraVideoCapturer, in order to produce frames.
51+
*/
4952
- (RTCVideoSource *)videoSource;
5053

5154
/** Initialize an RTCVideoTrack with a source and an id. */

webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoCapturer.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ NS_ASSUME_NONNULL_BEGIN
1515
@class RTCVideoCapturer;
1616

1717
RTC_EXPORT
18-
19-
@protocol RTCVideoCapturerDelegate
18+
@protocol RTCVideoCapturerDelegate <NSObject>
2019
- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame;
2120
@end
2221

22+
RTC_EXPORT
2323
@interface RTCVideoCapturer : NSObject
24-
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate;
24+
2525
@property(nonatomic, readonly, weak) id<RTCVideoCapturerDelegate> delegate;
26+
27+
- (instancetype)initWithDelegate:(id<RTCVideoCapturerDelegate>)delegate;
28+
2629
@end
2730

2831
NS_ASSUME_NONNULL_END

webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoSource.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
1818

1919
RTC_EXPORT
2020

21-
@interface RTCVideoSource : RTCMediaSource<RTCVideoCapturerDelegate>
21+
@interface RTCVideoSource : RTCMediaSource <RTCVideoCapturerDelegate>
2222

2323
- (instancetype)init NS_UNAVAILABLE;
2424

25-
// RTCVideoCapturerDelegate protocol implementation.
26-
- (void)capturer:(RTCVideoCapturer*)capturer didCaptureVideoFrame:(RTCVideoFrame*)frame;
27-
2825
/**
2926
* Calling this function will cause frames to be scaled down to the
3027
* requested resolution. Also, frames will be cropped to match the

0 commit comments

Comments
 (0)