Remove SMACK rule file(.rule) according three domain model
[apps/core/preloaded/video-player.git] / src / mp-video-player-mgr.c
old mode 100755 (executable)
new mode 100644 (file)
index 768da7b..e1b786f
@@ -1,19 +1,17 @@
 /*
- * To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+ * Copyright (c) [2012] Samsung Electronics Co., Ltd.
  *
- *    Copyright [2012] [JongDong Lee <jongdong.lee@samsung.com>, ChangSun Lee <cs78.lee@samsung.com>]
+ * 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
  *
- *    Licensed under the Flora License, Version 1.0 (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/
  *
- *        http://www.tizenopensource.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.
+ * 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>
 static player_h pPlayerHandle;
 
 
-
 bool MpPlayerMgrIsActive(void)
 {
        return pPlayerHandle ? true : false;
 }
 
-bool MpPlayerMgrRegistePlayerCallback(void *PlayerCompletedCbFunc, void *PlayerInterruptedCbFunc, void *PlayerErrorCbFunc, void *PlayerBufferingCbFunc, void *pUserData)
+bool MpPlayerMgrRegistePlayerCallback(void *PlayerCompletedCbFunc, void *PlayerInterruptedCbFunc, void *PlayerErrorCbFunc, void *PlayerBufferingCbFunc, void *PlayerSubtitleCbFunc, void *pUserData)
 {
        VideoLogInfo("");
 
@@ -76,9 +73,14 @@ bool MpPlayerMgrRegistePlayerCallback(void *PlayerCompletedCbFunc, void *PlayerI
                return false;
        }
 
-       return true;
+       if(player_set_subtitle_updated_cb(pPlayerHandle, PlayerSubtitleCbFunc, pUserData) != PLAYER_ERROR_NONE)
+       {
+               VideoLogInfo("[ERR]");
+               return false;
 }
 
+       return true;
+}
 
 bool MpPlayerMgrCreate(const char *szPath)
 {
@@ -110,7 +112,6 @@ bool MpPlayerMgrCreate(const char *szPath)
                        VideoLogInfo("[ERR] (%x) Fail to set attribute ", nErr);
                        return false;
                }
-
        }
        else
        {
@@ -144,7 +145,6 @@ bool MpPlayerMgrDestroy(void)
                VideoLogInfo("[ERR] Error code : 0x%x", nErr);
                return false;
        }
-
        pPlayerHandle = NULL;
 
        return true;
@@ -329,6 +329,25 @@ void MpPlayerMgrSetPosition(unsigned int nPos, void *pSeekCb, void *pUserData)
        }
 }
 
+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("");
@@ -366,6 +385,37 @@ bool MpPlayerMgrGetMute(void)
        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("");
@@ -395,21 +445,45 @@ bool MpPlayerMgrSetOverlayXid(void *pOverlayXid)
                VideoLogInfo("[ERR]");
                return false;
        }
-
+/*
        if(!pOverlayXid)
        {
                VideoLogInfo("[ERR]");
                return false;
        }
-
-       /* prevent 2011/07/12 */
-       VideoLogInfo("XID : %p", pOverlayXid);
+*/
+       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;
 }
@@ -497,6 +571,32 @@ int MpPlayerMgrGetVideoHeightResolution(void)
        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("");
@@ -506,7 +606,12 @@ bool MpPlayerMgrSetDisplayMode(MpPlayerMgrDisplayMethod nMethodMode)
                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;
 }
 
@@ -534,13 +639,13 @@ bool MpPlayerMgrSetRotate(MpVideoRotation nRotation)
        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;
 }
 
@@ -583,11 +688,58 @@ bool MpPlayerMgrSetCookieForStreaming(const char *szCookie)
        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())
@@ -630,3 +782,75 @@ bool MpPlayerMgrSetScaling(bool bScale)
        }
        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;
+}
+