LOG_ERROR("failed to 'push-buffer', gst_ret[0x%x]", gst_ret);
}
+static GstPadProbeReturn __fakesink_block_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ webrtc_gst_slot_s *source = u_data;
+ gchar *media = NULL;
+
+ gst_structure_get(gst_caps_get_structure(gst_pad_get_current_caps(pad), 0), "media", G_TYPE_STRING, &media, NULL);
+
+ LOG_DEBUG("source[%p, id:%u] fakesink pad[%p] for [%s] is blocked", source, source->id, pad, media);
+
+ return GST_PAD_PROBE_OK;
+}
+
static GstPadProbeReturn __fakesink_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
webrtc_gst_slot_s *source = u_data;
GstCaps *new_cap = NULL;
GstElement *appsrc = NULL;
gchar *media = NULL;
+ int av_idx;
gst_structure_get(gst_caps_get_structure(gst_pad_get_current_caps(pad), 0), "media", G_TYPE_STRING, &media, NULL);
- if (g_strrstr(media, "audio"))
- appsrc = gst_bin_get_by_name(source->bin, ELEMENT_NAME_AUDIO_APPSRC);
- else
- appsrc = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEO_APPSRC);
+ if (!g_strrstr(media, "audio") && !g_strrstr(media, "video")) {
+ LOG_ERROR("not supported media type [%s]", media);
+ return GST_PAD_PROBE_OK;
+ }
+ av_idx = GET_AV_IDX(g_strrstr(media, "audio"));
+
+ appsrc = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].appsrc_name);
RET_VAL_IF(appsrc == NULL, GST_PAD_PROBE_OK, "There is no appsrc for [%s]", media);
new_cap = gst_caps_copy(gst_pad_get_current_caps(pad));
LOG_INFO("setting caps for [%s appsrc] successfully", media);
PRINT_CAPS(new_cap, "appsrc");
+ source->filesrc_av[av_idx].sink_pad = pad;
+ source->filesrc_av[av_idx].sink_pad_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BLOCK,
+ __fakesink_block_probe_cb, source, NULL);
+
return GST_PAD_PROBE_REMOVE;
}
LOG_INFO("[%s] new_pad[%s] media_type[%s]", GST_ELEMENT_NAME(element), GST_PAD_NAME(pad), media_type);
if (!g_strrstr(media_type, "audio") && !g_strrstr(media_type, "video")) {
- LOG_ERROR("invalid media type [%s]", media_type);
+ LOG_ERROR("not supported media type [%s]", media_type);
return;
}
return WEBRTC_ERROR_NONE;
}
+
+static void __remove_filesrc_pad_block_foreach_cb(gpointer key, gpointer value, gpointer user_data)
+{
+ webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)value;
+ int av_idx;
+
+ if (source->type != WEBRTC_MEDIA_SOURCE_TYPE_FILE)
+ return;
+
+ for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) {
+ if (source->filesrc_av[av_idx].sink_pad_probe_id == 0)
+ continue;
+
+ LOG_DEBUG("source[%p, id:%u] fakesink pad[%p] for [%s] is unblocked",
+ source, source->id, source->filesrc_av[av_idx].sink_pad, GET_MEDIA_TYPE_NAME(av_idx == AV_IDX_AUDIO));
+ gst_pad_remove_probe(source->filesrc_av[av_idx].sink_pad, source->filesrc_av[av_idx].sink_pad_probe_id);
+ source->filesrc_av[av_idx].sink_pad = NULL;
+ source->filesrc_av[av_idx].sink_pad_probe_id = 0;
+ }
+}
+
+int _remove_filesrc_pad_block_probe(webrtc_s *webrtc)
+{
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+
+ g_hash_table_foreach(webrtc->gst.source_slots, __remove_filesrc_pad_block_foreach_cb, NULL);
+
+ return WEBRTC_ERROR_NONE;
+}
//LCOV_EXCL_STOP