/*
- * 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 [2012] [JongDong Lee <jongdong.lee@samsung.com>, ChangSun Lee <cs78.lee@samsung.com>]
- *
- * 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://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.
+ * 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.
*/
#define MP_VIDEO_START_POS_TIME_KEY "start_pos_time"
#define MP_VIDEO_URI_PATH "path"
#define MP_VIDEO_COOKIE "cookie"
-
+#define MP_VIDEO_MULTI_WIN_TYPE_KEY "is_multi_win_type"
+#define MP_VIDEO_LAUNCH_TYPE "launch-type"
+#define MP_VIDEO_SHORTCUT_VIDEO "shortcut-videoplayer"
static service_h pAppSvcHandle = NULL;
-static int nPlayerType = MP_VIDEO_PLAYER_SIMPLE;
-static char szStreamingCookie[STR_LEN_MAX] = {0};
+static int nPlayerType = MP_NONE_VIEW_TYPE;
+static int nPrevPlayerType = MP_NONE_VIEW_TYPE;
+static int nGalleryLatestTime = 0;
+static char *g_szStreamingCookie = NULL;
+static bool bIsShortcutType = FALSE;
/////////////////////////////////////////////////////////////////////////////
// Internal Function
-bool MpVideoServiceCtrlCheckMime(service_h pVideoServiceHandle, char *szMediaUri)
+bool MpVideoServiceCtrlCheckMime(service_h pVideoServiceHandle, char **szMediaUri)
{
VideoLogInfo("");
return FALSE;
}
- if(!szMediaUri)
- {
- VideoLogInfo("[ERR] No Exist media uri.");
- return FALSE;
- }
-
bool bRet = TRUE;
char *szMimeContent = NULL;
if(szMimeContent)
{
- strncpy(szMediaUri, szMimeContent, STR_LEN_MAX - 1);
- VideoLogInfo("Mime content : %s", szMediaUri);
+ *szMediaUri = (char*)malloc(strlen(szMimeContent) + 1);
+ memset(*szMediaUri, 0, strlen(szMimeContent) + 1);
+ strncpy(*szMediaUri, szMimeContent, strlen(szMimeContent));
+ VideoLogInfo("Mime content : %s", *szMediaUri);
free(szMimeContent);
bRet = TRUE;
}
return bRet;
}
-bool MpVideoServiceCtrlCheckBundle(service_h pVideoServiceHandle, char *szMediaUri)
+bool MpVideoServiceCtrlCheckBundle(service_h pVideoServiceHandle, char **szMediaUri)
{
if(!pVideoServiceHandle)
{
}
bool bRet = TRUE;
- char *pStrVideoURI = NULL;
+ char *szStrVideoURI = NULL;
- if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_URI_PATH, &pStrVideoURI) != SERVICE_ERROR_NONE)
+ if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_URI_PATH, &szStrVideoURI) != SERVICE_ERROR_NONE)
{
- VideoLogInfo("[ERR] No exist KEY of video/streaming URI.");
+ VideoLogInfo("No exist KEY of video/streaming URI.");
bRet = FALSE;
+ return bRet;
}
- if(pStrVideoURI)
+ if(szStrVideoURI)
{
- strncpy(szMediaUri, pStrVideoURI, STR_LEN_MAX - 1);
- VideoLogInfo("Video/Streaming URI path : %s", szMediaUri);
- free(pStrVideoURI);
+ *szMediaUri = (char*)malloc(strlen(szStrVideoURI) + 1);
+ memset(*szMediaUri, 0, strlen(szStrVideoURI) + 1);
+ strncpy(*szMediaUri, szStrVideoURI, strlen(szStrVideoURI));
+ VideoLogInfo("Video/Streaming URI path : %s", *szMediaUri);
+ free(szStrVideoURI);
+ szStrVideoURI = NULL;
bRet = TRUE;
}
else
{
- VideoLogInfo("[ERR] No exist video/streaming URI.");
+ VideoLogInfo("No exist video/streaming URI.");
bRet = FALSE;
}
return bRet;
}
-bool MpVideoServiceCtrlCheckAUL(service_h pVideoServiceHandle, char *szMediaUri)
+bool MpVideoServiceCtrlCheckAUL(service_h pVideoServiceHandle, char **szMediaUri)
{
if(!pVideoServiceHandle)
{
return FALSE;
}
- char *pStrVideoURI = (char*)malloc(sizeof(char) * STR_LEN_MAX);
- char *pGetOperation = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
+
+ char *pGetOperation = NULL;
service_get_operation(pVideoServiceHandle, &pGetOperation);
+
+ if(pGetOperation == NULL)
+ {
+ return FALSE;
+ }
+
if(!strcmp(SERVICE_OPERATION_VIEW , pGetOperation))
{
- service_get_uri(pVideoServiceHandle, &pStrVideoURI);
- if(strlen(pStrVideoURI) > 1)
+ char *szStrVideoURI = NULL;
+
+ service_get_uri(pVideoServiceHandle, &szStrVideoURI);
+
+ if(szStrVideoURI)
{
- strncpy(szMediaUri, pStrVideoURI, STR_LEN_MAX - 1);
+ *szMediaUri = (char*)malloc(strlen(szStrVideoURI) + 1);
+ memset(*szMediaUri, 0, strlen(szStrVideoURI) + 1);
+ strncpy(*szMediaUri, szStrVideoURI, strlen(szStrVideoURI));
+ VideoLogInfo("Video/Streaming URI path : %s", *szMediaUri);
+ free(szStrVideoURI);
+ szStrVideoURI = NULL;
}
else
{
VideoLogInfo("[ERR] No exist video/streaming URI.");
+
+ if(pGetOperation)
+ {
+ free(pGetOperation);
+ pGetOperation = NULL;
+ }
+
return FALSE;
}
}
else
{
- VideoLogInfo("[ERR] No exist Operation.");
+ VideoLogInfo("No exist Operation.");
+
+ if(pGetOperation)
+ {
+ free(pGetOperation);
+ pGetOperation = NULL;
+ }
+
return FALSE;
}
- VideoLogInfo("Video/Streaming URI path pStrVideoURI : %s", pStrVideoURI);
- VideoLogInfo("Video/Streaming URI path pAppData->szMediaUri : %s", szMediaUri);
+ VideoLogInfo("Video/Streaming URI path pAppData->szMediaUri : %s", *szMediaUri);
- free(pStrVideoURI);
+ if(pGetOperation)
+ {
free(pGetOperation);
-
- return TRUE;
-}
-
-bool MpVideoServiceCtrlIsXMLUrl(char *szMediaUri)
-{
- VideoLogInfo("URI : %s", szMediaUri);
-
- if (!g_str_has_suffix(szMediaUri, ".xml")) {
- VideoLogInfo("No have xml uri.");
- return FALSE;
+ pGetOperation = NULL;
}
return TRUE;
}
-bool MpVideoServiceCtrlGetUri(service_h pVideoServiceHandle, char* szMediaUri)
+
+bool MpVideoServiceCtrlParseUri(service_h pVideoServiceHandle, char** szMediaUri)
{
VideoLogInfo("");
}
}
- VideoLogInfo("szMediaUri", szMediaUri);
+ VideoLogInfo("szMediaUri : %s", *szMediaUri);
return TRUE;
}
-int MpVideoServiceCtrlVideoUriType(char* szMediaUri)
+int MpVideoServiceCtrlCheckUriType(char* szMediaUri)
{
- if(szMediaUri == NULL)
+ if(!szMediaUri)
{
- VideoLogInfo("[ERR]");
+ VideoLogInfo("[ERR] No exist media uri.");
return MP_ERROR_PLAYER_TYPE;
}
int nRet = 0;
- if(strlen(szMediaUri) > 0)
- {
- if(MpUtilCheckPlayerType(szMediaUri))
+ if(MpUtilCheckUriType(szMediaUri))
{
VideoLogInfo("MP_STREAMING_PLAYER");
nRet = MP_STREAMING_PLAYER;
VideoLogInfo("MP_VIDEO_PLAYER");
nRet = MP_VIDEO_PLAYER;
}
- }
- else
- {
- VideoLogInfo("[ERR] No exist video/streaming URI. : MP_ERROR_PLAYER_TYPE");
- return MP_ERROR_PLAYER_TYPE;
- }
-
- VideoLogInfo("pAppData->szMediaUri : %s", szMediaUri);
return nRet;
}
-bool MpVideoServiceCtrlCheckCookieForStreaming(service_h pVideoServiceHandle, char* szCookie)
+bool MpVideoServiceCtrlCheckCookieForStreaming(service_h pVideoServiceHandle)
{
if(!pVideoServiceHandle)
{
return FALSE;
}
- if(!szCookie)
- {
- VideoLogInfo("[ERR] No allocate szCookie.");
- return FALSE;
- }
-
bool bRet = TRUE;
char *pStrVideoCookie = NULL;
if(pStrVideoCookie)
{
- strncpy(szCookie, pStrVideoCookie, STR_LEN_MAX - 1);
- VideoLogInfo("Video/Streaming URI path Cookie : %s", szCookie);
+ g_szStreamingCookie = (char*)malloc(strlen(pStrVideoCookie) + 1);
+ memset(g_szStreamingCookie, 0, strlen(pStrVideoCookie) + 1);
+ strncpy(g_szStreamingCookie, pStrVideoCookie, strlen(pStrVideoCookie));
+ VideoLogInfo("Video/Streaming URI path Cookie : %s", g_szStreamingCookie);
free(pStrVideoCookie);
- bRet = TRUE;
}
else
{
return TRUE;
}
+int MpVideoServiceCtrlCheckStartPositionTime(service_h pVideoServiceHandle, char *szBundleKey)
+{
+ VideoLogInfo("");
+
+ if(!pVideoServiceHandle)
+ {
+ VideoLogInfo("No exist Service handle data.");
+ return 0;
+ }
+
+ int nStartPositionTime = 0;
+ char *szStartPosTime = NULL;
+
+ if(service_get_extra_data(pVideoServiceHandle, szBundleKey, &szStartPosTime) != SERVICE_ERROR_NONE)
+ {
+ VideoLogInfo("No exist mime type.");
+ return 0;
+ }
+
+ if(!szStartPosTime)
+ {
+ VideoLogInfo("No exist pointer of position time.");
+ return 0;
+ }
+
+ nStartPositionTime = atoi(szStartPosTime);
+
+ VideoLogInfo("Start position time : %d", nStartPositionTime);
+
+ free(szStartPosTime);
+
+ if(nStartPositionTime < 0)
+ {
+ nStartPositionTime = 0;
+ }
+
+ return nStartPositionTime;
+}
+
bool MpVideoServiceCtrlGetTagNameOfGallery(service_h pVideoServiceHandle, char *szBundleKey, char *szTagName)
{
VideoLogInfo("");
}
bool nRet = TRUE;
- char *szVideoTagName = NULL; //char *szVideoTagName = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
+ char *szVideoTagName = NULL;
if(service_get_extra_data(pVideoServiceHandle, szBundleKey, &szVideoTagName) != SERVICE_ERROR_NONE)
{
return MP_VIDEO_PLAYER_SIMPLE;
}
- char *szLaunchingByOtherApp = NULL; //char *szLaunchingByOtherApp = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
+ char *szLaunchingByOtherApp = NULL;
if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_LAUNCHED_BY_APP_KEY, &szLaunchingByOtherApp) != SERVICE_ERROR_NONE)
{
if(!strcmp(szLaunchingByOtherApp, "gallery"))
{
nTmpLaunchingAppType = MP_VIDEO_PLAYER_GALLERY;
+
+ nGalleryLatestTime = MpVideoServiceCtrlCheckStartPositionTime(pVideoServiceHandle, MP_VIDEO_START_POS_TIME_KEY);
}
else if(!strcmp(szLaunchingByOtherApp, "image_viewer"))
{
return (int)nTmpLaunchingAppType;
}
+bool MpVideoServiceCtrlCheckShortcut(service_h pVideoServiceHandle)
+{
+ if(!pVideoServiceHandle)
+ {
+ VideoLogInfo("No exist Service handle.");
+ return FALSE;
+ }
+
+ VideoLogInfo("");
+
+ char *pGetOperation = NULL;
+
+ service_get_operation(pVideoServiceHandle, &pGetOperation);
+
+ if(pGetOperation == NULL)
+ {
+ bIsShortcutType = FALSE;
+ return bIsShortcutType;
+ }
+
+ if(!strcmp(pGetOperation, SERVICE_OPERATION_DEFAULT))
+ {
+ char *szOperationType = NULL;
+
+ if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_LAUNCH_TYPE, &szOperationType) != SERVICE_ERROR_NONE)
+ {
+ VideoLogInfo("No exist Service handle key of MP_VIDEO_LAUNCHED_BY_APP_KEY");
+ bIsShortcutType = FALSE;
+ }
+
+ if(!szOperationType)
+ {
+ VideoLogInfo("No exist pointer of szOperationType");
+ bIsShortcutType = FALSE;
+ }
+ else
+ {
+ if(!strcmp(szOperationType, MP_VIDEO_SHORTCUT_VIDEO))
+ {
+ bIsShortcutType = TRUE;
+ }
+ else
+ {
+ bIsShortcutType = FALSE;
+ }
+
+ if(szOperationType)
+ {
+ free(szOperationType);
+ szOperationType = NULL;
+ }
+ }
+ }
+
+ return bIsShortcutType;
+}
+
/////////////////////////////////////////////////////////////////////////////
pAppSvcHandle = NULL;
- memset(szStreamingCookie, 0, STR_LEN_MAX);
+ nGalleryLatestTime = 0;
+
+ if(g_szStreamingCookie)
+ {
+ free(g_szStreamingCookie);
+ g_szStreamingCookie = NULL;
+ }
}
-int MpVideoServiceCtrlInitServiceParser(void* pAppServiceHandle, char* szMediaUri)
+int MpVideoServiceCtrlInitServiceParser(void* pAppServiceHandle, char** szMediaUri)
{
if(!pAppServiceHandle)
{
MpVideoServiceCtrlReset();
pAppSvcHandle = (service_h)pAppServiceHandle;
+ nPlayerType = MP_NONE_VIEW_TYPE;
- if(!MpVideoServiceCtrlGetUri(pAppSvcHandle, szMediaUri))
+ if(!MpVideoServiceCtrlParseUri(pAppSvcHandle, szMediaUri))
{
- VideoLogInfo("MP_ERROR_PLAYER_TYPE");
- nPlayerType = MP_ERROR_PLAYER_TYPE;
- return nPlayerType;
+ VideoLogInfo("MP_VIDEO_PLAYER_LIST");
+ nPlayerType = MP_VIDEO_PLAYER;
}
- if(MpUtilIsXMLUrl(szMediaUri))
- {
- if(!MpUtilParsingXML(szMediaUri))
+ if(!*szMediaUri)
{
- VideoLogInfo("[ERR] Fail to get streaming URI path from XML.");
- nPlayerType = MP_ERROR_PLAYER_TYPE;
return nPlayerType;
}
-
- VideoLogInfo("MP_STREAMING_PLAYER");
- nPlayerType = MP_STREAMING_PLAYER;
- return nPlayerType;
+ else
+ {
+ VideoLogInfo("szMediaUri : %s", *szMediaUri);
}
- if(strlen(szMediaUri) > 0)
- {
- int nResultPlayerType = 0;
+ int nUriType = 0;
- nResultPlayerType = MpVideoServiceCtrlVideoUriType(szMediaUri);
+ nUriType = MpVideoServiceCtrlCheckUriType(*szMediaUri);
- if(nResultPlayerType == MP_ERROR_PLAYER_TYPE)
- {
- VideoLogInfo("MP_ERROR_PLAYER_TYPE");
- nPlayerType = MP_ERROR_PLAYER_TYPE;
- }
- else if(nResultPlayerType == MP_VIDEO_PLAYER)
+ if(nUriType == MP_VIDEO_PLAYER)
{
nPlayerType = MpVideoServiceCtrlCheckLauncher(pAppSvcHandle);
}
- else if(nResultPlayerType == MP_STREAMING_PLAYER)
+
+ if(nUriType == MP_STREAMING_PLAYER)
{
nPlayerType = MP_STREAMING_PLAYER;
- MpVideoServiceCtrlCheckCookieForStreaming(pAppSvcHandle, szStreamingCookie);
+ MpVideoServiceCtrlCheckCookieForStreaming(pAppSvcHandle);
}
- else
- {
+
+ return nPlayerType;
}
+
+int MpVideoServiceCtrlGetLatestTime(void)
+{
+ VideoLogInfo("");
+
+ if(nGalleryLatestTime < 0)
+ {
+ nGalleryLatestTime = 0;
}
- return nPlayerType;
+ return nGalleryLatestTime;
}
int MpVideoServiceCtrlGetPlayerTypeWithoutLog(void)
if(MP_ERROR_PLAYER_TYPE < nSetPlayerType || MP_MAX_PLAYER_TYPE > nSetPlayerType)
{
+ MpVideoServiceCtrlSetPrevPlayerType(nPlayerType);
nPlayerType = nSetPlayerType;
}
}
+int MpVideoServiceCtrlGetPrevPlayerType(void)
+{
+ VideoLogInfo("");
+
+ if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
+ {
+ nPrevPlayerType = MP_ERROR_PLAYER_TYPE;
+ }
+
+ VideoLogInfo("nPrevPlayerType : %d", nPrevPlayerType);
+
+ return nPrevPlayerType;
+}
+
+void MpVideoServiceCtrlSetPrevPlayerType(int nSetPlayerType)
+{
+ VideoLogInfo("nSetPlayerType : %d", nSetPlayerType);
+
+ if(MP_ERROR_PLAYER_TYPE < nSetPlayerType || MP_MAX_PLAYER_TYPE > nSetPlayerType)
+ {
+ nPrevPlayerType = nSetPlayerType;
+ }
+}
+
char* MpVideoServiceCtrlGetCookieForStreaming(void)
{
VideoLogInfo("");
- if(strlen(szStreamingCookie) < 1)
+ if(!g_szStreamingCookie)
{
VideoLogInfo("No exist streaming cookie.");
+ return NULL;
}
- return szStreamingCookie;
+ return g_szStreamingCookie;
}
\ No newline at end of file