float rw, rh;
int left, right, top, bottom;
#if !defined(TIZEN_TV) && defined(TIZEN_FEATURE_UI)
- bool rotated = webrtc->screen_rotated;
+ bool rotated = webrtc->rotate_info.rotated;
#else
bool rotated = false;
#endif
g_mutex_lock(&webrtc->mutex);
if (angle == 0 || angle == 180)
- webrtc->screen_rotated = false;
+ webrtc->rotate_info.rotated = false;
else
- webrtc->screen_rotated = true;
+ webrtc->rotate_info.rotated = true;
g_mutex_unlock(&webrtc->mutex);
}
int _set_screen_rotation_changed_cb(webrtc_s *webrtc)
{
bool supported;
- sensor_h *sh;
+ sensor_h *sh = NULL;
int count;
- sensor_listener_h lh;
+ sensor_listener_h lh = NULL;
+ int ret;
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+ RET_VAL_IF(webrtc->rotate_info.sensor != NULL, WEBRTC_ERROR_INVALID_OPERATION, "sensor is already set");
+ RET_VAL_IF(webrtc->rotate_info.sensor_listener != NULL, WEBRTC_ERROR_INVALID_OPERATION, "sensor_listener is already set");
- sensor_is_supported(AUTO_ROTATION_SENSOR, &supported);
-
+ ret = sensor_is_supported(AUTO_ROTATION_SENSOR, &supported);
+ RET_VAL_IF(ret != SENSOR_ERROR_NONE, WEBRTC_ERROR_INVALID_OPERATION, "failed to sensor_is_supported()");
if (!supported) {
LOG_INFO("AUTO_ROTATION_SENSOR is not supported");
return WEBRTC_ERROR_NONE;
}
- sensor_get_sensor_list(AUTO_ROTATION_SENSOR, &sh, &count);
+ ret = sensor_get_sensor_list(AUTO_ROTATION_SENSOR, &sh, &count);
+ if (ret != SENSOR_ERROR_NONE) {
+ LOG_ERROR("failed to sensor_get_sensor_list()");
+ goto error;
+ }
- sensor_create_listener(sh[0], &lh);
+ ret = sensor_create_listener(sh[0], &lh);
+ if (ret != SENSOR_ERROR_NONE) {
+ LOG_ERROR("failed to sensor_create_listener()");
+ goto error;
+ }
- 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);
+ ret = sensor_listener_set_events_cb(lh, __screen_rotation_changed_cb, webrtc);
+ ret |= sensor_listener_set_option(lh, SENSOR_OPTION_ALWAYS_ON);
+ ret |= sensor_listener_set_interval(lh, 100);
+ if (ret != SENSOR_ERROR_NONE) {
+ LOG_ERROR("failed to sensor listener setting");
+ goto error;
+ }
if (sensor_listener_start(lh) != SENSOR_ERROR_NONE) {
LOG_ERROR("failed to sensor_listener_start()");
- sensor_destroy_listener(lh);
- return WEBRTC_ERROR_INVALID_OPERATION;
+ goto error;
}
- webrtc->rotate_sensor_listener = (void *)lh;
+ webrtc->rotate_info.sensor = (void *)sh;
+ webrtc->rotate_info.sensor_listener = (void *)lh;
LOG_INFO("AUTO_ROTATION_SENSOR is supported");
return WEBRTC_ERROR_NONE;
+
+error:
+ if (lh)
+ sensor_destroy_listener(lh);
+ if (sh)
+ free(sh);
+ return WEBRTC_ERROR_INVALID_OPERATION;
}
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");
+ RET_IF(webrtc->rotate_info.sensor == NULL, "rotate_info.sensor is NULL");
+ RET_IF(webrtc->rotate_info.sensor_listener == NULL, "rotate_info.sensor_listener is NULL");
+
+ sensor_destroy_listener((sensor_listener_h)webrtc->rotate_info.sensor_listener);
+ free(webrtc->rotate_info.sensor);
- sensor_destroy_listener((sensor_listener_h)webrtc->rotate_sensor_listener);
+ webrtc->rotate_info.sensor_listener = NULL;
+ webrtc->rotate_info.sensor = NULL;
LOG_INFO("AUTO_ROTATION_SENSOR is destroyed");
}