Rename webrtc_source_common.* to webrtc_source_private.* 08/277808/2 accepted/tizen/unified/20220720.034058 submit/tizen/20220715.111618
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 13 Jul 2022 14:43:57 +0000 (23:43 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 14 Jul 2022 08:11:02 +0000 (17:11 +0900)
It is to unify the naming of files. It is the same relationship between
webrtc.c and webrtc_private.c.

webrtc_source_mediapacket.h is also removed and function prototypes
in this file are moved to webrtc_private.h.

[Version] 0.3.157
[Issue Type] Rename

Change-Id: I2104f081d65c4ae4bed4df72106a854a7013ef96
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
12 files changed:
include/webrtc_private.h
include/webrtc_source_common.h [deleted file]
include/webrtc_source_mediapacket.h [deleted file]
include/webrtc_source_private.h [new file with mode: 0644]
packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_source.c
src/webrtc_source_common.c [deleted file]
src/webrtc_source_file.c
src/webrtc_source_mediapacket.c
src/webrtc_source_private.c [new file with mode: 0644]
src/webrtc_source_screen.c

index 98aad0d6bbe150559b59a716c7a847ceb41c88e2..8d71172cb0ea35653abe2914397b5f428a30bec0 100644 (file)
@@ -673,6 +673,15 @@ bool _check_if_format_is_set_to_packet_sources(webrtc_s *webrtc);
 int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path);
 int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, bool portrait_mode, int *width, int *height);
 int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id);
+int _gst_filesrc_pipeline_set_state(webrtc_s *webrtc, GstState state);
+int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping);
+int _get_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool *looping);
+int _remove_filesrc_pad_block_probe(webrtc_s *webrtc);
+int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source);
+int _complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list);
+int _complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source);
+GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source);
+int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h packet);
 bool _check_if_path_is_set_to_file_sources(webrtc_s *webrtc);
 int _set_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float probability);
 int _get_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float *probability);
@@ -767,11 +776,6 @@ int _stop_websocket(webrtc_websocket_s *ws);
 int _check_privilege(const char *privilege);
 int _check_feature(const char *feature);
 
-int _gst_filesrc_pipeline_set_state(webrtc_s *webrtc, GstState state);
-int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping);
-int _get_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool *looping);
-int _remove_filesrc_pad_block_probe(webrtc_s *webrtc);
-
 gchar * _get_media_type_from_pad(GstPad *pad);
 gchar * _get_mime_type_from_pad(GstPad *pad);
 int _get_payload_type_from_pad(GstPad *pad);
