Check supported HW codec 30/261330/3 accepted/tizen_6.5_unified accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix accepted/tizen_8.0_unified accepted/tizen_unified tizen tizen_6.5 tizen_7.0 tizen_7.0_hotfix tizen_8.0 accepted/tizen/6.5/unified/20211028.114834 accepted/tizen/7.0/unified/20221110.060909 accepted/tizen/7.0/unified/hotfix/20221116.110324 accepted/tizen/8.0/unified/20231005.094408 accepted/tizen/unified/20210716.131313 submit/tizen/20210716.003845 submit/tizen_6.5/20211028.163201 tizen_6.5.m2_release tizen_7.0_m2_release tizen_8.0_m2_release
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 15 Jul 2021 09:15:38 +0000 (18:15 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 15 Jul 2021 10:18:48 +0000 (19:18 +0900)
[Version] 0.0.2
[Issue Type] Update

Change-Id: Ie495f05eed982192dfb3318c7dd851aca8e3873b
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/hal-api-codec.spec
tests/codec_hal_test.cpp

index fa71e35..f1a6a66 100644 (file)
@@ -5,7 +5,7 @@
 ### main package #########
 Name:       %{name}
 Summary:    %{name} interface
-Version:    0.0.1
+Version:    0.0.2
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 63b78f2..58dfc1b 100644 (file)
@@ -52,6 +52,11 @@ typedef enum {
        MPEG4
 } codec_list_e;
 
+typedef enum {
+       DECODER,
+       ENCODER
+} codec_type_e;
+
 struct _codec_list_t {
        codec_list_e ename;
        char cname[CODEC_INI_MAX_STRLEN];
@@ -76,8 +81,8 @@ void get_plugins_list_from_ini(dictionary *dict, codec_list_t *codec_list, int c
        char temp[CNAME_SIZE];
        char cname[CNAME_SIZE];
        const char *type[2];
-       type[0] = ":hw_decoder";
-       type[1] = ":hw_encoder";
+       type[DECODER] = ":hw_decoder";
+       type[ENCODER] = ":hw_encoder";
 
        CODEC_INI_GET_STRING(dict, port_name, (char *)"port_in_use:media_codec_port", (char *)DEFAULT_PORT);
 
@@ -117,13 +122,13 @@ pad_added_cb(GstElement * demux, GstPad * pad, GstBin * pipeline)
 
        if (strstr(caps_str, "h264")) {
                parse = gst_element_factory_make("h264parse", NULL);
-               codec = gst_element_factory_make(codec_list[H264].plugins[0], NULL);
+               codec = gst_element_factory_make(codec_list[H264].plugins[DECODER], NULL);
        } else if (strstr(caps_str, "h263")) {
                parse = gst_element_factory_make("h263parse", NULL);
-               codec = gst_element_factory_make(codec_list[H263].plugins[0], NULL);
+               codec = gst_element_factory_make(codec_list[H263].plugins[DECODER], NULL);
        } else if (strstr(caps_str, "video/mpeg")) {
                parse = gst_element_factory_make("mpeg4videoparse", NULL);
-               codec = gst_element_factory_make(codec_list[MPEG4].plugins[0], NULL);
+               codec = gst_element_factory_make(codec_list[MPEG4].plugins[DECODER], NULL);
        } else {
                GST_WARNING_OBJECT(pad, "non video pad");
                g_free(caps_str);
@@ -172,6 +177,16 @@ void buffer_add(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer da
 {
 }
 
+static gboolean __is_hw_codec_supported(codec_list_e codec, codec_type_e type)
+{
+       if (strlen(codec_list[codec].plugins[type]) == 0) {
+               std::cout << "NO HW CODEC SUPPORTED" << std::endl;
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
 /*
  * main class
  */
@@ -210,9 +225,12 @@ TEST_F(CodecHalTest, InitH263DecoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(H263, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[H263].plugins[0], NULL);
+       codec = gst_element_factory_make(codec_list[H263].plugins[DECODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -241,9 +259,12 @@ TEST_F(CodecHalTest, InitH264DecoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(H264, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[H264].plugins[0], NULL);
+       codec = gst_element_factory_make(codec_list[H264].plugins[DECODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -272,9 +293,12 @@ TEST_F(CodecHalTest, InitMpeg4DecoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(MPEG4, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[MPEG4].plugins[0], NULL);
+       codec = gst_element_factory_make(codec_list[MPEG4].plugins[DECODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -303,9 +327,12 @@ TEST_F(CodecHalTest, InitH263EncoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(H263, ENCODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[H263].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[H263].plugins[ENCODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -334,9 +361,12 @@ TEST_F(CodecHalTest, InitH264EncoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(H264, ENCODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[H264].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[H264].plugins[ENCODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -365,9 +395,12 @@ TEST_F(CodecHalTest, InitMpeg4EncoderP)
        GstElement *sink, *src, *codec, *pipeline;
        GstStateChangeReturn ret;
 
+       if (!__is_hw_codec_supported(MPEG4, ENCODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
        src = gst_element_factory_make("fakesrc", NULL);
-       codec = gst_element_factory_make(codec_list[MPEG4].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[MPEG4].plugins[ENCODER], NULL);
        sink = gst_element_factory_make("fakesink", NULL);
 
        gst_bin_add_many(GST_BIN(pipeline), src, codec, sink, NULL);
@@ -399,6 +432,9 @@ TEST_F(CodecHalTest, DecodeH264P)
        GstBus *bus;
        gchar *path;
 
+       if (!__is_hw_codec_supported(H264, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
 
        src = gst_element_factory_make("filesrc", NULL);
@@ -467,6 +503,9 @@ TEST_F(CodecHalTest, DecodeH263P)
        GstBus *bus;
        gchar *path;
 
+       if (!__is_hw_codec_supported(H263, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
 
        src = gst_element_factory_make("filesrc", NULL);
@@ -535,6 +574,9 @@ TEST_F(CodecHalTest, DecodeMPEG4P)
        GstBus *bus;
        gchar *path;
 
+       if (!__is_hw_codec_supported(MPEG4, DECODER))
+               return;
+
        pipeline = gst_pipeline_new("pipeline");
 
        src = gst_element_factory_make("filesrc", NULL);
@@ -617,7 +659,7 @@ TEST_F(CodecHalTest, EncodeH264P)
 
        src = gst_element_factory_make("appsrc", NULL);
 
-       codec = gst_element_factory_make(codec_list[H264].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[H264].plugins[ENCODER], NULL);
 
        bus = gst_element_get_bus(pipeline);
        bus_watch_id = gst_bus_add_watch(bus, bus_callback, NULL);
@@ -679,7 +721,7 @@ TEST_F(CodecHalTest, EncodeH263P)
 
        src = gst_element_factory_make("appsrc", NULL);
 
-       codec = gst_element_factory_make(codec_list[H263].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[H263].plugins[ENCODER], NULL);
 
        bus = gst_element_get_bus(pipeline);
        bus_watch_id = gst_bus_add_watch(bus, bus_callback, NULL);
@@ -730,7 +772,7 @@ TEST_F(CodecHalTest, EncodeMPEG4P)
 
        src = gst_element_factory_make("appsrc", NULL);
 
-       codec = gst_element_factory_make(codec_list[MPEG4].plugins[1], NULL);
+       codec = gst_element_factory_make(codec_list[MPEG4].plugins[ENCODER], NULL);
 
        bus = gst_element_get_bus(pipeline);
        bus_watch_id = gst_bus_add_watch(bus, bus_callback, NULL);