From: hj kim Date: Fri, 2 Sep 2022 06:38:46 +0000 (+0900) Subject: Move some APIs to proper source file and make them static X-Git-Tag: submit/tizen/20220902.091410^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fe1f383eb68f41dd698ce5252e163e6f75caea9;p=platform%2Fcore%2Fapi%2Fwebrtc.git Move some APIs to proper source file and make them static [Version] 0.3.229 [Issue Type] Refactoring Change-Id: I377c6c12b46d0d4ec80aa77be773efb19309c155 --- diff --git a/include/webrtc_source_private.h b/include/webrtc_source_private.h index 4c052708..17bac0e2 100644 --- a/include/webrtc_source_private.h +++ b/include/webrtc_source_private.h @@ -19,7 +19,6 @@ #include "webrtc.h" #include "webrtc_private.h" -#include #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); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 193410a2..478fc019 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -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 diff --git a/src/webrtc_source_mediapacket.c b/src/webrtc_source_mediapacket.c index 875c0d0c..e5af6fd9 100644 --- a/src/webrtc_source_mediapacket.c +++ b/src/webrtc_source_mediapacket.c @@ -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; diff --git a/src/webrtc_source_private.c b/src/webrtc_source_private.c index d998261b..5c1aa3be 100644 --- a/src/webrtc_source_private.c +++ b/src/webrtc_source_private.c @@ -17,52 +17,7 @@ #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 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);