#define ELEMENT_NAME_AUDIO_APPSRC "audioAppsrc"
#define ELEMENT_NAME_VIDEO_APPSRC "videoAppsrc"
+#define MIN_DYNAMIC_PAYLOAD_TYPE 96
+#define MAX_DYNAMIC_PAYLOAD_TYPE 127
+
#define APPEND_ELEMENT(x_list, x_element) \
do { \
if (!(x_element)) \
}
webrtc->payload_types |= bitmask;
LOG_DEBUG("found available payload type[%d]", count + 95);
- return count + 95; /* 96 ~ 127 */
+ return count + (MIN_DYNAMIC_PAYLOAD_TYPE - 1); /* 96 ~ 127 */
}
LOG_ERROR("could not assign payload type");
int bitmask = 0x1;
RET_IF(webrtc == NULL, "webrtc is NULL");
- RET_IF(payload_type < 96 || payload_type > 127, "invalid payload_type(%u)", payload_type);
+ RET_IF(payload_type < MIN_DYNAMIC_PAYLOAD_TYPE || payload_type > MAX_DYNAMIC_PAYLOAD_TYPE, "invalid payload_type(%u)", payload_type);
+
+ i = payload_type - MIN_DYNAMIC_PAYLOAD_TYPE;
- i = payload_type - 96;
while (i-- > 0)
bitmask <<= 1;
return WEBRTC_ERROR_INVALID_OPERATION;
}
+static int __add_transceiver(webrtc_gst_slot_s *source, webrtc_media_type_e media_type, rtp_payload_info_s *payload_info)
+{
+ GstWebRTCRTPTransceiver *trans = NULL;
+ GstCaps *caps = NULL;
+ int av_idx = (media_type == WEBRTC_MEDIA_TYPE_AUDIO) ? AV_IDX_AUDIO : AV_IDX_VIDEO;
+
+ RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+ RET_VAL_IF(payload_info == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "payload_info is NULL");
+
+ caps = __make_transceiver_caps(payload_info, source->av[av_idx].pt);
+ PRINT_CAPS(caps, "transceiver");
+
+ if (!source->av[av_idx].transceiver) {
+ g_signal_emit_by_name(source->webrtc->gst.webrtcbin, "add-transceiver",
+ GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY, caps, &trans, NULL);
+ gst_object_unref(trans);
+ } else {
+ g_object_set(G_OBJECT(source->av[av_idx].transceiver), "codec-preferences", caps, NULL);
+ }
+
+ gst_caps_unref(caps);
+
+ LOG_DEBUG("webrtc[%p] source_id[%u] [%s] transceiver[%p] codec[%s]",
+ source->webrtc, source->id, payload_info->media_type, source->av[av_idx].transceiver, payload_info->encoding_name);
+
+ return WEBRTC_ERROR_NONE;
+}
+
int _complete_sources(webrtc_s *webrtc)
{
int i;
RET_VAL_IF(slots == NULL, 0, "slot is NULL");
- /* Payload identifiers 96–127 are used for payloads defined dynamically during a session,
+ /* Payload identifiers 96 ~ 127 are used for payloads defined dynamically during a session,
* hence the id range is limited here to 1-32. */
for (i = 1; i < MAX_SOURCE_NUM + 1; i++) {
key = g_strdup_printf("media_source_%u", i);
source->av[av_idx].codec = payload_info->encoding_name;
if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL) {
- GstWebRTCRTPTransceiver *trans = NULL;
- GstCaps *caps;
int payload_type;
+ if (source->av[av_idx].pt >= MIN_DYNAMIC_PAYLOAD_TYPE)
+ __return_payload_type(webrtc, source->av[av_idx].pt);
+
if ((payload_type = __get_fixed_payload_type(payload_info->gst_media_type)) == -1)
if ((payload_type = __get_available_payload_type(webrtc)) == 0)
return WEBRTC_ERROR_NONE;
- source->av[av_idx].pt = payload_type;
-
- caps = __make_transceiver_caps(payload_info, payload_type);
- PRINT_CAPS(caps, "transceiver");
- if (!source->av[av_idx].transceiver) {
- g_signal_emit_by_name(webrtc->gst.webrtcbin, "add-transceiver",
- GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY, caps, &trans, NULL);
- gst_object_unref(trans);
- } else {
- g_object_set(G_OBJECT(source->av[av_idx].transceiver), "codec-preferences", caps, NULL);
- }
- LOG_DEBUG("webrtc[%p] source_id[%u] [%s] transceiver[%p] codec[%s]",
- webrtc, source_id, payload_info->media_type, source->av[av_idx].transceiver, payload_info->encoding_name);
+ source->av[av_idx].pt = payload_type;
- gst_caps_unref(caps);
+ ret = __add_transceiver(source, media_type, payload_info);
+ RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to __add_transceiver");
}
/* FIXME: to utilize 'codec-preferences' of trans object, we need to re-create and re-link elements again */