Add new field to configure to control interval of audio buffer
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_util.h
index bb1bfbc..75a8a6a 100644 (file)
@@ -27,6 +27,7 @@
 ========================================================================================*/
 #include <gio/gio.h>
 #include <linux/magic.h>
+#include <storage.h>
 
 
 #ifdef __cplusplus
@@ -41,7 +42,7 @@ extern "C" {
 | MACRO DEFINITIONS                                                                    |
 ========================================================================================*/
 #ifndef CLEAR
-#define CLEAR(x)            memset (&(x), 0, sizeof (x))
+#define CLEAR(x)            memset(&(x), 0, sizeof(x))
 #endif
 
 #define MMCAMCORDER_ADD_BUFFER_PROBE(x_pad, x_category, x_callback, x_hcamcorder) \
@@ -57,7 +58,8 @@ do { \
                item->category = x_category; \
                item->handler_id = gst_pad_add_probe(x_pad, GST_PAD_PROBE_TYPE_BUFFER, x_callback, x_hcamcorder, NULL); \
                x_hcamcorder->buffer_probes = g_list_append(x_hcamcorder->buffer_probes, item); \
-               _mmcam_dbg_log("Adding buffer probe on [%s:%s] - [ID : %lu], [Category : %x] ", GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \
+               _mmcam_dbg_log("Adding buffer probe on [%s:%s] - [ID : %lu], [Category : %x] ", \
+                       GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \
        } \
 } while (0);
 
@@ -71,50 +73,52 @@ do { \
        else if (x_category == 0 || !(x_category & _MMCAMCORDER_HANDLER_CATEGORY_ALL)) { \
                _mmcam_dbg_err("Invalid handler category : %x \n", x_category); \
        } else { \
-               item->object =G_OBJECT(x_pad); \
+               item->object = G_OBJECT(x_pad); \
                item->category = x_category; \
                item->handler_id = gst_pad_add_probe(x_pad, GST_PAD_PROBE_TYPE_EVENT_BOTH, x_callback, x_hcamcorder, NULL); \
                x_hcamcorder->event_probes = g_list_append(x_hcamcorder->event_probes, item); \
-               _mmcam_dbg_log("Adding event probe on [%s:%s] - [ID : %lu], [Category : %x] ", GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \
+               _mmcam_dbg_log("Adding event probe on [%s:%s] - [ID : %lu], [Category : %x] ", \
+                       GST_DEBUG_PAD_NAME(item->object), item->handler_id, item->category); \
        } \
 } while (0);
 
-#define MMCAMCORDER_SIGNAL_CONNECT( x_object, x_category, x_signal, x_callback, x_hcamcorder) \
+#define MMCAMCORDER_SIGNAL_CONNECT(x_object, x_category, x_signal, x_callback, x_hcamcorder) \
 do { \
        MMCamcorderHandlerItem* item = NULL; \
        item = (MMCamcorderHandlerItem *) g_malloc(sizeof(MMCamcorderHandlerItem)); \
        if (!item) { \
-               _mmcam_dbg_err("Cannot connect signal [%s]\n", x_signal ); \
+               _mmcam_dbg_err("Cannot connect signal [%s]\n", x_signal); \
        } else if (x_category == 0 || !(x_category & _MMCAMCORDER_HANDLER_CATEGORY_ALL)) { \
                _mmcam_dbg_err("Invalid handler category : %x \n", x_category); \
        } else { \
                item->object = G_OBJECT(x_object); \
                item->category = x_category; \
-               item->handler_id = g_signal_connect(G_OBJECT(x_object), x_signal,\
-                                                   G_CALLBACK(x_callback), x_hcamcorder ); \
+               item->handler_id = g_signal_connect(G_OBJECT(x_object), x_signal, \
+                       G_CALLBACK(x_callback), x_hcamcorder); \
                x_hcamcorder->signals = g_list_append(x_hcamcorder->signals, item); \
-               _mmcam_dbg_log("Connecting signal on [%s][%p] - [ID : %lu], [Category : %x] ", GST_OBJECT_NAME(item->object), item->object, item->handler_id, item->category); \
+               _mmcam_dbg_log("Connecting signal on [%s][%p] - [ID : %lu], [Category : %x] ", \
+                       GST_OBJECT_NAME(item->object), item->object, item->handler_id, item->category); \
        } \
 } while (0);
 
 #define MMCAMCORDER_G_OBJECT_GET(obj, name, value) \
 do { \
        if (obj) { \
-               if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \
+               if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name)) { \
                        g_object_get(G_OBJECT(obj), name, value, NULL); \
                } else { \
-                       _mmcam_dbg_warn ("The object doesn't have a property named(%s)", name); \
+                       _mmcam_dbg_warn("The object doesn't have a property named(%s)", name); \
                } \
        } else { \
                _mmcam_dbg_err("Null object"); \
        } \
-} while(0);
+} while (0);
 
 #define MMCAMCORDER_G_OBJECT_SET(obj, name, value) \
 do { \
        if (obj) { \
                GParamSpec *spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name);\
-               if(spec) { \
+               if (spec) { \
                        if (spec->value_type == G_TYPE_INT64) {\
                                g_object_set(G_OBJECT(obj), name, (gint64)value, NULL); \
                        } else if (spec->value_type == G_TYPE_UINT64) { \
@@ -127,33 +131,33 @@ do { \
                                g_object_set(G_OBJECT(obj), name, value, NULL); \
                        } \
                } else { \
-                       _mmcam_dbg_warn ("The object doesn't have a property named(%s)", name); \
+                       _mmcam_dbg_warn("The object doesn't have a property named(%s)", name); \
                } \
        } else { \
                _mmcam_dbg_err("Null object"); \
        } \
-} while(0);
+} while (0);
 
 #define MMCAMCORDER_G_OBJECT_SET_POINTER(obj, name, value) \
 do { \
        if (obj) { \
                GParamSpec *spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(obj)), name);\
