if (!__link_switch_srcs(videoswitch, switch_src_list))
goto exit_with_remove_from_bin;
+ if (source->av[AV_IDX_VIDEO].mute) {
+ GstPad *pad = gst_element_get_static_pad(videoswitch, "sink_1");
+ if (!pad)
+ goto exit_with_remove_from_bin;
+ g_object_set(G_OBJECT(videoswitch), "active-pad", pad, NULL);
+ gst_object_unref(pad);
+ }
+
if (!__link_elements(element_list))
goto exit_with_remove_from_bin;
}
_gst_set_element_properties(videosrc_element, ini_source->source_element_properties);
+ /* NOTE: in case of videotestsrc with mute operation */
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(videosrc_element), "pattern") && source->av[AV_IDX_VIDEO].mute)
+ g_object_set(G_OBJECT(videosrc_element), "pattern", 2, NULL); /* 2: black */
+
/* NOTE: in case of an element that supports tizen zerocopy format, not to emit an error in GST_STATE_PLAYING
* without buffer consumption before finishing negotiation, set this property to 0 here. */
if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(videosrc_element)), "empty-buffer-timeout"))
static int __mute_camerasrc(webrtc_gst_slot_s *source, bool mute)
{
- int ret = WEBRTC_ERROR_NONE;
GstElement *camerasrc = NULL;
- GstPad *src_pad = NULL;
-
- LOG_DEBUG_ENTER();
+ g_autoptr(GstPad) src_pad = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(source->video_muted == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
+ RET_VAL_IF(source->av[AV_IDX_VIDEO].mute == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
- camerasrc = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SRC);
- src_pad = gst_element_get_static_pad(camerasrc, "src");
+ if ((camerasrc = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SRC))) {
+ src_pad = gst_element_get_static_pad(camerasrc, "src");
- if (mute) {
- if (source->camerasrc_probe_id != 0) {
- LOG_ERROR("fail to change to mute");
- ret = WEBRTC_ERROR_INVALID_OPERATION;
- } else {
+ if (mute && source->camerasrc_probe_id == 0) {
source->camerasrc_probe_id = gst_pad_add_probe(src_pad, GST_PAD_PROBE_TYPE_BUFFER, __camerasrc_probe_cb, NULL, NULL);
if (source->camerasrc_probe_id == 0) {
LOG_ERROR("failed to gst_pad_add_probe()");
- ret = WEBRTC_ERROR_INVALID_OPERATION;
+ return WEBRTC_ERROR_INVALID_OPERATION;
}
- }
- } else {
- if (source->camerasrc_probe_id == 0) {
- LOG_ERROR("fail to change to unmute");
- ret = WEBRTC_ERROR_INVALID_OPERATION;
- } else {
+
+ } else if (!mute && source->camerasrc_probe_id != 0) {
gst_pad_remove_probe(src_pad, source->camerasrc_probe_id);
source->camerasrc_probe_id = 0;
+
+ } else {
+ LOG_ERROR("failed to change mute to (%d)", mute);
+ return WEBRTC_ERROR_INVALID_OPERATION;
}
}
- gst_object_unref(src_pad);
+ source->av[AV_IDX_VIDEO].mute = mute;
- return ret;
+ return WEBRTC_ERROR_NONE;
}
static int __mute_videosrc(webrtc_gst_slot_s *source, bool mute)
GstPad *new_pad = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(source->video_muted == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
+ RET_VAL_IF(source->av[AV_IDX_VIDEO].mute == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
- video_switch = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SWITCH);
+ if ((video_switch = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SWITCH))) {
+ new_pad = gst_element_get_static_pad(video_switch, mute ? "sink_1" : "sink_0");
+ RET_VAL_IF(new_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "new_pad is NULL");
- new_pad = gst_element_get_static_pad(video_switch, mute ? "sink_1" : "sink_0");
- RET_VAL_IF(new_pad == NULL, WEBRTC_ERROR_INVALID_OPERATION, "new_pad is NULL");
+ g_object_set(G_OBJECT(video_switch), "active-pad", new_pad, NULL);
+ gst_object_unref(new_pad);
+ }
- g_object_set(G_OBJECT(video_switch), "active-pad", new_pad, NULL);
- gst_object_unref(new_pad);
+ source->av[AV_IDX_VIDEO].mute = mute;
return WEBRTC_ERROR_NONE;
}
GstElement *src_element = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(source->video_muted == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
+ RET_VAL_IF(source->av[AV_IDX_VIDEO].mute == mute, WEBRTC_ERROR_NONE, "Already %s", mute ? "muted" : "unmuted");
- src_element = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SRC);
- RET_VAL_IF(src_element == NULL, WEBRTC_ERROR_INVALID_OPERATION, "src_element is NULL");
-
- if (!g_object_class_find_property(G_OBJECT_GET_CLASS(src_element), "pattern")) {
- LOG_ERROR("there is no pattern property");
- return WEBRTC_ERROR_INVALID_OPERATION;
+ if ((src_element = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_SRC))) {
+ if (!g_object_class_find_property(G_OBJECT_GET_CLASS(src_element), "pattern")) {
+ LOG_ERROR("there is no pattern property");
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+ /* FIXME: get original value from ini file */
+ g_object_set(G_OBJECT(src_element), "pattern", mute ? 2 : 18, NULL); /* 2: black 18: ball */
}
- g_object_set(G_OBJECT(src_element), "pattern", mute ? 2 : 18, NULL); /* 2: black 18: ball */
+ source->av[AV_IDX_VIDEO].mute = mute;
return WEBRTC_ERROR_NONE;
}
LOG_DEBUG("webrtc[%p] source_id[%u] mute[%d]", webrtc, source_id, mute);
- if ((ret = (videosrc_mute_funcs[source->type])(source, mute)) == WEBRTC_ERROR_NONE)
- source->video_muted = mute;
-
- return ret;
+ return (videosrc_mute_funcs[source->type])(source, mute);
}
//LCOV_EXCL_START
if ((ret = __validate_video_source_for_mute(webrtc, source_id, &source)) != WEBRTC_ERROR_NONE)
return ret;
- *muted = source->video_muted;
+ *muted = source->av[AV_IDX_VIDEO].mute;
LOG_INFO("webrtc[%p] source_id[%u] muted[%d]", webrtc, source_id, *muted);