const char *_get_source_element(webrtc_s *webrtc, int type);
GstElement *_find_element_in_bin(GstBin *bin, const gchar *name);
bool _is_hw_encoder_used(webrtc_s *webrtc, webrtc_media_source_type_e source_type, media_type_e media_type);
-const char *_get_audio_media_type(const char *codec_name);
-const char *_get_video_media_type(const char *codec_name);
GstAudioFormat _get_gst_audio_raw_format_from_string(const char *format);
bool _is_supported_mime_type(media_format_mimetype_e mime_type);
bool _is_encoded_format_supported(webrtc_media_source_type_e type, webrtc_ini_s *ini);
webrtc_s *_webrtc = (webrtc_s *)webrtc;
webrtc_gst_slot_s *source;
g_autoptr(GMutexLocker) locker = NULL;
+ const char *_media_type;
+ int _pt;
RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
RET_VAL_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL,
WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
- locker = g_mutex_locker_new(&_webrtc->mutex);
+ if (media_type == WEBRTC_MEDIA_TYPE_AUDIO)
+ _media_type = _get_audio_media_type(source->av[AV_IDX_AUDIO].codec);
+ else
+ _media_type = _get_video_media_type(source->av[AV_IDX_VIDEO].codec);
+ RET_VAL_IF(_media_type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "_media_type is NULL");
RET_VAL_IF(_webrtc->state != WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should be IDLE");
+ _pt = _get_fixed_payload_type(_media_type);
+ if (_pt != -1 && (unsigned int)_pt != pt) {
+ LOG_ERROR("this media_type[%s] only allows fixed payload type[%d]", _media_type, _pt);
+ return WEBRTC_ERROR_INVALID_PARAMETER;
+ } else if (pt < 96 || pt > 127) {
+ LOG_ERROR("invalid value[%u] for dynamic payload type (96 ~ 127)", pt);
+ return WEBRTC_ERROR_INVALID_PARAMETER;
+ }
+
source->av[GET_AV_IDX(media_type == WEBRTC_MEDIA_TYPE_AUDIO)].pt = pt;
source->av[GET_AV_IDX(media_type == WEBRTC_MEDIA_TYPE_AUDIO)].pt_set_by_api = true;
RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
RET_VAL_IF(pt == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "pt is NULL");
- RET_VAL_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL,
- WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
locker = g_mutex_locker_new(&_webrtc->mutex);
+ RET_VAL_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL,
+ WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
+
*pt = source->av[GET_AV_IDX(media_type == WEBRTC_MEDIA_TYPE_AUDIO)].pt;
LOG_INFO("webrtc[%p] source_id[%u] media_type[%u] payload type[%u]", _webrtc, source_id, media_type, *pt);
return _av_element_tbl[av_idx][element];
}
-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;
}
if (media_type)
- if ((payload_type = __get_fixed_payload_type(media_type)) != -1)
+ if ((payload_type = _get_fixed_payload_type(media_type)) != -1)
goto out;
if ((payload_type = __get_available_payload_type(webrtc)) == -1)