* @description Creates a player handler, sets an uri and prepares the handler
* @parameter [IN] bool bPrepare [if it is true, player would be prepared. Otherwise, player would not be prepared]
* [IN] int eMediaType [if it is 0, player_set_uri would be set with an audio file. Otherwise, player_set_uri would be set with a video file]
-* @return true if successful, otherwise false.
+* @return true if successful, otherwise false.
*/
bool PlayerInitialization(bool bPrepare, MediaTypeEnumeration eMediaType)
{
{
FPRINTF("[Line : %d][%s] player_create failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
return false;
- }
+ }
if ( g_PlayerHandler == NULL )
{
FPRINTF("[Line : %d][%s] player handler is NULL\\n", __LINE__, API_NAMESPACE);
return false;
- }
+ }
nRet = player_get_state(g_PlayerHandler, &eState);
if ( nRet != PLAYER_ERROR_NONE )
if ( eMediaType == MeidaType_Audio )
{
char *pszAudioPath = MediaPlayerGetDataPath(MEDIA_AUDIO);
-
+
nRet = player_set_uri(g_PlayerHandler, pszAudioPath);
#if defined(WEARABLE)
bool bValue = false;
FPRINTF("[Line : %d][%s] player_prepare failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
PlayerDestroy(false);
return false;
- }
+ }
nRet = player_get_state(g_PlayerHandler, &eState);
if ( nRet != PLAYER_ERROR_NONE )
PlayerDestroy(false);
return false;
}
-
+
FPRINTF("[Line : %d][%s] player_get_state returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetState(eState));
if ( eState != PLAYER_STATE_READY )
{
return false;
}
}
+
return true;
}
/**
* @function PlayerDestroy
* @description Unprepare and destroy the player handler
* @parameter [IN] bIsUnprepare, whether unprepare needed or not
-* @return true if successful, else false
+* @return true if successful, else false
*/
bool PlayerDestroy(bool bIsUnprepare)
{
+ bool ret = true;
int nRet = PLAYER_ERROR_NONE;
if ( bIsUnprepare )
{
- nRet = player_unprepare(g_PlayerHandler);
+ nRet = player_unprepare(g_PlayerHandler);
if ( nRet != PLAYER_ERROR_NONE )
{
FPRINTF("[Line : %d][%s] player_unprepare failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
- return false;
+ ret = false;
}
}
nRet = player_destroy(g_PlayerHandler);
if ( nRet != PLAYER_ERROR_NONE )
{
FPRINTF("[Line : %d][%s] player_destroy failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
- return false;
+ ret = false;
}
g_PlayerHandler = NULL;
- return true;
+ return ret;
}
/**
* [OUT] pfPreserveRightVol, save the right vol
* [IN] fSetLeftVol, set the current left vol
* [IN] fSetRightVol, set the current right vol
-* @return true if successful, else false
+* @return true if successful, else false
*/
bool PlayerSetVolume(float *pfPreserveLeftVol, float *pfPreserveRightVol, float fSetLeftVol, float fSetRightVol)
{
return true;
}
-/**
+/**
* @function PlayerGmainLoopCallBack
* @description Callback for GmainLoop and player start during callback time.
* @parameter [IN] data, user data
{
nRet = player_start(g_PlayerHandler);
if ( nRet != PLAYER_ERROR_NONE )
- {
+ {
FPRINTF("[Line : %d][%s] player_start failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
PlayerDestroy(true);
}
{
nRet = player_stop(g_PlayerHandler);
if ( nRet != PLAYER_ERROR_NONE )
- {
+ {
FPRINTF("[Line : %d][%s] player_stop failed, error returned = %s\\n", __LINE__, API_NAMESPACE, PlayerGetError(nRet));
PlayerDestroy(true);
}
case RUNTIME_INFO_ERROR_INVALID_PARAMETER: pszErrInfo = "RUNTIME_INFO_ERROR_INVALID_PARAMETER"; break;
case RUNTIME_INFO_ERROR_OUT_OF_MEMORY: pszErrInfo = "RUNTIME_INFO_ERROR_OUT_OF_MEMORY"; break;
case RUNTIME_INFO_ERROR_IO_ERROR: pszErrInfo = "RUNTIME_INFO_ERROR_IO_ERROR"; break;
- case RUNTIME_INFO_ERROR_PERMISSION_DENIED: pszErrInfo = "RUNTIME_INFO_ERROR_PERMISSION_DENIED"; break;
+ case RUNTIME_INFO_ERROR_PERMISSION_DENIED: pszErrInfo = "RUNTIME_INFO_ERROR_PERMISSION_DENIED"; break;
}
FPRINTF("[Line : %d][%s] %s is failed, error returned = %s\\n", __LINE__, API_NAMESPACE, pszApiName, pszErrInfo);
FPRINTF("[Line : %d][%s] app_get_resource_path() returned invalid path\\n", __LINE__, API_NAMESPACE);
return pszImgPath;
}
-
+
pszImgPath = (char*) calloc(1, strlen(pszAppData) + strlen(pszFileName)+1);
if (pszImgPath == NULL)
return pszImgPath;
-
+
snprintf(pszImgPath, strlen(pszAppData) + strlen(pszFileName)+2, "%s%s",pszAppData, pszFileName);
FPRINTF("[Line : %d][%s] app_get_resource_path() is %s\\n", __LINE__, API_NAMESPACE,pszImgPath);
return pszImgPath;
int read = 0;
void *buf_data_ptr = NULL;
- if (media_packet_create_alloc(video_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- PRINT_UTC_LOG("[Line : %d][%s] fail to alloc media_packet\\n", __LINE__, API_NAMESPACE);
+ if (media_packet_new_alloc(video_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ PRINT_UTC_LOG("[Line : %d][%s] fail to alloc media_packet\\n", __LINE__, API_NAMESPACE);
return;
}
g_ret = player_push_media_stream(player, video_pkt);
pts += ES_DEFAULT_VIDEO_PTS_OFFSET;
- goto FREE_PACKET;
-
FREE_PACKET:
/* destroy media packet after use */
- media_packet_destroy(video_pkt);
+ media_packet_unref(video_pkt);
video_pkt = NULL;
- return;
}
static void feed_video_data_thread_func()
int read = 0;
void *buf_data_ptr = NULL;
- if (media_packet_create_alloc(audio_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ if (media_packet_new_alloc(audio_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
PRINT_UTC_LOG("[Line : %d][%s] fail to alloc media_packet\\n", __LINE__, API_NAMESPACE);
return;
}
g_ret = player_push_media_stream(player, audio_pkt);
pts += ES_DEFAULT_AUDIO_PTS_OFFSET;
- goto FREE_PACKET;
-
FREE_PACKET:
/* destroy media packet after use */
- media_packet_destroy(audio_pkt);
- video_pkt = NULL;
- return;
+ media_packet_unref(audio_pkt);
+ audio_pkt = NULL;
}
static void feed_audio_data_thread_func()
if (video_fmt)
media_format_unref(video_fmt);
+ video_fmt = NULL;
if (audio_fmt)
media_format_unref(audio_fmt);
+ audio_fmt = NULL;
- if (file_src) {
+ if (file_src)
fclose(file_src);
- file_src = NULL;
- }
+ file_src = NULL;
- if (audio_file_src) {
+ if (audio_file_src)
fclose(audio_file_src);
- audio_file_src = NULL;
- }
+ audio_file_src = NULL;
if (player){
ret = player_get_state (player, &state);
}
if (media_path)
free(media_path);
+ media_path = NULL;
if (audio_media_path)
free(audio_media_path);
+ audio_media_path = NULL;
#ifndef TIZENIOT
destroy_window();