summaryrefslogtreecommitdiff
path: root/src/mp-video-ctrl-mgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mp-video-ctrl-mgr.c')
-rwxr-xr-xsrc/mp-video-ctrl-mgr.c571
1 files changed, 571 insertions, 0 deletions
diff --git a/src/mp-video-ctrl-mgr.c b/src/mp-video-ctrl-mgr.c
new file mode 100755
index 0000000..240fbd2
--- /dev/null
+++ b/src/mp-video-ctrl-mgr.c
@@ -0,0 +1,571 @@
+/*
+ * 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 <image_util.h>
+
+#include "mp-util.h"
+#include "mp-video-log.h"
+#include "video-player.h"
+#include "mp-video-ctrl-mgr.h"
+#include "mp-video-player-mgr.h"
+#include "mp-video-type-define.h"
+#include "mp-video-service-ctrl.h"
+
+bool MpVideoCtrlMgrMediaCreate(char *szMediaURI, void *pOverlayXid, void *pEvasSinkID, char* szSubtitleUri, void *pUserData)
+{
+ if(!pUserData)
+ {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return FALSE;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if(!MpPlayerMgrCreate(szMediaURI))
+ {
+ VideoLogInfo("[ERR] Fail to create player handle.");
+ return FALSE;
+ }
+
+ MpUtilGetUserAgent(pAppData);
+
+ if(!MpPlayerMgrSetUseragentForStreaming(pAppData->szUserAgent))
+ {
+ VideoLogInfo("[ERR] Fail to set useragent.");
+ return FALSE;
+ }
+
+ if(!MpPlayerMgrSetProxyAddressForStreaming(pAppData->szProxyAddress))
+ {
+ VideoLogInfo("[ERR] Fail to set proxy address.");
+ return FALSE;
+ }
+
+ if(!MpPlayerMgrSetCookieForStreaming(pAppData->szCookie))
+ {
+ VideoLogInfo("[ERR] Fail to set Cookie.");
+ return FALSE;
+ }
+
+ if(szSubtitleUri && strlen((char*)szSubtitleUri) > 0)
+ {
+ VideoLogInfo("Subtitle URI : %s", szSubtitleUri);
+
+ if(!MpPlayerMgrSetSubtitle(szSubtitleUri))
+ {
+ VideoLogInfo("Fail to set subtitle uri.");
+ }
+ }
+ else
+ {
+ VideoLogInfo("No exist subtitle uri.");
+ }
+
+ if(!MpPlayerMgrSetOverlayXid(pOverlayXid))
+ {
+ VideoLogInfo("[ERR] Fail to set overlay window.");
+ return FALSE;
+ }
+
+ if(!MpVideoCtrlMgrSetScaling(FALSE))
+ {
+ VideoLogInfo("[ERR] Fail to set scaling.");
+ return FALSE;
+ }
+
+ if(!MpPlayerMgrSetSoundPriority())
+ {
+ VideoLogInfo("[ERR] Fail to set sound priority.");
+ return FALSE;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_CLEAR;
+
+ return TRUE;
+}
+
+bool MpVideoCtrlMgrMediaRealize(void)
+{
+ VideoLogInfo("");
+
+ if(!MpPlayerMgrRealize())
+ {
+ VideoLogInfo("[ERR] Fail relization.");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool MpVideoCtrlMgrMediaRealizeAsync(void *pReailzeCb, void *pUserData)
+{
+ VideoLogInfo("");
+
+ if(!MpPlayerMgrRealizeAsync(pReailzeCb, pUserData))
+ {
+ VideoLogInfo("[ERR] Fail relization.");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void MpVideoCtrlMgrMediaDestroy(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrIsActive()) {
+ VideoLogInfo(" Already destroy player handle.");
+ return;
+ }
+
+ if (!MpPlayerMgrUnrealize()) {
+ VideoLogInfo("[ERR] Fail to unrealize player handle.");
+ }
+
+ if (!MpPlayerMgrDestroy()) {
+ VideoLogInfo("[ERR] Fail to destroy player handle.");
+ return;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_CLEAR;
+}
+
+bool MpVideoCtrlMgrMediaPlay(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return FALSE;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrPlay()) {
+ VideoLogInfo("[ERR] Fail to play multimedia player.");
+ return FALSE;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_PLAY;
+
+ return TRUE;
+}
+
+void MpVideoCtrlMgrMediaStop(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrIsActive()) {
+ VideoLogInfo("[ERR] Player handle is destroyed.");
+ return;
+ }
+
+ if (!MpPlayerMgrStop()) {
+ VideoLogInfo("[ERR] Fail to stop multimedia player.");
+ return;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_STOP;
+}
+
+void MpVideoCtrlMgrMediaPause(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (pAppData->nCurPlayerState == MP_PLAYER_STATE_STOP) {
+ VideoLogInfo
+ ("It is not possible to pause when player state is stop.");
+ return;
+ }
+
+ if (!MpPlayerMgrPause()) {
+ VideoLogInfo("[ERR] Fail to pause multimedia player.");
+ return;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_PAUSE;
+}
+
+void MpVideoCtrlMgrMediaResume(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (pAppData->nCurPlayerState == MP_PLAYER_STATE_STOP) {
+ VideoLogInfo
+ ("It is not possible to resume when player state is stop.");
+ return;
+ }
+
+ if (!MpPlayerMgrResume()) {
+ VideoLogInfo("[ERR] Fail to resume multimedia player.");
+ return;
+ }
+
+ pAppData->nCurPlayerState = MP_PLAYER_STATE_RESUME;
+}
+
+void MpVideoCtrlMgrSetPlayerCallback(void *PlayerCompletedCb, void *PlayerInterruptedCb, void *PlayerErrorCb, void *PlayerBufferingCb, void *PlayerSubtitleCb, void *pUserData)
+{
+ if(!pUserData)
+ {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ if(!PlayerCompletedCb || !PlayerInterruptedCb || !PlayerErrorCb || !PlayerBufferingCb)
+ {
+ VideoLogInfo("[ERR] No exist player callback function pointer.");
+ return;
+ }
+
+ VideoLogInfo("");
+
+ MpPlayerMgrRegistePlayerCallback(PlayerCompletedCb, PlayerInterruptedCb, PlayerErrorCb, PlayerBufferingCb, PlayerSubtitleCb, pUserData);
+}
+
+void MpVideoCtrlMgrSetOverlayXid(void *pXid)
+{
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrSetOverlayXid(pXid)) {
+ VideoLogInfo("[ERR] Fail to set overlay window.");
+ return;
+ }
+}
+void MpVideoCtrlMgrSetEvasSinkID(void *pEvasSinkID)
+{
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrSetEvasSinkID(pEvasSinkID)) {
+ VideoLogInfo("[ERR] Fail to set overlay window.");
+ return;
+ }
+}
+
+void MpVideoCtrlMgrSetPosition(int nSetPosition, void *pSeekCb, void *pUserData)
+{
+ VideoLogInfo("");
+
+ VideoLogInfo("Set position - %d", nSetPosition);
+
+ if (nSetPosition > -1) {
+ MpPlayerMgrSetPosition(nSetPosition, pSeekCb, pUserData);
+ }
+}
+void MpVideoCtrlMgrSetSubtitlePosition(int nSetPosition)
+{
+ VideoLogInfo("");
+
+ if (nSetPosition > -1) {
+ MpPlayerMgrSetSubtitlePosition(nSetPosition);
+ }
+}
+
+int MpVideoCtrlMgrGetPosition(void)
+{
+ /* VideoLogInfo(""); */
+
+ return MpPlayerMgrGetPosition();
+}
+
+int MpVideoCtrlMgrGetDuration(void)
+{
+ VideoLogInfo("");
+
+ int nDuration = 0;
+
+ nDuration = MpPlayerMgrGetDuration();
+
+ VideoLogInfo(" content duration : %d ms", nDuration);
+
+ return nDuration;
+}
+
+void MpVideoCtrlMgrResetPlaySpeed(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (!MpPlayerMgrSetPlaySpeed(1.0)) {
+ VideoLogInfo("[ERR] Fail to reset play speed.");
+ return;
+ }
+
+ pAppData->nPlayingSpeed = MP_PLAYING_SPEED_NORMAL;
+}
+
+void MpVideoCtrlMgrSetPlaySpeedUp(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (pAppData->nPlayingSpeed > MP_PLAYING_SPEED_MAX) {
+ VideoLogInfo("Current speed is full.(5X)");
+ pAppData->nPlayingSpeed = MP_PLAYING_SPEED_5X;
+ }
+
+
+ float val = 0;
+ val = (float)pAppData->nPlayingSpeed;
+
+ MpPlayerMgrSetPlaySpeed(val);
+
+}
+
+void MpVideoCtrlMgrSetPlaySpeedDown(void *pUserData)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoAppData *pAppData = (VideoAppData *)pUserData;
+
+ VideoLogInfo("");
+
+ if (pAppData->nPlayingSpeed > MP_PLAYING_SPEED_MAX) {
+ VideoLogInfo("Current speed is full.(5X)");
+ return;
+ }
+
+ float val = 0;
+ val = -(float)pAppData->nPlayingSpeed;
+ MpPlayerMgrSetPlaySpeed(val);
+
+}
+
+int MpVideoCtrlMgrGetVideoWidthResolution(void)
+{
+ VideoLogInfo("");
+
+ int nVideoWidthResolution = MpPlayerMgrGetVideoWidthResolution();
+
+ VideoLogInfo("Video width resolution : %d", nVideoWidthResolution);
+
+ return nVideoWidthResolution;
+}
+
+int MpVideoCtrlMgrGetVideoHeightResolution(void)
+{
+ VideoLogInfo("");
+
+ int nVideoHeightResolution = MpPlayerMgrGetVideoHeightResolution();
+
+ VideoLogInfo("Video height resolution : %d", nVideoHeightResolution);
+
+ return nVideoHeightResolution;
+}
+
+void MpVideoCtrlMgrSetRatioVideoScreen(void *pUserData, int nRatioScreenSize)
+{
+ if (!pUserData) {
+ VideoLogInfo("[ERR] No exist pUserData.");
+ return;
+ }
+
+ VideoLogInfo("");
+
+ int nDisplayMode = PLAYER_DISPLAY_MODE_LETTER_BOX;
+
+ MpPlayerMgrSetDisplayMode(nDisplayMode);
+}
+
+void MpVideoCtrlMgrRotateVideoScreen(int nVideoRotateValue)
+{
+ VideoLogInfo("");
+
+ switch (nVideoRotateValue) {
+ case VIDEO_ROTATE_PORTRAIT_NORMAL:
+ VideoLogInfo("Set Portrait.");
+ MpPlayerMgrSetRotate(VIDEO_SCREEN_PORTRAIT);
+ break;
+
+ case VIDEO_ROTATE_LANDSCAPE_NORMAL:
+ VideoLogInfo("Set Landscape.");
+ MpPlayerMgrSetRotate(VIDEO_SCREEN_LANDSCAPE);
+ break;
+
+ case VIDEO_ROTATE_PORTRAIT_REVERSE:
+ VideoLogInfo("Set Portrait reverse.");
+ MpPlayerMgrSetRotate(VIDEO_SCREEN_PORTRAIT_UPSIDEDOWN);
+ break;
+
+ case VIDEO_ROTATE_LANDSCAPE_REVERSE:
+ VideoLogInfo("Set Landscape reverse.");
+ MpPlayerMgrSetRotate(VIDEO_SCREEN_LANDSCAPE_UPSIDEDOWN);
+ break;
+
+ default:
+ VideoLogInfo("Set Portrait.");
+ MpPlayerMgrSetRotate(VIDEO_SCREEN_PORTRAIT);
+ break;
+ }
+}
+
+void MpVideoCtrlMgrSetMute(bool bMuteEnable)
+{
+ VideoLogInfo("");
+
+ MpPlayerMgrSetMute(bMuteEnable);
+}
+
+bool MpVideoCtrlMgrGetMuteState(void)
+{
+ VideoLogInfo("");
+
+ return MpPlayerMgrGetMute();
+}
+
+bool MpVideoCtrlMgrStartCapture(void *pVideoCaptureCb, void *pUserData)
+{
+ VideoLogInfo("");
+
+ return MpPlayerMgrCaptureVideo(pVideoCaptureCb, pUserData);
+}
+
+int MpVideoCtrlMgrGetBufferingPosition(void)
+{
+ return MpPlayerMgrGetBufferingPosition();
+}
+
+bool MpVideoCtrlMgrIsExistPlayerHandle(void)
+{
+ VideoLogInfo("");
+
+ return MpPlayerMgrIsActive();
+}
+
+bool MpVideoCtrlMgrIsOnlyAudio(void)
+{
+ VideoLogInfo("");
+
+ int nStreamFileType = MpPlayerMgrGetFileStreamType();
+
+ if(nStreamFileType == MP_FILE_STREAM_TYPE_AUDIO)
+ {
+ VideoLogInfo("A file stream type is only audio.");
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+bool MpVideoCtrlMgrSetScaling(bool bScale)
+{
+ VideoLogInfo("");
+
+ return MpPlayerMgrSetScaling(bScale);
+
+}
+
+int MpVideoCtrlMgrGetErrorType(int nErrorVal)
+{
+ VideoLogInfo("");
+
+ switch(nErrorVal)
+ {
+ case PLAYER_ERROR_NONE:
+ return MP_PLAYER_ERROR_NONE;
+
+ case PLAYER_ERROR_OUT_OF_MEMORY:
+ return MP_PLAYER_ERROR_OUT_OF_MEMORY;
+
+ case PLAYER_ERROR_INVALID_PARAMETER:
+ return MP_PLAYER_ERROR_INVALID_PARAMETER;
+
+ case PLAYER_ERROR_NO_SUCH_FILE:
+ return MP_PLAYER_ERROR_NO_SUCH_FILE;
+
+ case PLAYER_ERROR_INVALID_OPERATION:
+ return MP_PLAYER_ERROR_INVALID_OPERATION;
+
+ case PLAYER_ERROR_SEEK_FAILED:
+ return MP_PLAYER_ERROR_SEEK_FAILED;
+
+ case PLAYER_ERROR_INVALID_STATE:
+ return MP_PLAYER_ERROR_INVALID_STATE;
+
+ case PLAYER_ERROR_NOT_SUPPORTED_FILE:
+ return MP_PLAYER_ERROR_NOT_SUPPORTED_FILE;
+
+ case PLAYER_ERROR_INVALID_URI:
+ return MP_PLAYER_ERROR_INVALID_URI;
+
+ case PLAYER_ERROR_SOUND_POLICY:
+ return MP_PLAYER_ERROR_SOUND_POLICY;
+
+ case PLAYER_ERROR_CONNECTION_FAILED:
+ return MP_PLAYER_ERROR_CONNECTION_FAILED;
+
+ case PLAYER_ERROR_VIDEO_CAPTURE_FAILED:
+ return MP_PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
+
+ default:
+ return MP_PLAYER_ERROR_UNKNOWN_ERROR;
+ }
+}
+
+int MpVideoCtrlMgrGetClosedCaptionCount(void)
+{
+ VideoLogInfo("");
+
+ return MpPlayerMgrGetClosedCaptionCount();
+
+} \ No newline at end of file