Move some APIs to proper source file and make them static 83/280683/2 accepted/tizen/unified/20220904.214041 submit/tizen/20220902.091410
authorhj kim <backto.kim@samsung.com>
Fri, 2 Sep 2022 06:38:46 +0000 (15:38 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 2 Sep 2022 06:47:14 +0000 (15:47 +0900)
[Version] 0.3.229
[Issue Type] Refactoring

Change-Id: I377c6c12b46d0d4ec80aa77be773efb19309c155

include/webrtc_source_private.h
packaging/capi-media-webrtc.spec
src/webrtc_source_mediapacket.c
src/webrtc_source_private.c

index 4c052708bf857ad534293b9ea8021fe611b48fea..17bac0e2df08eb3e87d190c713787c24ad429c3f 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "webrtc.h"
 #include "webrtc_private.h"
-#include <gst/audio/audio.h>
 
 #define GET_AV_IDX_BY_TYPE(x_media_type) GET_AV_IDX(x_media_type == MEDIA_TYPE_AUDIO)
 
@@ -74,13 +73,9 @@ typedef enum {
        ELEMENT_FAKESINK
 } gst_element_e;
 
-const char *_get_audio_format_name(media_format_mimetype_e mime_type);
-const char *_get_video_format_name(media_format_mimetype_e mime_type, bool zerocopy_enabled);
 const char *_get_source_element(webrtc_s *webrtc, int type);
 GstElement *_find_element_in_bin(GstBin *bin, const gchar *name);
 bool _is_hw_encoder_used(webrtc_s *webrtc, webrtc_media_source_type_e source_type, media_type_e media_type);
-GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format);
-bool _is_supported_mime_type(media_format_mimetype_e mime_type);
 GstCaps *_get_caps_from_encoded_audio_media_type(const char *media_type, int channels, int samplerate);
 GstCaps *_get_caps_from_encoded_video_media_type(const char *media_type, int width, int height);
 GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source, GstElement *encoder);
index 193410a212fb3ad615c912a11f551c2b06299726..478fc0199f47ee6e373748e8ece8a123894be4df 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.228
+Version:    0.3.229
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 875c0d0cf5e971834f739a424dc94edf3b0c27ce..e5af6fd92dc8a978f2caf7fb75b542e99bea006d 100644 (file)
@@ -347,6 +347,52 @@ error:
 }
 //LCOV_EXCL_STOP
 
+static const char *__get_audio_format_name(media_format_mimetype_e mime_type)
+{
+       switch (mime_type) {
+       /* RAW formats */
+       case MEDIA_FORMAT_PCM_S16LE:
+               return "S16LE";
+       /* ENCODED formats */
+       case MEDIA_FORMAT_PCMU:
+               return "PCMU";
+       case MEDIA_FORMAT_PCMA:
+               return "PCMA";
+       case MEDIA_FORMAT_OPUS:
+               return "OPUS";
+       case MEDIA_FORMAT_VORBIS:
+               return "VORBIS";
+       default:
+               LOG_ERROR("not supported audio mime_type(0x%x)", mime_type);
+               return NULL;
+       }
+}
+
+static const char *__get_video_format_name(media_format_mimetype_e mime_type, bool zerocopy_enabled)
+{
+       switch (mime_type) {
+       /* RAW formats */
+       case MEDIA_FORMAT_I420:
+               return zerocopy_enabled ? "S420" : "I420";
+       case MEDIA_FORMAT_NV12:
+               return zerocopy_enabled ? "SN12" : "NV12";
+       /* ENCODED formats */
+       case MEDIA_FORMAT_VP8:
+               return "VP8";
+       case MEDIA_FORMAT_VP9:
+               return "VP9";
+       case MEDIA_FORMAT_H264_SP: /* baseline profile */
+       case MEDIA_FORMAT_H264_MP: /* main profile */
+       case MEDIA_FORMAT_H264_HP: /* high profile */
+               return "H264";
+       case MEDIA_FORMAT_MJPEG:
+               return "JPEG";
+       default:
+               LOG_ERROR("not supported video mime_type(0x%x)", mime_type);
+               return NULL;
+       }
+}
+
 GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source)
 {
        GstCaps *caps = NULL;
@@ -382,7 +428,7 @@ GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *sour
                RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE,
                        NULL, "failed to media_format_get_video_frame_rate()");
                caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
