To support dynamic resolution change for sources that do not support dynamic resolution change.
[Version] 0.3.204
[Issue Type] Improvement
Change-Id: I617951d757150168e81a1f7efb8e4e390f1f9153
* @since_tizen 6.5
* @remarks If @a source_id does not support for the dynamic resolution change, #WEBRTC_ERROR_INVALID_OPERATION will be returned\n
* while @a webrtc state is #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
+ * Since 7.0, this function supports dynamic resolution change regardless of state for all video sources mentioned in details.\n
+ * However, some sources cannot be changed to a greater value than the resolution set in the #WEBRTC_STATE_IDLE.
* @param[in] webrtc WebRTC handle
* @param[in] source_id The video source id
* @param[in] width The video width
} render;
} av[AV_IDX_MAX];
struct {
+ int origin_width;
+ int origin_height;
int width;
int height;
int framerate;
#define DEFAULT_ELEMENT_VOLUME "volume"
#define DEFAULT_ELEMENT_INPUT_SELECTOR "input-selector"
#define DEFAULT_ELEMENT_VIDEOCROP "videocrop"
+#define DEFAULT_ELEMENT_VIDEOSCALE "videoscale"
#define DEFAULT_ELEMENT_FILESRC "filesrc"
#define ELEMENT_NAME_FIRST_CAPSFILTER "firstCapsfilter"
#define ELEMENT_NAME_VIDEO_FAKESINK "videoFakeSink"
#define ELEMENT_NAME_AUDIO_APPSRC "audioAppsrc"
#define ELEMENT_NAME_VIDEO_APPSRC "videoAppsrc"
+#define ELEMENT_NAME_VIDEOSCALE_CAPSFILTER "videoscaleCapsfilter"
typedef enum {
ELEMENT_APPSRC,
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.3.203
+Version: 0.3.204
Release: 0
Group: Multimedia/API
License: Apache-2.0
RET_VAL_IF(ini_source == NULL, false, "ini_source is NULL");
source->video_info.framerate = ini_source->v_framerate;
+ source->video_info.origin_width = ini_source->v_width;
+ source->video_info.origin_height = ini_source->v_height;
source->video_info.width = ini_source->v_width;
source->video_info.height = ini_source->v_height;
return true;
}
}
+
+ source->video_info.origin_width = width;
+ source->video_info.origin_height = height;
source->video_info.width = width;
source->video_info.height = height;
#else
{
webrtc_gst_slot_s *source;
GstElement *capsfilter;
- GstCaps *new_caps = NULL;
+ bool drc_support = false;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc 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");
const ini_item_media_source_s *ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
if (ini_source == NULL)
ini_source = &webrtc->ini.media_source;
- RET_VAL_IF(!ini_source->v_drc_support, WEBRTC_ERROR_INVALID_OPERATION, "not supported dynamic resolution change");
+
+ if (ini_source->v_drc_support)
+ drc_support = true;
}
- if ((capsfilter = _find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER))) {
- /* FIXME: check if the [width x height] is supported or not */
+ if (webrtc->state == WEBRTC_STATE_IDLE || drc_support) {
+ capsfilter = _find_element_in_bin(source->bin, ELEMENT_NAME_FIRST_CAPSFILTER);
+
+ source->video_info.origin_width = width;
+ source->video_info.origin_height = height;
+ } else {
+
+ RET_VAL_IF(width > source->video_info.origin_width, WEBRTC_ERROR_INVALID_OPERATION,
+ "it doesn't support upscale. invalid width. origin [%d] requested [%d]", source->video_info.origin_width, width);
+ RET_VAL_IF(height > source->video_info.origin_height, WEBRTC_ERROR_INVALID_OPERATION,
+ "it doesn't support upscale. invalid height. origin [%d] requested [%d]", source->video_info.origin_height, height);
+
+ capsfilter = _find_element_in_bin(source->bin, ELEMENT_NAME_VIDEOSCALE_CAPSFILTER);
+ RET_VAL_IF(!capsfilter, WEBRTC_ERROR_INVALID_OPERATION, "not supported dynamic resolution change");
+ }
+
+ if (capsfilter) {
+ GstCaps *new_caps;
+
if (!(new_caps = __make_video_raw_caps_with_resolution(source, &webrtc->ini, width, height)))
return WEBRTC_ERROR_INVALID_OPERATION;
PRINT_CAPS(new_caps, "capsfilter");
g_object_set(G_OBJECT(capsfilter), "caps", new_caps, NULL);
gst_caps_unref(new_caps);
-
}
source->video_info.width = width;
return encoder;
}
+static bool __is_videoscale_needed(webrtc_s *webrtc, webrtc_gst_slot_s *source)
+{
+ const ini_item_media_source_s *ini_source;
+
+ RET_VAL_IF(webrtc == NULL, false, "webrtc is NULL");
+ RET_VAL_IF(source == NULL, false, "source is NULL");
+
+ if (!(source->media_types & MEDIA_TYPE_VIDEO))
+ return false;
+
+ if (_is_encoded_format_supported(source->type, &webrtc->ini))
+ return false;
+
+ ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
+ if (ini_source == NULL)
+ ini_source = &webrtc->ini.media_source;
+
+ if (ini_source->v_drc_support)
+ return false;
+
+ if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE || source->type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET)
+ return false;
+
+ return true;
+}
+
int _create_rest_of_elements(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool need_capsfilter, GList **element_list, bool is_audio)
{
GstElement *encoder = NULL;
_add_probe_to_pad_for_render(source, idx, gst_element_get_static_pad(capsfilter, "src"), _source_data_probe_cb);
}
+ if (__is_videoscale_needed(webrtc, source)) {
+ GstElement *videoscale;
+ GstElement *videoscaleCapsfilter;
+ GstCaps *caps;
+
+ if (!(videoscale = _create_element(DEFAULT_ELEMENT_VIDEOSCALE, NULL)))
+ goto error;
+ APPEND_ELEMENT(*element_list, videoscale);
+
+ if (!(videoscaleCapsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, ELEMENT_NAME_VIDEOSCALE_CAPSFILTER)))
+ goto error;
+ APPEND_ELEMENT(*element_list, videoscaleCapsfilter);
+
+ if ((caps = __make_default_raw_caps(source, &webrtc->ini))) {
+ PRINT_CAPS(caps, ELEMENT_NAME_VIDEOSCALE_CAPSFILTER);
+ g_object_set(G_OBJECT(videoscaleCapsfilter), "caps", caps, NULL);
+ }
+ }
+
if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_SCREEN && !source->zerocopy_enabled) {
if (!(videocrop = _create_element(DEFAULT_ELEMENT_VIDEOCROP, ELEMENT_NAME_VIDEOCROP)))
goto error;