g_strrstr(pad_name, MS_RTP_PAD_VIDEO_IN)) {
media = "video";
payload = 96;
- } else if (!media_format_get_audio_info(fmt, &mime, NULL, NULL, NULL, NULL) &&
+ } else if (!media_format_get_audio_info(fmt, &mime, NULL, NULL, NULL, NULL) &&
g_strrstr(pad_name, MS_RTP_PAD_AUDIO_IN)) {
media = "audio";
payload = 97;
media_streamer_node_s *webrtc_node = (media_streamer_node_s *)user_data;
const gchar *new_pad_name;
const gchar *media_type;
+ GstPad *src_pad = NULL;
+ const gchar *src_pad_name = NULL;
ms_retm_if(decodebin == NULL, "decodebin is NULL");
ms_retm_if(new_pad == NULL, "new_pad is NULL");
ms_retm_if(GST_PAD_DIRECTION(new_pad) != GST_PAD_SRC, "new_pad is not for source");
ms_retm_if(gst_pad_has_current_caps(new_pad) == FALSE, "new_pad does not have caps");
- new_pad_name = GST_PAD_NAME(new_pad);
media_type = gst_structure_get_name(gst_caps_get_structure(gst_pad_get_current_caps(new_pad), 0));
+ ms_debug("type is [%s]", media_type);
+
+ if (MS_ELEMENT_IS_VIDEO(media_type)) {
+ src_pad_name = MS_RTP_PAD_VIDEO_OUT;
+ } else if (MS_ELEMENT_IS_AUDIO(media_type)) {
+ src_pad_name = MS_RTP_PAD_AUDIO_OUT;
+ } else {
+ ms_error("Not supported media type[%s]", media_type);
+ return;
+ }
+
+ src_pad = gst_element_get_static_pad(webrtc_node->gst_element, src_pad_name);
+ if (!src_pad) {
+ ms_error("Failed to get pad of %s", src_pad_name);
+ return;
+ }
+ new_pad_name = GST_PAD_NAME(src_pad);
+
+ if (!gst_ghost_pad_set_target(GST_GHOST_PAD(src_pad), new_pad)) {
+ ms_error("Failed to link %s:%s", src_pad_name, GST_PAD_NAME(new_pad));
+ return;
+ }
ms_debug("new_pad_name[%s], media_type[%s]", new_pad_name, media_type);
__trigger_decoded_ready_callback(webrtc_node, new_pad_name, media_type);
+
+ gst_object_unref(src_pad);
}
void ms_webrtcbin_pad_added_cb(GstElement *webrtcbin, GstPad *new_pad, gpointer user_data)
{
media_streamer_node_s *webrtc_node = (media_streamer_node_s *)user_data;
media_streamer_webrtc_callbacks_s *_callbacks;
- GstPad *sink_pad;
- GstElement *decodebin;
+ GstPad *sink_pad = NULL;
+ GstElement *decodebin = NULL;
ms_retm_if(new_pad == NULL, "new_pad is NULL");
ms_retm_if(webrtc_node == NULL, "webrtc_node is NULL");
decodebin = ms_element_create(DEFAULT_DECODEBIN, NULL);
ms_retm_if(decodebin == NULL, "decodebin is NULL");
- ms_retm_if(webrtc_node->parent_streamer == NULL, "parent_streamer is NULL");
- ms_retm_if(webrtc_node->parent_streamer->pipeline == NULL, "pipeline is NULL");
- gst_bin_add(GST_BIN(webrtc_node->parent_streamer->pipeline), decodebin);
-
+ ms_retm_if(webrtc_node->gst_element == NULL, "webrtc_container is NULL");
+ gst_bin_add(GST_BIN(webrtc_node->gst_element), decodebin);
gst_element_sync_state_with_parent(decodebin);
g_signal_connect(decodebin, "pad-added", G_CALLBACK(__decodebin_pad_added_cb), webrtc_node);
-
sink_pad = gst_element_get_static_pad(decodebin, "sink");
ms_retm_if(sink_pad == NULL, "sink_pad is NULL");
- gst_pad_link(new_pad, sink_pad);
+ if (gst_pad_link(new_pad, sink_pad) != GST_PAD_LINK_OK)
+ ms_error("Failed to link %s:%s", GST_PAD_NAME(new_pad), GST_PAD_NAME(sink_pad));
+
gst_object_unref(sink_pad);
ms_debug_fleave();
ms_retvm_if(!webrtc_container, (GstElement *) NULL, "Failed to create webrtc container");
ms_add_no_target_ghostpad(webrtc_container, MS_RTP_PAD_VIDEO_IN, GST_PAD_SINK);
+ ms_add_no_target_ghostpad(webrtc_container, MS_RTP_PAD_VIDEO_OUT, GST_PAD_SRC);
+ ms_add_no_target_ghostpad(webrtc_container, MS_RTP_PAD_AUDIO_IN, GST_PAD_SINK);
+ ms_add_no_target_ghostpad(webrtc_container, MS_RTP_PAD_AUDIO_OUT, GST_PAD_SRC);
MS_SET_INT_STATIC_STRING_PARAM(webrtc_container, MEDIA_STREAMER_PARAM_WEBRTC_PEER_TYPE, DEFAULT_WEBRTC_PEER);
MS_SET_INT_STATIC_STRING_PARAM(webrtc_container, MEDIA_STREAMER_PARAM_WEBRTC_STUN_SERVER, DEFAULT_WEBRTC_STUN_SERVER);