webrtc_internal: Revise webrtc_media_source_set_payload_type() for media packet source 33/281133/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 13 Sep 2022 07:12:25 +0000 (16:12 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 13 Sep 2022 07:12:33 +0000 (16:12 +0900)
This function should affect media packet source. It is fixed.

[Version] 0.3.237
[Issue Type] Bug fix

Change-Id: I12b49da60526d2ba93cef07e1ceea9b4e887df33
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_internal.c
src/webrtc_source_mediapacket.c

index 869123068894d751fc9a100f52e011f4216ac353..1c71f0f8d2920e158d801e41616288d9a2fed479 100644 (file)
@@ -730,6 +730,7 @@ int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source);
 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);
index 84ec88cd87180d08a08b0d6a25e63c1f809a5150..bff8802f8d8c35eabe5f693ec018bf3b1ad26edc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.236
+Version:    0.3.237
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 45cd57c99185fab624b7475478d1cb029dafbe07..4773536849f8219d4c70067e91600f73287b4195 100644 (file)
@@ -117,7 +117,7 @@ int webrtc_media_source_set_payload_type(webrtc_h webrtc, unsigned int source_id
 
        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)
index e5af6fd92dc8a978f2caf7fb75b542e99bea006d..74d5329dbfa26fb2aff9abca9ee786ebb41db2df 100644 (file)
@@ -836,3 +836,34 @@ error:
        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