Giter Site home page Giter Site logo

Comments (10)

rostopira avatar rostopira commented on May 21, 2024 1

Here is my fork: https://github.com/rostopira/flutter-webrtc
I will work on updating android for now

from flutter-webrtc.

cloudwebrtc avatar cloudwebrtc commented on May 21, 2024 1

@rostopira Ok, I have joined gitter.

from flutter-webrtc.

cloudwebrtc avatar cloudwebrtc commented on May 21, 2024 1

@rostopira
I found the problem, in the file https://github.com/rostopira/flutter-webrtc/blob/master/ios/Classes/FlutterRTCMediaStream.m#L262 RTCCameraVideoCapturer object needs to be saved, to ensure that it is not destroyed before the session is completed.

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];

from flutter-webrtc.

cloudwebrtc avatar cloudwebrtc commented on May 21, 2024

Hi, is there a more detailed error log?

from flutter-webrtc.

rostopira avatar rostopira commented on May 21, 2024

@cloudwebrtc if there were any log, I could fix it myself :D

from flutter-webrtc.

cloudwebrtc avatar cloudwebrtc commented on May 21, 2024

@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.

from flutter-webrtc.

rostopira avatar rostopira commented on May 21, 2024

@cloudwebrtc yeah, I've did some research, it appears to be in YUV format
Soon I will publish what I've already done in master branch of my fork and will switch to branch to do the same for android (I'm much more android guy than ios, I think I will handle it myself)

from flutter-webrtc.

rostopira avatar rostopira commented on May 21, 2024

I have some progress on updating Android (=
https://github.com/rostopira/flutter-webrtc/tree/android_update_webrtc
What about creating gitter chat?

from flutter-webrtc.

cloudwebrtc avatar cloudwebrtc commented on May 21, 2024

@rostopira
I created an ios_update_webrtc branch from your master and fixed VideoCapturer and VideoRenderer, other issues I am working on.

from flutter-webrtc.

MegaManX32 avatar MegaManX32 commented on May 21, 2024

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

from flutter-webrtc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.