2 * 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.
4 * Copyright [2012] [JongDong Lee <jongdong.lee@samsung.com>, ChangSun Lee <cs78.lee@samsung.com>]
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.tizenopensource.org/license
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
25 #include "mp-video-log.h"
26 #include "mp-video-service-ctrl.h"
29 #define MP_VIDEO_LAUNCHED_BY_APP_KEY "launching_application"
30 #define MP_VIDEO_SORT_TYPE_KEY "order_type"
31 #define MP_VIDEO_LIST_TYPE_KEY "video_list_type"
32 #define MP_VIDEO_TAG_NAME_KEY "tag_name"
33 #define MP_VIDEO_EDIT_MODE_KEY "edit_mode"
34 #define MP_VIDEO_START_POS_TIME_KEY "start_pos_time"
35 #define MP_VIDEO_URI_PATH "path"
36 #define MP_VIDEO_COOKIE "cookie"
37 #define MP_VIDEO_MULTI_WIN_TYPE_KEY "is_multi_win_type"
38 #define MP_VIDEO_LAUNCH_TYPE "launch-type"
39 #define MP_VIDEO_SHORTCUT_VIDEO "shortcut-videoplayer"
41 static service_h pAppSvcHandle = NULL;
42 static int nPlayerType = MP_NONE_VIEW_TYPE;
43 static int nPrevPlayerType = MP_NONE_VIEW_TYPE;
44 static int nGalleryLatestTime = 0;
45 static char *g_szStreamingCookie = NULL;
46 static bool bIsShortcutType = FALSE;
49 /////////////////////////////////////////////////////////////////////////////
52 bool MpVideoServiceCtrlCheckMime(service_h pVideoServiceHandle, char **szMediaUri)
56 if(!pVideoServiceHandle)
58 VideoLogInfo("[ERR] No Exist Service handle.");
63 char *szMimeContent = NULL;
65 if(service_get_extra_data(pVideoServiceHandle, AUL_K_MIME_CONTENT, &szMimeContent) != SERVICE_ERROR_NONE)
67 VideoLogInfo("No exist mime type.");
73 *szMediaUri = (char*)malloc(strlen(szMimeContent) + 1);
74 memset(*szMediaUri, 0, strlen(szMimeContent) + 1);
75 strncpy(*szMediaUri, szMimeContent, strlen(szMimeContent));
76 VideoLogInfo("Mime content : %s", *szMediaUri);
82 VideoLogInfo("No exist MIME type.");
89 bool MpVideoServiceCtrlCheckBundle(service_h pVideoServiceHandle, char **szMediaUri)
91 if(!pVideoServiceHandle)
93 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
98 char *szStrVideoURI = NULL;
100 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_URI_PATH, &szStrVideoURI) != SERVICE_ERROR_NONE)
102 VideoLogInfo("No exist KEY of video/streaming URI.");
109 *szMediaUri = (char*)malloc(strlen(szStrVideoURI) + 1);
110 memset(*szMediaUri, 0, strlen(szStrVideoURI) + 1);
111 strncpy(*szMediaUri, szStrVideoURI, strlen(szStrVideoURI));
112 VideoLogInfo("Video/Streaming URI path : %s", *szMediaUri);
114 szStrVideoURI = NULL;
119 VideoLogInfo("No exist video/streaming URI.");
126 bool MpVideoServiceCtrlCheckAUL(service_h pVideoServiceHandle, char **szMediaUri)
128 if(!pVideoServiceHandle)
130 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
135 char *pGetOperation = NULL;
137 service_get_operation(pVideoServiceHandle, &pGetOperation);
139 if(pGetOperation == NULL)
144 if(!strcmp(SERVICE_OPERATION_VIEW , pGetOperation))
146 char *szStrVideoURI = NULL;
148 service_get_uri(pVideoServiceHandle, &szStrVideoURI);
152 *szMediaUri = (char*)malloc(strlen(szStrVideoURI) + 1);
153 memset(*szMediaUri, 0, strlen(szStrVideoURI) + 1);
154 strncpy(*szMediaUri, szStrVideoURI, strlen(szStrVideoURI));
155 VideoLogInfo("Video/Streaming URI path : %s", *szMediaUri);
157 szStrVideoURI = NULL;
161 VideoLogInfo("[ERR] No exist video/streaming URI.");
166 pGetOperation = NULL;
174 VideoLogInfo("No exist Operation.");
179 pGetOperation = NULL;
185 VideoLogInfo("Video/Streaming URI path pAppData->szMediaUri : %s", *szMediaUri);
190 pGetOperation = NULL;
197 bool MpVideoServiceCtrlParseUri(service_h pVideoServiceHandle, char** szMediaUri)
201 if(!MpVideoServiceCtrlCheckMime(pVideoServiceHandle, szMediaUri))
203 if(!MpVideoServiceCtrlCheckBundle(pVideoServiceHandle, szMediaUri))
205 if(!MpVideoServiceCtrlCheckAUL(pVideoServiceHandle, szMediaUri))
207 VideoLogInfo("No exist URI path.");
213 VideoLogInfo("szMediaUri : %s", *szMediaUri);
218 int MpVideoServiceCtrlCheckUriType(char* szMediaUri)
222 VideoLogInfo("[ERR] No exist media uri.");
223 return MP_ERROR_PLAYER_TYPE;
230 if(MpUtilCheckUriType(szMediaUri))
232 VideoLogInfo("MP_STREAMING_PLAYER");
233 nRet = MP_STREAMING_PLAYER;
237 VideoLogInfo("MP_VIDEO_PLAYER");
238 nRet = MP_VIDEO_PLAYER;
244 bool MpVideoServiceCtrlCheckCookieForStreaming(service_h pVideoServiceHandle)
246 if(!pVideoServiceHandle)
248 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
253 char *pStrVideoCookie = NULL;
255 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_COOKIE, &pStrVideoCookie) != SERVICE_ERROR_NONE)
257 VideoLogInfo("[ERR] No exist KEY of streaming COOKIE.");
263 g_szStreamingCookie = (char*)malloc(strlen(pStrVideoCookie) + 1);
264 memset(g_szStreamingCookie, 0, strlen(pStrVideoCookie) + 1);
265 strncpy(g_szStreamingCookie, pStrVideoCookie, strlen(pStrVideoCookie));
266 VideoLogInfo("Video/Streaming URI path Cookie : %s", g_szStreamingCookie);
267 free(pStrVideoCookie);
271 VideoLogInfo("[ERR] No exist video/streaming URI.");
278 int MpVideoServiceCtrlCheckStartPositionTime(service_h pVideoServiceHandle, char *szBundleKey)
282 if(!pVideoServiceHandle)
284 VideoLogInfo("No exist Service handle data.");
288 int nStartPositionTime = 0;
289 char *szStartPosTime = NULL;
291 if(service_get_extra_data(pVideoServiceHandle, szBundleKey, &szStartPosTime) != SERVICE_ERROR_NONE)
293 VideoLogInfo("No exist mime type.");
299 VideoLogInfo("No exist pointer of position time.");
303 nStartPositionTime = atoi(szStartPosTime);
305 VideoLogInfo("Start position time : %d", nStartPositionTime);
307 free(szStartPosTime);
309 if(nStartPositionTime < 0)
311 nStartPositionTime = 0;
314 return nStartPositionTime;
317 bool MpVideoServiceCtrlGetTagNameOfGallery(service_h pVideoServiceHandle, char *szBundleKey, char *szTagName)
321 if(!pVideoServiceHandle)
323 VideoLogInfo("No exist Service handle.");
329 VideoLogInfo("No exist Service handle kay.");
335 VideoLogInfo("No exist pAppData.");
340 char *szVideoTagName = NULL;
342 if(service_get_extra_data(pVideoServiceHandle, szBundleKey, &szVideoTagName) != SERVICE_ERROR_NONE)
344 VideoLogInfo("No exist mime type.");
350 strncpy(szTagName, szVideoTagName, STR_LEN_MAX - 1);
351 VideoLogInfo("szTagName : %s", szTagName);
352 free(szVideoTagName);
357 VideoLogInfo("No exist pointer of szVideoTagName.");
364 int MpVideoServiceCtrlCheckLauncher(service_h pVideoServiceHandle)
368 if(!pVideoServiceHandle)
370 VideoLogInfo("No exist Service handle data.");
371 return MP_VIDEO_PLAYER_SIMPLE;
374 char *szLaunchingByOtherApp = NULL;
376 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_LAUNCHED_BY_APP_KEY, &szLaunchingByOtherApp) != SERVICE_ERROR_NONE)
378 VideoLogInfo("No exist Service handle key of MP_VIDEO_LAUNCHED_BY_APP_KEY");
379 return MP_VIDEO_PLAYER_SIMPLE;
382 if(!szLaunchingByOtherApp)
384 VideoLogInfo("No exist pointer of szLaunchingByOtherApp");
385 return MP_VIDEO_PLAYER_SIMPLE;
388 MpPlayerViewType nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
390 if(!strcmp(szLaunchingByOtherApp, "gallery"))
392 nTmpLaunchingAppType = MP_VIDEO_PLAYER_GALLERY;
394 nGalleryLatestTime = MpVideoServiceCtrlCheckStartPositionTime(pVideoServiceHandle, MP_VIDEO_START_POS_TIME_KEY);
396 else if(!strcmp(szLaunchingByOtherApp, "image_viewer"))
398 nTmpLaunchingAppType = MP_VIDEO_PLAYER_GALLERY;
400 else if(!strcmp(szLaunchingByOtherApp, "email"))
402 nTmpLaunchingAppType = MP_VIDEO_PLAYER_EMAIL;
404 else if(!strcmp(szLaunchingByOtherApp, "message"))
406 nTmpLaunchingAppType = MP_VIDEO_PLAYER_MMS;
408 else if(!strcmp(szLaunchingByOtherApp, "light_play_view"))
410 nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
414 nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
417 VideoLogInfo("Start position time : %d", nTmpLaunchingAppType);
419 free(szLaunchingByOtherApp);
421 return (int)nTmpLaunchingAppType;
424 bool MpVideoServiceCtrlCheckShortcut(service_h pVideoServiceHandle)
426 if(!pVideoServiceHandle)
428 VideoLogInfo("No exist Service handle.");
434 char *pGetOperation = NULL;
436 service_get_operation(pVideoServiceHandle, &pGetOperation);
438 if(pGetOperation == NULL)
440 bIsShortcutType = FALSE;
441 return bIsShortcutType;
444 if(!strcmp(pGetOperation, SERVICE_OPERATION_DEFAULT))
446 char *szOperationType = NULL;
448 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_LAUNCH_TYPE, &szOperationType) != SERVICE_ERROR_NONE)
450 VideoLogInfo("No exist Service handle key of MP_VIDEO_LAUNCHED_BY_APP_KEY");
451 bIsShortcutType = FALSE;
456 VideoLogInfo("No exist pointer of szOperationType");
457 bIsShortcutType = FALSE;
461 if(!strcmp(szOperationType, MP_VIDEO_SHORTCUT_VIDEO))
463 bIsShortcutType = TRUE;
467 bIsShortcutType = FALSE;
472 free(szOperationType);
473 szOperationType = NULL;
478 return bIsShortcutType;
483 /////////////////////////////////////////////////////////////////////////////
486 void MpVideoServiceCtrlReset(void)
490 pAppSvcHandle = NULL;
492 nGalleryLatestTime = 0;
494 if(g_szStreamingCookie)
496 free(g_szStreamingCookie);
497 g_szStreamingCookie = NULL;
501 int MpVideoServiceCtrlInitServiceParser(void* pAppServiceHandle, char** szMediaUri)
503 if(!pAppServiceHandle)
506 return MP_ERROR_PLAYER_TYPE;
511 MpVideoServiceCtrlReset();
513 pAppSvcHandle = (service_h)pAppServiceHandle;
514 nPlayerType = MP_NONE_VIEW_TYPE;
516 if(!MpVideoServiceCtrlParseUri(pAppSvcHandle, szMediaUri))
518 VideoLogInfo("MP_VIDEO_PLAYER_LIST");
519 nPlayerType = MP_VIDEO_PLAYER;
528 VideoLogInfo("szMediaUri : %s", *szMediaUri);
533 nUriType = MpVideoServiceCtrlCheckUriType(*szMediaUri);
535 if(nUriType == MP_VIDEO_PLAYER)
537 nPlayerType = MpVideoServiceCtrlCheckLauncher(pAppSvcHandle);
540 if(nUriType == MP_STREAMING_PLAYER)
542 nPlayerType = MP_STREAMING_PLAYER;
543 MpVideoServiceCtrlCheckCookieForStreaming(pAppSvcHandle);
549 int MpVideoServiceCtrlGetLatestTime(void)
553 if(nGalleryLatestTime < 0)
555 nGalleryLatestTime = 0;
558 return nGalleryLatestTime;
561 int MpVideoServiceCtrlGetPlayerTypeWithoutLog(void)
563 if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
565 nPlayerType = MP_ERROR_PLAYER_TYPE;
571 int MpVideoServiceCtrlGetPlayerType(void)
575 if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
577 nPlayerType = MP_ERROR_PLAYER_TYPE;
580 VideoLogInfo("nPlayerType : %d", nPlayerType);
585 void MpVideoServiceCtrlSetPlayerType(int nSetPlayerType)
587 VideoLogInfo("nSetPlayerType : %d", nSetPlayerType);
589 if(MP_ERROR_PLAYER_TYPE < nSetPlayerType || MP_MAX_PLAYER_TYPE > nSetPlayerType)
591 MpVideoServiceCtrlSetPrevPlayerType(nPlayerType);
592 nPlayerType = nSetPlayerType;
596 int MpVideoServiceCtrlGetPrevPlayerType(void)
600 if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
602 nPrevPlayerType = MP_ERROR_PLAYER_TYPE;
605 VideoLogInfo("nPrevPlayerType : %d", nPrevPlayerType);
607 return nPrevPlayerType;
610 void MpVideoServiceCtrlSetPrevPlayerType(int nSetPlayerType)
612 VideoLogInfo("nSetPlayerType : %d", nSetPlayerType);
614 if(MP_ERROR_PLAYER_TYPE < nSetPlayerType || MP_MAX_PLAYER_TYPE > nSetPlayerType)
616 nPrevPlayerType = nSetPlayerType;
620 char* MpVideoServiceCtrlGetCookieForStreaming(void)
624 if(!g_szStreamingCookie)
626 VideoLogInfo("No exist streaming cookie.");
630 return g_szStreamingCookie;