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);
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);
+++ /dev/null
-/*
- * 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__ */
+++ /dev/null
-/*
- * 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__ */
--- /dev/null
+/*
+ * 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__ */
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
#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"
#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>
+++ /dev/null
-/*
- * 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
*/
#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)
{
*/
#include "webrtc_private.h"
-#include "webrtc_source_common.h"
+#include "webrtc_source_private.h"
#include <gst/audio/audio.h>
#include <gst/allocators/gsttizenmemory.h>
--- /dev/null
+/*
+ * 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
*/
#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)