-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
😭help wantedExtra attention is neededExtra attention is needed
Description
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
if (videoDevice) {
RTCVideoSource *videoSource = [self.peerConnectionFactory videoSource];
// FIXME The effort above to find a videoDevice value which satisfies the
// specified constraints was pretty much wasted. Salvage facingMode for
// starters because it is kind of a common and hence important feature on
// a mobile device.
RTCCameraVideoCapturer *capt = [[RTCCameraVideoCapturer alloc] initWithDelegate:videoSource];
AVCaptureDeviceFormat *selectedFormat = nil;
int currentDiff = INT_MAX;
int targetWidth = 1280;
int targetHeight = 720;
for (AVCaptureDeviceFormat *format in [RTCCameraVideoCapturer supportedFormatsForDevice:videoDevice]) {
CMVideoDimensions dimension = CMVideoFormatDescriptionGetDimensions(format.formatDescription);
FourCharCode pixelFormat = CMFormatDescriptionGetMediaSubType(format.formatDescription);
int diff = abs(targetWidth - dimension.width) + abs(targetHeight - dimension.height);
if (diff < currentDiff) {
selectedFormat = format;
currentDiff = diff;
} else if (diff == currentDiff && pixelFormat == [capt preferredOutputPixelFormat]) {
selectedFormat = format;
}
}
//NSLog(@"test %@", [(NSString *)selectedFormat lowercaseString]);
if (selectedFormat == nil) {
NSLog(@"Capture format fucked up. Fallback");
selectedFormat = [RTCCameraVideoCapturer supportedFormatsForDevice:videoDevice].firstObject;
}
[capt startCaptureWithDevice:videoDevice format:selectedFormat fps:30 completionHandler:^(NSError *error) {
NSLog(@"Start capture error: %@", [error localizedDescription]);
}];
NSString *trackUUID = [[NSUUID UUID] UUIDString];
RTCVideoTrack *videoTrack = [self.peerConnectionFactory videoTrackWithSource:videoSource trackId:trackUUID];
[mediaStream addVideoTrack:videoTrack];
successCallback(mediaStream);
} else {
// According to step 6.2.3 of the getUserMedia() algorithm, if there is no
// source, fail with a new OverconstrainedError.
errorCallback(@"OverconstrainedError", /* errorMessage */ nil);
}
Metadata
Metadata
Assignees
Labels
😭help wantedExtra attention is neededExtra attention is needed