bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini);
GstCaps *_get_caps_from_encoded_audio_media_type(const char *media_type, int channels, int samplerate);
GstCaps *_get_caps_from_encoded_video_media_type(const char *media_type, int width, int height);
-unsigned int _get_available_payload_type(webrtc_s *webrtc);
GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source);
int _set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_type);
int _get_screen_resolution(int *width, int *height);
const char *_get_element_name(int av_idx, gst_element_e element);
+int _set_payload_type(webrtc_s *webrtc, webrtc_gst_slot_s *source, int av_idx, const gchar *media_type);
#endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.164
+Version: 0.3.165
Release: 0
Group: Multimedia/API
License: Apache-2.0
}
//LCOV_EXCL_STOP
-static int __get_fixed_payload_type(const gchar *media_type)
-{
- RET_VAL_IF(media_type == NULL, -1, "media_type is NULL");
-
- if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_MULAW))
- return 0;
- if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_ALAW))
- return 8;
-
- LOG_DEBUG("%s might need to use dynamic id", media_type);
- return -1;
-}
-
static void __return_payload_type(webrtc_s *webrtc, unsigned int payload_type)
{
int i;
return encoder;
}
-static int __set_payload_type(webrtc_s *webrtc, webrtc_gst_slot_s *source, int av_idx, const gchar *media_type)
-{
- int payload_type = -1;
-
- 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 (media_type)
- if ((payload_type = __get_fixed_payload_type(media_type)) != -1)
- goto out;
-
- if ((payload_type = _get_available_payload_type(webrtc)) == 0)
- return WEBRTC_ERROR_INVALID_OPERATION;
-
-out:
- source->av[av_idx].pt = payload_type;
-
- return WEBRTC_ERROR_NONE;
-}
-
static GstPadProbeReturn __payloaded_data_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
{
probe_userdata_s *probe_data = (probe_userdata_s *)user_data;
GstCaps *sink_caps;
element_info_s elem_info;
gchar *media_type = NULL;
- int payload_type;
int idx;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
goto error;
APPEND_ELEMENT(*element_list, capsfilter2);
- if ((payload_type = __get_fixed_payload_type(media_type)) == -1)
- if ((payload_type = _get_available_payload_type(webrtc)) == 0)
- goto error;
-
- source->av[idx].pt = payload_type;
+ if(_set_payload_type(webrtc, source, idx, media_type) != WEBRTC_ERROR_NONE)
+ goto error;
- if ((sink_caps = _make_rtp_caps(media_type, payload_type, source))) {
+ if ((sink_caps = _make_rtp_caps(media_type, source->av[idx].pt, source))) {
g_object_set(G_OBJECT(capsfilter2), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
}
if (!(capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, _get_element_name(GET_AV_IDX(is_audio), ELEMENT_CAPSFILTER))))
return NULL;
- if(__set_payload_type(source->webrtc, source, GET_AV_IDX(is_audio), NULL) != WEBRTC_ERROR_NONE) {
+ if(_set_payload_type(source->webrtc, source, GET_AV_IDX(is_audio), NULL) != WEBRTC_ERROR_NONE) {
SAFE_GST_OBJECT_UNREF(capsfilter);
return NULL;
}
if (source->av[av_idx].pt >= MIN_DYNAMIC_PAYLOAD_TYPE)
__return_payload_type(webrtc, source->av[av_idx].pt);
- if((ret = __set_payload_type(webrtc, source, av_idx, payload_info->gst_media_type)) != WEBRTC_ERROR_NONE)
+ if((ret = _set_payload_type(webrtc, source, av_idx, payload_info->gst_media_type)) != WEBRTC_ERROR_NONE)
return ret;
}
GstElement *payloader;
GstElement *queue;
GstElement *capsfilter;
- 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");
goto error;
APPEND_ELEMENT(*element_list, capsfilter);
- payload_type = _get_available_payload_type(webrtc);
- if (payload_type == 0)
+ if(_set_payload_type(webrtc, source, GET_AV_IDX_BY_TYPE(source->media_types), NULL) != WEBRTC_ERROR_NONE)
goto error;
- source->av[GET_AV_IDX_BY_TYPE(source->media_types)].pt = payload_type;
-
- if ((sink_caps = _make_rtp_caps(media_type, payload_type, source))) {
+ if ((sink_caps = _make_rtp_caps(media_type, source->av[GET_AV_IDX_BY_TYPE(source->media_types)].pt, source))) {
g_object_set(G_OBJECT(capsfilter), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
}
}
}
-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_TYPE_BITS) {
- if (webrtc->payload_types & bitmask) {
- bitmask <<= 1;
- continue;
- }
- webrtc->payload_types |= bitmask;
- LOG_DEBUG("found available payload type[%d]", count + 95);
- return count + 95; /* 96 ~ 127 */
- }
-
- LOG_ERROR("could not assign payload type");
- return 0;
-}
-
GstCaps *_make_rtp_caps(const gchar *media_type, unsigned int payload_type, webrtc_gst_slot_s *source)
{
GstCaps *caps;
RET_VAL_IF((element > ELEMENT_FAKESINK), NULL, "invalid element [%d]", element);
return _av_element_tbl[av_idx][element];
-}
\ No newline at end of file
+}
+
+static int __get_fixed_payload_type(const gchar *media_type)
+{
+ RET_VAL_IF(media_type == NULL, -1, "media_type is NULL");
+
+ if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_MULAW))
+ return 0;
+ if (!g_strcmp0(media_type, MEDIA_TYPE_AUDIO_ALAW))
+ return 8;
+
+ LOG_DEBUG("%s might need to use dynamic id", media_type);
+
+ return -1;
+}
+
+static 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_TYPE_BITS) {
+ if (webrtc->payload_types & bitmask) {
+ bitmask <<= 1;
+ continue;
+ }
+ webrtc->payload_types |= bitmask;
+ LOG_DEBUG("found available payload type[%d]", count + 95);
+ return count + 95; /* 96 ~ 127 */
+ }
+
+ LOG_ERROR("could not assign payload type");
+
+ return -1;
+}
+
+int _set_payload_type(webrtc_s *webrtc, webrtc_gst_slot_s *source, int av_idx, const gchar *media_type)
+{
+ int payload_type = -1;
+
+ 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 (media_type)
+ if ((payload_type = __get_fixed_payload_type(media_type)) != -1)
+ goto out;
+
+ if ((payload_type = __get_available_payload_type(webrtc)) == -1)
+ return WEBRTC_ERROR_INVALID_OPERATION;
+
+out:
+ source->av[av_idx].pt = payload_type;
+
+ return WEBRTC_ERROR_NONE;
+}