diff --git a/include/webrtc_source_common.h b/include/webrtc_source_common.h
deleted file mode 100644 (file)
index 7b58bc2..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__
-#define __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__
-
-#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)
-
-#define GST_KLASS_NAME_ENCODER_AUDIO   "Codec/Encoder/Audio"
-#define GST_KLASS_NAME_ENCODER_VIDEO   "Codec/Encoder/Video"
-#define GST_KLASS_NAME_DECODER_AUDIO   "Codec/Decoder/Audio"
-#define GST_KLASS_NAME_DECODER_VIDEO   "Codec/Decoder/Video"
-#define GST_KLASS_NAME_CONVERTER_AUDIO "Filter/Converter/Audio"
-#define GST_KLASS_NAME_CONVERTER_VIDEO "Filter/Converter/Video"
-
-#define DEFAULT_ELEMENT_CAMERASRC         "v4l2src"
-#define DEFAULT_ELEMENT_AUDIOSRC          "pulsesrc"
-#define DEFAULT_ELEMENT_VIDEOTESTSRC      "videotestsrc"
-#define DEFAULT_ELEMENT_AUDIOTESTSRC      "audiotestsrc"
-#define DEFAULT_ELEMENT_APPSRC            "appsrc"
-#define DEFAULT_ELEMENT_SCREENSRC         "waylandsrc"
-#define DEFAULT_ELEMENT_QUEUE             "queue"
-#define DEFAULT_ELEMENT_VOLUME            "volume"
-#define DEFAULT_ELEMENT_INPUT_SELECTOR    "input-selector"
-#define DEFAULT_ELEMENT_VIDEOCROP         "videocrop"
-#define DEFAULT_ELEMENT_FILESRC           "filesrc"
-
-#define ELEMENT_NAME_FIRST_CAPSFILTER        "firstCapsfilter"
-#define ELEMENT_NAME_RTP_CAPSFILTER          "rtpCapsfilter"
-#define ELEMENT_NAME_VIDEO_SRC               "videoSrc"
-#define ELEMENT_NAME_VIDEO_SWITCH            "videoSwitch"
-#define ELEMENT_NAME_VIDEO_MUTE_SRC          "videoMuteSrc"
-#define ELEMENT_NAME_VOLUME                  "volume"
-#define ELEMENT_NAME_AUDIO_SRC               "audioSrc"
-#define ELEMENT_NAME_MIC_SRC                 "micSrc"
-#define ELEMENT_NAME_FILE_SRC                "fileSrc"
-#define ELEMENT_NAME_AUDIO_QUEUE             "audioQueue"
-#define ELEMENT_NAME_VIDEO_QUEUE             "videoQueue"
-#define ELEMENT_NAME_AUDIO_CAPSFILTER        "audioCapsfilter"
-#define ELEMENT_NAME_VIDEO_CAPSFILTER        "videoCapsfilter"
-#define ELEMENT_NAME_AUDIO_PAYLOADER         "audioPayloader"
-#define ELEMENT_NAME_VIDEO_PAYLOADER         "videoPayloader"
-#define ELEMENT_NAME_VIDEOCROP               "videoCrop"
-#define ELEMENT_NAME_SCREENSRC               "waylandSrc"
-#define ELEMENT_NAME_AUDIO_FAKESINK          "audioFakeSink"
-#define ELEMENT_NAME_VIDEO_FAKESINK          "videoFakeSink"
-#define ELEMENT_NAME_AUDIO_APPSRC            "audioAppsrc"
-#define ELEMENT_NAME_VIDEO_APPSRC            "videoAppsrc"
-
-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);
-const char *_get_audio_media_type(const char *codec_name);
-const char *_get_video_media_type(const char *codec_name);
-GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format);
-bool _is_supported_mime_type(media_format_mimetype_e mime_type);
-bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini);
-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);
-unsigned int _get_available_payload_type(webrtc_s *webrtc);
-GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source);
-
-#endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */
diff --git a/include/webrtc_source_mediapacket.h b/include/webrtc_source_mediapacket.h
deleted file mode 100644 (file)
index 71b2cae..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __TIZEN_MEDIA_WEBRTC_SOURCE_MEDIAPACKET_H__
-#define __TIZEN_MEDIA_WEBRTC_SOURCE_MEDIAPACKET_H__
-
-#include "webrtc_private.h"
-
-int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source);
-int _complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list);
-int _complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source);
-GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source);
-int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h packet);
-
-#endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_MEDIAPACKET_H__ */
diff --git a/include/webrtc_source_private.h b/include/webrtc_source_private.h
new file mode 100644 (file)
index 0000000..0d6eb56
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_MEDIA_WEBRTC_SOURCE_PRIVATE_H__
+#define __TIZEN_MEDIA_WEBRTC_SOURCE_PRIVATE_H__
+
+#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)
+
+#define GST_KLASS_NAME_ENCODER_AUDIO   "Codec/Encoder/Audio"
+#define GST_KLASS_NAME_ENCODER_VIDEO   "Codec/Encoder/Video"
+#define GST_KLASS_NAME_DECODER_AUDIO   "Codec/Decoder/Audio"
+#define GST_KLASS_NAME_DECODER_VIDEO   "Codec/Decoder/Video"
+#define GST_KLASS_NAME_CONVERTER_AUDIO "Filter/Converter/Audio"
+#define GST_KLASS_NAME_CONVERTER_VIDEO "Filter/Converter/Video"
+
+#define DEFAULT_ELEMENT_CAMERASRC         "v4l2src"
+#define DEFAULT_ELEMENT_AUDIOSRC          "pulsesrc"
+#define DEFAULT_ELEMENT_VIDEOTESTSRC      "videotestsrc"
+#define DEFAULT_ELEMENT_AUDIOTESTSRC      "audiotestsrc"
+#define DEFAULT_ELEMENT_APPSRC            "appsrc"
+#define DEFAULT_ELEMENT_SCREENSRC         "waylandsrc"
+#define DEFAULT_ELEMENT_QUEUE             "queue"
+#define DEFAULT_ELEMENT_VOLUME            "volume"
+#define DEFAULT_ELEMENT_INPUT_SELECTOR    "input-selector"
+#define DEFAULT_ELEMENT_VIDEOCROP         "videocrop"
+#define DEFAULT_ELEMENT_FILESRC           "filesrc"
+
+#define ELEMENT_NAME_FIRST_CAPSFILTER        "firstCapsfilter"
+#define ELEMENT_NAME_RTP_CAPSFILTER          "rtpCapsfilter"
+#define ELEMENT_NAME_VIDEO_SRC               "videoSrc"
+#define ELEMENT_NAME_VIDEO_SWITCH            "videoSwitch"
+#define ELEMENT_NAME_VIDEO_MUTE_SRC          "videoMuteSrc"
+#define ELEMENT_NAME_VOLUME                  "volume"
+#define ELEMENT_NAME_AUDIO_SRC               "audioSrc"
+#define ELEMENT_NAME_MIC_SRC                 "micSrc"
+#define ELEMENT_NAME_FILE_SRC                "fileSrc"
+#define ELEMENT_NAME_AUDIO_QUEUE             "audioQueue"
+#define ELEMENT_NAME_VIDEO_QUEUE             "videoQueue"
+#define ELEMENT_NAME_AUDIO_CAPSFILTER        "audioCapsfilter"
+#define ELEMENT_NAME_VIDEO_CAPSFILTER        "videoCapsfilter"
+#define ELEMENT_NAME_AUDIO_PAYLOADER         "audioPayloader"
+#define ELEMENT_NAME_VIDEO_PAYLOADER         "videoPayloader"
+#define ELEMENT_NAME_VIDEOCROP               "videoCrop"
+#define ELEMENT_NAME_SCREENSRC               "waylandSrc"
+#define ELEMENT_NAME_AUDIO_FAKESINK          "audioFakeSink"
+#define ELEMENT_NAME_VIDEO_FAKESINK          "videoFakeSink"
+#define ELEMENT_NAME_AUDIO_APPSRC            "audioAppsrc"
+#define ELEMENT_NAME_VIDEO_APPSRC            "videoAppsrc"
+
+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);
+const char *_get_audio_media_type(const char *codec_name);
+const char *_get_video_media_type(const char *codec_name);
+GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format);
+bool _is_supported_mime_type(media_format_mimetype_e mime_type);
+bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini);
+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);
+unsigned int _get_available_payload_type(webrtc_s *webrtc);
+GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source);
+
+#endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */
index cd5e915411e35157f77aabf675e60689a903106d..69c71377f30423b9c125372b6baed5daac874510 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.156
+Version:    0.3.157
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index d62f7f387dea74057b9671fd09d099cb3c0d525b..aef2e7e47b0ec956266e75c59ce60e95bc25b2f2 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "webrtc.h"
 #include "webrtc_private.h"
