int _get_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e *direction)
{
- int ret = WEBRTC_ERROR_NONE;
+ int ret = WEBRTC_ERROR_INVALID_OPERATION;
webrtc_gst_slot_s *source;
GstWebRTCRTPTransceiver *trans;
GArray *transceivers;
trans = g_array_index(transceivers, GstWebRTCRTPTransceiver *, i);
if (trans->mline == mline) {
ret = __convert_direction(trans->direction, direction);
- if (ret != WEBRTC_ERROR_NONE)
- return ret;
- LOG_DEBUG("found transceiver[%p, index:%d, mline:%u, mid:%s, direction:%s]",
- trans, i, trans->mline, trans->mid, __direction_str[*direction]);
- return WEBRTC_ERROR_NONE;
+ if (ret == WEBRTC_ERROR_NONE)
+ LOG_DEBUG("found transceiver[%p, index:%d, mline:%u, mid:%s, direction:%s]",
+ trans, i, trans->mline, trans->mid, __direction_str[*direction]);
+ goto end;
}
}
LOG_ERROR("could not find a transceiver with mline[%d]", mline);
- return WEBRTC_ERROR_INVALID_OPERATION;
+end:
+ g_array_unref(transceivers);
+
+ return ret;
}
int _set_transceiver_direction(webrtc_s *webrtc, unsigned int source_id, webrtc_media_type_e media_type, webrtc_transceiver_direction_e direction)
{
+ int ret = WEBRTC_ERROR_INVALID_OPERATION;
webrtc_gst_slot_s *source;
GstWebRTCRTPTransceiver *trans;
GArray *transceivers;
trans->direction = __direction_gst[direction];
LOG_DEBUG("Set direction to transceiver[%p, index:%d, mline:%u, direction:%s]",
trans, i, trans->mline, __direction_str[direction]);
- return WEBRTC_ERROR_NONE;
+ ret = WEBRTC_ERROR_NONE;
+ goto end;
}
}
LOG_ERROR("could not find a transceiver with mline[%d]", mline);
- return WEBRTC_ERROR_INVALID_OPERATION;
+end:
+ g_array_unref(transceivers);
+
+ return ret;
}
void _webrtcbin_on_negotiation_needed(GstElement *webrtcbin, gpointer user_data)