From: Sangchul Lee Date: Thu, 6 May 2021 05:43:19 +0000 (+0900) Subject: webrtc_source: Get ready for audio/video source pads in a media source X-Git-Tag: submit/tizen/20210729.023123~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81d2a69ff13fd766e614bd6d965a6a36d942379f;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source: Get ready for audio/video source pads in a media source This patch is to prepare a media source that have two source pads. Currently, we only support two kinds of stream, audio and video. [Version] 0.1.167 [Issue Type] Improvement Change-Id: I2fbccfc66d2fff36faa98ae98c01a8051a71216b Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 58180c91..910e4831 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -388,10 +388,10 @@ typedef struct _webrtc_gst_slot_s { GstElement *webrtcbin; GList *signals; - GstPad *src_pad; webrtc_media_source_type_e type; int media_types; /* values of media_type_e combined with bitwise 'or' */ int mlines[AV_IDX_MAX]; + GstPad *src_pads[AV_IDX_MAX]; struct { int width; int height; diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index b426f28f..ce416cd4 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.1.166 +Version: 0.1.167 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 6b035c28..e6a14988 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -767,7 +767,9 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pads[AV_IDX_VIDEO]); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); source->media_types = MEDIA_TYPE_VIDEO; @@ -787,7 +789,7 @@ static int __build_screensrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) goto exit_with_remove_from_bin; } - ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true); + ret = _set_ghost_pad_target(source->src_pads[AV_IDX_VIDEO], capsfilter2, true); if (ret != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; @@ -821,7 +823,9 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pads[AV_IDX_VIDEO]); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); source->media_types = MEDIA_TYPE_VIDEO; #ifdef TIZEN_FEATURE_RES_MGR @@ -847,7 +851,7 @@ static int __build_camerasrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) goto exit_with_remove_from_bin; } - ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true); + ret = _set_ghost_pad_target(source->src_pads[AV_IDX_VIDEO], capsfilter2, true); if (ret != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; @@ -880,7 +884,9 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pads[AV_IDX_AUDIO]); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); source->media_types = MEDIA_TYPE_AUDIO; @@ -897,7 +903,7 @@ static int __build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) goto exit_with_remove_from_bin; } - ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true); + ret = _set_ghost_pad_target(source->src_pads[AV_IDX_AUDIO], capsfilter2, true); if (ret != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; @@ -930,7 +936,9 @@ static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pads[AV_IDX_VIDEO]); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); source->media_types = MEDIA_TYPE_VIDEO; @@ -949,7 +957,7 @@ static int __build_videotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) goto exit_with_remove_from_bin; } - ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true); + ret = _set_ghost_pad_target(source->src_pads[AV_IDX_VIDEO], capsfilter2, true); if (ret != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; @@ -982,7 +990,9 @@ static int __build_audiotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pads[AV_IDX_AUDIO]); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); source->media_types = MEDIA_TYPE_AUDIO; @@ -1001,7 +1011,7 @@ static int __build_audiotestsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source) goto exit_with_remove_from_bin; } - ret = _set_ghost_pad_target(source->src_pad, capsfilter2, true); + ret = _set_ghost_pad_target(source->src_pads[AV_IDX_AUDIO], capsfilter2, true); if (ret != WEBRTC_ERROR_NONE) goto exit_with_remove_from_bin; @@ -1115,6 +1125,7 @@ static GstElement *__find_element_in_bin(GstBin *bin, const gchar *name) static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gst_slot_s *source) { int ret = WEBRTC_ERROR_NONE; + GstPad **src_pad; GstElement *appsrc; GstElement *encoder; GstElement *payloader; @@ -1126,7 +1137,10 @@ static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gs RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + src_pad = (source->media_types == MEDIA_TYPE_AUDIO) ? &source->src_pads[AV_IDX_AUDIO] : &source->src_pads[AV_IDX_VIDEO]; + ret = _add_no_target_ghostpad_to_slot(source, true, src_pad); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); appsrc = __find_element_in_bin(source->bin, "appsrc"); RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL"); @@ -1151,7 +1165,7 @@ static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gs return WEBRTC_ERROR_INVALID_OPERATION; } - return _set_ghost_pad_target(source->src_pad, capsfilter, true); + return _set_ghost_pad_target(*src_pad, capsfilter, true); } static GstCaps *__make_encoded_caps_for_appsrc(webrtc_gst_slot_s *source) @@ -1181,6 +1195,7 @@ static GstCaps *__make_encoded_caps_for_appsrc(webrtc_gst_slot_s *source) static int __complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source) { int ret = WEBRTC_ERROR_NONE; + GstPad **src_pad; GstElement *appsrc; GstElement *payloader; GstElement *queue; @@ -1191,7 +1206,10 @@ static int __complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrt RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - RET_VAL_IF(source->src_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_pad is NULL"); + + src_pad = (source->media_types == MEDIA_TYPE_AUDIO) ? &source->src_pads[AV_IDX_AUDIO] : &source->src_pads[AV_IDX_VIDEO]; + ret = _add_no_target_ghostpad_to_slot(source, true, src_pad); + RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); appsrc = __find_element_in_bin(source->bin, "appsrc"); RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL"); @@ -1216,20 +1234,15 @@ static int __complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrt return WEBRTC_ERROR_INVALID_OPERATION; } - return _set_ghost_pad_target(source->src_pad, capsfilter, true); + return _set_ghost_pad_target(*src_pad, capsfilter, true); } static int __build_source_bin(webrtc_s *webrtc, webrtc_gst_slot_s *source) { - int ret = WEBRTC_ERROR_NONE; - RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL"); - ret = _add_no_target_ghostpad_to_slot(source, true, &source->src_pad); - RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()"); - switch (source->type) { case WEBRTC_MEDIA_SOURCE_TYPE_CAMERA: return __build_camerasrc(webrtc, source);