Commit Graph

242 Commits

Author SHA1 Message Date
cristianoccazinsp
7abf3f78cb feat(ios): Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start. Update advanced example app to use camera ready event instead. (#2642) 2019-12-13 14:51:50 -03:00
cristianoccazinsp
fe5d11d12f feat(iOS): allow for audio session to be kept (#2636)
* allow for audio session to be kept even after unmounts

* readme typo
2019-12-10 11:02:45 -03:00
annakoro
b3d0ebe649 fix(ios): camera is not detecting any faces (#2611) 2019-11-29 11:02:25 -03:00
Moritz
e35cc2dfd3 fix(mlkit): implement proper RNFaceDetectorModuleMLKit if FirebaseMLVision is una… (#2599)
* implement proper RNFaceDetectorModuleMLKit if FirebaseMLVision is unavailable

* fix constants
2019-11-20 07:09:34 -03:00
cristianoccazinsp
aa22fd1fff feat(exif): Implement writeExif for iOS, Android improvements (#2577)
* - Improve Android code so skipProcessing is not needed, the code is more in line with iOS, and is "fast" by default. This means that skipProcessing is no longer needed (nor used), and adding additional options will "slow down" the capture as expected, rather than having always a lot of processing. This shouldn't be a breaking change.

- document the writeExif option, and implement it for iOS as well.

* Release CF object which could cause a memleak
2019-11-20 00:22:08 -03:00
cristianoccazinsp
ffbd805bcf feat(ios): Handle audio interruption in session queue. This prevents the session isRunning flag from getting corrupted due to concurrent updates to the session. (#2567) 2019-11-11 11:42:58 -03:00
cristianoccazinsp
fabacb4e93 feat(ios): Preserve exif/metadata on photo capture. (#2573)
* Preserve exif/metadata on photo capture. Add a few comments to each step of the capture process

* orientation must be fixed before mirroring

* x/y dimensions are redundantly updated (storing the image sets them automatically). However, orientation must be reset on any image change since the final stored image is automatically rotated when it is modified in place.

* revert mirrorImage order, has to be first since forceUpOrientation adjusts the image afterwards.

* Minor change: also implement `onPictureTaken` for iOS in case anyone needs the early event.
2019-11-11 11:29:16 -03:00
cristianoccazinsp
59dfdb649a feat(Ios): handle audio interruptions (#2565)
* This update tries to improve audio recording interruptions on iOS due to phone calls or background music.

- Use a more generic event to handle session interruptions. This removes the need to listen to foreground/background events, and stopping the session this way was actually redundant/wrong (see https://forums.developer.apple.com/thread/61406). This also makes session stopping detection more reliable (calls, suspension due to a call or notification, etc., which would previously not set the recording interrupted flag on every case)

From the above docs: "No, incorrect. You _never_ need to stop your capture session. The capture session automatically stops itself when your app goes to the background and resumes itself when you come back to the foreground."

- Allow for `captureAudio` updates to also update the audio connections internally so the prop can be correctly updated on the fly without remounting.

- add onAudioInterrupted and onAudioConnected events so the UI can handle scenarios where audio is wanted but not available. This should also help in keeping the preview active even if audio is interrupted and we have captureAudio={true}. Lastly, it can be used to detect if we can record audio or not due to the dummy implementation of the audio permission on iOS always returning true.

- check, activate, and release audio sessions (if captureAudio) so we can detect early if audio is available before attempting to connect the input. This will also allow us to detect if we can record even if there was already a call before opening the camera.

- use proper observer for session error instead of of the strong self block. No benefit, but makes code more readable and allows access to instance variables

- getDeviceOrientationWithBlock might fire more than once under some circumstances, ending up taking a picture or video twice. Add a lock and additional check to prevent this.

* no need for change check,

* do not resume audio if we were hinted not to (e.g., music playback happening)

* start session here also on session queue.

* check for session running before trying to record or capture.
This should fix a possible race condition where both the session start call happens at the same time as the record call

* no need to set orientation on constructor, and set it on session queue to prevent race conditions

* move device init and checks also to session queue. This prevents possible double initializations.
2019-11-04 18:39:37 -03:00
cristianoccazinsp
8f4601b3b0 fix(ios): Fix for a possible crash when changing devices and changing focus. If the new device resets the focus, "defocusing" might not be possible if the new device does not support auto focus. For this reason, we need to do a different cleanup on the focus and exposed flags and events. (#2557) 2019-11-04 17:42:28 -03:00
cristianoccazinsp
7abc7c2e01 feat(torch): Torch fixes for iOS and a few nil checks. (#2543)
* Torch fixes for iOS and a few nil checks.

- Torch turned on by default should work as expected (turned on after mounting and camera type switch)
- Torch maintained when video recording starts (it will flicked if preset has to change)
- Torch resumed when app comes back from background (it is disabled on session pause)

* Fix Torch mode while recording for Android as well.
2019-10-16 18:09:07 -03:00
cristianoccazinsp
db8ce264bf fix(ios): Honor captureAudio flag by not requesting audio input if set to false. (#2542)
Further improve video stopping after the slight delay was added so the stop operation works even if video didn't start yet.
2019-10-16 06:50:59 -03:00
cristianoccazinsp
127da64382 fix(ios): Remove flickering due to audio input (#2539)
* Use connection for muting instead of adding/removing outputs to reduce/remove flickering while recording.

* Add a tiny delay before recording starts to prevent the first frame of the video from being underexposed/black.
2019-10-14 10:37:39 -03:00
cristianoccazinsp
6b7d7f4a64 feature(ios): Ios exposure poi (#2514)
* feat: autoexposure on point of interest and defocus on subject change

* Impelement cameraIds for iOS, and various iOS bug fixes.

Summary:

- Implement getCameraIds and cameraId property to manually select a camera device.

- Fix the internal preset being used to properly use a photo and video preset, and check for invalid presets on camera switch.
    - This fixes a bug that would happen after recording. After a recording is complete, the camera preset was set to 4k permanently, and attempting to select any camera that does not support that preset would result in an totally unusable camera. Now, the "Photo" preset is the default which should be the highest quality option for photos, and the previously used "High" preset will be used as video default if no value is provided.
    - This also adds proper support to setting the undocumented "pictureSize" property. Setting this property will change the default photo quality to be that one.

- Minor cleanup to the camera initialization so the same code is not called as many times redundantly (start session / device happening multiple times)
    - The reduced redundant calls to start session and session updates should make the camera startup slightly faster.

- Fix for warnings issued due to misuse of the "isRecording" property. This property was defined as both as a property and a method and was both getting set manually and retrieved with a function. It should now consistently only be retrieved with a function based on the real recording status. Should have no behaivour change, but removes a pesky warning.

- Fix an issue related to the camera getting stuck after a background resume by removing the use of the queue for those two events.

- Fixes a wrong event unsubscription (UIDeviceOrientationDidChangeNotification to UIApplicationDidChangeStatusBarOrientationNotification) from a previous change. Also move event subscriptions to superview changes for consistency and so they are not used/consumed if not needed. After testing, the View of RNCamera is instantiated twice (for some reason I couldn't find) but used only once. RN keeps a reference to the view in memory even after the camera is destroyed, resulting in these events getting fired and handled all the time during the app's lifetime.

* add maxZoom property to iOS.

Android: Not needed as of now. Also, zoom multiplier behaves different on Android and can't be used with the same value as iOS.

* add auto exposure option.
This branch is temporary from the other changes until the proper changes from https://github.com/react-native-community/react-native-camera/pull/2423/files are merged.

* allow for expose POI to also be cleared

* Add ultra-wide lense support. Requires XCode with SDK for iOS 13

* check that video capture device is ready before capturing, fix for string cameraId assignment

* add missing ios 13 camera types and exposure check.

* remove duplicates from camera id list, return its type on IOS, handle WB crash on unsupported devices.

* Do not return virtual devices (we can't really use them with the library), update zoom and flash on preset change so they are maintained while recording/restoring.

* remove redundant duplicates check, add SDK macro check for ultra wide lenses, remove virtual cameras from query

* Add more info about deviceType and iOS camera IDs behaviour.
2019-10-10 12:01:16 -03:00
cristianoccazinsp
58f3b3edbd feat(ios): Add cameraId feature to iOS and various bug fixes (#2510)
* Impelement cameraIds for iOS, and various iOS bug fixes.

Summary:

- Implement getCameraIds and cameraId property to manually select a camera device.

- Fix the internal preset being used to properly use a photo and video preset, and check for invalid presets on camera switch.
    - This fixes a bug that would happen after recording. After a recording is complete, the camera preset was set to 4k permanently, and attempting to select any camera that does not support that preset would result in an totally unusable camera. Now, the "Photo" preset is the default which should be the highest quality option for photos, and the previously used "High" preset will be used as video default if no value is provided.
    - This also adds proper support to setting the undocumented "pictureSize" property. Setting this property will change the default photo quality to be that one.

- Minor cleanup to the camera initialization so the same code is not called as many times redundantly (start session / device happening multiple times)
    - The reduced redundant calls to start session and session updates should make the camera startup slightly faster.

- Fix for warnings issued due to misuse of the "isRecording" property. This property was defined as both as a property and a method and was both getting set manually and retrieved with a function. It should now consistently only be retrieved with a function based on the real recording status. Should have no behaivour change, but removes a pesky warning.

- Fix an issue related to the camera getting stuck after a background resume by removing the use of the queue for those two events.

- Fixes a wrong event unsubscription (UIDeviceOrientationDidChangeNotification to UIApplicationDidChangeStatusBarOrientationNotification) from a previous change. Also move event subscriptions to superview changes for consistency and so they are not used/consumed if not needed. After testing, the View of RNCamera is instantiated twice (for some reason I couldn't find) but used only once. RN keeps a reference to the view in memory even after the camera is destroyed, resulting in these events getting fired and handled all the time during the app's lifetime.

* add maxZoom property to iOS.

Android: Not needed as of now. Also, zoom multiplier behaves different on Android and can't be used with the same value as iOS.
2019-10-08 12:24:21 -03:00
Nathan Heinrich
38a5ffb2eb feat(ios): videoBitrate option for iOS (#2504)
* Update RNCamera.m

Add videoBitrate option for ios, setting video bitrate requires a codec to be set

* Update API documentation

* Update documentation

* Update typings
2019-09-24 09:32:22 -03:00
cristianoccazinsp
653714991b
Use a more appropriate orientation change event
Since the code relies on the status bar orientation, it makes sense to use UIApplicationDidChangeStatusBarOrientationNotification instead. This should fix some issues where the orientation value of the status bar has not been updated when the event is received.
2019-09-19 17:49:25 -03:00
Dominik Schwarz
ccd6f0b57c feat(android): Add exposure (brightness) support for iOS and standardize exposure value (#2419)
* Use standardized exposure value between 0 and 1

* Add iOS native exposure control

* Delete logging

* Add documentation + spell fixes

* Update RNCamera.m

* Remove reset of exposure after tap-to-focus
2019-08-22 15:38:53 -03:00
Zayin Krige
c9402b2ddd fix(ios): for issue #2434 (#2439)
When VCARD doesnt contain ALL name fields, app crashes because it is trying to insert nil values into dictionary. This provides blank strings for nil values in vcard
2019-08-22 11:48:56 -03:00
chubakueno
b47b80d5a4 feat(ios): rectOfInterest (#1852) 2019-08-21 04:40:24 -03:00
Ruslan Bekenev
adac26f5cf fix(ios): wrap captureStillImageAsynchronouslyFromConnection with try/catch (#2056)
* wrap captureStillImageAsynchronouslyFromConnection with try/catch

the diff may look pretty big but the only change made here is
try/catch block added for captureStillImageAsynchronouslyFromConnection
call.
For some reason, this method may throw an exception saying about
inconsistent state.

* make sure null in cameraHandle isn't passed to Native code
2019-08-08 14:32:38 -03:00
Mateus Andrade
ce5311cb86
Merge pull request #2328 from xaphod/bugfix/ios-crash-on-error
Fix two crashes on iOS where error leads to runSession being called b…
2019-07-16 09:31:24 -03:00
Can Ozinci
de88f74788
Update RNCamera.m 2019-06-25 17:27:06 +03:00
Tim Carr
7ea241fa78 Fix two crashes on iOS where error leads to runSession being called before commitConfiguration 2019-06-21 15:48:51 -04:00
Alan Kenyon
e609edc9a6 added node_modules (#2282) 2019-05-26 16:41:03 -03:00
Daniil Ovoshchnikov
1b9fb63e56 feat(mlkit): add mlkit barcode detection ios (#2209)
extend barcode type cases for android
2019-04-16 15:33:46 -03:00
Sankaran Kaliappan
8cc3ca2898 fix(ios): [iOS] Video Interrupted on incoming call fix (#2207)
* [iOS] Video Interrupted on incoming call fix

* Update index.d.ts
2019-04-14 08:47:12 -03:00
Daniil Ovoshchnikov
025e7d97a4 feat(ios): migrate face detection to mlkit (#2193)
add face detection using mlkit
add enable tracking prop
cleanup android set tracking methods
remove old face detection
fix basic example not building on ios
2019-04-11 09:10:19 -03:00
Daniil Ovoshchnikov
773d5e88ba fix(ios): add application will enter foreground listener [iOS] (#2158) 2019-03-20 11:46:03 -03:00
Daniil Ovoshchnikov
0ab570a636 feat(mlkit): Migrate Face, Barcode and Text Recognition to Firebase MLKit (iOS - text, Android - all) (#2075)
* switch to firebase mlkit for text recognition

* migrate android to MLKit

migrate Text detection android to MLKit
update gradle of example app
Update build.gradle
separate gms vision facedetector to general flavor

migrate faceDetector to mlkit and fix incorrect bounds due to padding

migrate barCode detector to mlkit
update android instructions in readme
safe face implementation move gms to generalImplementation

* add mlkit example

setup android of mlkit example

setup ios of mlkit example
fix typo in readme
update example project readme

* amend mlkit migration to include raw data

add barcode detection in basic and mlkit examples

* fix duplicate bridgeDidBackground method

BREAKING CHANGE: We migrated to MLKit instead of Google Mobile Vision
2019-03-11 08:56:24 -03:00
Marius Reimer
1a89d7981a Feature: isRecordingInterrupted video promise property (#2007)
* feat(rn-camera): add isRecordingInterrupted return property

* docs(rn-camera): added isRecordingInterrupted description

* Merge branch 'master' into feat-isRecordingInterrupted
2019-03-10 14:51:51 -03:00
Laurin Quast
959327e99b fix: only call requestRecordPermission in debug mode (#2119) 2019-03-08 18:24:28 -03:00
Laurin Quast
3f8b7954c5
fix(ios): only check permission descriptions availability in debug build (#2070), Fixes #2069
It seems like Apple is rejecting apps that access a Info.plist usage description that is not available. This conflicts with enhanced developer warnings I implemented in #2048.

To fix that I changed the implementation to only check if the usage descriptions are available in `DEBUG` mode. I also added a note developer warnings, that the app might crash in release mode because using a feature that requires a usage description without having one provided will result in an application crash).
2019-01-25 11:03:50 +01:00
Laurin Quast
22533ed8e8
feat: allow camera scene when audio permissions are denied (#2048), Fixes #2047, Fixes #2051 2019-01-18 15:58:48 +01:00
Laurin Quast
4bdcbd372e
fix(ios): workaround accidental breaking change (#2024)
v1.6.0 introduced an accidental breaking change which resulted in videos being recorded without audio.

Closes #2029
2019-01-08 11:15:52 +01:00
TMomemt
960c5b1c16 fix(rct-camera): crash when metadata.stringValue is nil (#2016) 2018-12-19 09:24:00 +01:00
justinkiang
cf0e96417d fix(ios): ensure orientation is retrieved from main thread (#1958) 2018-12-13 10:44:07 +01:00
Laurin Quast
401c485db3
feat(rn-camera): deviceOrientation, videoOrientation, pictureOrientation
* feat(rn-camera): add deviceOrientation and videoOrientation to record response.

* feat(rn-camera): add deviceOrientation and pictureOrientation to take-picture-response

* fix(rn-camera): unify orientation handling for recording and takeing picture

* fix(types): adjust typescript types

* docs(rn-camra): document new properties

* fix(android): respect actual boolean value instead of only checking if it is present.

* feat(android): implement orientation prop for takePictureAsync

* feat(android): implement orientation prop for recordVideoAsync

* docs(rn-camera): adjust documentation

* fix(types): unmark properties as ios only

* fix(android): use constants
2018-12-12 15:04:08 +01:00
Benas Svipas
54fedeedd3 feat(ios): add new method isRecording (#1969)
* feat: isRecording() to RNCamera which returns boolean

* docs: update RNCamera and typings
2018-12-05 17:38:33 +01:00
Laurin Quast
776725ea2b
fix(ios): only mute recording if mute property is set to false (#1932)
Closes #1864
2018-11-19 21:39:19 +01:00
Cosmo Wolfe
41079d54cb fix(ios): select correct capture session preset when defaultVideoQuality is not provided (#1908)
Closes #1900
2018-11-07 12:18:40 +01:00
Cosmo Wolfe
d69d28b400 feat(qr-code): return raw barcode data if available (#1904) 2018-11-07 08:53:56 +01:00
Ruben Maher
f6f9f2916d feat: add property pauseAfterCapture to takePictureAsync (#1641) 2018-11-06 13:18:48 +01:00
watacoz3
5b2631548f fix(ios): use roundf instead of casting to prevent truncated images (#1832) 2018-11-06 11:07:45 +01:00
Michael Elsdörfer
7603706ede feat(rn-camera): trigger onCameraReady on ios emulator (#1881) 2018-11-05 10:07:05 +01:00
Ruben Velazquez Calva
09828cdf1e fix(rn-camera) prevent camera-flickering on ios by introducing new property defaultVideoQuality (#1886)
* Adding defaultVideoQuality property for iOS

* Remove quality in Readme

* Restore preset when cleanup the camera

* Validate isRecording to stopRecording

* Update the quality only if has changed.

* Fix AVCaptureSessionPreset type
2018-10-29 15:59:57 +01:00
Marius Reimer
9efd755458 revert: check if face or text detector libraries are included independently (#1882) 2018-10-24 14:20:56 -03:00
Grzegorz Mandziak
fc3f7bdd29 fix for "ios crash when scan barcode many times #1112" (#1868) 2018-10-22 12:46:25 -03:00
Daniil Ovoshchnikov
1ecef00048 check if face or text detector libraries are included independently (#1863) 2018-10-19 09:30:01 -03:00
Laurin Quast
1bc6d5bff0 Merge remote-tracking branch 'upstream/master' into pull-1640 2018-09-25 08:45:48 +02:00
Laurin Quast
6787cf48d2
Merge pull request #1801 from MrPluto/master
clean up camera when recording finished
2018-09-24 16:32:34 +02:00