-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update WebRTC framework #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, is there a more detailed error log? |
@cloudwebrtc if there were any log, I could fix it myself :D |
@rostopira Updating to the new WebRTC takes more time, you can create a branch so we can try it together. The video renderer is also a place to modify because the WebRTC rendering interface does not have the CVPixelBufferRef output of kCVPixelFormatType_32BGRA. |
@cloudwebrtc yeah, I've did some research, it appears to be in YUV format |
Here is my fork: https://github.com/rostopira/flutter-webrtc |
I have some progress on updating Android (= |
@rostopira Ok, I have joined gitter. |
@rostopira I made a patch that you can apply to the code to solve this problem. diff --git a/ios/Classes/FlutterRTCMediaStream.m b/ios/Classes/FlutterRTCMediaStream.m
index 14086b9..e2c7d6b 100755
--- a/ios/Classes/FlutterRTCMediaStream.m
+++ b/ios/Classes/FlutterRTCMediaStream.m
@@ -259,7 +259,7 @@ typedef void (^NavigatorUserMediaSuccessCallback)(RTCMediaStream *mediaStream);
if (videoDevice) {
RTCVideoSource *videoSource = [self.peerConnectionFactory videoSource];
// FIXME: Video capturer shouldn't be local to be able to stop
- RTCCameraVideoCapturer *capt = [[RTCCameraVideoCapturer alloc] initWithDelegate:videoSource];
+ self.videoCapturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:videoSource];
AVCaptureDeviceFormat *selectedFormat = nil;
int currentDiff = INT_MAX;
// TODO: use values from constraints map
@@ -272,7 +272,7 @@ typedef void (^NavigatorUserMediaSuccessCallback)(RTCMediaStream *mediaStream);
if (diff < currentDiff) {
selectedFormat = format;
currentDiff = diff;
- } else if (diff == currentDiff && pixelFormat == [capt preferredOutputPixelFormat]) {
+ } else if (diff == currentDiff && pixelFormat == [self.videoCapturer preferredOutputPixelFormat]) {
selectedFormat = format;
}
}
@@ -280,7 +280,7 @@ typedef void (^NavigatorUserMediaSuccessCallback)(RTCMediaStream *mediaStream);
NSLog(@"Capture format is nil. Fallback");
selectedFormat = [RTCCameraVideoCapturer supportedFormatsForDevice:videoDevice].firstObject;
}
- [capt startCaptureWithDevice:videoDevice format:selectedFormat fps:30 completionHandler:^(NSError *error) {
+ [self.videoCapturer startCaptureWithDevice:videoDevice format:selectedFormat fps:30 completionHandler:^(NSError *error) {
if (error) {
NSLog(@"Start capture error: %@", [error localizedDescription]);
}
diff --git a/ios/Classes/FlutterRTCVideoRenderer.m b/ios/Classes/FlutterRTCVideoRenderer.m
index b840b88..904464c 100755
--- a/ios/Classes/FlutterRTCVideoRenderer.m
+++ b/ios/Classes/FlutterRTCVideoRenderer.m
@@ -74,6 +74,7 @@
#pragma mark - RTCVideoRenderer methods
- (void)renderFrame:(RTCVideoFrame *)frame {
+ NSLog(@"renderFrame: %dx%d", frame.width, frame.height);
//TODO: got a frame => scale to _renderSize => convert to BGRA32 pixelBufferRef
RTCI420Buffer *buffer = [[frame buffer] toI420];
buffer.dataY;
diff --git a/ios/Classes/FlutterWebRTCPlugin.h b/ios/Classes/FlutterWebRTCPlugin.h
index 0c5e648..3682f7f 100644
--- a/ios/Classes/FlutterWebRTCPlugin.h
+++ b/ios/Classes/FlutterWebRTCPlugin.h
@@ -6,6 +6,7 @@
#import <WebRTC/RTCDataChannel.h>
#import <WebRTC/RTCDataChannelConfiguration.h>
#import <WebRTC/RTCMediaStreamTrack.h>
+#import <WebRTC/RTCCameraVideoCapturer.h>
@class FlutterRTCVideoRenderer;
@@ -18,6 +19,7 @@
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, FlutterRTCVideoRenderer *> *renders;
@property (nonatomic, retain) UIViewController *viewController;/*for broadcast or ReplayKit */
@property (nonatomic, strong) NSObject<FlutterBinaryMessenger>* messenger;
+@property (nonatomic, strong) RTCCameraVideoCapturer *videoCapturer;
- (RTCMediaStream*)streamForId:(NSString*)streamId;
diff --git a/ios/Classes/FlutterWebRTCPlugin.m b/ios/Classes/FlutterWebRTCPlugin.m
index 6d84a22..1d7b01f 100644
--- a/ios/Classes/FlutterWebRTCPlugin.m
+++ b/ios/Classes/FlutterWebRTCPlugin.m
@@ -257,7 +257,11 @@
for (RTCVideoTrack *track in stream.videoTracks) {
[self.localTracks removeObjectForKey:track.trackId];
RTCVideoTrack *videoTrack = (RTCVideoTrack *)track;
- //TODO(rostopira)
+ RTCVideoSource *source = videoTrack.source;
+ if(source){
+ [self.videoCapturer stopCapture];
+ self.videoCapturer = nil;
+ }
}
for (RTCAudioTrack *track in stream.audioTracks) {
[self.localTracks removeObjectForKey:track.trackId];
|
@rostopira |
Hey @cloudwebrtc, I am currently using latest webRTC on iOS, and documentation is really sparce, even non existing. I just wanted to thank you, your comment about video capturer not being retained solved my problems also |
Currently I'm trying to update WebRTC
Goal is to make this plugin easily updatable with rolling dependency version
I've removed WebRTC.framework in root, and using CocoaPods dependency (just set
s.dependency 'GoogleWebRTC'
in podspec)However I'm stuck at updating FlutterRTCMediaStream.m
Following code not working
The text was updated successfully, but these errors were encountered: