summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2019-12-09 15:54:22 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2019-12-09 15:54:34 +0900
commit7edc612af14024a26c1149677361f03136dfb5df (patch)
tree46a7b535cadd99f908ac108c698800ed2fa85a6e
parent51240fb4749ecc1c920c64e522f304d4528e985a (diff)
parentae343049a019912dd965d9405e1a15813a071c6b (diff)
downloadlibmm-camcorder-7edc612af14024a26c1149677361f03136dfb5df.tar.gz
libmm-camcorder-7edc612af14024a26c1149677361f03136dfb5df.tar.bz2
libmm-camcorder-7edc612af14024a26c1149677361f03136dfb5df.zip
Change-Id: Ib75eb151a1824c4221d2b641791454a94427d70c Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--packaging/libmm-camcorder.spec2
-rw-r--r--src/Makefile.am6
-rw-r--r--src/include/mm_camcorder_gstcommon.h2
-rw-r--r--src/include/mm_camcorder_rm.h40
-rw-r--r--src/mm_camcorder_gstcommon.c28
-rw-r--r--src/mm_camcorder_internal.c186
-rw-r--r--src/mm_camcorder_rm.c233
-rw-r--r--src/mm_camcorder_stillshot.c16
-rw-r--r--src/mm_camcorder_videorec.c57
9 files changed, 327 insertions, 243 deletions
diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec
index d20b3d1..f4c5eb4 100644
--- a/packaging/libmm-camcorder.spec
+++ b/packaging/libmm-camcorder.spec
@@ -1,6 +1,6 @@
Name: libmm-camcorder
Summary: Camera and recorder library
-Version: 0.10.189
+Version: 0.10.191
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
diff --git a/src/Makefile.am b/src/Makefile.am
index d6403cc..0fdc6db 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,6 +18,9 @@ noinst_HEADERS = include/mm_camcorder_audiorec.h \
include/mm_camcorder_exifinfo.h \
include/mm_camcorder_exifdef.h \
include/mm_camcorder_sound.h
+if RM_SUPPORT
+noinst_HEADERS += include/mm_camcorder_rm.h
+endif
libmmfcamcorder_la_SOURCES = mm_camcorder.c \
mm_camcorder_internal.c \
@@ -31,6 +34,9 @@ libmmfcamcorder_la_SOURCES = mm_camcorder.c \
mm_camcorder_util.c \
mm_camcorder_exifinfo.c \
mm_camcorder_sound.c
+if RM_SUPPORT
+libmmfcamcorder_la_SOURCES += mm_camcorder_rm.c
+endif
libmmfcamcorder_la_CFLAGS = -I$(srcdir)/include \
$(GST_CFLAGS) \
diff --git a/src/include/mm_camcorder_gstcommon.h b/src/include/mm_camcorder_gstcommon.h
index 01250aa..7babef8 100644
--- a/src/include/mm_camcorder_gstcommon.h
+++ b/src/include/mm_camcorder_gstcommon.h
@@ -178,7 +178,7 @@ bool _mmcamcorder_set_videosrc_anti_shake(MMHandleType handle, int anti_shake);
bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilization);
bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int height);
bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate);
-bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop);
+bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop_interval);
bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type, int stream_index);
void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, int bitrate, GstElement *element);
GstPadProbeReturn __mmcamcorder_muxed_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
diff --git a/src/include/mm_camcorder_rm.h b/src/include/mm_camcorder_rm.h
new file mode 100644
index 0000000..f5f83f5
--- /dev/null
+++ b/src/include/mm_camcorder_rm.h
@@ -0,0 +1,40 @@
+/*
+ * libmm-camcorder
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyuntae Kim <ht1211.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __MM_CAMCORDER_RM_H__
+#define __MM_CAMCORDER_RM_H__
+
+#include <mm_types.h>
+
+/*=======================================================================================
+| GLOBAL FUNCTION PROTOTYPES |
+========================================================================================*/
+
+int _mmcamcorder_rm_create(MMHandleType handle);
+
+int _mmcamcorder_rm_allocate(MMHandleType handle);
+
+
+int _mmcamcorder_rm_deallocate(MMHandleType handle);
+
+int _mmcamcorder_rm_release(MMHandleType handle);
+
+#endif /*__MM_CAMCORDER_RM_H__*/
+
diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c
index a0da705..fc4d1e8 100644
--- a/src/mm_camcorder_gstcommon.c
+++ b/src/mm_camcorder_gstcommon.c
@@ -2953,10 +2953,6 @@ bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int heig
bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
{
_MMCamcorderSubContext *sc = NULL;
- GstCameraControl *CameraControl = NULL;
- GstCameraControlChannel *CameraControlChannel = NULL;
- const GList *controls = NULL;
- const GList *item = NULL;
if ((void *)handle == NULL) {
_mmcam_dbg_warn("handle is NULL");
@@ -2976,27 +2972,13 @@ bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
_mmcam_dbg_log("set encoded preview bitrate : %d bps", bitrate);
- CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- controls = gst_camera_control_list_channels(CameraControl);
- _mmcam_dbg_log("controls : %p", controls);
- if (controls != NULL) {
- for (item = controls ; item && item->data ; item = item->next) {
- CameraControlChannel = item->data;
- _mmcam_dbg_log("label : %s", CameraControlChannel->label);
- if (!strcmp(CameraControlChannel->label, "bitrate")) {
- _mmcam_dbg_log("set encoded preview bitrate %d", bitrate);
- return gst_camera_control_set_value(CameraControl, CameraControlChannel, bitrate);
- }
- }
-
- _mmcam_dbg_warn("failed to find \"bitrate\" control channel");
- }
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", bitrate);
- return FALSE;
+ return TRUE;
}
-bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int interval)
+bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop_interval)
{
_MMCamcorderSubContext *sc = NULL;
@@ -3016,9 +2998,9 @@ bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int inte
return FALSE;
}
- _mmcam_dbg_log("set encoded preview GOP interval : %d ms", interval);
+ _mmcam_dbg_log("set encoded preview GOP interval : %d ms", gop_interval);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", interval);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "gop-interval", gop_interval);
return TRUE;
}
diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c
index a48529f..200b068 100644
--- a/src/mm_camcorder_internal.c
+++ b/src/mm_camcorder_internal.c
@@ -42,7 +42,7 @@
#include <system_info.h>
#ifdef _MMCAMCORDER_RM_SUPPORT
-#include <aul.h>
+#include "mm_camcorder_rm.h"
#endif /* _MMCAMCORDER_RM_SUPPORT */
/*---------------------------------------------------------------------------------------
@@ -85,10 +85,6 @@ static gboolean __mmcamcorder_handle_gst_warning(MMHandleType handle, GstMessage
static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
mm_resource_manager_res_h res, void *user_data);
#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-#ifdef _MMCAMCORDER_RM_SUPPORT
-rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
- rm_device_request_s *info, void *cb_data);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
#ifdef _MMCAMCORDER_USE_SET_ATTR_CB
static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data);
#endif /* _MMCAMCORDER_USE_SET_ATTR_CB */
@@ -676,9 +672,6 @@ int _mmcamcorder_destroy(MMHandleType handle)
{
int ret = MM_ERROR_NONE;
int state = MM_CAMCORDER_STATE_NONE;
-#ifdef _MMCAMCORDER_RM_SUPPORT
- int iret = RM_OK;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
GstElement *sink_element = NULL;
int sink_element_size = 0;
@@ -754,12 +747,7 @@ int _mmcamcorder_destroy(MMHandleType handle)
_mmcamcorder_remove_message_all(handle);
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle != 0) {
- iret = rm_unregister(hcamcorder->rm_handle);
- if (iret != RM_OK)
- _mmcam_dbg_err("rm_unregister() failed");
- hcamcorder->rm_handle = 0;
- }
+ _mmcamcorder_rm_release(handle);
#endif /* _MMCAMCORDER_RM_SUPPORT */
/* release DPM handle */
@@ -809,15 +797,6 @@ int _mmcamcorder_realize(MMHandleType handle)
char *socket_path = NULL;
int socket_path_len = 0;
int conn_size = 0;
-#ifdef _MMCAMCORDER_RM_SUPPORT
- int iret = RM_OK;
- int preview_format = MM_PIXEL_FORMAT_NV12;
- int qret = RM_OK;
- int qret_avail = 0; /* 0: not available, 1: available */
- rm_consumer_info rci;
- int app_pid = 0;
- int resource_count = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
@@ -1021,84 +1000,16 @@ int _mmcamcorder_realize(MMHandleType handle)
#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CLIENT_PID, &app_pid,
- NULL);
- rci.app_pid = app_pid;
- aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
-
- /* RM register */
- if (hcamcorder->rm_handle == 0) {
- iret = rm_register((rm_resource_cb)_mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
- if (iret != RM_OK) {
- _mmcam_dbg_err("rm_register fail");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- }
-
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_FORMAT, &preview_format,
- NULL);
-
- resource_count = 0;
- memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
- memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
-
- if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
- hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
-
- _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
-
- resource_count++;
- }
-
- if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
- hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
- hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
-
- _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
-
- resource_count++;
- }
-
- hcamcorder->request_resources.request_num = resource_count;
-
- if (resource_count > 0) {
- qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
- if (qret != RM_OK || qret_avail != 1) {
- _mmcam_dbg_log("rm query failed. retry with sub devices");
-
- resource_count = 0;
-
- if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
- _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
- resource_count++;
- }
-
- if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
- hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
- _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
- resource_count++;
- }
- }
- }
-
- hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
- hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
-
- hcamcorder->request_resources.request_num = resource_count + 1;
- _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
-
- iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
- if (iret != RM_OK) {
- _mmcam_dbg_err("Resource allocation request failed");
- ret = MM_ERROR_RESOURCE_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
+ ret = _mmcamcorder_rm_create(handle);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("Resource create failed");
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ }
+ ret = _mmcamcorder_rm_allocate(handle);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("Resource allocation request failed");
+ _mmcamcorder_rm_release(handle);
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
#endif /* _MMCAMCORDER_RM_SUPPORT */
}
@@ -1158,26 +1069,8 @@ _ERR_CAMCORDER_CMD:
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle) {
- if (hcamcorder->returned_devices.allocated_num > 0) {
- int idx = 0;
- rm_device_request_s requested;
- memset(&requested, 0x0, sizeof(rm_device_request_s));
- requested.request_num = hcamcorder->returned_devices.allocated_num;
- for (idx = 0; idx < requested.request_num; idx++)
- requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
- iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
- if (iret != RM_OK)
- _mmcam_dbg_err("Resource deallocation request failed ");
- }
-
- /* unregister RM */
- int ires = rm_unregister(hcamcorder->rm_handle);
- if (ires != RM_OK)
- _mmcam_dbg_err("rm_unregister() failed");
- hcamcorder->rm_handle = 0;
- }
+ _mmcamcorder_rm_deallocate(handle);
+ _mmcamcorder_rm_release(handle);
#endif /* _MMCAMCORDER_RM_SUPPORT*/
_ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK:
@@ -1284,19 +1177,7 @@ int _mmcamcorder_unrealize(MMHandleType handle)
#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->rm_handle && (hcamcorder->returned_devices.allocated_num > 0)) {
- int iret = RM_OK;
- int idx = 0;
- rm_device_request_s requested;
- memset(&requested, 0x0, sizeof(rm_device_request_s));
- requested.request_num = hcamcorder->returned_devices.allocated_num;
- for (idx = 0; idx < requested.request_num; idx++)
- requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
-
- iret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
- if (iret != RM_OK)
- _mmcam_dbg_err("Resource deallocation request failed ");
- }
+ _mmcamcorder_rm_deallocate(handle);
#endif /* _MMCAMCORDER_RM_SUPPORT*/
/* Deinitialize main context member */
@@ -4081,43 +3962,6 @@ static int __mmcamcorder_resource_release_cb(mm_resource_manager_h rm,
}
#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
-
-#ifdef _MMCAMCORDER_RM_SUPPORT
-rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
- rm_device_request_s *info, void* cb_data)
-{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
- int current_state = MM_CAMCORDER_STATE_NONE;
- rm_cb_result cb_res = RM_CB_RESULT_OK;
-
- mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
-
- current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
-
- _mmcam_dbg_warn("current state %d (handle %p)", current_state, hcamcorder);
-
- _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
-
- /* set RM event code for sending it to application */
- hcamcorder->interrupt_code = event_src;
-
- _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
- switch (event_src) {
- case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
- case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
- __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
- break;
- default:
- break;
- }
-
- _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
-
- return cb_res;
-}
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-
-
int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
{
int ret = MM_ERROR_NONE;
diff --git a/src/mm_camcorder_rm.c b/src/mm_camcorder_rm.c
new file mode 100644
index 0000000..7291d54
--- /dev/null
+++ b/src/mm_camcorder_rm.c
@@ -0,0 +1,233 @@
+/*
+ * libmm-camcorder
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyuntae Kim <ht1211.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+ /*=======================================================================================
+| INCLUDE FILES |
+========================================================================================*/
+#ifdef _MMCAMCORDER_RM_SUPPORT
+#include <aul.h>
+#include <rm_api.h>
+#include "mm_camcorder_rm.h"
+#include "mm_camcorder_internal.h"
+
+static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
+ rm_device_request_s *info, void* cb_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(cb_data);
+ int current_state = MM_CAMCORDER_STATE_NONE;
+ rm_cb_result cb_res = RM_CB_RESULT_OK;
+
+ mmf_return_val_if_fail((MMHandleType)hcamcorder, RM_CB_RESULT_OK);
+
+ current_state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
+
+ _mmcam_dbg_warn("current state %d (handle %p)", current_state, hcamcorder);
+
+ _MMCAMCORDER_LOCK_INTERRUPT(hcamcorder);
+
+ /* set RM event code for sending it to application */
+ hcamcorder->interrupt_code = event_src;
+
+ _mmcam_dbg_log("RM conflict callback : event code 0x%x", event_src);
+ switch (event_src) {
+ case RM_CALLBACK_TYPE_RESOURCE_CONFLICT:
+ case RM_CALLBACK_TYPE_RESOURCE_CONFLICT_UD:
+ __mmcamcorder_force_stop(hcamcorder, _MMCAMCORDER_STATE_CHANGE_BY_RM);
+ break;
+ default:
+ break;
+ }
+
+ _MMCAMCORDER_UNLOCK_INTERRUPT(hcamcorder);
+
+ return cb_res;
+}
+
+
+
+int _mmcamcorder_rm_create(MMHandleType handle)
+{
+ int ret = RM_OK;
+ rm_consumer_info rci;
+ int app_pid = 0;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ if (!hcamcorder) {
+ _mmcam_dbg_err("Not initialized");
+ return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_CLIENT_PID, &app_pid,
+ NULL);
+ rci.app_pid = app_pid;
+ aul_app_get_appid_bypid(rci.app_pid, rci.app_id, sizeof(rci.app_id));
+
+ /* RM register */
+ if (hcamcorder->rm_handle == 0) {
+ ret = rm_register((rm_resource_cb)__mmcamcorder_rm_callback, (void*)hcamcorder, &(hcamcorder->rm_handle), &rci);
+ if (ret != RM_OK) {
+ _mmcam_dbg_err("rm_register fail ret = %d",ret);
+ return MM_ERROR_RESOURCE_INTERNAL;
+ }
+ }
+ return MM_ERROR_NONE;
+}
+
+int _mmcamcorder_rm_allocate(MMHandleType handle)
+{
+ int iret = RM_OK;
+ int preview_format = MM_PIXEL_FORMAT_NV12;
+ int qret = RM_OK;
+ int qret_avail = 0; /* 0: not available, 1: available */
+ int resource_count = 0;
+ int display_surface_type = MM_DISPLAY_SURFACE_OVERLAY;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ if (!hcamcorder) {
+ _mmcam_dbg_err("Not initialized");
+ return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_SURFACE, &display_surface_type,
+ NULL);
+
+ if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_CAMERA_FORMAT, &preview_format,
+ NULL);
+
+ resource_count = 0;
+ memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+ memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+
+ if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER;
+
+ _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER);
+
+ resource_count++;
+ }
+
+ if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER;
+
+ _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER);
+
+ resource_count++;
+ }
+
+ hcamcorder->request_resources.request_num = resource_count;
+
+ if (resource_count > 0) {
+ qret = rm_query(hcamcorder->rm_handle, RM_QUERY_ALLOCATION, &(hcamcorder->request_resources), &qret_avail);
+ if (qret != RM_OK || qret_avail != 1) {
+ _mmcam_dbg_log("rm query failed. retry with sub devices");
+
+ resource_count = 0;
+ memset(&hcamcorder->request_resources, 0x0, sizeof(rm_category_request_s));
+ memset(&hcamcorder->returned_devices, 0x0, sizeof(rm_device_return_s));
+
+ if (preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_VIDEO_DECODER_SUB;
+ _mmcam_dbg_log("request dec rsc - category 0x%x", RM_CATEGORY_VIDEO_DECODER_SUB);
+ resource_count++;
+ }
+
+ if (display_surface_type == MM_DISPLAY_SURFACE_OVERLAY) {
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_SCALER_SUB;
+ _mmcam_dbg_log("request scaler rsc - category 0x%x", RM_CATEGORY_SCALER_SUB);
+ resource_count++;
+ }
+ }
+ }
+ }
+
+ hcamcorder->request_resources.state[resource_count] = RM_STATE_EXCLUSIVE;
+ hcamcorder->request_resources.category_id[resource_count] = RM_CATEGORY_CAMERA;
+
+ hcamcorder->request_resources.request_num = resource_count + 1;
+ _mmcam_dbg_log("request camera rsc - category 0x%x", RM_CATEGORY_CAMERA);
+
+ iret = rm_allocate_resources(hcamcorder->rm_handle, &(hcamcorder->request_resources), &hcamcorder->returned_devices);
+ if (iret != RM_OK) {
+ _mmcam_dbg_err("Resource allocation request failed ret = %d",iret);
+ return MM_ERROR_RESOURCE_INTERNAL;
+ }
+
+ return MM_ERROR_NONE;
+}
+
+
+int _mmcamcorder_rm_deallocate(MMHandleType handle)
+{
+ int rm_ret = RM_OK;
+ int idx = 0;
+ rm_device_request_s requested;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ if (!hcamcorder->rm_handle) {
+ _mmcam_dbg_err("Resource is not initialized ");
+ return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+ }
+
+ if (hcamcorder->returned_devices.allocated_num > 0) {
+ memset(&requested, 0x0, sizeof(rm_device_request_s));
+ requested.request_num = hcamcorder->returned_devices.allocated_num;
+ for (idx = 0; idx < requested.request_num; idx++)
+ requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
+
+ rm_ret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
+ if (rm_ret != RM_OK)
+ _mmcam_dbg_err("Resource deallocation request failed ");
+ }
+
+ return MM_ERROR_NONE;
+}
+
+int _mmcamcorder_rm_release(MMHandleType handle)
+{
+ int rm_ret = RM_OK;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+ if (!hcamcorder->rm_handle) {
+ _mmcam_dbg_err("Resource is not initialized ");
+ return MM_ERROR_RESOURCE_NOT_INITIALIZED;
+ }
+
+ /* unregister RM */
+ rm_ret = rm_unregister(hcamcorder->rm_handle);
+ if (rm_ret != RM_OK)
+ _mmcam_dbg_err("rm_unregister() failed");
+ hcamcorder->rm_handle = 0;
+
+ return MM_ERROR_NONE;
+}
+
+#endif /* _MMCAMCORDER_RM_SUPPORT*/
+
diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c
index 0b0ab0e..5fc9c95 100644
--- a/src/mm_camcorder_stillshot.c
+++ b/src/mm_camcorder_stillshot.c
@@ -53,8 +53,6 @@ do { \
#define THUMBNAIL_JPEG_QUALITY 90
#define TRY_LOCK_MAX_COUNT 100
#define TRY_LOCK_TIME 20000 /* ms */
-#define H264_PREVIEW_BITRATE 1024*10 /* kbps */
-#define H264_PREVIEW_NEWGOP_INTERVAL 1000 /* ms */
#define _MMCAMCORDER_MAKE_THUMBNAIL_INTERNAL_ENCODE
@@ -633,6 +631,8 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
int height = 0;
int fps = 0;
int rotation = 0;
+ int bitrate = 0;
+ int gop_interval = 0;
unsigned int current_framecount = 0;
int current_state = MM_CAMCORDER_STATE_NONE;
gboolean fps_auto = FALSE;
@@ -817,8 +817,16 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
_mmcamcorder_sound_finalize(handle);
} else {
if (info->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", H264_PREVIEW_BITRATE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", H264_PREVIEW_NEWGOP_INTERVAL);
+ ret = mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_ENCODED_PREVIEW_BITRATE, &bitrate,
+ MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
+ NULL);
+ if (ret == MM_ERROR_NONE) {
+ _mmcamcorder_set_encoded_preview_bitrate(handle, bitrate);
+ _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
+ } else {
+ _mmcam_dbg_err("failed to get encoded preview setting");
+ }
}
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
diff --git a/src/mm_camcorder_videorec.c b/src/mm_camcorder_videorec.c
index 7eac0b9..f7d0c42 100644
--- a/src/mm_camcorder_videorec.c
+++ b/src/mm_camcorder_videorec.c
@@ -501,14 +501,12 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
int size = 0;
int fileformat = 0;
int count = 0;
+ int gop_interval = 0;
int ret = MM_ERROR_NONE;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
char *err_name = NULL;
char *target_filename = NULL;
GstCameraControl *CameraControl = NULL;
- GstCameraControlChannel *CameraControlChannel = NULL;
- const GList *controls = NULL;
- const GList *item = NULL;
gint fps = 0;
GstElement *pipeline = NULL;
@@ -822,49 +820,22 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
goto _ERR_CAMCORDER_VIDEO_COMMAND;
}
- /*set the camera control to create the GOP so that video record will get a new key frame*/
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
- GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- controls = gst_camera_control_list_channels(CameraControl);
- if (controls != NULL) {
- for (item = controls ; item && item->data ; item = item->next) {
- CameraControlChannel = item->data;
- _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
- if (!strcmp(CameraControlChannel->label, "new-gop")) {
- /* gst_camera_control_set_value(CameraControl, CameraControlChannel, 1); */
- break;
- }
- }
-
- if (item == NULL)
- _mmcam_dbg_warn("failed to find new-gop control channel");
- }
- } else {
- _mmcam_dbg_warn("Can't cast Video source into camera control or not H264 prevew format[%d]",
- sc->info_image->preview_format);
+ /*set the GOP so that video record will get a new key frame*/
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ if (mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval, NULL) == MM_ERROR_NONE)
+ _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
+ else
+ _mmcam_dbg_err("get gop interval failed");
}
} else {
/* Resume case */
-
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
- GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
- /* generate and I-frame on resuming */
- CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- controls = gst_camera_control_list_channels(CameraControl);
- if (controls != NULL) {
- for (item = controls ; item && item->data ; item = item->next) {
- CameraControlChannel = item->data;
- _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
- if (!strcmp(CameraControlChannel->label, "new-gop")) {
- /* gst_camera_control_set_value(CameraControl, CameraControlChannel, 1); */
- break;
- }
- }
-
- if (item == NULL)
- _mmcam_dbg_warn("failed to find new-gop control channel");
- }
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ if (mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval, NULL) == MM_ERROR_NONE)
+ _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
+ else
+ _mmcam_dbg_err("get gop interval failed");
}
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "runtime-pause", FALSE);