Camera API (Tizen Extension)
Since: 2.2
Table of Contents
- 1. Interfaces
- 1.1. NavigatorTizenCamera
- 1.2. TizenCamera
- 1.3. CreateCameraSuccessCallback
- 1.4. CameraErrorCallback
- 1.5. CameraControl
- 1.6. CameraControlSettings
- 1.7. CameraSuccessCallback
- 1.8. CameraSettingErrorCallback
- 1.9. CameraMediaRecorder
- 1.10. CameraImageCapture
- 1.11. CameraCapabilities
- 1.12. CameraSize
- 1.13. CameraArea
- 1.14. CameraPictureSettings
- 1.15. CameraRecorderSettings
- 1.16. CameraError
- 1.17. CameraSettingErrors
- 2. Related Feature
- 3. Full WebIDL
Summary of Interfaces and Methods
1. Interfaces
1.2. TizenCamera
[NoInterfaceObject] interface TizenCamera { void createCameraControl(MediaStream stream, CreateCameraSuccessCallback successCallback, CameraErrorCallback errorCallback); };
Since: 2.2
Methods
createCameraControl
-
Asynchronously create CameraControl object using input stream.
void createCameraControl(MediaStream stream, CreateCameraSuccessCallback successCallback, CameraErrorCallback errorCallback);
Since: 2.2
Privilege level: public
Privilege: http://tizen.org/privilege/camera
Privilege: http://tizen.org/privilege/audiorecorder
Remark : For video recording and image capture, use http://tizen.org/privilege/camera privilege. For audio recording, use http://tizen.org/privilege/audiorecorder privilege.
Parameters:
- stream: Stream object obtained from getUserMedia. "audio" of MediaStreamOptions dictionary is supported
- successCallback: The method to invoke when CameraControl object is created successfully.
- errorCallback: The method to invoke when an error occurs.
Code example:
navigator.webkitGetUserMedia({video:true,audio:true}, gotStream, noStream); /* For audio recording, use the API as following: navigator.webkitGetUserMedia({video:false,audio:true}, gotStream, noStream); WARNING : Audio recording is not supported in initial target platform version 2.2.1 Version can be checked by tizen.systeminfo.getCapability("http://tizen.org/feature/platform.version") */ function gotStream(stream) { navigator.tizCamera.createCameraControl(stream, gotCamera, noCamera); } function noStream() {} function gotCamera(cam) { /* CameraControl */ camera = cam; } function noCamera() {}
1.3. CreateCameraSuccessCallback
callback interface CreateCameraSuccessCallback { void handleEvent(CameraControl cameraControl); };
Since: 2.2
Methods
handleEvent
-
Called on successful creation of Camera Control object.
void handleEvent(CameraControl cameraControl);
Since: 2.2
Parameters:
- cameraControl: Created camera control.
1.4. CameraErrorCallback
callback interface CameraErrorCallback { void handleEvent(CameraError error); };
Since: 2.2
Methods
handleEvent
-
Called upon Camera API call errors.
void handleEvent(CameraError error);
Since: 2.2
Parameters:
- error: Error that occurred.
1.5. CameraControl
[NoInterfaceObject] interface CameraControl { readonly attribute CameraCapabilities capabilities; readonly attribute CameraMediaRecorder recorder; readonly attribute CameraImageCapture image; void applySettings(CameraControlSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); boolean autoFocus(); void release(); };
Since: 2.2
Attributes
-
readonly
CameraCapabilities capabilitiesRepresents a collection of camera capabilities that camera device provides.
Since: 2.2
-
readonly
CameraMediaRecorder recorderRepresents an object defines media recording related methods.
Since: 2.2
-
readonly
CameraImageCapture imageRepresents an object defines image capture related methods.
Since: 2.2
Methods
applySettings
-
Method to apply new settings to CameraControl object.
void applySettings(CameraControlSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror);
Since: 2.2
Parameters:
- settings: Settings for camera.
- onsuccess: The method to invoke when a new setting is applied successfully.
- onerror: The method to invoke when setting related error occurs.
autoFocus
-
Method responsible for autofocus.
boolean autoFocus();
Since: 2.2
release
-
Method to release the camera resource when an application exits the use of camera.
void release();
Since: 2.2
1.6. CameraControlSettings
dictionary CameraControlSettings { CameraArea focusArea; };
Since: 2.2
Dictionary members
- CameraArea focusArea
-
Specifies focus area bounds.
Since: 2.2
1.7. CameraSuccessCallback
callback interface CameraSuccessCallback { void handleEvent(); };
Since: 2.2
Methods
handleEvent
-
Called on success.
void handleEvent();
Since: 2.2
1.8. CameraSettingErrorCallback
callback interface CameraSettingErrorCallback { void handleEvent(CameraSettingErrors errors); };
Since: 2.2
Methods
handleEvent
-
Called on error.
void handleEvent(CameraSettingErrors errors);
Since: 2.2
Parameters:
- errors: Containing error codes.
1.9. CameraMediaRecorder
[NoInterfaceObject] interface CameraMediaRecorder { attribute onrecordingstatechange; void applySettings(CameraRecorderSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); void start(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); void stop(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); };
Since: 2.2
Attributes
-
EventHandler onrecordingstatechangeRecording state change event handler.
Since: 2.2
Methods
applySettings
-
Set new settings for camera recording.
void applySettings(CameraRecorderSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror);
Since: 2.2
Parameters:
- settings: New settings for camera recording.
- onsuccess: The method to invoke when new settings is applied successfully.
- onerror: The method to invoke when some error occurs.
start
-
Start recording video using camera device.
void start(CameraSuccessCallback onsuccess, CameraErrorCallback onerror);
Since: 2.2
Parameters:
- onsuccess: The method to invoke when recording is started successfully.
- onerror: The method to invoke when some error occurs.
stop
-
Stop recording video using camera device.
void stop(CameraSuccessCallback onsuccess, CameraErrorCallback onerror);
Since: 2.2
Parameters:
- onsuccess: The method to invoke when recording is started successfully.
- onerror: The method to invoke when en error occurs.
1.10. CameraImageCapture
[NoInterfaceObject] interface CameraImageCapture { attribute onshutter; void applySettings(CameraPictureSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); void takePicture(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); };
Since: 2.2
Attributes
-
EventHandler onshutterShutter event handler.
Since: 2.2
Methods
applySettings
-
Set new settings for camera image capture.
void applySettings(CameraPictureSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror);
Since: 2.2
Parameters:
- settings: New settings for photo.
- onsuccess: The method to invoke when new settings is applied successfully.
- onerror: The method to invoke when en error occurs.
takePicture
-
Take picture using camera.
void takePicture(CameraSuccessCallback onsuccess, CameraErrorCallback onerror);
Since: 2.2
Parameters:
- onsuccess
- onerror
1.11. CameraCapabilities
[NoInterfaceObject] interface CameraCapabilities { readonly attribute CameraSize[] pictureSizes; readonly attribute DOMString[] pictureFormats; readonly attribute DOMString[] recordingFormats; };
Since: 2.2
Attributes
-
readonly
CameraSize[]
pictureSizesArray containing available picture sizes.
The following values must be supported:
Device
- [320, 240]
- [320, 320]
- [640, 480]
- [640, 640]
- [1280, 720]
- [1280, 960]
Emulator
- [320, 240]
- [640, 480]
Since: 2.2
-
readonly
DOMString[]
pictureFormatsArray containing available picture formats.
The following formats must be supported:
- "jpeg"
- "png"
Since: 2.2
-
readonly
DOMString[]
recordingFormatsArray containing available picture formats.
The following formats must be supported:
- "3gp"
- "amr"
Since: 2.2
1.12. CameraSize
dictionary CameraSize { long width; long height; };
Since: 2.2
Dictionary members
- long width
-
Width of photo/video.
Since: 2.2
- long height
-
Height of photo/video.
Since: 2.2
1.13. CameraArea
dictionary CameraArea { long top; long left; long bottom; long right; };
Since: 2.2
Dictionary members
- long top
-
Top position of selected area.
Since: 2.2
- long left
-
Left position of selected area.
Since: 2.2
- long bottom
-
Bottom position of selected area.
Since: 2.2
- long right
-
Right position of selected area.
Since: 2.2
1.14. CameraPictureSettings
dictionary CameraPictureSettings { CameraSize pictureSize; DOMString pictureFormat; DOMString fileName; };
Since: 2.2
Dictionary members
- CameraSize pictureSize
-
Contains size of picture. Only sizes in CameraCapabilities are allowed.
Since: 2.2
- DOMString pictureFormat
-
Picture format. Available formats described in CameraCapabilities.pictureFormats.
Since: 2.2
- DOMString fileName
-
File name (without directory) of the picture taken. Files are stored in "/opt/usr/media/Images".
Since: 2.2
1.15. CameraRecorderSettings
dictionary CameraRecorderSettings { long maxFileSizeBytes; DOMString recordingFormat; DOMString fileName; };
Since: 2.2
Dictionary members
- long maxFileSizeBytes
-
Max size of file in bytes. Maximum file size is 10MB (10485760 bytes).
Since: 2.2
- DOMString recordingFormat
-
Format of recording video. Available formats are listed in CameraCapabilities.recordingFormats.
Since: 2.2
- DOMString fileName
-
File name (without directory) of the recorded video. Files are stored in "/opt/usr/media/Videos".
Since: 2.2
1.16. CameraError
[NoInterfaceObject] interface CameraError { readonly attribute unsigned short code; const unsigned short CREATION_FAILED = 0; const unsigned short PERMISSION_DENIED = 1; const unsigned short NO_CAMERA = 2; const unsigned short PIPELINE_ERR = 3; const unsigned short FILE_WRITE_ERR = 4; };
Since: 2.2
Constants
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Attributes
-
readonly
unsigned short codeError code.
Since: 2.2
1.17. CameraSettingErrors
[NoInterfaceObject] interface CameraSettingErrors { readonly attribute unsigned short[] codes; const unsigned short FOCUS_AREA_ERR = 0; const unsigned short PICTURE_SIZE_ERR = 1; const unsigned short PICTURE_FORMAT_ERR = 2; const unsigned short RECORDING_FORMAT_ERR = 3; const unsigned short FILENAME_ERR = 4; const unsigned short MAX_FILE_SIZE_BYTES_ERR = 5; };
Since: 2.2
Constants
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Attributes
-
readonly
unsigned short[]
codesError code.
Since: 2.2
2. Related Feature
To guarantee the running of this application on a device with audio recording, define the following requirements in the config file:
To guarantee the running of this application on a device with image capture, define the following requirements in the config file:
To guarantee the running of this application on a device with video recording, define the following requirements in the config file:
3. Full WebIDL
module Camera { [NoInterfaceObject] interface NavigatorTizenCamera { readonly attribute TizenCamera tizCamera; }; Navigator implements NavigatorTizenCamera; [NoInterfaceObject] interface TizenCamera { void createCameraControl(MediaStream stream, CreateCameraSuccessCallback successCallback, CameraErrorCallback errorCallback); }; callback interface CreateCameraSuccessCallback { void handleEvent(CameraControl cameraControl); }; callback interface CameraErrorCallback { void handleEvent(CameraError error); }; [NoInterfaceObject] interface CameraControl { readonly attribute CameraCapabilities capabilities; readonly attribute CameraMediaRecorder recorder; readonly attribute CameraImageCapture image; void applySettings(CameraControlSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); boolean autoFocus(); void release(); }; dictionary CameraControlSettings { CameraArea focusArea; }; callback interface CameraSuccessCallback { void handleEvent(); }; callback interface CameraSettingErrorCallback { void handleEvent(CameraSettingErrors errors); }; [NoInterfaceObject] interface CameraMediaRecorder { attribute onrecordingstatechange; void applySettings(CameraRecorderSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); void start(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); void stop(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); }; [NoInterfaceObject] interface CameraImageCapture { attribute onshutter; void applySettings(CameraPictureSettings settings, CameraSuccessCallback onsuccess, CameraSettingErrorCallback onerror); void takePicture(CameraSuccessCallback onsuccess, CameraErrorCallback onerror); }; [NoInterfaceObject] interface CameraCapabilities { readonly attribute CameraSize[] pictureSizes; readonly attribute DOMString[] pictureFormats; readonly attribute DOMString[] recordingFormats; }; dictionary CameraSize { long width; long height; }; dictionary CameraArea { long top; long left; long bottom; long right; }; dictionary CameraPictureSettings { CameraSize pictureSize; DOMString pictureFormat; DOMString fileName; }; dictionary CameraRecorderSettings { long maxFileSizeBytes; DOMString recordingFormat; DOMString fileName; }; [NoInterfaceObject] interface CameraError { readonly attribute unsigned short code; const unsigned short CREATION_FAILED = 0; const unsigned short PERMISSION_DENIED = 1; const unsigned short NO_CAMERA = 2; const unsigned short PIPELINE_ERR = 3; const unsigned short FILE_WRITE_ERR = 4; }; [NoInterfaceObject] interface CameraSettingErrors { readonly attribute unsigned short[] codes; const unsigned short FOCUS_AREA_ERR = 0; const unsigned short PICTURE_SIZE_ERR = 1; const unsigned short PICTURE_FORMAT_ERR = 2; const unsigned short RECORDING_FORMAT_ERR = 3; const unsigned short FILENAME_ERR = 4; const unsigned short MAX_FILE_SIZE_BYTES_ERR = 5; }; };