[ITC][capi-media-tool][ACR-1394][New TC for channel mask APIs] 85/206885/3
authorABHISHEK JAIN <j.abhishek@samsung.com>
Tue, 28 May 2019 12:26:24 +0000 (17:56 +0530)
committermanoj gupta <manoj.g2@samsung.com>
Wed, 29 May 2019 10:33:02 +0000 (10:33 +0000)
Change-Id: Ib3559f2576d93703446f5cae53e58e955d702d7f
Signed-off-by: ABHISHEK JAIN <j.abhishek@samsung.com>
src/itc/capi-media-tool/ITs-capi-media-format.c
src/itc/capi-media-tool/tct-capi-media-tool-native_mobile.h
src/itc/capi-media-tool/tct-capi-media-tool-native_tizeniot.h
src/itc/capi-media-tool/tct-capi-media-tool-native_wearable.h

index 14f97782016032f5b14f3d898e21dd40cbb1bc80..82b1f8715a41b16f78dd60cca5b5a5b6bc4bc71e 100755 (executable)
 media_format_h g_hfmt;
 static bool g_bMediaTools = false;
 
+media_format_channel_position_e g_eSetPosition[] = {
+       MEDIA_FORMAT_CHANNEL_POSITION_FRONT_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_FRONT_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_FRONT_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_LFE1,
+       MEDIA_FORMAT_CHANNEL_POSITION_REAR_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_REAR_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_REAR_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_LFE2,
+       MEDIA_FORMAT_CHANNEL_POSITION_SIDE_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_SIDE_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_FRONT_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_FRONT_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_FRONT_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_REAR_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_REAR_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_SIDE_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_SIDE_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_TOP_REAR_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_BOTTOM_FRONT_CENTER,
+       MEDIA_FORMAT_CHANNEL_POSITION_BOTTOM_FRONT_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_WIDE_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_WIDE_RIGHT,
+       MEDIA_FORMAT_CHANNEL_POSITION_SURROUND_LEFT,
+       MEDIA_FORMAT_CHANNEL_POSITION_SURROUND_RIGHT
+};
+
+media_format_mimetype_e g_eFormateMime[] = {
+       MEDIA_FORMAT_PCM,
+        MEDIA_FORMAT_PCM_S16LE,
+        MEDIA_FORMAT_PCM_S24LE,
+        MEDIA_FORMAT_PCM_S32LE,
+        MEDIA_FORMAT_PCM_S16BE,
+        MEDIA_FORMAT_PCM_S24BE,
+        MEDIA_FORMAT_PCM_S32BE,
+        MEDIA_FORMAT_PCM_F32LE,
+        MEDIA_FORMAT_PCM_F32BE,
+        MEDIA_FORMAT_PCM_U16LE,
+        MEDIA_FORMAT_PCM_U24LE,
+        MEDIA_FORMAT_PCM_U32LE,
+        MEDIA_FORMAT_PCM_U16BE,
+        MEDIA_FORMAT_PCM_U24BE,
+        MEDIA_FORMAT_PCM_U32BE,
+        MEDIA_FORMAT_PCMA,
+        MEDIA_FORMAT_PCMU
+};
+
+int g_nBitDepth[] = {
+       16,
+       16,
+       24,
+       32,
+       16,
+       24,
+       32,
+       32,
+       32,
+       16,
+       24,
+       32,
+       16,
+       24,
+       32,
+       32,
+       32
+};
+
 void ITs_media_format_startup(void)
 {
        struct stat stBuff;
@@ -1054,5 +1125,194 @@ int ITc_media_format_get_extra_p(void)
        return 0;
 }
 
