2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "mm_player_utils.h"
18 #include "gtest_mm_player_priv.h"
20 MMPlayerPriv::MMPlayerPriv()
25 MMPlayerPriv::~MMPlayerPriv()
28 _mmplayer_destroy((MMHandleType)priv_player);
29 g_mutex_clear(&priv_player->cmd_lock);
30 g_mutex_clear(&priv_player->playback_lock);
37 int MMPlayerPriv::Create(void)
39 int ret = MM_ERROR_NONE;
40 mmplayer_t *new_player = NULL;
42 /* alloc player structure */
43 new_player = (mmplayer_t *)g_malloc0(sizeof(mmplayer_t));
45 /* create player lock */
46 g_mutex_init(&new_player->cmd_lock);
48 /* create player lock */
49 g_mutex_init(&new_player->playback_lock);
52 if (mm_player_ini_load(&new_player->ini) != MM_ERROR_NONE) {
53 LOGE("can't load ini");
54 return MM_ERROR_PLAYER_INTERNAL;
57 if (mm_player_audio_effect_ini_load(&new_player->ini) != MM_ERROR_NONE) {
58 LOGE("can't load audio ini");
59 return MM_ERROR_PLAYER_INTERNAL;
63 ret = _mmplayer_create_player((MMHandleType)new_player);
65 priv_player = new_player;
70 int MMPlayerPriv::Destroy(void)
72 int ret = MM_ERROR_NONE;
75 return MM_ERROR_PLAYER_NOT_INITIALIZED;
77 __mmplayer_bus_msg_thread_destroy(priv_player);
79 MMPLAYER_CMD_LOCK(priv_player);
81 ret = _mmplayer_destroy(priv_player);
83 MMPLAYER_CMD_UNLOCK(priv_player);
85 g_mutex_clear(&((mmplayer_t *)priv_player)->cmd_lock);
86 g_mutex_clear(&((mmplayer_t *)priv_player)->playback_lock);
88 memset((mmplayer_t *)priv_player, 0x00, sizeof(mmplayer_t));
91 g_free((void *)priv_player);
97 int MMPlayerPriv::SetUri(const gchar *uri)
99 int ret = MM_ERROR_NONE;
101 MMPLAYER_CMD_LOCK(priv_player);
102 ret = _mmplayer_set_uri(priv_player, uri);
103 MMPLAYER_CMD_UNLOCK(priv_player);
108 int MMPlayerPriv::Realize(void)
110 int ret = MM_ERROR_NONE;
112 MMPLAYER_CMD_LOCK(priv_player);
113 ret = _mmplayer_realize(priv_player);
114 MMPLAYER_CMD_UNLOCK(priv_player);
119 int MMPlayerPriv::Unrealize(void)
121 int ret = MM_ERROR_NONE;
123 MMPLAYER_CMD_LOCK(priv_player);
124 ret = _mmplayer_unrealize(priv_player);
125 MMPLAYER_CMD_UNLOCK(priv_player);
130 int MMPlayerPriv::GetCurrentState(mmplayer_state_e *state)
132 int ret = MM_ERROR_NONE;
134 *state = MM_PLAYER_STATE_NULL;
135 ret = _mmplayer_get_state(priv_player, (int *)state);
140 int MMPlayerPriv::ParseProfile(const gchar *uri, int *uri_type)
142 int ret = MM_ERROR_NONE;
143 mmplayer_parse_profile_t profile;
145 memset((void *)&profile, 0, sizeof(mmplayer_parse_profile_t));
147 ret = __mmplayer_parse_profile(uri, NULL, &profile);
149 *uri_type = profile.uri_type;