Add new thread for muxed stream callback 96/131996/1 accepted/tizen/unified/20170612.073915 submit/tizen/20170612.030116
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 31 May 2017 12:13:25 +0000 (21:13 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 31 May 2017 12:13:25 +0000 (21:13 +0900)
[Version] 0.3.2
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20170524.4]

Change-Id: I948f991177da436761b8f6b99316fdd9676d8f3d
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/recorder_private.h
packaging/capi-media-recorder.spec
src/recorder.c
test/recorder_test.c

index 504ba7f..b69f691 100644 (file)
@@ -61,7 +61,8 @@ enum {
 
 enum {
        _RECORDER_MESSAGE_HANDLER_TYPE_GENERAL,
-       _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB
+       _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB,
+       _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB
 };
 
 typedef struct _recorder_msg_handler_info_s {
@@ -92,9 +93,12 @@ typedef struct _recorder_cb_info_s {
        /* general message handler info */
        recorder_msg_handler_info_s msg_handler_info;
 
-       /* preview cb message handler info */
+       /* audio stream cb message handler info */
        recorder_msg_handler_info_s audio_stream_cb_info;
 
+       /* muxed stream cb message handler info */
+       recorder_msg_handler_info_s muxed_stream_cb_info;
+
        /* idle event */
        GList *idle_event_list;
        GCond idle_event_cond;
index c96d19b..52d7a2a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-recorder
 Summary:    A Recorder API
-Version:    0.3.1
+Version:    0.3.2
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index dae6827..de81bd5 100644 (file)
@@ -519,6 +519,7 @@ static void _recorder_deactivate_idle_event_all(recorder_cb_info_s *cb_info)
 static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
 {
        recorder_message_s *rec_msg = NULL;
+       recorder_msg_handler_info_s *msg_handler_info = NULL;
 
        if (!cb_info || !msg) {
                LOGE("NULL pointer %p %p", cb_info, msg);
@@ -539,17 +540,17 @@ static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, in
 
        /*LOGD("add recorder message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
 
-       if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM) {
-               g_mutex_lock(&cb_info->audio_stream_cb_info.mutex);
-               g_queue_push_tail(cb_info->audio_stream_cb_info.queue, (gpointer)rec_msg);
-               g_cond_signal(&cb_info->audio_stream_cb_info.cond);
-               g_mutex_unlock(&cb_info->audio_stream_cb_info.mutex);
-       } else {
-               g_mutex_lock(&cb_info->msg_handler_info.mutex);
-               g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)rec_msg);
-               g_cond_signal(&cb_info->msg_handler_info.cond);
-               g_mutex_unlock(&cb_info->msg_handler_info.mutex);
-       }
+       if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM)
+               msg_handler_info = &cb_info->audio_stream_cb_info;
+       else if (event == MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM)
+               msg_handler_info = &cb_info->muxed_stream_cb_info;
+       else
+               msg_handler_info = &cb_info->msg_handler_info;
+
+       g_mutex_lock(&msg_handler_info->mutex);
+       g_queue_push_tail(msg_handler_info->queue, (gpointer)rec_msg);
+       g_cond_signal(&msg_handler_info->cond);
+       g_mutex_unlock(&msg_handler_info->mutex);
 
        rec_msg = NULL;
 
@@ -1171,6 +1172,13 @@ static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
                goto ErrorExit;
        }
 
+       /* message handler thread for muxed stream callback */
+       if (!__create_msg_handler_thread(&cb_info->muxed_stream_cb_info,
+               _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB, "recorder_msg_handler:muxed_stream_cb", cb_info)) {
+               LOGE("muxed_stream_cb_info failed");
+               goto ErrorExit;
+       }
+
        cb_info->fd = sockfd;
 
        /* message receive thread */
@@ -1190,6 +1198,7 @@ ErrorExit:
        if (cb_info) {
                __destroy_msg_handler_thread(&cb_info->msg_handler_info);
                __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+               __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
 
                g_mutex_clear(&cb_info->idle_event_mutex);
                g_cond_clear(&cb_info->idle_event_cond);
@@ -1371,6 +1380,7 @@ static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
 
        __destroy_msg_handler_thread(&cb_info->msg_handler_info);
        __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+       __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
 
        g_mutex_clear(&cb_info->idle_event_mutex);
        g_cond_clear(&cb_info->idle_event_cond);
index 1009754..ce48d36 100644 (file)
@@ -478,6 +478,7 @@ static void print_menu()
                        g_print("\t     'z' Video-stabilization \n");
                        g_print("\t     'm' Camcorder Motion Rate setting \n");
                        g_print("\t     'M' Set/Unset muxed stream callback \n");
+                       g_print("\t     'F' Set file name - %s\n", TARGET_FILENAME_VIDEO);
                        g_print("\t     'b' back\n");
                        g_print("\t=======================================\n");
                } else {
@@ -492,6 +493,7 @@ static void print_menu()
                        g_print("\t     '6' Channel \n");
                        g_print("\t     '7' Encoder bitrate \n");
                        g_print("\t     'M' Set/Unset muxed stream callback \n");
+                       g_print("\t     'F' Set file name - %s\n", TARGET_FILENAME_AUDIO);
                        g_print("\t     'b' back\n");
                        g_print("\t=======================================\n");
                }
@@ -982,6 +984,10 @@ static void setting_menu(gchar buf)
 
                        break;
 
+               case 'F': /* Set file name */
+                       result = recorder_set_filename(hcamcorder->recorder, TARGET_FILENAME_VIDEO);
+                       break;
+
                case 'b': /* back */
                        hcamcorder->menu_state = MENU_STATE_MAIN;
                        break;
@@ -1095,6 +1101,10 @@ static void setting_menu(gchar buf)
 
                        break;
 
+               case 'F': /* Set file name */
+                       result = recorder_set_filename(hcamcorder->recorder, TARGET_FILENAME_AUDIO);
+                       break;
+
                case 'b': /* back */
                        hcamcorder->menu_state = MENU_STATE_MAIN;
                        break;
@@ -1218,11 +1228,6 @@ static gboolean init(int type)
                        g_print("Init fail. (%x)\n", err);
                        goto ERROR;
                }
-               err = recorder_set_filename(hcamcorder->recorder, TARGET_FILENAME_VIDEO);
-               if (err < 0) {
-                       g_print("Init fail. (%x)\n", err);
-                       goto ERROR;
-               }
        } else if (type == MODE_AUDIO) {
        /*================================================================================
          Audio mode
@@ -1252,11 +1257,6 @@ static gboolean init(int type)
                        g_print("Init fail. (%x)\n", err);
                        goto ERROR;
                }
-               err = recorder_set_filename(hcamcorder->recorder, TARGET_FILENAME_AUDIO);
-               if (err < 0) {
-                       g_print("Init fail. (%x)\n", err);
-                       goto ERROR;
-               }
                err = recorder_attr_set_time_limit(hcamcorder->recorder, 360000);
                if (err < 0) {
                        g_print("Init fail. (%x)\n", err);