diff options
Diffstat (limited to 'src/mp-video-player-mgr.c')
-rw-r--r-- | src/mp-video-player-mgr.c | 856 |
1 files changed, 0 insertions, 856 deletions
diff --git a/src/mp-video-player-mgr.c b/src/mp-video-player-mgr.c deleted file mode 100644 index e1b786f..0000000 --- a/src/mp-video-player-mgr.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * Copyright (c) [2012] Samsung Electronics Co., Ltd. - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/stat.h> - -#include "mp-video-log.h" -#include "mp-video-player-mgr.h" - -#define MAX_PATH_LEN 2048 - - -static player_h pPlayerHandle; - - -bool MpPlayerMgrIsActive(void) -{ - return pPlayerHandle ? true : false; -} - -bool MpPlayerMgrRegistePlayerCallback(void *PlayerCompletedCbFunc, void *PlayerInterruptedCbFunc, void *PlayerErrorCbFunc, void *PlayerBufferingCbFunc, void *PlayerSubtitleCbFunc, void *pUserData) -{ - VideoLogInfo(""); - - if(!pUserData) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(player_set_completed_cb(pPlayerHandle, PlayerCompletedCbFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(player_set_interrupted_cb(pPlayerHandle, PlayerInterruptedCbFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(player_set_error_cb(pPlayerHandle, PlayerErrorCbFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(player_set_buffering_cb(pPlayerHandle, PlayerBufferingCbFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(player_set_subtitle_updated_cb(pPlayerHandle, PlayerSubtitleCbFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR]"); - return false; -} - - return true; -} - -bool MpPlayerMgrCreate(const char *szPath) -{ - VideoLogInfo(""); - - if(!szPath) - { - VideoLogInfo("[ERR] Not correct Meida URI."); - return false; - } - - int nPathLength = strlen(szPath); - int nErr = PLAYER_ERROR_NONE; - - VideoLogInfo(" Media path (%s)", szPath); - - if(nPathLength > 0 && nPathLength < MAX_PATH_LEN) - { - nErr = player_create(&pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to create player handle. (MMF Error code : %x)", nErr); - return false; - } - - nErr = player_set_uri(pPlayerHandle, szPath); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] (%x) Fail to set attribute ", nErr); - return false; - } - } - else - { - VideoLogInfo("[ERR] File path is too long."); - return false; - } - - nErr = player_set_sound_type(pPlayerHandle, SOUND_TYPE_MEDIA); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] (%x):: Fail to set attribute ", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrDestroy(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_destroy(pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - pPlayerHandle = NULL; - - return true; -} - -bool MpPlayerMgrRealize(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_prepare(pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrRealizeAsync(void *pPrepareCb, void *pUserData) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_prepare_async(pPlayerHandle, pPrepareCb, pUserData); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrUnrealize(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_unprepare (pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrPlay(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_start(pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrStop(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_stop (pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrResume(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_start(pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrPause(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_pause(pPlayerHandle); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x", nErr); - return false; - } - - return true; -} - -int MpPlayerMgrGetPosition(void) -{ - if(!MpPlayerMgrIsActive()) - { - return 0; - } - - int nPos = 0; - int nErr = 0; - - nErr = player_get_position(pPlayerHandle, &nPos); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x ", nErr); - return 0; - } - - return nPos; -} - -void MpPlayerMgrSetPosition(unsigned int nPos, void *pSeekCb, void *pUserData) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return; - } - - VideoLogInfo("Set position - %d", nPos); - - int nErr = player_set_position(pPlayerHandle, (int)nPos, pSeekCb, pUserData); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x ", nErr); - } -} - -void MpPlayerMgrSetSubtitlePosition(unsigned int nPos) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return; - } - - int nErr = player_set_subtitle_position(pPlayerHandle, nPos); - - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : 0x%x ", nErr); - } -} - - -void MpPlayerMgrSetMute(bool bMuteEnable) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return; - } - - if(player_set_mute(pPlayerHandle, bMuteEnable) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to set mute."); - } -} - -bool MpPlayerMgrGetMute(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - bool bIsMute = false; - - if(player_is_muted(pPlayerHandle, &bIsMute) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to get mute state."); - return false; - } - - return bIsMute; -} - -bool MpPlayerMgrSetSurroundFilters(int nSurround) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - audio_effect_preset_e ePresetValue = (audio_effect_preset_e)nSurround; - - bool available = false; - - player_audio_effect_preset_is_available (pPlayerHandle, ePresetValue, &available); - - if(available == false) - { - VideoLogInfo("[ERR] unavailable to set audio effect."); - return false; - } - - if(player_audio_effect_set_preset(pPlayerHandle,ePresetValue) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to set audio effect."); - return false; - } - - return true; -} - -int MpPlayerMgrGetDuration(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return 0; - } - - int nDuration = -1; - - int nErr = player_get_duration(pPlayerHandle, &nDuration); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to get attribute ", nErr); - return 0; - } - - return nDuration; -} - -bool MpPlayerMgrSetOverlayXid(void *pOverlayXid) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } -/* - if(!pOverlayXid) - { - VideoLogInfo("[ERR]"); - return false; - } -*/ - VideoLogInfo("XID : %x, %d", pOverlayXid, (int)pOverlayXid); - int nErr = player_set_display(pPlayerHandle, PLAYER_DISPLAY_TYPE_X11, (void*)pOverlayXid); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nErr); - return false; - } - return true; -} - -bool MpPlayerMgrSetEvasSinkID(void *pEvasSinkID) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } -/* - if(!pEvasSinkID) - { - VideoLogInfo("[ERR]"); - return false; - } -*/ - VideoLogInfo("Evas Sink ID : %x", pEvasSinkID); - - int nErr = player_set_display(pPlayerHandle, PLAYER_DISPLAY_TYPE_EVAS, (void*)pEvasSinkID); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrSetSoundPriority(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nErr = player_set_sound_type(pPlayerHandle, SOUND_TYPE_MEDIA); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nErr); - return false; - } - - return true; -} - -int MpPlayerMgrSetPlaySpeed(float nSpeedValue) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return -1; - } - int nErr = player_set_playback_rate(pPlayerHandle, nSpeedValue); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to get attribute ", nErr); - return -1; - } - - return 0; -} - -int MpPlayerMgrGetVideoWidthResolution(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return 0; - } - - int nWidth = 0; - int nHeight = 0; - int nErr = player_get_video_size(pPlayerHandle, &nWidth, &nHeight); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to get attribute ", nErr); - return 0; - } - - return nWidth; -} - -int MpPlayerMgrGetVideoHeightResolution(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return 0; - } - - int nWidth = 0; - int nHeight = 0; - int nErr = player_get_video_size(pPlayerHandle, &nWidth, &nHeight); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to get attribute ", nErr); - return 0; - } - - return nHeight; -} - -bool MpPlayerMgrSetSubtitle(char *szSubtitlePath) -{ - VideoLogInfo("%s", szSubtitlePath); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(!szSubtitlePath) - { - VideoLogInfo("[ERR] subtitle path is null."); - return false; - } - - int nErr = player_set_subtitle_path(pPlayerHandle, szSubtitlePath); - if(nErr != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nErr); - return false; - } - - return true; -} - -bool MpPlayerMgrSetDisplayMode(MpPlayerMgrDisplayMethod nMethodMode) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - int nRet = player_set_display_mode (pPlayerHandle , nMethodMode); - if(nRet != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nRet); - return false; - } - return true; -} - -bool MpPlayerMgrSetRotate(MpVideoRotation nRotation) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - int nRotVal = PLAYER_DISPLAY_ROTATION_NONE; - - if(nRotation == VIDEO_SCREEN_PORTRAIT) { - nRotVal = PLAYER_DISPLAY_ROTATION_NONE; - } - else if(nRotation == VIDEO_SCREEN_PORTRAIT_UPSIDEDOWN) { - nRotVal = PLAYER_DISPLAY_ROTATION_180; - } - else if(nRotation == VIDEO_SCREEN_LANDSCAPE) { - nRotVal = PLAYER_DISPLAY_ROTATION_270; - } - else if(nRotation == VIDEO_SCREEN_LANDSCAPE_UPSIDEDOWN) { - nRotVal = PLAYER_DISPLAY_ROTATION_90; - } - - int nRet = player_set_x11_display_rotation (pPlayerHandle , nRotVal); - if(nRet != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Error code : %x - Fail to set attribute ", nRet); - return false; - } - return true; -} - -bool MpPlayerMgrSetUseragentForStreaming(const char *szUserAgent) -{ - VideoLogInfo("!!!!!! NO EXIST FUNCTION FOR SETTING USER AGENT. !!!!!!"); - - return true; -} - -bool MpPlayerMgrSetProxyAddressForStreaming(const char *szProxyAddress) -{ - VideoLogInfo("!!!!!! NO EXIST FUNCTION FOR SETTING PROXY ADDRESS. !!!!!!"); - return true; -} - -bool MpPlayerMgrSetCookieForStreaming(const char *szCookie) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - if(!szCookie) - { - VideoLogInfo("No exist cookie."); - return false; - } - - VideoLogInfo(""); - - int nRet = player_set_streaming_cookie(pPlayerHandle , szCookie, strlen(szCookie)); - if(nRet == PLAYER_ERROR_INVALID_PARAMETER) - { - VideoLogInfo("PLAYER_ERROR_INVALID_PARAMETER"); - return false; - } - - return true; -} - -bool MpPlayerMgrStartCapture() -{ - VideoLogInfo(""); - return true; -} - -bool MpPlayerMgrCaptureVideo(void *pCallbackFunc, void *pUserData) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo(""); - return false; - } - - VideoLogInfo(""); - - int nRet = player_capture_video(pPlayerHandle, pCallbackFunc, pUserData); - if(nRet == PLAYER_ERROR_INVALID_PARAMETER) - { - VideoLogInfo("PLAYER_ERROR_INVALID_PARAMETER"); - return false; - } - - if(nRet == PLAYER_ERROR_INVALID_OPERATION) - { - VideoLogInfo("PLAYER_ERROR_INVALID_OPERATION"); - return false; - } - - if(nRet == PLAYER_ERROR_INVALID_STATE) - { - VideoLogInfo("PLAYER_ERROR_INVALID_STATE"); - return false; - } - - return true; -} - -int MpPlayerMgrGetBufferingPosition(void) -{ - int nStartPos = 0; - int nCurrentPos = 0; - - if(player_get_streaming_download_progress(pPlayerHandle,&nStartPos, &nCurrentPos) != PLAYER_ERROR_NONE) - { - VideoLogError(""); - return 0; -} - - return nCurrentPos; -} - -bool MpPlayerMgrRegisteBufferingCallBack(void *pCallbackFunc, void *pUserData) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - // !!! CHECK player_buffering_cb !!! - if(player_set_buffering_cb(pPlayerHandle, pCallbackFunc, pUserData) != PLAYER_ERROR_NONE) - { - VideoLogInfo(""); - return false; - } - - return true; -} - -int MpPlayerMgrGetFileStreamType(void) -{ - VideoLogInfo(""); - -// jdlee - return FILE_STREAM_TYPE_VIDEO; -} - -bool MpPlayerMgrSetScaling(bool bScale) -{ - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return false; - } - - VideoLogInfo(""); - - if(player_enable_evas_display_scaling(pPlayerHandle, bScale) != PLAYER_ERROR_NONE) { - VideoLogInfo("[ERR]"); - return false; - } - return true; -} - -player_state_e MpPlayerMgrGetPlayerState(void) -{ - int ret = 0; - player_state_e player_state = PLAYER_STATE_NONE; - ret = player_get_state(pPlayerHandle, &player_state); - if (ret != PLAYER_ERROR_NONE) { - player_state = PLAYER_STATE_NONE; - } - return player_state; -} - -void MpPlayerMgrSetVolume(float volume) -{ - VideoLogInfo("volume = %f", volume); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return; - } - - if(player_set_volume(pPlayerHandle, volume, volume) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to set volume."); - } -} - -float MpPlayerMgrGetVolume(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return 0.0; - } - - float volume_left = 0.0; - float volume_right = 0.0; - - if(player_get_volume(pPlayerHandle, &volume_left, &volume_right) != PLAYER_ERROR_NONE) - { - VideoLogInfo("[ERR] Fail to get volume."); - return 0.0; - } - - return volume_left; -} - -int MpPlayerMgrGetClosedCaptionCount(void) -{ - VideoLogInfo(""); - - if(!MpPlayerMgrIsActive()) - { - VideoLogInfo("[ERR]"); - return 0; - } - int nCount = 0; - - if(player_get_track_count(pPlayerHandle, PLAYER_TRACK_TYPE_TEXT, &nCount) != PLAYER_ERROR_NONE) - { - VideoLogError("[ERR] player_get_track_count."); - return 0; - } - - VideoLogError("== %d ===========================================", nCount); - - return nCount; -} - |