Fix cyclic build dependency 44/139944/3 accepted/tizen/4.0/unified/20170816.011729 accepted/tizen/4.0/unified/20170816.014854 accepted/tizen/unified/20170728.195515 submit/tizen/20170727.075608 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0_unified/20170814.115522
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 21 Jul 2017 06:26:25 +0000 (15:26 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Fri, 21 Jul 2017 06:44:51 +0000 (15:44 +0900)
remove capi-media-codec depency for test

[Version] 0.1.21
[Profile] Mobile, Wearable, TV
[Issue Type] Fix cyclic dependency

Change-Id: I5fae29310ba9a8d56098a485deb890f6288186fe

CMakeLists.txt
packaging/capi-mediademuxer.spec
test/mediademuxer_test.c

index 4c7acfa..fa91135 100755 (executable)
@@ -13,7 +13,8 @@ SET(INC_PORT_CUSTOM_DIR include/port_custom)
 SET(INC_PORT_FFMPEG_DIR include/port_ffmpeg)
 INCLUDE_DIRECTORIES(${INC_DIR} ${INC_PORT_GST_DIR} ${INC_PORT_CUSTOM_DIR} ${INC_PORT_FFMPEG_DIR})
 
-SET(dependents "dlog glib-2.0 mm-common capi-media-tool iniparser gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 capi-media-codec")
+#SET(dependents "dlog glib-2.0 mm-common capi-media-tool iniparser gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0 capi-media-codec")
+SET(dependents "dlog glib-2.0 mm-common capi-media-tool iniparser gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0")
 SET(pc_dependents "capi-base-common capi-media-tool")
 
 INCLUDE(FindPkgConfig)
index add2edf..4b07b67 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-mediademuxer
 Summary:    A Media Demuxer library in Tizen Native API
-Version:    0.1.20
+Version:    0.1.21
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -11,8 +11,7 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(mm-common)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-media-tool)
-BuildRequires:  pkgconfig(capi-media-codec)
-BuildRequires:  pkgconfig(libtbm)
+#BuildRequires:  pkgconfig(capi-media-codec)
 BuildRequires:  pkgconfig(gstreamer-1.0)
 BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
 BuildRequires:  pkgconfig(gstreamer-video-1.0)
index b532d60..526c6b7 100755 (executable)
@@ -29,7 +29,9 @@
 #include <mediademuxer.h>
 #include <media_format.h>
 #include <media_packet.h>
+#ifdef USE_MEDIA_CODEC
 #include <media_codec.h>
