From: Sangchul Lee Date: Tue, 28 Dec 2021 07:27:26 +0000 (+0900) Subject: Rename payload id to payload type(pt) X-Git-Tag: submit/tizen/20211229.072812^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fd915cf778beeb54b5f2ec690e1f40f98679e4c;p=platform%2Fcore%2Fapi%2Fwebrtc.git Rename payload id to payload type(pt) New one is the term the most commonly used. [Version] 0.3.35 [Issue Type] Refactoring Change-Id: Ic0b070cab1fd445ae0bd327f382a4f3d349356ff Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 0b783b73..eea7ebf6 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -240,7 +240,7 @@ do { \ #define MEDIA_TYPE_VIDEO_JPEG "image/jpeg" #define WEBRTC_DISPLAY_TYPE_ECORE_WL 2 -#define PAYLOAD_ID_BITS 32 /* 96 ~ 127 */ +#define PAYLOAD_TYPE_BITS 32 /* 96 ~ 127 */ #define TRACK_ID_THRESHOLD_OF_LOOPBACK 100 #define MAX_MLINE_NUM 16 @@ -425,7 +425,7 @@ typedef struct _webrtc_s { GCond desc_cond; webrtc_gst_s gst; - unsigned int payload_ids; + unsigned int payload_types; gchar *stun_server_url; GList *turn_server_urls; @@ -480,7 +480,7 @@ typedef struct _webrtc_gst_slot_s { gulong src_pad_probe_id; bool pause; bool inbandfec; - unsigned int payload_id; + unsigned int pt; struct { unsigned int track_id; bool need_decoding; @@ -709,7 +709,7 @@ int _remove_filesrc_pad_block_probe(webrtc_s *webrtc); gchar * _get_media_type_from_pad(GstPad *pad); gchar * _get_mime_type_from_pad(GstPad *pad); -int _get_payload_id_from_pad(GstPad *pad); +int _get_payload_type_from_pad(GstPad *pad); bool _is_supported_media_type(const char *media_type); bool _is_audio_media_type(const char *media_type); diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index ccc2294e..b55b8b84 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.3.34 +Version: 0.3.35 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index c49e9745..9bb26f9f 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -1271,24 +1271,24 @@ gchar * _get_mime_type_from_pad(GstPad *pad) return mime_type; } -int _get_payload_id_from_pad(GstPad *pad) +int _get_payload_type_from_pad(GstPad *pad) { GstCaps *caps = NULL; - gint id = -1; + gint pt = -1; RET_VAL_IF(pad == NULL, -1, "pad is NULL"); caps = gst_pad_get_current_caps(pad); RET_VAL_IF(caps == NULL, -1, "caps is NULL"); - if (!gst_structure_get_int(gst_caps_get_structure(caps, 0), "payload", &id)) + if (!gst_structure_get_int(gst_caps_get_structure(caps, 0), "payload", &pt)) LOG_ERROR("failed to gst_structure_get_int()"); else - LOG_DEBUG("payload id[%d]", id); + LOG_DEBUG("payload type[%d]", pt); gst_caps_unref(caps); - return id; + return pt; } //LCOV_EXCL_STOP diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index ab131a61..6bd6be49 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -362,7 +362,7 @@ static void __decodebin_element_added_cb(GstElement *decodebin, GstElement *elem for (i = 0; i < MAX_MLINE_NUM; i ++) { /* FIXME: we don't know mline in this situation, so retrieve the array here. */ if (!sink->webrtc->data_recovery_types[i].inbandfec.use) continue; - if (sink->webrtc->data_recovery_types[i].inbandfec.pt != (int)sink->av[AV_IDX_AUDIO].payload_id) + if (sink->webrtc->data_recovery_types[i].inbandfec.pt != (int)sink->av[AV_IDX_AUDIO].pt) continue; if (!g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(element)), "use-inband-fec")) { LOG_WARNING("could not find 'use-inband-fec' property"); @@ -550,7 +550,7 @@ int _add_rendering_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_audio) if (!decodebin) goto error_before_insert; - sink->av[GET_AV_IDX(is_audio)].payload_id = _get_payload_id_from_pad(src_pad); + sink->av[GET_AV_IDX(is_audio)].pt = _get_payload_type_from_pad(src_pad); gst_bin_add(sink->bin, decodebin); diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 4ac01d3b..0bee0756 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -616,7 +616,7 @@ static GstCaps *__make_encoded_caps_from_media_format(webrtc_gst_slot_s *source, } //LCOV_EXCL_STOP -static GstCaps *__make_rtp_caps(const gchar *media_type, unsigned int payload_id, webrtc_gst_slot_s *source) +static GstCaps *__make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source) { GstCaps *caps; bool is_audio; @@ -627,7 +627,7 @@ static GstCaps *__make_rtp_caps(const gchar *media_type, unsigned int payload_id caps = gst_caps_new_simple("application/x-rtp", "media", G_TYPE_STRING, GET_MEDIA_TYPE_NAME(is_audio), - "payload", G_TYPE_INT, payload_id, + "payload", G_TYPE_INT, payload_type, NULL); if (is_audio && source->av[AV_IDX_AUDIO].inbandfec) @@ -723,7 +723,7 @@ static bool __is_encoded_format_supported(webrtc_media_source_type_e type, webrt return ini_source->v_encoded_fmt_support; } -static int __get_fixed_payload_id(const gchar *media_type) +static int __get_fixed_payload_type(const gchar *media_type) { RET_VAL_IF(media_type == NULL, -1, "media_type is NULL"); @@ -736,40 +736,40 @@ static int __get_fixed_payload_id(const gchar *media_type) return -1; } -static unsigned int __get_available_payload_id(webrtc_s *webrtc) +static unsigned int __get_available_payload_type(webrtc_s *webrtc) { int bitmask = 0x1; int count = 0; RET_VAL_IF(webrtc == NULL, 0, "webrtc is NULL"); - while (count++ < PAYLOAD_ID_BITS) { - if (webrtc->payload_ids & bitmask) { + while (count++ < PAYLOAD_TYPE_BITS) { + if (webrtc->payload_types & bitmask) { bitmask <<= 1; continue; } - webrtc->payload_ids |= bitmask; - LOG_DEBUG("found available payload id[%d]", count + 95); + webrtc->payload_types |= bitmask; + LOG_DEBUG("found available payload type[%d]", count + 95); return count + 95; /* 96 ~ 127 */ } - LOG_ERROR("could not assign payload id"); + LOG_ERROR("could not assign payload type"); return 0; } -static void __return_payload_id(webrtc_s *webrtc, unsigned int payload_id) +static void __return_payload_type(webrtc_s *webrtc, unsigned int payload_type) { int i; int bitmask = 0x1; RET_IF(webrtc == NULL, "webrtc is NULL"); - RET_IF(payload_id < 96 || payload_id > 127, "invalid payload_id(%u)", payload_id); + RET_IF(payload_type < 96 || payload_type > 127, "invalid payload_type(%u)", payload_type); - i = payload_id - 96; + i = payload_type - 96; while (i-- > 0) bitmask <<= 1; - webrtc->payload_ids ^= bitmask; + webrtc->payload_types ^= bitmask; } static GstPadProbeReturn __source_data_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data) @@ -913,7 +913,7 @@ static int __create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source GstCaps *sink_caps; element_info_s elem_info; gchar *media_type = NULL; - int payload_id; + int payload_type; int idx; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); @@ -983,13 +983,13 @@ skip_encoder: goto error; APPEND_ELEMENT(*element_list, capsfilter2); - if ((payload_id = __get_fixed_payload_id(media_type)) == -1) - if ((payload_id = __get_available_payload_id(webrtc)) == 0) + if ((payload_type = __get_fixed_payload_type(media_type)) == -1) + if ((payload_type = __get_available_payload_type(webrtc)) == 0) goto error; - source->av[idx].payload_id = payload_id; + source->av[idx].pt = payload_type; - if ((sink_caps = __make_rtp_caps(media_type, payload_id, source))) { + if ((sink_caps = __make_rtp_caps(media_type, payload_type, source))) { g_object_set(G_OBJECT(capsfilter2), "caps", sink_caps, NULL); gst_caps_unref(sink_caps); } @@ -1015,7 +1015,7 @@ static int __create_rest_of_elements_for_encoded_format(webrtc_s *webrtc, webrtc GstElement *payloader; GstElement *queue; GstElement *capsfilter; - unsigned int payload_id; + unsigned int payload_type; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); @@ -1038,13 +1038,13 @@ static int __create_rest_of_elements_for_encoded_format(webrtc_s *webrtc, webrtc goto error; APPEND_ELEMENT(*element_list, capsfilter); - payload_id = __get_available_payload_id(webrtc); - if (payload_id == 0) + payload_type = __get_available_payload_type(webrtc); + if (payload_type == 0) goto error; - source->av[GET_AV_IDX_BY_TYPE(source->media_types)].payload_id = payload_id; + source->av[GET_AV_IDX_BY_TYPE(source->media_types)].pt = payload_type; - if ((sink_caps = __make_rtp_caps(media_type, payload_id, source))) { + if ((sink_caps = __make_rtp_caps(media_type, payload_type, source))) { g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL); gst_caps_unref(sink_caps); } @@ -1957,22 +1957,22 @@ static GstElement * __prepare_capsfilter_for_filesrc_pipeline(webrtc_gst_slot_s { GstElement *capsfilter = NULL; GstCaps *sink_caps = NULL; - unsigned int payload_id = 0; + unsigned int payload_type = 0; RET_VAL_IF(source == NULL, NULL, "source is NULL"); if (!(capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, _av_tbl[GET_AV_IDX(is_audio)].capsfilter_name))) return NULL; - payload_id = __get_available_payload_id(source->webrtc); - if (payload_id == 0) { + payload_type = __get_available_payload_type(source->webrtc); + if (payload_type == 0) { SAFE_GST_OBJECT_UNREF(capsfilter); return NULL; } - source->av[GET_AV_IDX(is_audio)].payload_id = payload_id; + source->av[GET_AV_IDX(is_audio)].pt = payload_type; - if ((sink_caps = __make_rtp_caps(GET_MEDIA_TYPE_NAME(is_audio), payload_id, source))) { + if ((sink_caps = __make_rtp_caps(GET_MEDIA_TYPE_NAME(is_audio), payload_type, source))) { g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL); gst_caps_unref(sink_caps); } @@ -2619,8 +2619,8 @@ void _source_slot_destroy_cb(gpointer data) __remove_probe_from_pad_for_pause(source, i); __remove_probe_from_pad_for_render(source, i); - if (source->av[i].payload_id > 0) - __return_payload_id(source->webrtc, source->av[i].payload_id); + if (source->av[i].pt > 0) + __return_payload_type(source->webrtc, source->av[i].pt); if (source->av[i].render.pipeline) { gst_element_set_state(source->av[i].render.pipeline, GST_STATE_NULL); @@ -3207,8 +3207,8 @@ static void __release_filesrc_resources(webrtc_gst_slot_s *source) __remove_probe_from_pad_for_pause(source, av_idx); __remove_probe_from_pad_for_render(source, av_idx); - if (source->av[av_idx].payload_id > 0) - __return_payload_id(source->webrtc, source->av[av_idx].payload_id); + if (source->av[av_idx].pt > 0) + __return_payload_type(source->webrtc, source->av[av_idx].pt); if (source->av[av_idx].render.pipeline) { gst_element_set_state(source->av[av_idx].render.pipeline, GST_STATE_NULL);