{
int ret = MEDIAEDITOR_ERROR_NONE;
mediaeditor_s *_editor = NULL;
- g_autoptr(GMutexLocker) locker = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
_editor = g_new0(mediaeditor_s, 1);
g_mutex_init(&_editor->mutex);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
g_mutex_init(&_editor->event_src_mutex);
g_cond_init(&_editor->cond);
int mediaeditor_destroy(mediaeditor_h editor)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
_remove_remained_event_sources(_editor);
int mediaeditor_set_display(mediaeditor_h editor, mediaeditor_display_type_e type, mediaeditor_display_h display)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(display == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "display is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(display);
+
RET_VAL_IF(type < MEDIAEDITOR_DISPLAY_TYPE_OVERLAY || type > MEDIAEDITOR_DISPLAY_TYPE_NONE,
MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid display type");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], type[%d], display[%p]", editor, type, display);
int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(state == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "state is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(state);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
*state = _editor->state;
int mediaeditor_start_render(mediaeditor_h editor, const char* path, mediaeditor_render_completed_cb callback, void *user_data)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(path);
+ NULL_PARAM_CHECK(callback);
ret = _check_privilege(path, false, R_OK | W_OK);
RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_cancel_render(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_RENDERING, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be RENDERING");
int mediaeditor_start_preview(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_stop_preview(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
RET_ERR_IF_FEATURE_IS_NOT_SUPPORTED(_MEDIAEDITOR_FEATURE_DISPLAY);
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_PREVIEW, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be PREVIEW");
int mediaeditor_add_layer(mediaeditor_h editor, unsigned int *layer_id, unsigned int *layer_priority)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
- RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(layer_id);
+ NULL_PARAM_CHECK(layer_priority);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_remove_layer(mediaeditor_h editor, unsigned int layer_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_move_layer(mediaeditor_h editor, unsigned int layer_id, unsigned int layer_priority)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_activate_layer(mediaeditor_h editor, unsigned int layer_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_deactivate_layer(mediaeditor_h editor, unsigned int layer_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_get_layer_priority(mediaeditor_h editor, unsigned int layer_id, unsigned int *layer_priority)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(layer_priority);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_layer_priority(_editor, layer_id, layer_priority);
int mediaeditor_get_layer_lowest_priority(mediaeditor_h editor, unsigned int *layer_priority)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(layer_priority);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_layer_lowest_priority(_editor, layer_priority);
int mediaeditor_get_layer_id(mediaeditor_h editor, unsigned int layer_priority, unsigned int *layer_id)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(layer_id);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_layer_id(_editor, layer_priority, layer_id);
int start, unsigned int duration, unsigned int in_point, unsigned int *clip_id)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(path);
+
ret = _check_privilege(path, true, R_OK);
RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_remove_clip(mediaeditor_h editor, unsigned int clip_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_split_clip(mediaeditor_h editor, unsigned int src_clip_id, unsigned int position,
unsigned int *new_clip_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_group_clip(mediaeditor_h editor, unsigned int *clip_ids, unsigned int size, unsigned int *group_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_ungroup_clip(mediaeditor_h editor, unsigned int group_id, unsigned int **clip_ids, unsigned int *size)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_move_clip_layer(mediaeditor_h editor, unsigned int clip_id, unsigned int layer_priority)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_get_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int *start)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(start == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "start is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(start);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_start(_editor, clip_id, start);
int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int start)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], start[%d]", editor, clip_id, start);
int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int *duration)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(duration == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "duration is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(duration);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_duration(_editor, clip_id, duration);
int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int duration)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], duration[%d]", editor, clip_id, duration);
int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int *in_point)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(in_point == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "in_point is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(in_point);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_in_point(_editor, clip_id, in_point);
int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int in_point)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], in_point[%d]", editor, clip_id, in_point);
int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int *width, unsigned int *height)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(width == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "width is NULL");
- RET_VAL_IF(height == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "height is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(width);
+ NULL_PARAM_CHECK(height);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_resolution(_editor, clip_id, width, height);
int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int width, unsigned int height)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], width[%d], height[%d]", editor, clip_id, width, height);
int mediaeditor_get_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int *pos_x, unsigned int *pos_y)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(pos_x == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_x is NULL");
- RET_VAL_IF(pos_y == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_y is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(pos_x);
+ NULL_PARAM_CHECK(pos_y);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_position(_editor, clip_id, pos_x, pos_y);
int mediaeditor_set_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int pos_x, unsigned int pos_y)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], pos_x[%d], pos_y[%d]", editor, clip_id, pos_x, pos_y);
int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int clip_id, double *volume)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(volume == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "volume is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(volume);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
ret = _mediaeditor_get_clip_volume(_editor, clip_id, volume);
int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int clip_id, double volume)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
RET_VAL_IF(volume < 0.0 || volume > 10.0, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "volume is out of range");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
LOG_DEBUG("editor[%p], clip_id[%d], volume[%f]", editor, clip_id, volume);
int mediaeditor_add_transition(mediaeditor_h editor, mediaeditor_transition_type_e type, unsigned int layer_id,
unsigned int start, unsigned int duration)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
RET_VAL_IF(type < MEDIAEDITOR_TRANSITION_TYPE_NONE || type > MEDIAEDITOR_TRANSITION_TYPE_CROSSFADE,
MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid transition type");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_add_effect(mediaeditor_h editor, mediaeditor_effect_type_e type, unsigned int layer_id,
unsigned int start, unsigned int duration, unsigned int *effect_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
RET_VAL_IF(type <= MEDIAEDITOR_EFFECT_TYPE_NONE || type > MEDIAEDITOR_EFFECT_AUDIO_TYPE_ECHO,
MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid effect type");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_remove_effect(mediaeditor_h editor, unsigned int effect_id)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_create_project(mediaeditor_h editor, const char *path)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(path);
+
ret = _check_privilege(path, false, R_OK | W_OK);
RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_load_project(mediaeditor_h editor, const char *path, mediaeditor_project_loaded_cb callback, void *user_data)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(path);
+ NULL_PARAM_CHECK(callback);
+
ret = _check_privilege(path, true, R_OK);
RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_save_project(mediaeditor_h editor)
{
int ret = MEDIAEDITOR_ERROR_NONE;
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
g_autofree gchar *uri = NULL;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
RET_VAL_IF(_editor->gst.project == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "project is not loaded or created");
uri = ges_project_get_uri(_editor->gst.project);
ret = _check_privilege(uri + URI_TO_PATH_OFFSET, false, W_OK);
RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to check privilege");
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_set_error_cb(mediaeditor_h editor, mediaeditor_error_cb callback, void *user_data)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(callback);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_unset_error_cb(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_set_state_changed_cb(mediaeditor_h editor, mediaeditor_state_changed_cb callback, void *user_data)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(callback);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_unset_state_changed_cb(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_set_layer_priority_changed_cb(mediaeditor_h editor, mediaeditor_layer_priority_changed_cb callback, void *user_data)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(callback == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "callback is NULL");
+ NULL_PARAM_CHECK(_editor);
+ NULL_PARAM_CHECK(callback);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
int mediaeditor_unset_layer_priority_changed_cb(mediaeditor_h editor)
{
- g_autoptr(GMutexLocker) locker = NULL;
mediaeditor_s *_editor = (mediaeditor_s *)editor;
- RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(_editor);
- locker = g_mutex_locker_new(&_editor->mutex);
+ AUTOCLEAN_LOCKER(&_editor->mutex);
RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
"the state should be IDLE");
guint64 in_point_nsec = 0;
g_autofree gchar *uri = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
- RET_VAL_IF(path == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "path is NULL");
- RET_VAL_IF(clip_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "clip_id is NULL");
+ NULL_PARAM_CHECK(editor);
+ NULL_PARAM_CHECK(path);
+ NULL_PARAM_CHECK(clip_id);
uri = gst_filename_to_uri(path, NULL);
RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get uri");
GESLayer *layer = NULL;
g_autofree mediaeditor_clip_s *clip_data = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip_data = _mediaeditor_find_clip_data(editor->clips, clip_id);
mediaeditor_clip_s *clip_data_new = NULL;
guint64 position_nsec = 0;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(src_clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, src_clip_id);
GESGroup *group = NULL;
mediaeditor_group_s *group_data = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
for (unsigned int i = 0 ; i < size ; i++)
RET_VAL_IF(clip_ids[i] <= 0 || clip_ids[i] >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
int number_of_clips = 0;
unsigned int *ids = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
+ NULL_PARAM_CHECK(clip_ids);
RET_VAL_IF(group_id <= 0 || group_id >= editor->group_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid group id");
group = __mediaeditor_find_group(editor->groups, group_id);
GESLayer *layer = NULL;
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
layer = ges_timeline_get_layer(editor->gst.timeline, layer_priority);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
GESClip *clip = NULL;
guint64 start_nsec = 0;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
GESClip *clip = NULL;
guint64 duration_nsec = 0;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
GESClip *clip = NULL;
guint64 in_point_nsec = 0;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
mediaeditor_clip_s *clip_data = NULL;
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
clip_data = _mediaeditor_find_clip_data(editor->clips, clip_id);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
{
GESClip *clip = NULL;
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
clip = __mediaeditor_find_clip(editor->clips, clip_id);
GESClip *clip = NULL;
GValue val = { 0 };
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
clip = __mediaeditor_find_clip(editor->clips, clip_id);
RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
GESClip *clip = NULL;
GValue val = { 0 };
- RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+ NULL_PARAM_CHECK(editor);
clip = __mediaeditor_find_clip(editor->clips, clip_id);
RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");