+#endif
 
 /*-----------------------------------------------------------------------
 |    GLOBAL CONSTANT DEFINITIONS:                                       |
@@ -131,10 +133,13 @@ int write_amrwb_header = 0;       /* write  magic number for AMR-WB Header at one time
 #endif
 
 bool validate_with_codec = false;
-mediacodec_h g_media_codec = NULL;
+
 FILE *fp_out_codec_audio = NULL;
-mediacodec_h g_media_codec_1 = NULL;
 FILE *fp_out_codec_video = NULL;
+#ifdef USE_MEDIA_CODEC
+mediacodec_h g_media_codec = NULL;
+mediacodec_h g_media_codec_1 = NULL;
+#endif
 
 /*-----------------------------------------------------------------------
 |    HELPER  FUNCTION                                                                 |
@@ -305,6 +310,7 @@ int test_mediademuxer_get_track_info()
        return ret;
 }
 
+#ifdef USE_MEDIA_CODEC
 static void mediacodec_finish(mediacodec_h handle, FILE *fp)
 {
        int err = 0;
@@ -397,6 +403,86 @@ static void mediacodec_process_audio_pkt(media_packet_h in_buf)
        }
 }
 
+static void _mediacodec_fill_video_buffer_cb(media_packet_h pkt, void *user_data)
+{
+       int err = 0;
+       uint64_t buf_size = 0;
+       void *data = NULL;
+       media_packet_h output_buf;
+
+       if (pkt != NULL) {
+               err = mediacodec_get_output(g_media_codec_1, &output_buf, 0);
+               if (err == MEDIACODEC_ERROR_NONE) {
+                       media_packet_get_buffer_size(output_buf, &buf_size);
+                       /* g_print("%s - output_buf size = %lld\n", __func__, buf_size); */
+                       media_packet_get_buffer_data_ptr(output_buf, &data);
+                       if (data != NULL)
+                               fwrite(data, 1, buf_size, fp_out_codec_video);
+                       else
+                               g_print("Data is null inside _mediacodec_fill_video_buffer_cb\n");
+                       media_packet_destroy(output_buf);
+               } else {
+                       g_print("mediacodec_get_output failed inside _mediacodec_fill_video_buffer_cb lerr = %d\n", err);
+                       return;
+               }
+       } else {
+               g_print("video pkt from mediacodec is null\n");
+       }
+       return;
+}
+
+static void mediacodec_init_video(int codecid, int flag, int width, int height)
+{
+       /* This file  will be used to dump the data */
+       fp_out_codec_video = fopen("/opt/usr/codec_dump_video.out", "wb");
+       g_print("Create dumped file as codec_dump_video.out\n");
+
+       if (g_media_codec_1 != NULL) {
+               mediacodec_unprepare(g_media_codec_1);
+               mediacodec_destroy(g_media_codec_1);
+               g_media_codec_1 = NULL;
+       }
+       if (mediacodec_create(&g_media_codec_1) != MEDIACODEC_ERROR_NONE) {
+               g_print("mediacodec_create is failed\n");
+               return;
+       }
+       /* Now set the code info */
+       if ((mediacodec_set_codec(g_media_codec_1, (mediacodec_codec_type_e)codecid,
+               (mediacodec_support_type_e)flag) != MEDIACODEC_ERROR_NONE)) {
+               g_print("mediacodec_set_codec is failed\n");
+               return;
+       }
+       /* set the video dec info */
+       if ((mediacodec_set_vdec_info(g_media_codec_1, width, height)) != MEDIACODEC_ERROR_NONE) {
+               g_print("mediacodec_set_vdec is failed\n");
+               return;
+       }
+       /* Set the callback for output data, which will be used to write the data to file */
+       mediacodec_set_output_buffer_available_cb(g_media_codec_1,
+                                                                                       _mediacodec_fill_video_buffer_cb,
+                                                                                       g_media_codec_1);
+
+       if (MEDIACODEC_ERROR_NONE !=  mediacodec_prepare(g_media_codec_1)) {
+               g_print("mediacodec_prepare is failed\n");
+               return;
+       }
+}
+
+static void mediacodec_process_video_pkt(media_packet_h in_buf)
+{
+       if (g_media_codec_1 != NULL) {
+               /* process the media packet */
+               if (MEDIACODEC_ERROR_NONE != mediacodec_process_input(g_media_codec_1, in_buf, 0)) {
+                       g_print("mediacodec process input is failed inside mediacodec_process_video_pkt\n");
+                       return;
+               }
+       } else {
+               g_print("mediacodec handle is invalid inside mediacodec_process_video_pkt()\n");
+       }
+}
+
+#endif
+
 void *_fetch_audio_data(void *ptr)
 {
        int ret = MEDIADEMUXER_ERROR_NONE;
@@ -413,6 +499,7 @@ void *_fetch_audio_data(void *ptr)
        *status = -1;
        g_print("Audio Data function\n");
 
+#ifdef USE_MEDIA_CODEC
        if (validate_with_codec) {
                int flag = 0;
                if (a_mime == MEDIA_FORMAT_AAC_LC || a_mime == MEDIA_FORMAT_AAC_HE ||
@@ -445,7 +532,7 @@ void *_fetch_audio_data(void *ptr)
                        return (void *)status;
                }
        }
-
+#endif
        while (1) {
                ret = mediademuxer_read_sample(demuxer, aud_track, &audbuf);
                if (ret != MEDIADEMUXER_ERROR_NONE) {
@@ -484,97 +571,23 @@ void *_fetch_audio_data(void *ptr)
                }
 #endif
 
+#ifdef USE_MEDIA_CODEC
                if (validate_with_codec)
                        mediacodec_process_audio_pkt(audbuf);
                else
+#endif
                        media_packet_destroy(audbuf);
        }
 
        g_print("EOS return of mediademuxer_read_sample() for audio\n");
        *status = 0;
+#ifdef USE_MEDIA_CODEC
        if (validate_with_codec)
                mediacodec_finish(g_media_codec, fp_out_codec_audio);
+#endif
        return (void *)status;
 }
 
