[ACR-1487] Add new preview format and update camera_preview_data_s 92/222192/6 accepted/tizen/unified/20200205.125315 submit/tizen/20200204.080130 submit/tizen/20200204.110420
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 10 Jan 2020 08:47:06 +0000 (17:47 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 16 Jan 2020 08:50:13 +0000 (17:50 +0900)
- new preview format : CAMERA_PIXEL_FORMAT_MJPEG for motion JPEG preview is added
- update camera_preview_data_s : is_delta_frame in camera_preview_data_s is added

[Version] 0.4.29
[Profile] Common
[Issue Type] ACR

Change-Id: If449b78fdaa5092565ab848677fd4d175760d602
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/camera.h
include/camera_private.h
packaging/capi-media-camera.spec
src/camera.c
test/camera_test.c

index 1b5dc7c..63c1739 100644 (file)
@@ -120,7 +120,8 @@ typedef enum {
        CAMERA_PIXEL_FORMAT_ARGB,           /**< ARGB pixel format */
        CAMERA_PIXEL_FORMAT_JPEG,           /**< Encoded pixel format */
        CAMERA_PIXEL_FORMAT_H264 = 15,      /**< Encoded pixel format : H264 (Since 3.0) */
-       CAMERA_PIXEL_FORMAT_INVZ            /**< Depth pixel format : INVZ (Since 5.0) */
+       CAMERA_PIXEL_FORMAT_INVZ,           /**< Depth pixel format : INVZ (Since 5.0) */
+       CAMERA_PIXEL_FORMAT_MJPEG           /**< Encoded pixel format : Motion JPEG for preview (Since 6.0) */
 } camera_pixel_format_e;
 
 /**
@@ -257,6 +258,7 @@ typedef struct {
                struct {
                        unsigned char *data;    /**< The encoded data pointer */
                        unsigned int size;      /**< The size of encoded data */
+                       bool is_delta_frame;    /**< The flag indicating whether it's delta frame or not (Since 6.0) */
                } encoded_plane;            /**< Encoded plane frame data */
 
                struct {
@@ -609,6 +611,7 @@ typedef void (*camera_focus_changed_cb)(camera_focus_state_e state, void *user_d
  *
  * @remarks This function is issued in the context of internal framework so the UI update code should not be directly invoked.\n
  *          If the camera is used as a recorder then this callback function won't be called.
+ * @remarks The @a frame should not be released and it's available until the callback returns.
  *
  * @param[in] frame The reference pointer to preview stream data
  * @param[in] user_data The user data passed from the callback registration function
index 2a74fa5..0ce8ed9 100644 (file)
@@ -87,6 +87,7 @@ typedef struct _camera_stream_data_s {
                struct {
                        unsigned char *data;
                        unsigned int length_data;
+                       int is_delta_frame;
                } encoded, depth, rgb;
        } data;                         /**< pointer of captured stream */
        int data_type;                  /**< data type */
index 27f9f7f..ddefff8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-camera
 Summary:    A Camera API
-Version:    0.4.28
+Version:    0.4.29
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 211b29c..9aa8b48 100644 (file)
@@ -1039,6 +1039,7 @@ static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_b
                if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
                        frame->data.encoded_plane.data = buf_pos;
                        frame->data.encoded_plane.size = stream->data.encoded.length_data;
+                       frame->data.encoded_plane.is_delta_frame = (bool)stream->data.encoded.is_delta_frame;
                        total_size = stream->data.encoded.length_data;
                } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
                        frame->data.depth_plane.data = buf_pos;
index 33e731d..f92cdfa 100644 (file)
@@ -88,6 +88,7 @@ GTimeVal result_time;
 |    LOCAL #defines:                                                    |
 -----------------------------------------------------------------------*/
 #define DEFAULT_FILE_PATH               "/home/owner/media"
+#define PREVIEW_CB_DUMP_FILE_NAME       "preview.data"
 #define MAX_FILE_NAME_LENGTH            256
 #define MAX_FILE_PATH_LENGTH            (MAX_FILE_NAME_LENGTH - 20)
 
@@ -461,9 +462,14 @@ static void _camera_interrupt_started_cb(camera_policy_e policy, camera_state_e
 void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
 {
 #if 1
-       FILE *fp = fopen(DEFAULT_FILE_PATH"/test.raw", "a");
+       char preview_dump[MAX_FILE_NAME_LENGTH] = {'\0',};
+       FILE *fp = NULL;
+
+       snprintf(preview_dump, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, PREVIEW_CB_DUMP_FILE_NAME);
+
+       fp = fopen(preview_dump, "a");
        if (fp == NULL) {
-               g_print("\n==== file[%s] open failed ====\n", DEFAULT_FILE_PATH"/test.raw");
+               g_print("\n==== file[%s] open failed ====\n", preview_dump);
                return;
        }
 
@@ -472,6 +478,8 @@ void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
                fwrite(frame->data.rgb_plane.data, 1, frame->data.rgb_plane.size, fp);
        } else if (frame->format == CAMERA_PIXEL_FORMAT_INVZ) {
                fwrite(frame->data.depth_plane.data, 1, frame->data.depth_plane.size, fp);
+       } else if (frame->format == CAMERA_PIXEL_FORMAT_MJPEG) {
+               fwrite(frame->data.encoded_plane.data, 1, frame->data.encoded_plane.size, fp);
        } else {
                switch (frame->num_of_planes) {
                case 1:
@@ -491,7 +499,7 @@ void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
                }
        }
 
-       g_print("==== file[%s] write done ====\n", DEFAULT_FILE_PATH"/test.raw");
+       g_print("==== file[%s] write done ====\n", preview_dump);
 
        fclose(fp);
        fp = NULL;