return WEBRTC_ERROR_INVALID_OPERATION;
}
-static void __complete_source_foreach_cb(gpointer key, gpointer value, gpointer user_data)
-{
- webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)value;
- webrtc_s *webrtc = (webrtc_s *)user_data;
-
- if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE ||
- source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET ||
- source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)
- return;
-
- LOG_DEBUG("source[%s, id:%u, type:%d]", (gchar *)key, source->id, source->type);
-
- if (source->media_types == MEDIA_TYPE_AUDIO)
- __complete_rest_of_audiosrc(webrtc, source);
- else
- __complete_rest_of_videosrc(webrtc, source);
-}
-
int _complete_sources(webrtc_s *webrtc)
{
+ int i;
+ webrtc_gst_slot_s *source;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
- g_hash_table_foreach(webrtc->gst.source_slots, __complete_source_foreach_cb, webrtc);
+ for (i = 0; i < MAX_SOURCE_NUM; i++) {
+ if (!(source = webrtc->gst.sources[i]))
+ continue;
+ if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE ||
+ source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET ||
+ source->type == WEBRTC_MEDIA_SOURCE_TYPE_NULL)
+ continue;
+
+ LOG_DEBUG("source[id:%u, type:%d, media_types:0x%x]", source->id, source->type, source->media_types);
+
+ if (source->media_types == MEDIA_TYPE_AUDIO)
+ __complete_rest_of_audiosrc(webrtc, source);
+ else
+ __complete_rest_of_videosrc(webrtc, source);
+ }
return WEBRTC_ERROR_NONE;
}
/* 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 < 33; i++) {
+ for (i = 1; i < MAX_SOURCE_NUM + 1; i++) {
key = g_strdup_printf("media_source_%u", i);
if (g_hash_table_contains(slots, key)) {
g_free(key);
source->bin ? GST_ELEMENT_NAME(source->bin) : "null", source->id, source->media_types,
source->av[AV_IDX_AUDIO].transceiver, source->av[AV_IDX_VIDEO].transceiver);
+ for (i = 0; i < MAX_SOURCE_NUM; i++) {
+ if (source->webrtc->gst.sources[i] == source)
+ source->webrtc->gst.sources[i] = NULL;
+ }
+
if (source->bin)
gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source);
}
*source_id = source->id;
+ webrtc->gst.sources[*source_id - 1] = source;
LOG_INFO("webrtc[%p] source[%p, name:%s, id:%u]", webrtc, source, bin_name, *source_id);