Comments (10)
Here is my fork: https://github.com/rostopira/flutter-webrtc
I will work on updating android for now
from flutter-webrtc.
@rostopira Ok, I have joined gitter.
from flutter-webrtc.
@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.
Hi, is there a more detailed error log?
from flutter-webrtc.
@cloudwebrtc if there were any log, I could fix it myself :D
from flutter-webrtc.
@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.
@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.
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.
@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.
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)
- MacOS: " HOT 1
- Fix URL error failure mode HOT 2
- I need help,always RTCPeerConnectionStateFailed HOT 3
- RTCPeerConnection.createDataChannel fails after updating to version 0.10.2 on web platforms HOT 1
- Ability to control details of jitter buffer (or better documentation on current behaviour)
- Many to many HOT 4
- Error: TypeError: Instance of 'LinkedMap<String, dynamic>': type 'LinkedMap<String, dynamic>' is not a subtype of type 'JSObject' HOT 8
- Disable a connection Video or Audio HOT 2
- Windows Communication Detection Caused System Volume to be Lowered Significantly HOT 1
- Ios audio sometimes missing HOT 2
- IOS pull stream hw decode
- Regarding how to compile the WebRTC library by myself and replace it / 关于如何自己编译webrtc库并替换 HOT 4
- It always end up in RTCPeerConnectionState.RTCPeerConnectionStateFailed. HOT 5
- Need a method to set Audio Output device for web.
- How to set Audio Output Device for web?
- 报错:channel sent a message from native to Flutter on a non-platform thread HOT 1
- can`t get streams
- library "liblkjingle_peerconnection_so.so" not found HOT 1
- onRenegotiationNeeded callback no longer being called on Web HOT 1
- webrtc will drop frames on Linux, is there any way to speed it up?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-webrtc.