-               if(spec) { \
+               if (spec) { \
                        g_object_set(G_OBJECT(obj), name, value, NULL); \
                } else { \
-                       _mmcam_dbg_warn ("The object doesn't have a property named(%s)", name); \
+                       _mmcam_dbg_warn("The object doesn't have a property named(%s)", name); \
                } \
        } else { \
                _mmcam_dbg_err("Null object"); \
        } \
-} while(0);
+} while (0);
 
-#define MMCAM_FOURCC(a,b,c,d)  (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
+#define MMCAM_FOURCC(a, b, c, d)  (guint32)((a)|(b)<<8|(c)<<16|(d)<<24)
 #define MMCAM_FOURCC_ARGS(fourcc) \
-        ((gchar)((fourcc)&0xff)), \
-        ((gchar)(((fourcc)>>8)&0xff)), \
-        ((gchar)(((fourcc)>>16)&0xff)), \
-        ((gchar)(((fourcc)>>24)&0xff))
+               ((gchar)((fourcc)&0xff)), \
+               ((gchar)(((fourcc)>>8)&0xff)), \
+               ((gchar)(((fourcc)>>16)&0xff)), \
+               ((gchar)(((fourcc)>>24)&0xff))
 
 #define MMCAM_SEND_MESSAGE(handle, msg_id, msg_code) \
 {\
@@ -177,6 +181,7 @@ typedef struct {
        int param;
        int is_playing;
        guint subscribe_id;
+       void *mm_handle;
 } _MMCamcorderGDbusCbInfo;
 
 /**
@@ -221,6 +226,14 @@ typedef struct {
        GMutex lock;                /**< mutex for item */
 } _MMCamcorderMsgItem;
 
+/**
+ * Structure of storage information
+ */
+typedef struct {
+       storage_type_e type;
+       int id;
+} _MMCamcorderStorageInfo;
+
 
 /*=======================================================================================
 | CONSTANT DEFINITIONS                                                                 |
@@ -276,14 +289,15 @@ gboolean _mmcamcorder_find_fourcc(FILE *f, guint32 tag_fourcc, gboolean do_rewin
 gint32 _mmcamcorder_double_to_fix(gdouble d_number);
 gboolean _mmcamcorder_update_size(FILE *f, gint64 prev_pos, gint64 curr_pos);
 gboolean _mmcamcorder_write_loci(FILE *f, _MMCamcorderLocationInfo info);
-gboolean _mmcamcorder_write_geodata(FILE *f,_MMCamcorderLocationInfo info);
+gboolean _mmcamcorder_write_geodata(FILE *f, _MMCamcorderLocationInfo info);
 gboolean _mmcamcorder_write_udta(FILE *f, int gps_enable, _MMCamcorderLocationInfo info, _MMCamcorderLocationInfo geotag);
 guint64 _mmcamcorder_get_container_size(const guchar *size);
 guint64 _mmcamcorder_get_container_size64(const guchar *size);
 gboolean _mmcamcorder_update_composition_matrix(FILE *f, int orientation);
 
 /* File system */
-int _mmcamcorder_get_freespace(const gchar *path, const gchar *root_directory, guint64 *free_space);
+int _mmcamcorder_get_storage_info(const gchar *path, const gchar *root_directory, _MMCamcorderStorageInfo *storage_info);
+int _mmcamcorder_get_freespace(storage_type_e type, guint64 *free_space);
 int _mmcamcorder_get_file_size(const char *filename, guint64 *size);
 int _mmcamcorder_get_file_system_type(const gchar *path, int *file_system_type);
 
@@ -297,6 +311,13 @@ int _mmcamcorder_get_device_flash_brightness(GDBusConnection *conn, int *brightn
 int _mmcamcorder_send_sound_play_message(GDBusConnection *conn, _MMCamcorderGDbusCbInfo *gdbus_info,
        const char *sample_name, const char *stream_role, const char *volume_gain, int sync_play);
 
+/* dbus signal emit */
+void _mmcamcorder_emit_dbus_signal(GDBusConnection *conn, const char *object_name,
+       const char *interface_name, const char *signal_name, int value);
+
+/* audio buffer */
+int _mmcamcorder_get_audiosrc_blocksize(int samplerate, int format, int channel, int interval, int *blocksize);
+
 #ifdef __cplusplus
 }
 #endif