return CODEC_TYPE_NOT_SUPPORTED;
}
-static const char *__get_format_name(media_format_mimetype_e mime_type)
+static const char *__get_format_name(media_format_mimetype_e mime_type, bool zerocopy_enabled)
{
switch (mime_type) {
/* RAW formats */
case MEDIA_FORMAT_PCM_S24LE:
return "S24LE";
case MEDIA_FORMAT_I420:
- return "I420";
+ return zerocopy_enabled ? "S420" : "I420";
case MEDIA_FORMAT_NV12:
- return "NV12";
+ return zerocopy_enabled ? "SN12" : "NV12";
/* ENCODED formats */
case MEDIA_FORMAT_OPUS:
return "OPUS";
case MEDIA_FORMAT_I420:
case MEDIA_FORMAT_NV12:
LOG_INFO("[%s][RAW/%s] mime_type[0x%x]", mime_type & MEDIA_FORMAT_AUDIO ? "AUDIO" : "VIDEO",
- __get_format_name(mime_type), mime_type);
+ __get_format_name(mime_type, false), mime_type);
return true;
/* ENCODED formats */
case MEDIA_FORMAT_OPUS:
case MEDIA_FORMAT_H264_MP:
case MEDIA_FORMAT_H264_HP:
LOG_INFO("[%s][ENCODED/%s] mime_type[0x%x]", mime_type & MEDIA_FORMAT_AUDIO ? "AUDIO" : "VIDEO",
- __get_format_name(mime_type), mime_type);
+ __get_format_name(mime_type, false), mime_type);
return true;
default:
LOG_ERROR("not supported mime_type(0x%x)", mime_type);
RET_VAL_IF(media_format_get_audio_info(source->media_format, &mime_type, &channels, &samplerate, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_audio_info()");
caps = gst_caps_new_simple(MEDIA_TYPE_AUDIO_RAW,
- "format", G_TYPE_STRING, __get_format_name(mime_type),
+ "format", G_TYPE_STRING, __get_format_name(mime_type, source->zerocopy_enabled),
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, samplerate,
NULL);
RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_video_frame_rate()");
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, __get_format_name(mime_type),
+ "format", G_TYPE_STRING, __get_format_name(mime_type, source->zerocopy_enabled),
"framerate", GST_TYPE_FRACTION, framerate, 1,
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_video_frame_rate()");
caps = gst_caps_new_simple(MEDIA_TYPE_VIDEO_RAW,
- "format", G_TYPE_STRING, __get_format_name(mime_type),
+ "format", G_TYPE_STRING, __get_format_name(mime_type, source->zerocopy_enabled),
"framerate", GST_TYPE_FRACTION, framerate, 1,
"width", G_TYPE_INT, width,
"height", G_TYPE_INT, height,
RET_VAL_IF(media_format_get_audio_info(source->media_format, &mime_type, &channels, &samplerate, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_audio_info()");
- _media_type = __get_audio_media_type(__get_format_name(mime_type));
+ _media_type = __get_audio_media_type(__get_format_name(mime_type, source->zerocopy_enabled));
RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL");
caps = gst_caps_new_simple(_media_type,
RET_VAL_IF(media_format_get_video_frame_rate(source->media_format, &framerate) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_video_frame_rate()");
- _media_type = __get_video_media_type(__get_format_name(mime_type));
+ _media_type = __get_video_media_type(__get_format_name(mime_type, source->zerocopy_enabled));
RET_VAL_IF(_media_type == NULL, NULL, "media_type is NULL");
caps = gst_caps_new_simple(_media_type,
#ifdef TIZEN_FEATURE_RES_MGR
webrtc->resource.need_to_acquire[MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_ENCODER] = true;
#endif
+ source->zerocopy_enabled = true;
return encoder;
}
appsrc = __find_element_in_bin(source->bin, "appsrc");
RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
+ if ((ret = __create_rest_of_elements(webrtc, source, NULL, &encoder, &payloader, &queue, &capsfilter)) != WEBRTC_ERROR_NONE)
+ return ret;
+
if (!(sink_caps = __make_raw_caps_from_media_format(source))) {
LOG_ERROR("failed to __make_raw_caps_from_media_format()");
return WEBRTC_ERROR_INVALID_OPERATION;
g_object_set(G_OBJECT(appsrc), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
- if ((ret = __create_rest_of_elements(webrtc, source, NULL, &encoder, &payloader, &queue, &capsfilter)) != WEBRTC_ERROR_NONE)
- return ret;
-
gst_bin_add_many(GST_BIN(source->bin), encoder, payloader, queue, capsfilter, NULL);
if (!gst_element_link_many(appsrc, encoder, payloader, queue, capsfilter, NULL)) {
LOG_ERROR("failed to gst_element_link_many()");
RET_VAL_IF(media_format_get_video_info(source->media_format, &mime_type, NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE,
NULL, "failed to media_format_get_video_info()");
- _media_type = __get_video_media_type(__get_format_name(mime_type));
+ _media_type = __get_video_media_type(__get_format_name(mime_type, source->zerocopy_enabled));
RET_VAL_IF(g_strcmp0(_media_type, MEDIA_TYPE_VIDEO_H264), NULL, "not supported type(%s)", _media_type);
/* FIXME: prepare other types */
appsrc = __find_element_in_bin(source->bin, "appsrc");
RET_VAL_IF(appsrc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "appsrc is NULL");
+ if ((ret = __create_rest_of_elements_for_encoded_format(webrtc, source, &payloader, &queue, &capsfilter)) != WEBRTC_ERROR_NONE)
+ return ret;
+
if (!(sink_caps = __make_encoded_caps_for_appsrc(source))) {
LOG_ERROR("failed to __make_encoded_caps_for_appsrc()");
return WEBRTC_ERROR_INVALID_OPERATION;
g_object_set(G_OBJECT(appsrc), "caps", sink_caps, NULL);
gst_caps_unref(sink_caps);
- if ((ret = __create_rest_of_elements_for_encoded_format(webrtc, source, &payloader, &queue, &capsfilter)) != WEBRTC_ERROR_NONE)
- return ret;
-
gst_bin_add_many(GST_BIN(source->bin), payloader, queue, capsfilter, NULL);
if (!gst_element_link_many(appsrc, payloader, queue, capsfilter, NULL)) {
LOG_ERROR("failed to gst_element_link_many()");