-                                               "format", G_TYPE_STRING, _get_video_format_name(mime_type, source->zerocopy_enabled),
+                                               "format", G_TYPE_STRING, __get_video_format_name(mime_type, source->zerocopy_enabled),
                                                "framerate", GST_TYPE_FRACTION, framerate, 1,
                                                "width", G_TYPE_INT, width,
                                                "height", G_TYPE_INT, height,
@@ -622,6 +668,40 @@ exit:
 }
 //LCOV_EXCL_STOP
 
+static bool __is_supported_mime_type(media_format_mimetype_e mime_type)
+{
+       switch (mime_type) {
+       /* AUDIO/RAW formats */
+       case MEDIA_FORMAT_PCM_S16LE:
+               LOG_INFO("[AUDIO][RAW/%s] mime_type[0x%x]", __get_audio_format_name(mime_type), mime_type);
+               return true;
+       /* VIDEO/RAW formats */
+       case MEDIA_FORMAT_I420:
+       case MEDIA_FORMAT_NV12:
+               LOG_INFO("[VIDEO][RAW/%s] mime_type[0x%x]", __get_video_format_name(mime_type, false), mime_type);
+               return true;
+       /* AUDIO/ENCODED formats */
+       case MEDIA_FORMAT_PCMU:
+       case MEDIA_FORMAT_PCMA:
+       case MEDIA_FORMAT_OPUS:
+       case MEDIA_FORMAT_VORBIS:
+               LOG_INFO("[AUDIO][ENCODED/%s] mime_type[0x%x]", __get_audio_format_name(mime_type), mime_type);
+               return true;
+       /* VIDEO/ENCODED formats */
+       case MEDIA_FORMAT_VP8:
+       case MEDIA_FORMAT_VP9:
+       case MEDIA_FORMAT_H264_SP:
+       case MEDIA_FORMAT_H264_MP:
+       case MEDIA_FORMAT_H264_HP:
+       case MEDIA_FORMAT_MJPEG:
+               LOG_INFO("[VIDEO][ENCODED/%s] mime_type[0x%x]", __get_video_format_name(mime_type, false), mime_type);
+               return true;
+       default:
+               LOG_ERROR("not supported mime_type(0x%x)", mime_type);
+               return false;
+       }
+}
+
 static int __set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_type)
 {
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
@@ -640,9 +720,9 @@ static int __set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *
 
        } else {
                if (source->media_types == MEDIA_TYPE_AUDIO)
-                       source->av[AV_IDX_AUDIO].codec = _get_audio_format_name(mime_type);
+                       source->av[AV_IDX_AUDIO].codec = __get_audio_format_name(mime_type);
                else
-                       source->av[AV_IDX_VIDEO].codec = _get_video_format_name(mime_type, source->zerocopy_enabled);
+                       source->av[AV_IDX_VIDEO].codec = __get_video_format_name(mime_type, source->zerocopy_enabled);
 
        }
 
@@ -726,7 +806,7 @@ int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h f
                return WEBRTC_ERROR_INVALID_OPERATION;
        }
 
-       RET_VAL_IF(!_is_supported_mime_type(mime_type), WEBRTC_ERROR_INVALID_PARAMETER, "mime_type[0x%x] is not supported", mime_type);
+       RET_VAL_IF(!__is_supported_mime_type(mime_type), WEBRTC_ERROR_INVALID_PARAMETER, "mime_type[0x%x] is not supported", mime_type);
 
        media_format_ref(format);
        source->media_format = format;
index d998261b13b6bdbb3142fdb524c07edb3eacc5b3..5c1aa3be74babcf0cf7cf4c029ee7eb4bbdf8e03 100644 (file)
 #include "webrtc_internal.h"
 #include "webrtc_private.h"
 #include "webrtc_source_private.h"
