return source->source_element;
}
-static GstPadProbeReturn __source_bin_pad_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
+static GstPadProbeReturn __payloaded_data_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
{
probe_userdata_s *probe_data = (probe_userdata_s *)user_data;
GstBuffer *buffer;
return GST_PAD_PROBE_OK;
}
-static void __add_probe_to_pad(GstPad *pad, media_type_e media_type, webrtc_gst_slot_s *source)
+static void __add_probe_to_pad(webrtc_gst_slot_s *source, unsigned int idx, GstPad *pad, void *probe_cb)
{
probe_userdata_s *probe_userdata;
- RET_IF(pad == NULL, "pad is NULL");
RET_IF(source == NULL, "source is NULL");
+ RET_IF(idx >= AV_IDX_MAX, "invalid idx(%u)", idx);
+ RET_IF(pad == NULL, "pad is NULL");
+ RET_IF(probe_cb == NULL, "probe_cb is NULL");
probe_userdata = g_new0(probe_userdata_s, 1);
- probe_userdata->av_idx = (media_type == MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
probe_userdata->source = source;
- source->av[probe_userdata->av_idx].src_pad_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER,
- __source_bin_pad_probe_cb, probe_userdata, g_free);
+ probe_userdata->av_idx = idx;
+ source->av[idx].src_pad = pad;
+ source->av[idx].src_pad_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER,
+ probe_cb, probe_userdata, g_free);
- LOG_DEBUG("probe[id:%lu] is added to pad[%p] for av_idx[%d] in source[%p]",
- source->av[probe_userdata->av_idx].src_pad_probe_id, pad, probe_userdata->av_idx, source);
+ LOG_DEBUG("source[id:%u, av_idx:%u] pad[%p] probe[id:%lu, callback:%p]",
+ source->id, idx, pad, source->av[idx].src_pad_probe_id, probe_cb);
+}
+
+static void __remove_probe_from_pad(webrtc_gst_slot_s *source, unsigned int idx)
+{
+ RET_IF(source == NULL, "source is NULL");
+ RET_IF(idx >= AV_IDX_MAX, "invalid idx(%u)", idx);
+
+ if (source->av[idx].src_pad_probe_id == 0)
+ return;
+
+ LOG_DEBUG("source[id:%u, av_idx:%u] pad[%p] probe_id[%lu]",
+ source->id, idx, source->av[idx].src_pad, source->av[idx].src_pad_probe_id);
+ gst_pad_remove_probe(source->av[idx].src_pad, source->av[idx].src_pad_probe_id);
+ source->av[idx].src_pad_probe_id = 0;
+ source->av[idx].src_pad = NULL;
}
static bool __add_elements_to_bin(GstBin *bin, GList *element_list)
GstElement *capsfilter;
GList *switch_src_list = NULL;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_VIDEO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_VIDEO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_VIDEO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_VIDEO].src_pad, MEDIA_TYPE_VIDEO, source);
+ __add_probe_to_pad(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(switch_src_list);
SAFE_G_LIST_FREE(element_list);
GstElement *camerasrc;
GstElement *capsfilter;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_VIDEO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_VIDEO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_VIDEO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_VIDEO].src_pad, MEDIA_TYPE_VIDEO, source);
+ __add_probe_to_pad(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(element_list);
GstElement *volume;
GstElement *capsfilter;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_AUDIO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_AUDIO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_AUDIO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_AUDIO].src_pad, MEDIA_TYPE_AUDIO, source);
+ __add_probe_to_pad(source, AV_IDX_AUDIO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(element_list);
GstElement *videotestsrc;
GstElement *capsfilter;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_VIDEO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_VIDEO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_VIDEO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_VIDEO].src_pad, MEDIA_TYPE_VIDEO, source);
+ __add_probe_to_pad(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(element_list);
GstElement *custom_videosrc;
GstElement *capsfilter;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_VIDEO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_VIDEO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_VIDEO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_VIDEO].src_pad, MEDIA_TYPE_VIDEO, source);
+ __add_probe_to_pad(source, AV_IDX_VIDEO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(element_list);
GstElement *volume;
GstElement *capsfilter;
GList *element_list = NULL;
+ GstPad *src_pad;
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->av[AV_IDX_AUDIO].src_pad);
+ 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()");
source->media_types = MEDIA_TYPE_AUDIO;
ret = WEBRTC_ERROR_INVALID_OPERATION;
goto exit_with_remove_from_bin;
}
- ret = _set_ghost_pad_target(source->av[AV_IDX_AUDIO].src_pad, capsfilter, true);
+ ret = _set_ghost_pad_target(src_pad, capsfilter, true);
if (ret != WEBRTC_ERROR_NONE)
goto exit_with_remove_from_bin;
- __add_probe_to_pad(source->av[AV_IDX_AUDIO].src_pad, MEDIA_TYPE_AUDIO, source);
+ __add_probe_to_pad(source, AV_IDX_AUDIO, src_pad, __payloaded_data_probe_cb);
SAFE_G_LIST_FREE(element_list);
gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source);
for (i = 0; i < AV_IDX_MAX; i++) {
- if (source->av[i].src_pad_probe_id) {
- gst_pad_remove_probe(source->av[i].src_pad, source->av[i].src_pad_probe_id);
- source->av[i].src_pad_probe_id = 0;
- }
+ __remove_probe_from_pad(source, i);
+
if (source->av[i].payload_id > 0)
__return_payload_id(source->webrtc, source->av[i].payload_id);
}