Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit e6145a1

Browse files
committed
formatting
1 parent 0291a29 commit e6145a1

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

packages/camera/android/src/main/java/io/flutter/plugins/camera/CameraPlugin.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,8 @@ private void startPreviewWithByteStream() throws CameraAccessException {
757757
SurfaceTexture surfaceTexture = textureEntry.surfaceTexture();
758758
surfaceTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
759759

760-
captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
760+
captureRequestBuilder =
761+
cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
761762

762763
List<Surface> surfaces = new ArrayList<>();
763764

@@ -800,30 +801,33 @@ private void registerByteStreamEventChannel() {
800801
final EventChannel cameraChannel =
801802
new EventChannel(registrar.messenger(), "plugins.flutter.io/camera/bytes");
802803

803-
cameraChannel.setStreamHandler(new EventChannel.StreamHandler() {
804-
@Override
805-
public void onListen(Object o, EventChannel.EventSink eventSink) {
806-
setByteStreamImageAvailableListener(eventSink);
807-
}
804+
cameraChannel.setStreamHandler(
805+
new EventChannel.StreamHandler() {
806+
@Override
807+
public void onListen(Object o, EventChannel.EventSink eventSink) {
808+
setByteStreamImageAvailableListener(eventSink);
809+
}
808810

809-
@Override
810-
public void onCancel(Object o) {
811-
byteImageReader.setOnImageAvailableListener(null, null);
812-
}
813-
});
811+
@Override
812+
public void onCancel(Object o) {
813+
byteImageReader.setOnImageAvailableListener(null, null);
814+
}
815+
});
814816
}
815817

816818
private void setByteStreamImageAvailableListener(final EventChannel.EventSink eventSink) {
817-
byteImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
818-
@Override
819-
public void onImageAvailable(final ImageReader reader) {
820-
Image img = reader.acquireLatestImage();
821-
if (img == null) return;
822-
823-
eventSink.success(YUV_420_888toNV21(img));
824-
img.close();
825-
}
826-
}, null);
819+
byteImageReader.setOnImageAvailableListener(
820+
new ImageReader.OnImageAvailableListener() {
821+
@Override
822+
public void onImageAvailable(final ImageReader reader) {
823+
Image img = reader.acquireLatestImage();
824+
if (img == null) return;
825+
826+
eventSink.success(YUV_420_888toNV21(img));
827+
img.close();
828+
}
829+
},
830+
null);
827831
}
828832

829833
private byte[] YUV_420_888toNV21(Image image) {

packages/camera/ios/Classes/CameraPlugin.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ @interface FLTByteStreamHandler : NSObject<FlutterStreamHandler>
2525
@property(readonly, nonatomic) FlutterEventSink eventSink;
2626
@end
2727

28-
@implementation FLTByteStreamHandler {}
28+
@implementation FLTByteStreamHandler {
29+
}
2930
- (FlutterError *_Nullable)onCancelWithArguments:(id _Nullable)arguments {
3031
return nil;
3132
}
3233

33-
- (FlutterError *_Nullable)onListenWithArguments:(id _Nullable)arguments eventSink:(nonnull FlutterEventSink)events {
34+
- (FlutterError *_Nullable)onListenWithArguments:(id _Nullable)arguments
35+
eventSink:(nonnull FlutterEventSink)events {
3436
_eventSink = events;
3537
return nil;
3638
}
@@ -210,7 +212,6 @@ - (void)captureOutput:(AVCaptureOutput *)output
210212
// Lock the base address of the pixel buffer
211213
CVPixelBufferLockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
212214

213-
214215
// Get the number of bytes per row for the pixel buffer
215216
void *baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer);
216217

@@ -225,9 +226,10 @@ - (void)captureOutput:(AVCaptureOutput *)output
225226

226227
// Create a bitmap graphics context with the sample buffer data
227228
CGBitmapInfo bitmapInfo =
228-
(kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedFirst) | kCGBitmapByteOrder32Little;
229+
(kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedFirst) | kCGBitmapByteOrder32Little;
229230

230-
CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, bitmapInfo);
231+
CGContextRef context =
232+
CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, bitmapInfo);
231233

232234
// Create a Quartz image from the pixel data in the bitmap graphics context
233235
CGImageRef quartzImage = CGBitmapContextCreateImage(context);
@@ -382,16 +384,17 @@ - (void)stopVideoRecordingWithResult:(FlutterResult)result {
382384

383385
- (void)startByteStreamWithMessenger:(NSObject<FlutterBinaryMessenger> *)messenger {
384386
if (!_isStreamingBytes) {
385-
FlutterEventChannel *eventChannel = [FlutterEventChannel
386-
eventChannelWithName:@"plugins.flutter.io/camera/bytes"
387-
binaryMessenger:messenger];
387+
FlutterEventChannel *eventChannel =
388+
[FlutterEventChannel eventChannelWithName:@"plugins.flutter.io/camera/bytes"
389+
binaryMessenger:messenger];
388390

389391
_byteStreamHandler = [[FLTByteStreamHandler alloc] init];
390392
[eventChannel setStreamHandler:_byteStreamHandler];
391393

392394
_isStreamingBytes = YES;
393395
} else {
394-
_eventSink(@{@"event" : @"error", @"errorDescription" : @"Bytes from camera are already streaming!"});
396+
_eventSink(
397+
@{@"event" : @"error", @"errorDescription" : @"Bytes from camera are already streaming!"});
395398
}
396399
}
397400

@@ -400,7 +403,8 @@ - (void)stopByteStream {
400403
_isStreamingBytes = NO;
401404
_byteStreamHandler = nil;
402405
} else {
403-
_eventSink(@{@"event" : @"error", @"errorDescription" : @"Bytes from camera are not streaming!"});
406+
_eventSink(
407+
@{@"event" : @"error", @"errorDescription" : @"Bytes from camera are not streaming!"});
404408
}
405409
}
406410

0 commit comments

Comments
 (0)