-
-const char *_get_audio_format_name(media_format_mimetype_e mime_type)
-{
-       switch (mime_type) {
-       /* RAW formats */
-       case MEDIA_FORMAT_PCM_S16LE:
-               return "S16LE";
-       /* ENCODED formats */
-       case MEDIA_FORMAT_PCMU:
-               return "PCMU";
-       case MEDIA_FORMAT_PCMA:
-               return "PCMA";
-       case MEDIA_FORMAT_OPUS:
-               return "OPUS";
-       case MEDIA_FORMAT_VORBIS:
-               return "VORBIS";
-       default:
-               LOG_ERROR("not supported audio mime_type(0x%x)", mime_type);
-               return NULL;
-       }
-}
-
-const char *_get_video_format_name(media_format_mimetype_e mime_type, bool zerocopy_enabled)
-{
-       switch (mime_type) {
-       /* RAW formats */
-       case MEDIA_FORMAT_I420:
-               return zerocopy_enabled ? "S420" : "I420";
-       case MEDIA_FORMAT_NV12:
-               return zerocopy_enabled ? "SN12" : "NV12";
-       /* ENCODED formats */
-       case MEDIA_FORMAT_VP8:
-               return "VP8";
-       case MEDIA_FORMAT_VP9:
-               return "VP9";
-       case MEDIA_FORMAT_H264_SP: /* baseline profile */
-       case MEDIA_FORMAT_H264_MP: /* main profile */
-       case MEDIA_FORMAT_H264_HP: /* high profile */
-               return "H264";
-       case MEDIA_FORMAT_MJPEG:
-               return "JPEG";
-       default:
-               LOG_ERROR("not supported video mime_type(0x%x)", mime_type);
-               return NULL;
-       }
-}
+#include <gst/audio/audio.h>
 
 static const char *__get_default_source_element(int type)
 {
@@ -232,7 +187,7 @@ const char * _get_video_media_type(const char *codec_name)
        return NULL;
 }
 
-GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format)
+static GstAudioFormat __get_gst_audio_raw_format_from_string(const char *format)
 {
        RET_VAL_IF(format == NULL, GST_AUDIO_FORMAT_UNKNOWN, "format is NULL");
 
@@ -243,40 +198,6 @@ GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format)
        return GST_AUDIO_FORMAT_UNKNOWN;
 }
 
-bool _is_supported_mime_type(media_format_mimetype_e mime_type)
-{
-       switch (mime_type) {
-       /* AUDIO/RAW formats */
-       case MEDIA_FORMAT_PCM_S16LE:
-               LOG_INFO("[AUDIO][RAW/%s] mime_type[0x%x]", _get_audio_format_name(mime_type), mime_type);
-               return true;
-       /* VIDEO/RAW formats */
-       case MEDIA_FORMAT_I420:
-       case MEDIA_FORMAT_NV12:
-               LOG_INFO("[VIDEO][RAW/%s] mime_type[0x%x]", _get_video_format_name(mime_type, false), mime_type);
-               return true;
-       /* AUDIO/ENCODED formats */
-       case MEDIA_FORMAT_PCMU:
-       case MEDIA_FORMAT_PCMA:
-       case MEDIA_FORMAT_OPUS:
-       case MEDIA_FORMAT_VORBIS:
-               LOG_INFO("[AUDIO][ENCODED/%s] mime_type[0x%x]", _get_audio_format_name(mime_type), mime_type);
-               return true;
-       /* VIDEO/ENCODED formats */
-       case MEDIA_FORMAT_VP8:
-       case MEDIA_FORMAT_VP9:
-       case MEDIA_FORMAT_H264_SP:
-       case MEDIA_FORMAT_H264_MP:
-       case MEDIA_FORMAT_H264_HP:
-       case MEDIA_FORMAT_MJPEG:
-               LOG_INFO("[VIDEO][ENCODED/%s] mime_type[0x%x]", _get_video_format_name(mime_type, false), mime_type);
-               return true;
-       default:
-               LOG_ERROR("not supported mime_type(0x%x)", mime_type);
-               return false;
-       }
-}
-
 GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source, GstElement *encoder)
 {
        GstCaps *caps;
@@ -582,7 +503,7 @@ static GstCaps *__make_default_raw_caps(webrtc_gst_slot_s *source, webrtc_ini_s
 #ifdef SUPPORT_FILESRC_AUDIO_FORMAT_CHANGE
        case WEBRTC_MEDIA_SOURCE_TYPE_FILE:
 #endif
-               format = _get_gst_audio_raw_format_from_string(_get_raw_format_from_ini(ini, source->type, MEDIA_TYPE_AUDIO));
+               format = __get_gst_audio_raw_format_from_string(_get_raw_format_from_ini(ini, source->type, MEDIA_TYPE_AUDIO));
                RET_VAL_IF(format == GST_AUDIO_FORMAT_UNKNOWN, NULL, "not supported raw format");
 
                _get_audio_info_from_ini(ini, source->type, &channels, &samplerate);