-static void _mediacodec_fill_video_buffer_cb(media_packet_h pkt, void *user_data)
-{
-       int err = 0;
-       uint64_t buf_size = 0;
-       void *data = NULL;
-       media_packet_h output_buf;
-
-       if (pkt != NULL) {
-               err = mediacodec_get_output(g_media_codec_1, &output_buf, 0);
-               if (err == MEDIACODEC_ERROR_NONE) {
-                       media_packet_get_buffer_size(output_buf, &buf_size);
-                       /* g_print("%s - output_buf size = %lld\n", __func__, buf_size); */
-                       media_packet_get_buffer_data_ptr(output_buf, &data);
-                       if (data != NULL)
-                               fwrite(data, 1, buf_size, fp_out_codec_video);
-                       else
-                               g_print("Data is null inside _mediacodec_fill_video_buffer_cb\n");
-                       media_packet_destroy(output_buf);
-               } else {
-                       g_print("mediacodec_get_output failed inside _mediacodec_fill_video_buffer_cb lerr = %d\n", err);
-                       return;
-               }
-       } else {
-               g_print("video pkt from mediacodec is null\n");
-       }
-       return;
-}
-
-static void mediacodec_init_video(int codecid, int flag, int width, int height)
-{
-       /* This file  will be used to dump the data */
-       fp_out_codec_video = fopen("/opt/usr/codec_dump_video.out", "wb");
-       g_print("Create dumped file as codec_dump_video.out\n");
-
-       if (g_media_codec_1 != NULL) {
-               mediacodec_unprepare(g_media_codec_1);
-               mediacodec_destroy(g_media_codec_1);
-               g_media_codec_1 = NULL;
-       }
-       if (mediacodec_create(&g_media_codec_1) != MEDIACODEC_ERROR_NONE) {
-               g_print("mediacodec_create is failed\n");
-               return;
-       }
-       /* Now set the code info */
-       if ((mediacodec_set_codec(g_media_codec_1, (mediacodec_codec_type_e)codecid,
-               (mediacodec_support_type_e)flag) != MEDIACODEC_ERROR_NONE)) {
-               g_print("mediacodec_set_codec is failed\n");
-               return;
-       }
-       /* set the video dec info */
-       if ((mediacodec_set_vdec_info(g_media_codec_1, width, height)) != MEDIACODEC_ERROR_NONE) {
-               g_print("mediacodec_set_vdec is failed\n");
-               return;
-       }
-       /* Set the callback for output data, which will be used to write the data to file */
-       mediacodec_set_output_buffer_available_cb(g_media_codec_1,
-                                                                                       _mediacodec_fill_video_buffer_cb,
-                                                                                       g_media_codec_1);
-
-       if (MEDIACODEC_ERROR_NONE !=  mediacodec_prepare(g_media_codec_1)) {
-               g_print("mediacodec_prepare is failed\n");
-               return;
-       }
-}
-
-static void mediacodec_process_video_pkt(media_packet_h in_buf)
-{
-       if (g_media_codec_1 != NULL) {
-               /* process the media packet */
-               if (MEDIACODEC_ERROR_NONE != mediacodec_process_input(g_media_codec_1, in_buf, 0)) {
-                       g_print("mediacodec process input is failed inside mediacodec_process_video_pkt\n");
-                       return;
-               }
-       } else {
-               g_print("mediacodec handle is invalid inside mediacodec_process_video_pkt()\n");
-       }
-}
-
 #if 0
 static void _local_media_packet_get_codec_data(media_packet_h pkt)
 {
@@ -610,6 +623,7 @@ void *_fetch_video_data(void *ptr)
        *status = -1;
        g_print("Video Data function\n");
 
+#ifdef USE_MEDIA_CODEC
        if (validate_with_codec) {
                int flag = 0;
                if (v_mime == MEDIA_FORMAT_H264_SP || v_mime == MEDIA_FORMAT_H264_MP ||
@@ -626,6 +640,7 @@ void *_fetch_video_data(void *ptr)
                        return (void *)status;
                }
        }
+#endif
        while (1) {
                ret = mediademuxer_read_sample(demuxer, vid_track, &vidbuf);
                if (ret != MEDIADEMUXER_ERROR_NONE) {
@@ -651,16 +666,20 @@ void *_fetch_video_data(void *ptr)
                }
 #endif
 
+#ifdef USE_MEDIA_CODEC
                if (validate_with_codec)
                        mediacodec_process_video_pkt(vidbuf);
                else
+#endif
                        media_packet_destroy(vidbuf);
        }
        g_print("EOS return of mediademuxer_read_sample() for video\n");
        *status = 0;
+
+#ifdef USE_MEDIA_CODEC
        if (validate_with_codec)
                mediacodec_finish(g_media_codec_1, fp_out_codec_video);
-
+#endif
        return (void *)status;
 }
 
@@ -903,9 +922,11 @@ static void display_sub_basic()
        g_print("d. Destroy \t");
        g_print("q. Quit \n");
        g_print("---------------------------------------------------------------------------\n");
+#ifdef USE_MEDIA_CODEC
        if (validate_with_codec)
                g_print("[Validation with Media codec]\n");
        else
+#endif
                g_print("[validation as stand alone. To validate with media codec, run mediademuxertest with -c option]\n");
 }
 
@@ -1046,11 +1067,6 @@ static void interpret(char *cmd)
                                        test_mediademuxer_is_encrypted();
                                else
                                        g_print("UNKNOW COMMAND\n");
-                       } else if (len == 2) {
-                               if (strncmp(cmd, "10", len) == 0)
-                                       g_print("UNKNOW COMMAND\n");
-                               else
-                                       g_print("UNKNOW COMMAND\n");
                        } else {
                                g_print("UNKNOW COMMAND\n");
                        }