Plus, remove some mediapacket internal APIs from webrtc_private.h and add static keyword.
[Version] 0.3.176
[Issue Type] Refactoring
Change-Id: I81f958dbc33a600075295ee558ce5a377a9d7045
/* media packet source */
int _build_mediapacketsrc(webrtc_s *webrtc, webrtc_gst_slot_s *source);
-int _complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list);
-int _complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source);
GstCaps *_make_mediapacketsrc_raw_caps_from_media_format(webrtc_gst_slot_s *source);
int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h packet);
-int _set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_type);
+int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format);
/* screen source */
int _get_screen_resolution(int *width, int *height);
int _set_video_loopback(webrtc_s *webrtc, unsigned int source_id, unsigned int type, void *display, unsigned int *track_id);
int _unset_video_loopback(webrtc_s *webrtc, unsigned int source_id);
int _set_sound_stream_info(webrtc_s *webrtc, unsigned int source_id, sound_stream_info_h stream_info);
-int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format);
int _set_media_path(webrtc_s *webrtc, unsigned int source_id, const char *path);
/* sink */
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.175
+Version: 0.3.176
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _apply_stream_info(element, stream_type, stream_index, aec_ref_device_id);
}
-static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gst_slot_s *source)
-{
- int ret;
- GstPad **src_pad;
- GstElement *appsrc;
- GList *element_list = NULL;
- GstCaps *sink_caps;
-
- RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
- RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-
- src_pad = &source->av[GET_AV_IDX_BY_TYPE(source->media_types)].src_pad;
- ret = _add_no_target_ghostpad_to_slot(source, true, src_pad);
- RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()");
-
- appsrc = _find_element_in_bin(source->bin, "appsrc");
- RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
-
- source->zerocopy_enabled = _is_hw_encoder_used(webrtc, source->type, source->media_types);
-
- if ((ret = _create_rest_of_elements(webrtc, source, false, &element_list, (source->media_types == MEDIA_TYPE_AUDIO))) != WEBRTC_ERROR_NONE)
- goto exit;
-
- if (!(sink_caps = _make_mediapacketsrc_raw_caps_from_media_format(source))) {
- ret = WEBRTC_ERROR_INVALID_OPERATION;
- goto exit;
- }
- PRINT_CAPS(sink_caps, "appsrc");
- g_object_set(G_OBJECT(appsrc), "caps", sink_caps, NULL);
- gst_caps_unref(sink_caps);
-
- if ((ret = _complete_rest_of_mediapacketsrc(source, src_pad, appsrc, element_list)) != WEBRTC_ERROR_NONE)
- goto exit;
-
- SAFE_G_LIST_FREE(element_list);
-
- return WEBRTC_ERROR_NONE;
-
-exit:
- SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
- return ret;
-}
-
-int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format)
-{
- int ret;
- webrtc_gst_slot_s *source;
- media_format_type_e format_type;
- media_format_mimetype_e mime_type;
-
- RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
- RET_VAL_IF(format == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "format 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");
- RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, "invalid media source type(%d)", source->type);
- RET_VAL_IF(source->media_format != NULL, WEBRTC_ERROR_INVALID_OPERATION, "format is already set to this media packet source");
-
- RET_VAL_IF(media_format_get_type(format, &format_type) != MEDIA_FORMAT_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION,
- "failed to media_format_get_type()");
-
- if (format_type == MEDIA_FORMAT_AUDIO) {
- source->media_types = MEDIA_TYPE_AUDIO;
- RET_VAL_IF(media_format_get_audio_info(format, &mime_type, NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
- WEBRTC_ERROR_INVALID_OPERATION, "failed to media_format_get_audio_info()");
-
- } else if (format_type == MEDIA_FORMAT_VIDEO) {
- source->media_types = MEDIA_TYPE_VIDEO;
- RET_VAL_IF(media_format_get_video_info(format, &mime_type, NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
- WEBRTC_ERROR_INVALID_OPERATION, "failed to media_format_get_video_info()");
-
- } else {
- LOG_ERROR("invalid media format type[0x%x]", format_type);
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
-
- RET_VAL_IF(!_is_supported_mime_type(mime_type), WEBRTC_ERROR_INVALID_PARAMETER, "mime_type[0x%x] is not supported", mime_type);
-
- media_format_ref(format);
- source->media_format = format;
- if((ret = _set_mediapacketsrc_codec_info(webrtc, source, mime_type)) != WEBRTC_ERROR_NONE)
- goto error;
-
- if ((mime_type & MEDIA_FORMAT_RAW) &&
- !(mime_type == MEDIA_FORMAT_PCMU || mime_type == MEDIA_FORMAT_PCMA)) /* FIXME: media_format.h defined PCMU/PCMA as a raw format, it's a bug. */
- ret = __complete_mediapacketsrc_from_raw_format(webrtc, source);
- else
- ret = _complete_mediapacketsrc_from_encoded_format(webrtc, source);
- if (ret != WEBRTC_ERROR_NONE) {
- LOG_ERROR("failed to complete mediapacketsrc");
- goto error;
- }
-
- ret = _link_source_with_webrtcbin(source, webrtc->gst.webrtcbin);
- if (ret != WEBRTC_ERROR_NONE)
- goto error;
-
- LOG_INFO("webrtc[%p] source_id[%u] format[%p]", webrtc, source_id, format);
-
- return WEBRTC_ERROR_NONE;
-
-error:
- media_format_unref(format);
- source->media_format = NULL;
- return ret;
-}
-
static gboolean __check_format_is_not_set_cb(gpointer key, gpointer value, gpointer user_data)
{
const webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)value;
return WEBRTC_ERROR_NONE;
}
-int _complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list)
+static int __complete_rest_of_mediapacketsrc(webrtc_gst_slot_s *source, GstPad **src_pad, GstElement *appsrc, GList *element_list)
{
int ret;
GstElement *capsfilter;
}
//LCOV_EXCL_START
-int _complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source)
+static int __complete_mediapacketsrc_from_encoded_format(webrtc_s *webrtc, webrtc_gst_slot_s *source)
{
int ret;
GstPad **src_pad;
g_object_set(G_OBJECT(appsrc), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
- if ((ret = _complete_rest_of_mediapacketsrc(source, src_pad, appsrc, element_list)) != WEBRTC_ERROR_NONE)
+ if ((ret = __complete_rest_of_mediapacketsrc(source, src_pad, appsrc, element_list)) != WEBRTC_ERROR_NONE)
goto exit;
SAFE_G_LIST_FREE(element_list);
}
//LCOV_EXCL_STOP
-int _set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_type)
+static int __set_mediapacketsrc_codec_info(webrtc_s *webrtc, webrtc_gst_slot_s *source, media_format_mimetype_e mime_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");
return WEBRTC_ERROR_NONE;
}
+
+static int __complete_mediapacketsrc_from_raw_format(webrtc_s *webrtc, webrtc_gst_slot_s *source)
+{
+ int ret;
+ GstPad **src_pad;
+ GstElement *appsrc;
+ GList *element_list = NULL;
+ GstCaps *sink_caps;
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+ RET_VAL_IF(source->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+
+ src_pad = &source->av[GET_AV_IDX_BY_TYPE(source->media_types)].src_pad;
+ ret = _add_no_target_ghostpad_to_slot(source, true, src_pad);
+ RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _add_no_target_ghostpad_to_slot()");
+
+ appsrc = _find_element_in_bin(source->bin, "appsrc");
+ RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
+
+ source->zerocopy_enabled = _is_hw_encoder_used(webrtc, source->type, source->media_types);
+
+ if ((ret = _create_rest_of_elements(webrtc, source, false, &element_list, (source->media_types == MEDIA_TYPE_AUDIO))) != WEBRTC_ERROR_NONE)
+ goto exit;
+
+ if (!(sink_caps = _make_mediapacketsrc_raw_caps_from_media_format(source))) {
+ ret = WEBRTC_ERROR_INVALID_OPERATION;
+ goto exit;
+ }
+ PRINT_CAPS(sink_caps, "appsrc");
+ g_object_set(G_OBJECT(appsrc), "caps", sink_caps, NULL);
+ gst_caps_unref(sink_caps);
+
+ if ((ret = __complete_rest_of_mediapacketsrc(source, src_pad, appsrc, element_list)) != WEBRTC_ERROR_NONE)
+ goto exit;
+
+ SAFE_G_LIST_FREE(element_list);
+
+ return WEBRTC_ERROR_NONE;
+
+exit:
+ SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
+ return ret;
+}
+
+int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h format)
+{
+ int ret;
+ webrtc_gst_slot_s *source;
+ media_format_type_e format_type;
+ media_format_mimetype_e mime_type;
+
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(format == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "format 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");
+ RET_VAL_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, "invalid media source type(%d)", source->type);
+ RET_VAL_IF(source->media_format != NULL, WEBRTC_ERROR_INVALID_OPERATION, "format is already set to this media packet source");
+
+ RET_VAL_IF(media_format_get_type(format, &format_type) != MEDIA_FORMAT_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION,
+ "failed to media_format_get_type()");
+
+ if (format_type == MEDIA_FORMAT_AUDIO) {
+ source->media_types = MEDIA_TYPE_AUDIO;
+ RET_VAL_IF(media_format_get_audio_info(format, &mime_type, NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
+ WEBRTC_ERROR_INVALID_OPERATION, "failed to media_format_get_audio_info()");
+
+ } else if (format_type == MEDIA_FORMAT_VIDEO) {
+ source->media_types = MEDIA_TYPE_VIDEO;
+ RET_VAL_IF(media_format_get_video_info(format, &mime_type, NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
+ WEBRTC_ERROR_INVALID_OPERATION, "failed to media_format_get_video_info()");
+
+ } else {
+ LOG_ERROR("invalid media format type[0x%x]", format_type);
+ return WEBRTC_ERROR_INVALID_OPERATION;
+ }
+
+ RET_VAL_IF(!_is_supported_mime_type(mime_type), WEBRTC_ERROR_INVALID_PARAMETER, "mime_type[0x%x] is not supported", mime_type);
+
+ media_format_ref(format);
+ source->media_format = format;
+ if((ret = __set_mediapacketsrc_codec_info(webrtc, source, mime_type)) != WEBRTC_ERROR_NONE)
+ goto error;
+
+ if ((mime_type & MEDIA_FORMAT_RAW) &&
+ !(mime_type == MEDIA_FORMAT_PCMU || mime_type == MEDIA_FORMAT_PCMA)) /* FIXME: media_format.h defined PCMU/PCMA as a raw format, it's a bug. */
+ ret = __complete_mediapacketsrc_from_raw_format(webrtc, source);
+ else
+ ret = __complete_mediapacketsrc_from_encoded_format(webrtc, source);
+ if (ret != WEBRTC_ERROR_NONE) {
+ LOG_ERROR("failed to complete mediapacketsrc");
+ goto error;
+ }
+
+ ret = _link_source_with_webrtcbin(source, webrtc->gst.webrtcbin);
+ if (ret != WEBRTC_ERROR_NONE)
+ goto error;
+
+ LOG_INFO("webrtc[%p] source_id[%u] format[%p]", webrtc, source_id, format);
+
+ return WEBRTC_ERROR_NONE;
+
+error:
+ media_format_unref(format);
+ source->media_format = NULL;
+ return ret;
+}