+//& purpose: Converts the channels in the channel mask to a positions array \n
+//& and Converts the positions array to a bitmask
+//& type: auto
+/**
+* @testcase                    ITc_media_format_channel_positions_to_from_mask_p
+* @since_tizen                 5.5
+* @author              SRID(j.abhishek)
+* @reviewer            SRID(manoj.g2)
+* @type                                auto
+* @description                 Converts the channels in the channel mask to a positions array \n
+*                              and Converts the positions array to a bitmask
+* @scenario                            Creates a media format, set audio channel \n
+*                                              Convert channel position to mask and mask to position array
+* @apicovered                  media_format_channel_positions_to_mask & media_format_channel_positions_from_mask
+* @passcase                            When media_format_channel_positions_to_mask and media_format_channel_positions_from_mask is successful.
+* @failcase                            If target API media_format_channel_positions_to_mask or media_format_channel_positions_from_mask fails or any precondition API fails.
+* @precondition                        Creates a media format and set audio channel
+* @postcondition               None
+*/
+int ITc_media_format_channel_positions_to_from_mask_p(void)
+{
+       START_TEST;
+
+       int nRet = MEDIA_FORMAT_ERROR_NONE;
+       uint64_t nsetChMask;
+       uint64_t ngetChMask;
+       int nAudioCh = 1;
+       int nChannels;
+       media_format_channel_position_e *eGetPositions;
+
+       nRet = media_format_set_audio_mime(g_hfmt, MEDIA_FORMAT_MP3);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_mime", MediaFormatGetError(nRet));
+
+       nRet = media_format_set_audio_channel(g_hfmt, nAudioCh);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_channel", MediaFormatGetError(nRet));
+
+       nRet = media_format_channel_positions_to_mask(g_hfmt, g_eSetPosition, &nsetChMask);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_channel_positions_to_mask", MediaFormatGetError(nRet));
+
+       nRet = media_format_get_audio_info(g_hfmt, NULL, &nChannels, NULL, NULL, NULL);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_get_audio_info", MediaFormatGetError(nRet));
+
+       eGetPositions = malloc(nChannels * sizeof(media_format_channel_position_e));
+
+       nRet = media_format_channel_positions_from_mask(g_hfmt, ngetChMask, &eGetPositions);
+       PRINT_RESULT_CLEANUP(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_channel_positions_from_mask", MediaFormatGetError(nRet), FREE_MEMORY(eGetPositions));
+
+       FREE_MEMORY(eGetPositions);
+
+       return 0;
+}
+
+//& purpose: Sets/Gets audio channel mask of media format
+//& type: auto
+/**
+* @testcase                    ITc_media_format_set_get_audio_channel_mask_p
+* @since_tizen                 5.5
+* @author              SRID(j.abhishek)
+* @reviewer            SRID(manoj.g2)
+* @type                                auto
+* @description                 Sets/Gets audio channel mask of media format
+* @scenario                            Creates a media format\n
+*                                              Sets/Gets audio channel mask of media format
+* @apicovered                  media_format_set_audio_channel_mask & media_format_get_audio_channel_mask
+* @passcase                            When media_format_set_audio_channel_mask and media_format_get_audio_channel_mask is successful.
+* @failcase                            If target API media_format_set_audio_channel_mask or media_format_get_audio_channel_mask fails or any precondition API fails.
+* @precondition                        Creates a media format and set audio channel
+* @postcondition               None
+*/
+int ITc_media_format_set_get_audio_channel_mask_p(void)
+{
+       START_TEST;
+
+       int nRet = MEDIA_FORMAT_ERROR_NONE;
+       uint64_t nsetChMask;
+       uint64_t ngetChMask;
+
+       nRet = media_format_set_audio_mime(g_hfmt, MEDIA_FORMAT_MP3);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_mime", MediaFormatGetError(nRet));
+
+       nRet = media_format_set_audio_channel(g_hfmt, 1);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_channel", MediaFormatGetError(nRet));
+
+       nRet = media_format_channel_positions_to_mask(g_hfmt, g_eSetPosition, &nsetChMask);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_channel_positions_to_mask", MediaFormatGetError(nRet));
+
+       media_format_set_audio_channel_mask(g_hfmt, nsetChMask);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_channel_mask", MediaFormatGetError(nRet));
+
+       media_format_get_audio_channel_mask(g_hfmt, &ngetChMask);
+       PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_get_audio_channel_mask",MediaFormatGetError(nRet));
+
+       if (nsetChMask != ngetChMask)
+       {
+               FPRINTF("Line : %d] [Function: %s][%s]value mismatch\\n",__LINE__, __FUNCTION__,API_NAMESPACE);
+
+               return 1;
+       }
+       return 0;
+}
+
+//& purpose: Checks whether the given media format is little endian.
+//& type: auto
+/**
+* @testcase                    ITc_media_format_is_little_endian_p
+* @since_tizen                 5.5
+* @author              SRID(j.abhishek)
+* @reviewer            SRID(manoj.g2)
+* @type                                auto
+* @description                 Checks whether the given media format is little endian.
+* @scenario                            Creates a media format\n
+*                                              Checks whether the given media format is little endian.
+* @apicovered                  media_format_is_little_endian
+* @passcase                            When media_format_is_little_endian is successful.
+* @failcase                            If target API media_format_is_little_endian fails or any precondition API fails.
+* @precondition                        Creates a media format and set audio mime
+* @postcondition               None
+*/
+int ITc_media_format_is_little_endian_p(void)
+{
+       START_TEST;
+       int nRet = MEDIA_FORMAT_ERROR_NONE;
+       bool bIsLittleEndian;
+
+       int nEnumSize = sizeof(g_eFormateMime) / sizeof(g_eFormateMime[0]);
+       int nEnumCounter;
+
+       for ( nEnumCounter=0; nEnumCounter<nEnumSize; nEnumCounter++)
+       {
+               nRet = media_format_set_audio_mime(g_hfmt, g_eFormateMime[nEnumCounter]); //MEDIA_FORMAT_PCM);
+               PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_mime", MediaFormatGetError(nRet));
+
+               nRet = media_format_is_little_endian(g_hfmt, &bIsLittleEndian);
+               PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_is_little_endian", MediaFormatGetError(nRet));
+
+               if(bIsLittleEndian)
+               {
+                       FPRINTF("Line : %d] [Function: %s][%s] audio format is little endian\\n",__LINE__, __FUNCTION__,API_NAMESPACE);
+               }
+               else
+               {
+                       FPRINTF("Line : %d] [Function: %s][%s] audio format is big endian\\n",__LINE__, __FUNCTION__,API_NAMESPACE);
+               }
+       }
+       return 0;
+}
+
+//& purpose: Gets the number of bits of information in digital audio using pulse-code modulation (PCM).
+//& type: auto
+/**
+* @testcase                    ITc_media_format_get_audio_bit_depth_p
+* @since_tizen                 5.5
+* @author              SRID(j.abhishek)
+* @reviewer            SRID(manoj.g2)
+* @type                                auto
+* @description                 Gets the number of bits of information in digital audio using pulse-code modulation (PCM).
+* @scenario                            Creates a media format\n
+*                                              Gets the number of bits of information in digital audio using pulse-code modulation (PCM).
+* @apicovered                  media_format_get_audio_bit_depth
+* @passcase                            When media_format_get_audio_bit_depth is successful.
+* @failcase                            If target API media_format_get_audio_bit_depth fails or any precondition API fails.
+* @precondition                        Creates a media format and set audio mime
+* @postcondition               None
+*/
+int ITc_media_format_get_audio_bit_depth_p(void)
+{
+       START_TEST;
+       int nRet = MEDIA_FORMAT_ERROR_NONE;
+       int nBitDepth;
+
+       int nEnumSize = sizeof(g_eFormateMime) / sizeof(g_eFormateMime[0]);
+       int nEnumCounter;
+
+       for ( nEnumCounter=0; nEnumCounter<nEnumSize; nEnumCounter++)
+       {
+               nRet = media_format_set_audio_mime(g_hfmt, g_eFormateMime[nEnumCounter]);
+               PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_set_audio_mime", MediaFormatGetError(nRet));
+
+               nRet = media_format_get_audio_bit_depth(g_hfmt, &nBitDepth);
+               PRINT_RESULT(MEDIA_FORMAT_ERROR_NONE, nRet, "media_format_get_audio_bit_depth", MediaFormatGetError(nRet));
+               if (g_nBitDepth[nEnumCounter] != nBitDepth)
+               {
+                       FPRINTF("Line : %d] [Function: %s][%s] Expected audio bit depth [%d] but retrieved audio bit depth [%d] \\n",__LINE__, __FUNCTION__,API_NAMESPACE, g_nBitDepth[nEnumCounter], nBitDepth);
+                       return 1;
+               }
+       }
+       return 0;
+}
+
 /** @} */ 
 /** @} */
index 6796121f274c8436d597254cbb2542f752258b68..7cdfce798534f79def789e9876fd37ae63f40b5c 100755 (executable)
@@ -85,7 +85,10 @@ extern int ITc_media_format_set_text_mime_set_text_type_get_text_info_p(void);
 extern int ITc_media_format_set_get_audio_aac_header_type_p(void);
 extern int ITc_media_format_set_extra_p(void);
 extern int ITc_media_format_get_extra_p(void);
-
+extern int ITc_media_format_set_get_audio_channel_mask_p(void);
+extern int ITc_media_format_channel_positions_to_from_mask_p(void);
+extern int ITc_media_format_is_little_endian_p(void);
+extern int ITc_media_format_get_audio_bit_depth_p(void);
 
 testcase tc_array[] = {
        {"ITc_media_packet_pool_create_destroy_p",ITc_media_packet_pool_create_destroy_p,ITs_media_pool_startup,ITs_media_pool_cleanup},
@@ -147,6 +150,10 @@ testcase tc_array[] = {
        {"ITc_media_format_set_get_audio_aac_header_type_p",ITc_media_format_set_get_audio_aac_header_type_p,ITs_media_format_startup,ITs_media_format_cleanup},
        {"ITc_media_format_set_extra_p",ITc_media_format_set_extra_p,ITs_media_format_startup,ITs_media_format_cleanup}, 
        {"ITc_media_format_get_extra_p",ITc_media_format_get_extra_p,ITs_media_format_startup,ITs_media_format_cleanup}, 
+       {"ITc_media_format_set_get_audio_channel_mask_p", ITc_media_format_set_get_audio_channel_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_channel_positions_to_from_mask_p", ITc_media_format_channel_positions_to_from_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_is_little_endian_p", ITc_media_format_is_little_endian_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_get_audio_bit_depth_p", ITc_media_format_get_audio_bit_depth_p, ITs_media_format_startup, ITs_media_format_cleanup},
        {NULL, NULL}
 };
 
index 6bf40026a0847bbffacc6668551a4b5fa880f9b0..68bdefb9d25d0c46828c0f42cb773fad35eadc85 100755 (executable)
@@ -84,7 +84,10 @@ extern int ITc_media_format_set_text_mime_set_text_type_get_text_info_p(void);
 extern int ITc_media_format_set_get_audio_aac_header_type_p(void);
 extern int ITc_media_format_set_extra_p(void);
 extern int ITc_media_format_get_extra_p(void);
-
+extern int ITc_media_format_set_get_audio_channel_mask_p(void);
+extern int ITc_media_format_channel_positions_to_from_mask_p(void);
+extern int ITc_media_format_is_little_endian_p(void);
+extern int ITc_media_format_get_audio_bit_depth_p(void);
 
 testcase tc_array[] = {
        {"ITc_media_packet_pool_create_destroy_p",ITc_media_packet_pool_create_destroy_p,ITs_media_pool_startup,ITs_media_pool_cleanup},
@@ -145,6 +148,10 @@ testcase tc_array[] = {
        {"ITc_media_format_set_get_audio_aac_header_type_p",ITc_media_format_set_get_audio_aac_header_type_p,ITs_media_format_startup,ITs_media_format_cleanup},
        {"ITc_media_format_set_extra_p",ITc_media_format_set_extra_p,ITs_media_format_startup,ITs_media_format_cleanup}, 
        {"ITc_media_format_get_extra_p",ITc_media_format_get_extra_p,ITs_media_format_startup,ITs_media_format_cleanup}, 
+       {"ITc_media_format_set_get_audio_channel_mask_p", ITc_media_format_set_get_audio_channel_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_channel_positions_to_from_mask_p", ITc_media_format_channel_positions_to_from_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_is_little_endian_p", ITc_media_format_is_little_endian_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_get_audio_bit_depth_p", ITc_media_format_get_audio_bit_depth_p, ITs_media_format_startup, ITs_media_format_cleanup},
        {NULL, NULL}
 };
 
index 8135dabce79017a015cb06cded2f110da1b138f5..0432abdd0148f5d57feb3ad4eb0ed1fcd4b4045f 100755 (executable)
@@ -85,8 +85,10 @@ extern int ITc_media_format_set_text_mime_set_text_type_get_text_info_p(void);
 extern int ITc_media_format_set_get_audio_aac_header_type_p(void);
 extern int ITc_media_format_set_extra_p(void);
 extern int ITc_media_format_get_extra_p(void);
-
-
+extern int ITc_media_format_set_get_audio_channel_mask_p(void);
+extern int ITc_media_format_channel_positions_to_from_mask_p(void);
+extern int ITc_media_format_is_little_endian_p(void);
+extern int ITc_media_format_get_audio_bit_depth_p(void);
 
 testcase tc_array[] = {
        {"ITc_media_packet_pool_create_destroy_p",ITc_media_packet_pool_create_destroy_p,ITs_media_pool_startup,ITs_media_pool_cleanup},
@@ -148,6 +150,10 @@ testcase tc_array[] = {
        {"ITc_media_format_set_get_audio_aac_header_type_p",ITc_media_format_set_get_audio_aac_header_type_p,ITs_media_format_startup,ITs_media_format_cleanup},
        {"ITc_media_format_set_extra_p",ITc_media_format_set_extra_p,ITs_media_format_startup,ITs_media_format_cleanup},
        {"ITc_media_format_get_extra_p",ITc_media_format_get_extra_p,ITs_media_format_startup,ITs_media_format_cleanup},
+       {"ITc_media_format_set_get_audio_channel_mask_p", ITc_media_format_set_get_audio_channel_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_channel_positions_to_from_mask_p", ITc_media_format_channel_positions_to_from_mask_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_is_little_endian_p", ITc_media_format_is_little_endian_p, ITs_media_format_startup, ITs_media_format_cleanup},
+       {"ITc_media_format_get_audio_bit_depth_p", ITc_media_format_get_audio_bit_depth_p, ITs_media_format_startup, ITs_media_format_cleanup},
        {NULL, NULL}
 };