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->reconfigure_lock);
31 g_cond_clear(&priv_player->reconfigure_cond);
38 int MMPlayerPriv::Create(void)
40 int ret = MM_ERROR_NONE;
41 mmplayer_t *new_player = NULL;
43 /* alloc player structure */
44 new_player = (mmplayer_t *)g_malloc0(sizeof(mmplayer_t));
46 /* create player lock */
47 g_mutex_init(&new_player->cmd_lock);
49 /* create reconfigure lock & cond */
50 g_mutex_init(&new_player->reconfigure_lock);
51 g_cond_init(&new_player->reconfigure_cond);
54 if (mm_player_ini_load(&new_player->ini) != MM_ERROR_NONE) {
55 LOGE("can't load ini");
56 return MM_ERROR_PLAYER_INTERNAL;
59 if (mm_player_audio_effect_ini_load(&new_player->ini) != MM_ERROR_NONE) {
60 LOGE("can't load audio ini");
61 return MM_ERROR_PLAYER_INTERNAL;
65 ret = _mmplayer_create_player((MMHandleType)new_player);
67 priv_player = new_player;
72 int MMPlayerPriv::Destroy(void)
74 int ret = MM_ERROR_NONE;
77 return MM_ERROR_PLAYER_NOT_INITIALIZED;
79 __mmplayer_bus_msg_thread_destroy(priv_player);
81 MMPLAYER_CMD_LOCK(priv_player);
83 ret = _mmplayer_destroy(priv_player);
85 MMPLAYER_CMD_UNLOCK(priv_player);
87 g_mutex_clear(&((mmplayer_t *)priv_player)->cmd_lock);
88 g_mutex_clear(&((mmplayer_t *)priv_player)->reconfigure_lock);
89 g_cond_clear(&((mmplayer_t *)priv_player)->reconfigure_cond);
91 memset((mmplayer_t *)priv_player, 0x00, sizeof(mmplayer_t));
94 g_free((void *)priv_player);
100 int MMPlayerPriv::SetUri(const gchar *uri)
102 int ret = MM_ERROR_NONE;
104 MMPLAYER_CMD_LOCK(priv_player);
105 ret = _mmplayer_set_uri(priv_player, uri);
106 MMPLAYER_CMD_UNLOCK(priv_player);
111 int MMPlayerPriv::Realize(void)
113 int ret = MM_ERROR_NONE;
115 MMPLAYER_CMD_LOCK(priv_player);
116 ret = _mmplayer_realize(priv_player);
117 MMPLAYER_CMD_UNLOCK(priv_player);
122 int MMPlayerPriv::Unrealize(void)
124 int ret = MM_ERROR_NONE;
126 MMPLAYER_CMD_LOCK(priv_player);
127 ret = _mmplayer_unrealize(priv_player);
128 MMPLAYER_CMD_UNLOCK(priv_player);
133 int MMPlayerPriv::GetCurrentState(mmplayer_state_e *state)
135 int ret = MM_ERROR_NONE;
137 *state = MM_PLAYER_STATE_NULL;
138 ret = _mmplayer_get_state(priv_player, (int *)state);
143 int MMPlayerPriv::ParseProfile(const gchar *uri, int *uri_type)
145 int ret = MM_ERROR_NONE;
146 mmplayer_parse_profile_t profile;
148 memset((void *)&profile, 0, sizeof(mmplayer_parse_profile_t));
150 ret = _mmplayer_parse_profile(uri, NULL, &profile);
152 *uri_type = profile.uri_type;