#ifndef TIZEN_TV
webrtc_resource_s resource;
#endif
+#ifdef TIZEN_FEATURE_UI
+ void *rotate_sensor_listener;
+ int screen_rotated;
+#endif
} webrtc_s;
/* FIXME: divide into two slot types or use union */
/* screen source */
int _get_screen_resolution(int *width, int *height);
-int _set_screen_rotation_changed_cb(webrtc_gst_slot_s *source);
+int _set_screen_rotation_changed_cb(webrtc_s *webrtc);
+void _unset_screen_rotation_changed_cb(webrtc_s *webrtc);
int _set_screen_source_crop(webrtc_s *webrtc, unsigned int source_id, int x, int y, int w, int h, int *width, int *height);
int _unset_screen_source_crop(webrtc_s *webrtc, unsigned int source_id);
bool _is_screen_source_cropped(webrtc_gst_slot_s *source);
videocrop = gst_bin_get_by_name(source->bin, ELEMENT_NAME_VIDEOCROP);
RET_VAL_IF(videocrop == NULL, WEBRTC_ERROR_INVALID_OPERATION, "videocrop is NULL");
- if (source->video_info.origin_width > source->video_info.origin_height)
+ if ((webrtc->screen_rotated) && (source->video_info.origin_width < source->video_info.origin_height))
+ portrait_mode = false;
+ else if ((!webrtc->screen_rotated) && (source->video_info.origin_width > source->video_info.origin_height))
portrait_mode = false;
LOG_INFO("set source crop x:%d, y:%d, width:%d, height:%d, mode:%s", x, y, w, h, (portrait_mode) ? "portrait" : "landscape");
static void __screen_rotation_changed_cb(sensor_h sensor, sensor_event_s events[], int events_count, void *user_data)
{
- webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)user_data;
- int width;
- int height;
+ webrtc_s *webrtc = (webrtc_s *)user_data;
int type;
int event;
int angle;
- RET_IF(source == NULL, "source is NULL");
- RET_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_SCREEN, "invalid source type [%d]", source->type);
+ RET_IF(webrtc == NULL, "webrtc is NULL");
sensor_get_type(sensor, &type);
if (type != AUTO_ROTATION_SENSOR)
LOG_DEBUG("screen rotation changed [%d]", angle);
- if (_get_screen_resolution(&width, &height) != WEBRTC_ERROR_NONE)
- return;
+ g_mutex_lock(&webrtc->mutex);
+ if (angle == 0 || angle == 180)
+ webrtc->screen_rotated = false;
+ else
+ webrtc->screen_rotated = true;
- g_mutex_lock(&source->webrtc->mutex);
- if (angle == 0 || angle == 180) {
- source->video_info.origin_width = width;
- source->video_info.origin_height = height;
- } else {
- source->video_info.origin_width = height;
- source->video_info.origin_height = width;
- }
- g_mutex_unlock(&source->webrtc->mutex);
+ g_mutex_unlock(&webrtc->mutex);
}
-int _set_screen_rotation_changed_cb(webrtc_gst_slot_s *source)
+int _set_screen_rotation_changed_cb(webrtc_s *webrtc)
{
bool supported;
sensor_h *sh;
int count;
sensor_listener_h lh;
- RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
+ RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
sensor_is_supported(AUTO_ROTATION_SENSOR, &supported);
sensor_create_listener(sh[0], &lh);
- sensor_listener_set_events_cb(lh, __screen_rotation_changed_cb, source);
+ sensor_listener_set_events_cb(lh, __screen_rotation_changed_cb, webrtc);
sensor_listener_set_option(lh, SENSOR_OPTION_ALWAYS_ON);
sensor_listener_set_interval(lh, 100);
if (sensor_listener_start(lh) != SENSOR_ERROR_NONE) {
LOG_ERROR("failed to sensor_listener_start()");
+ sensor_destroy_listener(lh);
return WEBRTC_ERROR_INVALID_OPERATION;
}
+ webrtc->rotate_sensor_listener = (void *)lh;
+
LOG_INFO("AUTO_ROTATION_SENSOR is supported");
return WEBRTC_ERROR_NONE;
}
+void _unset_screen_rotation_changed_cb(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+ RET_IF(webrtc->rotate_sensor_listener == NULL, "rotate_sensor_listener is NULL");
+
+ sensor_destroy_listener((sensor_listener_h)webrtc->rotate_sensor_listener);
+
+ LOG_INFO("AUTO_ROTATION_SENSOR is destroyed");
+}
+
bool _is_screen_source_cropped(webrtc_gst_slot_s *source)
{
GstElement *videocrop;