-#include "webrtc_source_mediapacket.h"
 
 #define _WEBRTC_FEATURE_CAMERA        "http://tizen.org/feature/camera"
 #define _WEBRTC_FEATURE_MICROPHONE    "http://tizen.org/feature/microphone"
index 651ef3802af20e556ecc3fd2b4820bca15625ce6..731fb2307d9207ff21cce65f263e2bad7a0562f9 100644 (file)
@@ -19,8 +19,7 @@
 
 #include "webrtc_internal.h"
 #include "webrtc_private.h"
-#include "webrtc_source_common.h"
-#include "webrtc_source_mediapacket.h"
+#include "webrtc_source_private.h"
 
 #include <tbm_surface_internal.h>
 #include <Elementary.h>
diff --git a/src/webrtc_source_common.c b/src/webrtc_source_common.c
deleted file mode 100644 (file)
index 47c6a59..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright (c) 202 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "webrtc_internal.h"
-#include "webrtc_private.h"
-#include "webrtc_source_common.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;
-       }
-}
-
-static const char *__get_default_source_element(int type)
-{
-       const char *element = NULL;
-
-       if (type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST)
-               element = DEFAULT_ELEMENT_AUDIOTESTSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST)
-               element = DEFAULT_ELEMENT_VIDEOTESTSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC)
-               element = DEFAULT_ELEMENT_AUDIOSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA)
-               element = DEFAULT_ELEMENT_CAMERASRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN)
-               element = DEFAULT_ELEMENT_SCREENSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET)
-               element = DEFAULT_ELEMENT_APPSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO)
-               element = DEFAULT_ELEMENT_AUDIOTESTSRC;
-       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO)
-               element = DEFAULT_ELEMENT_VIDEOTESTSRC;
-       else
-               LOG_ERROR_IF_REACHED("type(%d)", type);
-
-       LOG_DEBUG("type(%d) -> element[%s]", type, element);
-
-       return element;
-}
-
-const char *_get_source_element(webrtc_s *webrtc, int type)
-{
-       const ini_item_media_source_s *source;
-
-       RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
-
-       source = _ini_get_source_by_type(&webrtc->ini, type);
-       if (source == NULL || source->source_element == NULL)
-               return __get_default_source_element(type);
-
-       return source->source_element;
-}
-
-GstElement *_find_element_in_bin(GstBin *bin, const gchar *name)
-{
-       GValue value = G_VALUE_INIT;
-       GstElement *element;
-       GstIterator *bin_iterator;
-
-       RET_VAL_IF(bin == NULL, NULL, "bin is NULL");
-       RET_VAL_IF(name == NULL, NULL, "name is NULL");
-       RET_VAL_IF(!(bin_iterator = gst_bin_iterate_sorted(bin)), NULL, "bin_iterator is NULL");
-
-       while (GST_ITERATOR_OK == gst_iterator_next(bin_iterator, &value)) {
-               element = GST_ELEMENT(g_value_get_object(&value));
-
-               if (g_strrstr(GST_ELEMENT_NAME(element), name)) {
-                       LOG_DEBUG("found element by name [%s]", GST_ELEMENT_NAME(element));
-                       g_value_unset(&value);
-                       gst_iterator_free(bin_iterator);
-                       return element;
-               }
-
-               g_value_reset(&value);
-       }
-       g_value_unset(&value);
-       gst_iterator_free(bin_iterator);
-
-       return NULL;
-}
-
-bool _is_hw_encoder_used(webrtc_s *webrtc, webrtc_media_source_type_e source_type, media_type_e media_type)
-{
-       const ini_item_media_source_s *ini_source;
-
-       RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
-
-       ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
-
-       switch (media_type) {
-       case MEDIA_TYPE_AUDIO:
-               if (ini_source && ini_source->a_hw_encoder_element)
-                       return true;
-               else if (webrtc->ini.media_source.a_hw_encoder_element)
-                       return true;
-               break;
-       case MEDIA_TYPE_VIDEO:
-               if (ini_source && ini_source->v_hw_encoder_element)
-                       return true;
-               else if (webrtc->ini.media_source.v_hw_encoder_element)
-                       return true;
-               break;
-       default:
-               LOG_ERROR_IF_REACHED("type(%d)", media_type);
-               break;
-       }
-
-       LOG_DEBUG("no hw encoder is used, source_type(%d), media_type(%d)", source_type, media_type);
-       return false;
-}
-
-bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini)
-{
-       const ini_item_media_source_s *ini_source;
-
-       RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
-
-       ini_source = _ini_get_source_by_type(ini, type);
-       if (ini_source == NULL)
-               ini_source = &ini->media_source;
-
-       LOG_DEBUG("type[%d], v_encoded_fmt_support[%d]", type, ini_source->v_encoded_fmt_support);
-       return ini_source->v_encoded_fmt_support;
-}
-
-GstCaps *_get_caps_from_encoded_audio_media_type(const char *media_type, int channels, int samplerate)
-{
-       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
-
-       if (!strcmp(media_type, MEDIA_TYPE_AUDIO_MULAW) ||
-               !strcmp(media_type, MEDIA_TYPE_AUDIO_ALAW))
-               return gst_caps_new_simple(media_type,
-                       "rate", G_TYPE_INT, samplerate,
-                       "channels", G_TYPE_INT, channels,
-                       NULL);
-
-       if (!strcmp(media_type, MEDIA_TYPE_AUDIO_OPUS) ||
-               !strcmp(media_type, MEDIA_TYPE_AUDIO_VORBIS))
-               return gst_caps_new_simple(media_type, NULL, NULL);
-
-       LOG_ERROR_IF_REACHED("invalid media_type(%s)", media_type);
-
-       return NULL;
-}
-
-GstCaps *_get_caps_from_encoded_video_media_type(const char *media_type, int width, int height)
-{
-       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
-
-       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_H264) ||
-               !strcmp(media_type, MEDIA_TYPE_VIDEO_H265))
-               return gst_caps_new_simple(media_type,
-                       "stream-format", G_TYPE_STRING, "byte-stream",
-                       "alignment", G_TYPE_STRING, "au",
-                       "width", G_TYPE_INT, width,
-                       "height", G_TYPE_INT, height,
-                       NULL);
-
-       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_VP8) ||
-               !strcmp(media_type, MEDIA_TYPE_VIDEO_VP9) ||
-               !strcmp(media_type, MEDIA_TYPE_VIDEO_THEORA))
-               return gst_caps_new_simple(media_type, NULL, NULL); /* NOTE: need to verify these codecs */
-
-       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_JPEG))
-               return gst_caps_new_simple(media_type,
-                       "width", G_TYPE_INT, width,
-                       "height", G_TYPE_INT, height,
-                       NULL);
-
-       LOG_ERROR_IF_REACHED("invalid media_type(%s)", media_type);
-
-       return NULL;
-}
-
-const char * _get_audio_media_type(const char *codec_name)
-{
-       RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
-
-       if (!strcmp(codec_name, "pcmu") || !strcmp(codec_name, "PCMU"))
-               return MEDIA_TYPE_AUDIO_MULAW;
-       if (!strcmp(codec_name, "pcma") || !strcmp(codec_name, "PCMA"))
-               return MEDIA_TYPE_AUDIO_ALAW;
-       if (!strcmp(codec_name, "opus") || !strcmp(codec_name, "OPUS"))
-               return MEDIA_TYPE_AUDIO_OPUS;
-       if (!strcmp(codec_name, "vorbis") || !strcmp(codec_name, "VORBIS"))
-               return MEDIA_TYPE_AUDIO_VORBIS;
-
-       LOG_ERROR("not supported audio codec_name[%s]", codec_name);
-
-       return NULL;
-}
-
-const char * _get_video_media_type(const char *codec_name)
-{
-       RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
-
-       if (!strcmp(codec_name, "vp8") || !strcmp(codec_name, "VP8"))
-               return MEDIA_TYPE_VIDEO_VP8;
-       if (!strcmp(codec_name, "vp9") || !strcmp(codec_name, "VP9"))
-               return MEDIA_TYPE_VIDEO_VP9;
-       if (!strcmp(codec_name, "theora") || !strcmp(codec_name, "THEORA"))
-               return MEDIA_TYPE_VIDEO_THEORA;
-       if (!strcmp(codec_name, "h264") || !strcmp(codec_name, "H264"))
-               return MEDIA_TYPE_VIDEO_H264;
-       if (!strcmp(codec_name, "h265") || !strcmp(codec_name, "H265"))
-               return MEDIA_TYPE_VIDEO_H265;
-       if (!strcmp(codec_name, "jpeg") || !strcmp(codec_name, "JPEG") || !strcmp(codec_name, "mjpeg") || !strcmp(codec_name, "MJPEG"))
-               return MEDIA_TYPE_VIDEO_JPEG;
-
-       LOG_ERROR("not supported video codec_name[%s]", codec_name);
-
-       return NULL;
-}
-
-GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format)
-{
-       RET_VAL_IF(format == NULL, GST_AUDIO_FORMAT_UNKNOWN, "format is NULL");
-
-       if (!strcmp(format, "S16LE"))
-               return GST_AUDIO_FORMAT_S16LE;
-
-       LOG_ERROR("not supported raw format(%s)", 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;
-       }
-}
-
-unsigned int _get_available_payload_type(webrtc_s *webrtc)
-{
-       int bitmask = 0x1;
-       int count = 0;
-
-       RET_VAL_IF(webrtc == NULL, 0, "webrtc is NULL");
-
-       while (count++ < PAYLOAD_TYPE_BITS) {
-               if (webrtc->payload_types & bitmask) {
-                       bitmask <<= 1;
-                       continue;
-               }
-               webrtc->payload_types |= bitmask;
-               LOG_DEBUG("found available payload type[%d]", count + 95);
-               return count + 95; /* 96 ~ 127 */
-       }
-
-       LOG_ERROR("could not assign payload type");
-       return 0;
-}
-
-GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source)
-{
-       GstCaps *caps;
-       bool is_audio;
-
-       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
-
-       is_audio = !(g_strrstr(media_type, "video") || g_strrstr(media_type, "image"));
-
-       caps = gst_caps_new_simple("application/x-rtp",
-                               "media", G_TYPE_STRING, GET_MEDIA_TYPE_NAME(is_audio),
-                               "payload", G_TYPE_INT, payload_type,
-                               NULL);
-
-       if (is_audio && source->av[AV_IDX_AUDIO].inbandfec)
-               /* NOTE: set it with string type due to the parsing logic in gstwebrtcbin.c */
-               gst_structure_set(gst_caps_get_structure(caps, 0), "useinbandfec", G_TYPE_STRING, "1", NULL);
-
-       PRINT_CAPS(caps, "RTP");
-
-       return caps;
-}
\ No newline at end of file
index 06865a4c2cb35573dd0da80d8168356e85adeead..abcb77809dccd2378f5eedabbde24d732ad75ad3 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include "webrtc_private.h"
-#include "webrtc_source_common.h"
+#include "webrtc_source_private.h"
 
 static void __set_filesrc_pipline_state_foreach_cb(gpointer key, gpointer value, gpointer user_data)
 {
index a9b7edc8e0ba2e5e7f6fd537c5e20bef859295f5..ef0941989339fde5a46e5c5743fd567efdcc14e1 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include "webrtc_private.h"
-#include "webrtc_source_common.h"
+#include "webrtc_source_private.h"
 #include <gst/audio/audio.h>
 #include <gst/allocators/gsttizenmemory.h>
 
diff --git a/src/webrtc_source_private.c b/src/webrtc_source_private.c
new file mode 100644 (file)
index 0000000..b600347
--- /dev/null
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 202 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#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;
+       }
+}
+
+static const char *__get_default_source_element(int type)
+{
+       const char *element = NULL;
+
+       if (type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST)
+               element = DEFAULT_ELEMENT_AUDIOTESTSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST)
+               element = DEFAULT_ELEMENT_VIDEOTESTSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MIC)
+               element = DEFAULT_ELEMENT_AUDIOSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA)
+               element = DEFAULT_ELEMENT_CAMERASRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN)
+               element = DEFAULT_ELEMENT_SCREENSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET)
+               element = DEFAULT_ELEMENT_APPSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO)
+               element = DEFAULT_ELEMENT_AUDIOTESTSRC;
+       else if (type == WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO)
+               element = DEFAULT_ELEMENT_VIDEOTESTSRC;
+       else
+               LOG_ERROR_IF_REACHED("type(%d)", type);
+
+       LOG_DEBUG("type(%d) -> element[%s]", type, element);
+
+       return element;
+}
+
+const char *_get_source_element(webrtc_s *webrtc, int type)
+{
+       const ini_item_media_source_s *source;
+
+       RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
+
+       source = _ini_get_source_by_type(&webrtc->ini, type);
+       if (source == NULL || source->source_element == NULL)
+               return __get_default_source_element(type);
+
+       return source->source_element;
+}
+
+GstElement *_find_element_in_bin(GstBin *bin, const gchar *name)
+{
+       GValue value = G_VALUE_INIT;
+       GstElement *element;
+       GstIterator *bin_iterator;
+
+       RET_VAL_IF(bin == NULL, NULL, "bin is NULL");
+       RET_VAL_IF(name == NULL, NULL, "name is NULL");
+       RET_VAL_IF(!(bin_iterator = gst_bin_iterate_sorted(bin)), NULL, "bin_iterator is NULL");
+
+       while (GST_ITERATOR_OK == gst_iterator_next(bin_iterator, &value)) {
+               element = GST_ELEMENT(g_value_get_object(&value));
+
+               if (g_strrstr(GST_ELEMENT_NAME(element), name)) {
+                       LOG_DEBUG("found element by name [%s]", GST_ELEMENT_NAME(element));
+                       g_value_unset(&value);
+                       gst_iterator_free(bin_iterator);
+                       return element;
+               }
+
+               g_value_reset(&value);
+       }
+       g_value_unset(&value);
+       gst_iterator_free(bin_iterator);
+
+       return NULL;
+}
+
+bool _is_hw_encoder_used(webrtc_s *webrtc, webrtc_media_source_type_e source_type, media_type_e media_type)
+{
+       const ini_item_media_source_s *ini_source;
+
+       RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
+
+       ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
+
+       switch (media_type) {
+       case MEDIA_TYPE_AUDIO:
+               if (ini_source && ini_source->a_hw_encoder_element)
+                       return true;
+               else if (webrtc->ini.media_source.a_hw_encoder_element)
+                       return true;
+               break;
+       case MEDIA_TYPE_VIDEO:
+               if (ini_source && ini_source->v_hw_encoder_element)
+                       return true;
+               else if (webrtc->ini.media_source.v_hw_encoder_element)
+                       return true;
+               break;
+       default:
+               LOG_ERROR_IF_REACHED("type(%d)", media_type);
+               break;
+       }
+
+       LOG_DEBUG("no hw encoder is used, source_type(%d), media_type(%d)", source_type, media_type);
+       return false;
+}
+
+bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini)
+{
+       const ini_item_media_source_s *ini_source;
+
+       RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+
+       ini_source = _ini_get_source_by_type(ini, type);
+       if (ini_source == NULL)
+               ini_source = &ini->media_source;
+
+       LOG_DEBUG("type[%d], v_encoded_fmt_support[%d]", type, ini_source->v_encoded_fmt_support);
+       return ini_source->v_encoded_fmt_support;
+}
+
+GstCaps *_get_caps_from_encoded_audio_media_type(const char *media_type, int channels, int samplerate)
+{
+       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
+
+       if (!strcmp(media_type, MEDIA_TYPE_AUDIO_MULAW) ||
+               !strcmp(media_type, MEDIA_TYPE_AUDIO_ALAW))
+               return gst_caps_new_simple(media_type,
+                       "rate", G_TYPE_INT, samplerate,
+                       "channels", G_TYPE_INT, channels,
+                       NULL);
+
+       if (!strcmp(media_type, MEDIA_TYPE_AUDIO_OPUS) ||
+               !strcmp(media_type, MEDIA_TYPE_AUDIO_VORBIS))
+               return gst_caps_new_simple(media_type, NULL, NULL);
+
+       LOG_ERROR_IF_REACHED("invalid media_type(%s)", media_type);
+
+       return NULL;
+}
+
+GstCaps *_get_caps_from_encoded_video_media_type(const char *media_type, int width, int height)
+{
+       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
+
+       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_H264) ||
+               !strcmp(media_type, MEDIA_TYPE_VIDEO_H265))
+               return gst_caps_new_simple(media_type,
+                       "stream-format", G_TYPE_STRING, "byte-stream",
+                       "alignment", G_TYPE_STRING, "au",
+                       "width", G_TYPE_INT, width,
+                       "height", G_TYPE_INT, height,
+                       NULL);
+
+       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_VP8) ||
+               !strcmp(media_type, MEDIA_TYPE_VIDEO_VP9) ||
+               !strcmp(media_type, MEDIA_TYPE_VIDEO_THEORA))
+               return gst_caps_new_simple(media_type, NULL, NULL); /* NOTE: need to verify these codecs */
+
+       if (!strcmp(media_type, MEDIA_TYPE_VIDEO_JPEG))
+               return gst_caps_new_simple(media_type,
+                       "width", G_TYPE_INT, width,
+                       "height", G_TYPE_INT, height,
+                       NULL);
+
+       LOG_ERROR_IF_REACHED("invalid media_type(%s)", media_type);
+
+       return NULL;
+}
+
+const char * _get_audio_media_type(const char *codec_name)
+{
+       RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
+
+       if (!strcmp(codec_name, "pcmu") || !strcmp(codec_name, "PCMU"))
+               return MEDIA_TYPE_AUDIO_MULAW;
+       if (!strcmp(codec_name, "pcma") || !strcmp(codec_name, "PCMA"))
+               return MEDIA_TYPE_AUDIO_ALAW;
+       if (!strcmp(codec_name, "opus") || !strcmp(codec_name, "OPUS"))
+               return MEDIA_TYPE_AUDIO_OPUS;
+       if (!strcmp(codec_name, "vorbis") || !strcmp(codec_name, "VORBIS"))
+               return MEDIA_TYPE_AUDIO_VORBIS;
+
+       LOG_ERROR("not supported audio codec_name[%s]", codec_name);
+
+       return NULL;
+}
+
+const char * _get_video_media_type(const char *codec_name)
+{
+       RET_VAL_IF(codec_name == NULL, NULL, "codec_name is NULL");
+
+       if (!strcmp(codec_name, "vp8") || !strcmp(codec_name, "VP8"))
+               return MEDIA_TYPE_VIDEO_VP8;
+       if (!strcmp(codec_name, "vp9") || !strcmp(codec_name, "VP9"))
+               return MEDIA_TYPE_VIDEO_VP9;
+       if (!strcmp(codec_name, "theora") || !strcmp(codec_name, "THEORA"))
+               return MEDIA_TYPE_VIDEO_THEORA;
+       if (!strcmp(codec_name, "h264") || !strcmp(codec_name, "H264"))
+               return MEDIA_TYPE_VIDEO_H264;
+       if (!strcmp(codec_name, "h265") || !strcmp(codec_name, "H265"))
+               return MEDIA_TYPE_VIDEO_H265;
+       if (!strcmp(codec_name, "jpeg") || !strcmp(codec_name, "JPEG") || !strcmp(codec_name, "mjpeg") || !strcmp(codec_name, "MJPEG"))
+               return MEDIA_TYPE_VIDEO_JPEG;
+
+       LOG_ERROR("not supported video codec_name[%s]", codec_name);
+
+       return NULL;
+}
+
+GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format)
+{
+       RET_VAL_IF(format == NULL, GST_AUDIO_FORMAT_UNKNOWN, "format is NULL");
+
+       if (!strcmp(format, "S16LE"))
+               return GST_AUDIO_FORMAT_S16LE;
+
+       LOG_ERROR("not supported raw format(%s)", 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;
+       }
+}
+
+unsigned int _get_available_payload_type(webrtc_s *webrtc)
+{
+       int bitmask = 0x1;
+       int count = 0;
+
+       RET_VAL_IF(webrtc == NULL, 0, "webrtc is NULL");
+
+       while (count++ < PAYLOAD_TYPE_BITS) {
+               if (webrtc->payload_types & bitmask) {
+                       bitmask <<= 1;
+                       continue;
+               }
+               webrtc->payload_types |= bitmask;
+               LOG_DEBUG("found available payload type[%d]", count + 95);
+               return count + 95; /* 96 ~ 127 */
+       }
+
+       LOG_ERROR("could not assign payload type");
+       return 0;
+}
+
+GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source)
+{
+       GstCaps *caps;
+       bool is_audio;
+
+       RET_VAL_IF(media_type == NULL, NULL, "media_type is NULL");
+
+       is_audio = !(g_strrstr(media_type, "video") || g_strrstr(media_type, "image"));
+
+       caps = gst_caps_new_simple("application/x-rtp",
+                               "media", G_TYPE_STRING, GET_MEDIA_TYPE_NAME(is_audio),
+                               "payload", G_TYPE_INT, payload_type,
+                               NULL);
+
+       if (is_audio && source->av[AV_IDX_AUDIO].inbandfec)
+               /* NOTE: set it with string type due to the parsing logic in gstwebrtcbin.c */
+               gst_structure_set(gst_caps_get_structure(caps, 0), "useinbandfec", G_TYPE_STRING, "1", NULL);
+
+       PRINT_CAPS(caps, "RTP");
+
+       return caps;
+}
\ No newline at end of file
index fe51bed187dcd5817d389f89fe71dc1b12712412..b8a7b5300238e41154a26c405b175d5cb2986c24 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include "webrtc_private.h"
-#include "webrtc_source_common.h"
+#include "webrtc_source_private.h"
 
 //LCOV_EXCL_START
 int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, bool portrait_mode, int *width, int *height)