const ini_item_media_source_s* _ini_get_source_by_type(webrtc_ini_s *ini, int type);
bool _is_resource_required(webrtc_ini_s *ini);
bool _is_verbose_log(void);
+void _get_drc_support_from_ini(webrtc_ini_s *ini, int src_type, bool *drc_support);
+void _get_use_ulpfec_red_from_ini(webrtc_ini_s *ini, int src_type, bool *use_ulpfec_red);
+void _get_audio_info_from_ini(webrtc_ini_s *ini, int src_type, int *channels, int *samplerate);
+void _get_video_encoded_support_from_ini(webrtc_ini_s *ini, int src_type, bool *encoded_support);
+void _get_video_resolution_from_ini(webrtc_ini_s *ini, int src_type, int *width, int *height);
+int _get_fec_percentage_from_ini(webrtc_ini_s *ini, int src_type);
+const char *_get_source_element_from_ini(webrtc_ini_s *ini, int src_type);
+const char *_get_raw_format_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type);
+const char *_get_first_codec_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type);
+const char *_get_hw_encoder_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type);
+GStrv _get_supported_codecs_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type);
/* file source */
int _gst_filesrc_pipeline_set_state(webrtc_s *webrtc, GstState state);
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);
-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);
GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source, GstElement *encoder);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.225
+Version: 0.3.226
Release: 0
Group: Multimedia/API
License: Apache-2.0
ini->resource_acquisition.video_overlay);
}
+void _get_drc_support_from_ini(webrtc_ini_s *ini, int src_type, bool *drc_support)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_IF(ini == NULL, "ini is NULL");
+ RET_IF(drc_support == NULL, "drc_support is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ *drc_support = ini_source->v_drc_support;
+}
+
+void _get_use_ulpfec_red_from_ini(webrtc_ini_s *ini, int src_type, bool *use_ulpfec_red)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_IF(ini == NULL, "ini is NULL");
+ RET_IF(use_ulpfec_red == NULL, "use_ulpfec_red is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ *use_ulpfec_red = ini_source->use_ulpfec_red;
+}
+
+void _get_audio_info_from_ini(webrtc_ini_s *ini, int src_type, int *channels, int *samplerate)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_IF(ini == NULL, "ini is NULL");
+ RET_IF(channels == NULL, "channels is NULL");
+ RET_IF(samplerate == NULL, "samplerate is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ *channels = ini_source->a_channels;
+ *samplerate = ini_source->a_samplerate;
+}
+
+void _get_video_encoded_support_from_ini(webrtc_ini_s *ini, int src_type, bool *encoded_support)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_IF(ini == NULL, "ini is NULL");
+ RET_IF(encoded_support == NULL, "encoded_support is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ LOG_DEBUG("type[%d], v_encoded_fmt_support[%d]", src_type, ini_source->v_encoded_fmt_support);
+
+ *encoded_support = ini_source->v_encoded_fmt_support;
+}
+
+void _get_video_resolution_from_ini(webrtc_ini_s *ini, int src_type, int *width, int *height)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_IF(ini == NULL, "ini is NULL");
+ RET_IF(width == NULL, "width is NULL");
+ RET_IF(height == NULL, "height is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ *width = ini_source->v_width;
+ *height = ini_source->v_height;
+}
+
+int _get_fec_percentage_from_ini(webrtc_ini_s *ini, int src_type)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(ini == NULL, 0, "ini is NULL");
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ return ini_source->fec_percentage;
+}
+
+const char *_get_source_element_from_ini(webrtc_ini_s *ini, int src_type)
+{
+ 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, src_type);
+ RET_VAL_IF(ini_source == NULL, NULL, "ini_source is NULL");
+
+ return ini_source->source_element;
+}
+
+const char *_get_raw_format_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+ RET_VAL_IF((media_type != MEDIA_TYPE_AUDIO) && (media_type != MEDIA_TYPE_VIDEO), NULL, "invalid media_type[%d]", media_type);
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ if (media_type == MEDIA_TYPE_AUDIO)
+ return ini_source->a_raw_format;
+ else
+ return ini_source->v_raw_format;
+}
+
+const char *_get_first_codec_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+ RET_VAL_IF((media_type != MEDIA_TYPE_AUDIO) && (media_type != MEDIA_TYPE_VIDEO), NULL, "invalid media_type[%d]", media_type);
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ if (media_type == MEDIA_TYPE_AUDIO)
+ return ini_source->a_codecs[0];
+ else
+ return ini_source->v_codecs[0];
+}
+
+const char *_get_hw_encoder_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+ RET_VAL_IF((media_type != MEDIA_TYPE_AUDIO) && (media_type != MEDIA_TYPE_VIDEO), NULL, "invalid media_type[%d]", media_type);
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ if (media_type == MEDIA_TYPE_AUDIO)
+ return ini_source->a_hw_encoder_element;
+ else
+ return ini_source->v_hw_encoder_element;
+}
+
+GStrv _get_supported_codecs_from_ini(webrtc_ini_s *ini, int src_type, media_type_e media_type)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
+ RET_VAL_IF((media_type != MEDIA_TYPE_AUDIO) && (media_type != MEDIA_TYPE_VIDEO), NULL, "invalid media_type[%d]", media_type);
+
+ ini_source = _ini_get_source_by_type(ini, src_type);
+ if (ini_source == NULL)
+ ini_source = &ini->media_source;
+
+ if (media_type == MEDIA_TYPE_AUDIO)
+ return ini_source->a_codecs;
+ else
+ return ini_source->v_codecs;
+}
void _unload_ini(webrtc_s *webrtc)
{
RET_IF(webrtc == NULL, "webrtc is NULL");
void _update_transceivers_fec(webrtc_s *webrtc, bool is_offer)
{
- const ini_item_media_source_s *ini_source;
GstWebRTCRTPTransceiver *transceiver;
webrtc_gst_slot_s *source;
int i, j;
g_object_get(G_OBJECT(transceiver), "direction", &direction, NULL);
- ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &(webrtc->ini.media_source);
-
if (is_offer) {
- if (!ini_source->use_ulpfec_red)
+ bool use_ulpfec_red;
+ _get_use_ulpfec_red_from_ini(&webrtc->ini, source->type, &use_ulpfec_red);
+
+ if (!use_ulpfec_red)
continue;
+
__webrtcbin_transceiver_set_ulpfec_red(webrtc, transceiver);
} else {
if (!webrtc->data_recovery_types[i].red ||
if (direction == GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDONLY ||
direction == GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV)
- __webrtcbin_transceiver_set_fec_percentage(webrtc, transceiver, ini_source->fec_percentage);
+ __webrtcbin_transceiver_set_fec_percentage(webrtc, transceiver, _get_fec_percentage_from_ini(&webrtc->ini, source->type));
}
}
}
static GstCaps *__make_video_raw_caps_with_framerate(webrtc_gst_slot_s *source, webrtc_ini_s *ini, int framerate)
{
GstCaps *caps = NULL;
- const ini_item_media_source_s *ini_source;
RET_VAL_IF(source == NULL, NULL, "source is NULL");
RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
- ini_source = _ini_get_source_by_type(ini, source->type);
- if (ini_source == NULL)
- ini_source = &ini->media_source;
-
switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: {
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, ini_source->v_raw_format,
+ "format", G_TYPE_STRING, _get_raw_format_from_ini(ini, source->type, MEDIA_TYPE_VIDEO),
"framerate", GST_TYPE_FRACTION, framerate, 1,
"width", G_TYPE_INT, source->video_info.width,
"height", G_TYPE_INT, source->video_info.height,
int _foreach_supported_transceiver_codec(webrtc_s *webrtc, webrtc_media_source_type_e source_type, webrtc_media_type_e media_type, webrtc_media_source_supported_transceiver_codec_cb callback, void *user_data)
{
int ret;
- const ini_item_media_source_s *ini_source;
webrtc_transceiver_codec_e codec;
GStrv codecs;
guint i;
RET_VAL_IF((source_type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET), WEBRTC_ERROR_INVALID_PARAMETER, "this API does not support the media packet source");
RET_VAL_IF((source_type > WEBRTC_MEDIA_SOURCE_TYPE_NULL), WEBRTC_ERROR_INVALID_PARAMETER, "invalid source_type");
- ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
- RET_VAL_IF(ini_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "ini_source is NULL");
-
if (media_type == WEBRTC_MEDIA_TYPE_AUDIO &&
(source_type == WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST ||
source_type == WEBRTC_MEDIA_SOURCE_TYPE_MIC ||
source_type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)) {
- codecs = ini_source->a_codecs;
+ codecs = _get_supported_codecs_from_ini(&webrtc->ini, source_type, MEDIA_TYPE_AUDIO);
} else if (media_type == WEBRTC_MEDIA_TYPE_VIDEO &&
(source_type == WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST ||
source_type == WEBRTC_MEDIA_SOURCE_TYPE_CAMERA ||
source_type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN ||
source_type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)) {
- codecs = ini_source->v_codecs;
+ codecs = _get_supported_codecs_from_ini(&webrtc->ini, source_type, MEDIA_TYPE_VIDEO);
} else {
LOG_ERROR("invalid media_type[%d] for source_type[%u]", media_type, source_type);
static int __validate_codec(webrtc_s *webrtc, webrtc_gst_slot_s *source, webrtc_media_type_e media_type, webrtc_transceiver_codec_e codec)
{
int ret;
- const ini_item_media_source_s *ini_source;
GStrv codecs;
webrtc_transceiver_codec_e _codec;
guint i;
RET_VAL_IF(webrtc == NULL, FALSE, "webrtc is NULL");
RET_VAL_IF(source == NULL, FALSE, "source is NULL");
- ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- RET_VAL_IF(ini_source == NULL, WEBRTC_ERROR_INVALID_OPERATION, "ini_source is NULL");
-
if (media_type == WEBRTC_MEDIA_TYPE_AUDIO &&
source->media_types & MEDIA_TYPE_AUDIO &&
codec & CODEC_TYPE_AUDIO) {
- codecs = ini_source->a_codecs;
+ codecs = _get_supported_codecs_from_ini(&webrtc->ini, source->type, MEDIA_TYPE_AUDIO);
} else if (media_type == WEBRTC_MEDIA_TYPE_VIDEO &&
source->media_types & MEDIA_TYPE_VIDEO &&
codec & CODEC_TYPE_VIDEO) {
- codecs = ini_source->v_codecs;
+ codecs = _get_supported_codecs_from_ini(&webrtc->ini, source->type, MEDIA_TYPE_VIDEO);
} else {
LOG_ERROR("invalid media_type[%d], codec[0x%x] for source[media_types:0x%x, id:%u]",
{
webrtc_gst_slot_s *source;
GstElement *capsfilter;
- bool drc_support = false;
+ bool drc_support;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
return WEBRTC_ERROR_INVALID_OPERATION;
}
#endif
- const ini_item_media_source_s *ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &webrtc->ini.media_source;
- if (ini_source->v_drc_support)
- drc_support = true;
+ _get_drc_support_from_ini(&webrtc->ini, source->type, &drc_support);
}
if (webrtc->state == WEBRTC_STATE_IDLE || drc_support) {
source->video_info.origin_width = width;
source->video_info.origin_height = height;
} else {
- if (_is_encoded_format_supported(source->type, &webrtc->ini)) {
+ bool encoded_support;
+ _get_video_encoded_support_from_ini(&webrtc->ini, source->type, &encoded_support);
+ if (encoded_support) {
LOG_ERROR("this API does not support source with encoded format");
return WEBRTC_ERROR_INVALID_OPERATION;
}
if (is_audio && g_strrstr(media_type, "raw")) {
need_decoding = false;
- const ini_item_media_source_s *ini_source = _ini_get_source_by_type(&source->webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &(source->webrtc->ini.media_source);
-
- source->av[AV_IDX_AUDIO].codec = ini_source->a_codecs[0];
+ source->av[AV_IDX_AUDIO].codec = _get_first_codec_from_ini(&source->webrtc->ini, source->type, MEDIA_TYPE_AUDIO);
}
#endif
g_free(media_type);
if ((mime_type & MEDIA_FORMAT_RAW) &&
!(mime_type == MEDIA_FORMAT_PCMU || mime_type == MEDIA_FORMAT_PCMA)) { /* FIXME: media_format.h defined PCMU/PCMA as a raw format, it's a bug. */
- const ini_item_media_source_s *ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &(webrtc->ini.media_source);
-
if (source->media_types == MEDIA_TYPE_AUDIO)
- source->av[AV_IDX_AUDIO].codec = ini_source->a_codecs[0];
+ source->av[AV_IDX_AUDIO].codec = _get_first_codec_from_ini(&webrtc->ini, source->type, source->media_types);
else
- source->av[AV_IDX_VIDEO].codec = ini_source->v_codecs[0];
+ source->av[AV_IDX_VIDEO].codec = _get_first_codec_from_ini(&webrtc->ini, source->type, source->media_types);
} else {
if (source->media_types == MEDIA_TYPE_AUDIO)
const char *_get_source_element(webrtc_s *webrtc, int type)
{
- const ini_item_media_source_s *source;
+ const char *src_element;
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);
+ if ((src_element = _get_source_element_from_ini(&webrtc->ini, type)))
+ return src_element;
- return source->source_element;
+ return __get_default_source_element(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 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;
- }
+ if (_get_hw_encoder_from_ini(&webrtc->ini, source_type, media_type))
+ return true;
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");
static GstCaps *__make_default_raw_caps(webrtc_gst_slot_s *source, webrtc_ini_s *ini)
{
GstCaps *caps = NULL;
- const ini_item_media_source_s *ini_source;
GstAudioInfo info;
GstAudioFormat format;
+ int channels, samplerate;
RET_VAL_IF(source == NULL, NULL, "source is NULL");
RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
- ini_source = _ini_get_source_by_type(ini, source->type);
- if (ini_source == NULL)
- ini_source = &ini->media_source;
-
switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN:
case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO: {
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, ini_source->v_raw_format,
+ "format", G_TYPE_STRING, _get_raw_format_from_ini(ini, source->type, MEDIA_TYPE_VIDEO),
"framerate", GST_TYPE_FRACTION, source->video_info.framerate, 1,
"width", G_TYPE_INT, source->video_info.width,
"height", G_TYPE_INT, source->video_info.height,
#ifdef SUPPORT_FILESRC_AUDIO_FORMAT_CHANGE
case WEBRTC_MEDIA_SOURCE_TYPE_FILE:
#endif
- format = _get_gst_audio_raw_format_from_string(ini_source->a_raw_format);
+ 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");
- gst_audio_info_set_format(&info, format, ini_source->a_samplerate, ini_source->a_channels, NULL);
+ _get_audio_info_from_ini(ini, source->type, &channels, &samplerate);
+ gst_audio_info_set_format(&info, format, samplerate, channels, NULL);
caps = gst_audio_info_to_caps(&info);
break;
static GstCaps *__make_default_encoded_caps(webrtc_gst_slot_s *source, webrtc_ini_s *ini, gchar **media_type)
{
GstCaps *caps;
- const ini_item_media_source_s *ini_source;
const char *_media_type;
+ int channels, samplerate;
RET_VAL_IF(source == NULL, NULL, "source is NULL");
RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
- ini_source = _ini_get_source_by_type(ini, source->type);
- if (ini_source == NULL)
- ini_source = &ini->media_source;
-
- if (source->media_types == MEDIA_TYPE_AUDIO)
- RET_VAL_IF(ini_source->a_codecs == NULL, NULL, "a_codecs is NULL");
- else if (source->media_types == MEDIA_TYPE_VIDEO)
- RET_VAL_IF(ini_source->v_codecs == NULL, NULL, "v_codecs is NULL");
+ if (!_get_supported_codecs_from_ini(ini, source->type, source->media_types)) {
+ LOG_ERROR("failed to get supported codecs");
+ return NULL;
+ }
switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
_media_type = _get_audio_media_type(source->av[AV_IDX_AUDIO].codec);
RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL");
- caps = _get_caps_from_encoded_audio_media_type(_media_type, ini_source->a_channels, ini_source->a_samplerate);
+ _get_audio_info_from_ini(ini, source->type, &channels, &samplerate);
+ caps = _get_caps_from_encoded_audio_media_type(_media_type, channels, samplerate);
break;
case WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET:
_media_type = _get_audio_media_type(source->av[AV_IDX_AUDIO].codec);
RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL");
- caps = _get_caps_from_encoded_audio_media_type(_media_type, ini_source->a_channels, ini_source->a_samplerate);
+ _get_audio_info_from_ini(ini, source->type, &channels, &samplerate);
+ caps = _get_caps_from_encoded_audio_media_type(_media_type, channels, samplerate);
} else if (source->media_types == MEDIA_TYPE_VIDEO) {
+ int width, height;
_media_type = _get_video_media_type(source->av[AV_IDX_VIDEO].codec);
RET_VAL_IF(_media_type == NULL, NULL, "_media_type is NULL");
- caps = _get_caps_from_encoded_video_media_type(_media_type, ini_source->v_width, ini_source->v_height);
+ _get_video_resolution_from_ini(ini, source->type, &width, &height);
+ caps = _get_caps_from_encoded_video_media_type(_media_type, width, height);
} else {
LOG_ERROR_IF_REACHED("source->media_types(0x%x)", source->media_types);
//LCOV_EXCL_START
static GstElement *__get_hw_encoder_element(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
- const ini_item_media_source_s *ini_source;
GstElement *encoder = NULL;
RET_VAL_IF(webrtc == NULL, NULL, "webrtc is NULL");
RET_VAL_IF(source == NULL, NULL, "source is NULL");
- ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
-
switch (source->media_types) {
case MEDIA_TYPE_AUDIO:
- if (ini_source && ini_source->a_hw_encoder_element)
- return _create_element(ini_source->a_hw_encoder_element, ELEMENT_NAME_AUDIO_ENCODER);
- else if (webrtc->ini.media_source.a_hw_encoder_element)
- return _create_element(webrtc->ini.media_source.a_hw_encoder_element, ELEMENT_NAME_AUDIO_ENCODER);
+ return _create_element(_get_hw_encoder_from_ini(&webrtc->ini, source->type, MEDIA_TYPE_AUDIO), ELEMENT_NAME_AUDIO_ENCODER);
break;
case MEDIA_TYPE_VIDEO:
- if (ini_source && ini_source->v_hw_encoder_element)
- encoder = _create_element(ini_source->v_hw_encoder_element, ELEMENT_NAME_VIDEO_ENCODER);
- else if (webrtc->ini.media_source.v_hw_encoder_element)
- encoder = _create_element(webrtc->ini.media_source.v_hw_encoder_element, ELEMENT_NAME_VIDEO_ENCODER);
+ encoder = _create_element(_get_hw_encoder_from_ini(&webrtc->ini, source->type, MEDIA_TYPE_VIDEO), ELEMENT_NAME_VIDEO_ENCODER);
break;
default:
LOG_ERROR_IF_REACHED("type(0x%x)", source->media_types);
static bool __is_videoscale_needed(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
- const ini_item_media_source_s *ini_source;
+ bool drc_support;
+ bool encoded_support;
RET_VAL_IF(webrtc == NULL, false, "webrtc is NULL");
RET_VAL_IF(source == NULL, false, "source is NULL");
if (!(source->media_types & MEDIA_TYPE_VIDEO))
return false;
- if (_is_encoded_format_supported(source->type, &webrtc->ini))
+ _get_video_encoded_support_from_ini(&webrtc->ini, source->type, &encoded_support);
+ if (encoded_support)
return false;
- ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
- if (ini_source == NULL)
- ini_source = &webrtc->ini.media_source;
+ _get_drc_support_from_ini(&webrtc->ini, source->type, &drc_support);
- if (ini_source->v_drc_support)
+ if (drc_support)
return false;
if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE || source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET)
idx = GET_AV_IDX(is_audio);
if (need_capsfilter) {
+ bool encoded_support;
GstElement *capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, ELEMENT_NAME_FIRST_CAPSFILTER);
if (!capsfilter)
return WEBRTC_ERROR_INVALID_OPERATION;
APPEND_ELEMENT(*element_list, capsfilter);
- if (_is_encoded_format_supported(source->type, &webrtc->ini)) {
+ _get_video_encoded_support_from_ini(&webrtc->ini, source->type, &encoded_support);
+ if (encoded_support) {
if ((sink_caps = __make_default_encoded_caps(source, &webrtc->ini, NULL))) {
PRINT_CAPS(sink_caps, "capsfilter");
g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL);
GstCaps *_make_video_raw_caps_with_resolution(webrtc_gst_slot_s *source, webrtc_ini_s *ini, int width, int height)
{
GstCaps *caps = NULL;
- const ini_item_media_source_s *ini_source;
RET_VAL_IF(source == NULL, NULL, "source is NULL");
RET_VAL_IF(ini == NULL, NULL, "ini is NULL");
- ini_source = _ini_get_source_by_type(ini, source->type);
- if (ini_source == NULL)
- ini_source = &ini->media_source;
-
switch (source->type) {
case WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST:
case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA:
case WEBRTC_MEDIA_SOURCE_TYPE_SCREEN: {
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, ini_source->v_raw_format,
+ "format", G_TYPE_STRING, _get_raw_format_from_ini(ini, source->type, MEDIA_TYPE_VIDEO),
"framerate", GST_TYPE_FRACTION, source->video_info.framerate, 1,
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,