GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source);
int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h packet);
int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format);
+int _update_pt_if_media_packet_source(webrtc_s *webrtc, webrtc_gst_slot_s *source);
/* screen source */
int _get_screen_resolution(int *width, int *height);
LOG_INFO("webrtc[%p] source_id[%u] media_type[%u] payload type[%u]", _webrtc, source_id, media_type, pt);
- return WEBRTC_ERROR_NONE;
+ return _update_pt_if_media_packet_source(webrtc, source);
}
int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, unsigned int *pt)
source->media_format = NULL;
return ret;
}
+
+//LCOV_EXCL_START
+int _update_pt_if_media_packet_source(webrtc_s *webrtc, webrtc_gst_slot_s *source)
+{
+ GstCaps *sink_caps;
+ GstElement *capsfilter;
+ const char *media_type;
+ int idx;
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+ if (source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET)
+ return WEBRTC_ERROR_NONE;
+
+ if (!(capsfilter = gst_bin_get_by_name(source->bin, ELEMENT_NAME_RTP_CAPSFILTER))) {
+ LOG_ERROR("failed to gst_bin_get_by_name() for %s", ELEMENT_NAME_RTP_CAPSFILTER);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
+ idx = GET_AV_IDX_BY_TYPE(source->media_types);
+ media_type = (idx == AV_IDX_AUDIO) ? _get_audio_media_type(source->av[idx].codec) : _get_video_media_type(source->av[idx].codec);
+
+ if (!(sink_caps = _make_rtp_caps(media_type, source->av[idx].pt, source, NULL)))
+ return WEBRTC_ERROR_INVALID_OPERATION;
+
+ g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL);
+ gst_caps_unref(sink_caps);
+
+ return WEBRTC_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
\ No newline at end of file