const gchar *media_type = NULL;
GstElement *payload = NULL;
gboolean is_audio;
+ int av_idx;
RET_IF(source == NULL, "source is NULL");
}
is_audio = (g_strrstr(media_type, "audio")) ? TRUE : FALSE;
+ av_idx = (is_audio) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
- if (source->av[is_audio ? AV_IDX_AUDIO : AV_IDX_VIDEO].src_pad_probe_id > 0) {
+ if (source->av[av_idx].src_pad_probe_id > 0) {
LOG_INFO("Pipeline already built");
__link_decodebin_with_payload(pad, source, is_audio, false);
return;
g_hash_table_remove(source->webrtc->gst.source_slots, GST_ELEMENT_NAME(source->bin));
return;
}
+
+ source->av[av_idx].render.need_decoding = true;
+ source->av[av_idx].render.appsrc_caps = gst_pad_get_current_caps(pad);
+ __add_probe_to_pad_for_render(source, av_idx, pad, __source_data_probe_cb);
}
static GstAutoplugSelectResult __filesrc_decodebin_autoplug_select_cb(GstElement *bin, GstPad *pad, GstCaps *caps, GstElementFactory* factory, gpointer udata)
return GST_AUTOPLUG_SELECT_TRY;
}
+static void __filesrc_decodebin_pad_removed_cb(GstElement *element, GstPad *pad, gpointer data)
+{
+ webrtc_gst_slot_s *source = data;
+ int idx = 0;
+
+ RET_IF(source == NULL, "source is NULL");
+
+ if (GST_PAD_DIRECTION(pad) != GST_PAD_SRC)
+ return;
+
+ LOG_INFO("[%s] removed_pad[%s]", GST_ELEMENT_NAME(element), GST_PAD_NAME(pad));
+
+ for (idx = 0; idx < AV_IDX_MAX; idx++) {
+ if (source->av[idx].render.src_pad_probe_id > 0) {
+ source->av[idx].render.src_pad_probe_id = 0;
+ source->av[idx].render.src_pad = NULL;
+
+ gst_caps_unref(source->av[idx].render.appsrc_caps);
+ source->av[idx].render.appsrc_caps = NULL;
+ }
+ }
+}
+
static int __build_filesrc(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
GstElement *filesrc = NULL;
g_signal_connect(decodebin, "autoplug-select", G_CALLBACK(__filesrc_decodebin_autoplug_select_cb), NULL);
g_signal_connect(decodebin, "pad-added", G_CALLBACK(__filesrc_decodebin_pad_added_cb), (gpointer)source);
+ g_signal_connect(decodebin, "pad-removed", G_CALLBACK(__filesrc_decodebin_pad_removed_cb), (gpointer)source);
return WEBRTC_ERROR_NONE;
}