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"
39 static service_h pAppSvcHandle = NULL;
40 static int nPlayerType = MP_VIDEO_PLAYER_SIMPLE;
41 static char szStreamingCookie[STR_LEN_MAX] = {0};
44 /////////////////////////////////////////////////////////////////////////////
47 bool MpVideoServiceCtrlCheckMime(service_h pVideoServiceHandle, char *szMediaUri)
51 if(!pVideoServiceHandle)
53 VideoLogInfo("[ERR] No Exist Service handle.");
59 VideoLogInfo("[ERR] No Exist media uri.");
64 char *szMimeContent = NULL;
66 if(service_get_extra_data(pVideoServiceHandle, AUL_K_MIME_CONTENT, &szMimeContent) != SERVICE_ERROR_NONE)
68 VideoLogInfo("No exist mime type.");
74 strncpy(szMediaUri, szMimeContent, STR_LEN_MAX - 1);
75 VideoLogInfo("Mime content : %s", szMediaUri);
81 VideoLogInfo("No exist MIME type.");
88 bool MpVideoServiceCtrlCheckBundle(service_h pVideoServiceHandle, char *szMediaUri)
90 if(!pVideoServiceHandle)
92 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
97 char *pStrVideoURI = NULL;
99 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_URI_PATH, &pStrVideoURI) != SERVICE_ERROR_NONE)
101 VideoLogInfo("[ERR] No exist KEY of video/streaming URI.");
107 strncpy(szMediaUri, pStrVideoURI, STR_LEN_MAX - 1);
108 VideoLogInfo("Video/Streaming URI path : %s", szMediaUri);
114 VideoLogInfo("[ERR] No exist video/streaming URI.");
121 bool MpVideoServiceCtrlCheckAUL(service_h pVideoServiceHandle, char *szMediaUri)
123 if(!pVideoServiceHandle)
125 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
129 char *pStrVideoURI = (char*)malloc(sizeof(char) * STR_LEN_MAX);
130 char *pGetOperation = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
132 service_get_operation(pVideoServiceHandle, &pGetOperation);
133 if(!strcmp(SERVICE_OPERATION_VIEW , pGetOperation))
135 service_get_uri(pVideoServiceHandle, &pStrVideoURI);
136 if(strlen(pStrVideoURI) > 1)
138 strncpy(szMediaUri, pStrVideoURI, STR_LEN_MAX - 1);
142 VideoLogInfo("[ERR] No exist video/streaming URI.");
148 VideoLogInfo("[ERR] No exist Operation.");
152 VideoLogInfo("Video/Streaming URI path pStrVideoURI : %s", pStrVideoURI);
153 VideoLogInfo("Video/Streaming URI path pAppData->szMediaUri : %s", szMediaUri);
161 bool MpVideoServiceCtrlIsXMLUrl(char *szMediaUri)
163 VideoLogInfo("URI : %s", szMediaUri);
165 if (!g_str_has_suffix(szMediaUri, ".xml")) {
166 VideoLogInfo("No have xml uri.");
173 bool MpVideoServiceCtrlGetUri(service_h pVideoServiceHandle, char* szMediaUri)
177 if(!MpVideoServiceCtrlCheckMime(pVideoServiceHandle, szMediaUri))
179 if(!MpVideoServiceCtrlCheckBundle(pVideoServiceHandle, szMediaUri))
181 if(!MpVideoServiceCtrlCheckAUL(pVideoServiceHandle, szMediaUri))
183 VideoLogInfo("No exist URI path.");
189 VideoLogInfo("szMediaUri", szMediaUri);
194 int MpVideoServiceCtrlVideoUriType(char* szMediaUri)
196 if(szMediaUri == NULL)
198 VideoLogInfo("[ERR]");
199 return MP_ERROR_PLAYER_TYPE;
206 if(strlen(szMediaUri) > 0)
208 if(MpUtilCheckPlayerType(szMediaUri))
210 VideoLogInfo("MP_STREAMING_PLAYER");
211 nRet = MP_STREAMING_PLAYER;
215 VideoLogInfo("MP_VIDEO_PLAYER");
216 nRet = MP_VIDEO_PLAYER;
221 VideoLogInfo("[ERR] No exist video/streaming URI. : MP_ERROR_PLAYER_TYPE");
222 return MP_ERROR_PLAYER_TYPE;
225 VideoLogInfo("pAppData->szMediaUri : %s", szMediaUri);
230 bool MpVideoServiceCtrlCheckCookieForStreaming(service_h pVideoServiceHandle, char* szCookie)
232 if(!pVideoServiceHandle)
234 VideoLogInfo("[ERR] No exist pBundleData pointer or Service handle count value.");
240 VideoLogInfo("[ERR] No allocate szCookie.");
245 char *pStrVideoCookie = NULL;
247 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_COOKIE, &pStrVideoCookie) != SERVICE_ERROR_NONE)
249 VideoLogInfo("[ERR] No exist KEY of streaming COOKIE.");
255 strncpy(szCookie, pStrVideoCookie, STR_LEN_MAX - 1);
256 VideoLogInfo("Video/Streaming URI path Cookie : %s", szCookie);
257 free(pStrVideoCookie);
262 VideoLogInfo("[ERR] No exist video/streaming URI.");
269 bool MpVideoServiceCtrlGetTagNameOfGallery(service_h pVideoServiceHandle, char *szBundleKey, char *szTagName)
273 if(!pVideoServiceHandle)
275 VideoLogInfo("No exist Service handle.");
281 VideoLogInfo("No exist Service handle kay.");
287 VideoLogInfo("No exist pAppData.");
292 char *szVideoTagName = NULL; //char *szVideoTagName = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
294 if(service_get_extra_data(pVideoServiceHandle, szBundleKey, &szVideoTagName) != SERVICE_ERROR_NONE)
296 VideoLogInfo("No exist mime type.");
302 strncpy(szTagName, szVideoTagName, STR_LEN_MAX - 1);
303 VideoLogInfo("szTagName : %s", szTagName);
304 free(szVideoTagName);
309 VideoLogInfo("No exist pointer of szVideoTagName.");
316 int MpVideoServiceCtrlCheckLauncher(service_h pVideoServiceHandle)
320 if(!pVideoServiceHandle)
322 VideoLogInfo("No exist Service handle data.");
323 return MP_VIDEO_PLAYER_SIMPLE;
326 char *szLaunchingByOtherApp = NULL; //char *szLaunchingByOtherApp = (char*)malloc(sizeof(char) * SVC_LEN_MAX);
328 if(service_get_extra_data(pVideoServiceHandle, MP_VIDEO_LAUNCHED_BY_APP_KEY, &szLaunchingByOtherApp) != SERVICE_ERROR_NONE)
330 VideoLogInfo("No exist Service handle key of MP_VIDEO_LAUNCHED_BY_APP_KEY");
331 return MP_VIDEO_PLAYER_SIMPLE;
334 if(!szLaunchingByOtherApp)
336 VideoLogInfo("No exist pointer of szLaunchingByOtherApp");
337 return MP_VIDEO_PLAYER_SIMPLE;
340 MpPlayerViewType nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
342 if(!strcmp(szLaunchingByOtherApp, "gallery"))
344 nTmpLaunchingAppType = MP_VIDEO_PLAYER_GALLERY;
346 else if(!strcmp(szLaunchingByOtherApp, "image_viewer"))
348 nTmpLaunchingAppType = MP_VIDEO_PLAYER_GALLERY;
350 else if(!strcmp(szLaunchingByOtherApp, "email"))
352 nTmpLaunchingAppType = MP_VIDEO_PLAYER_EMAIL;
354 else if(!strcmp(szLaunchingByOtherApp, "message"))
356 nTmpLaunchingAppType = MP_VIDEO_PLAYER_MMS;
358 else if(!strcmp(szLaunchingByOtherApp, "light_play_view"))
360 nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
364 nTmpLaunchingAppType = MP_VIDEO_PLAYER_SIMPLE;
367 VideoLogInfo("Start position time : %d", nTmpLaunchingAppType);
369 free(szLaunchingByOtherApp);
371 return (int)nTmpLaunchingAppType;
376 /////////////////////////////////////////////////////////////////////////////
379 void MpVideoServiceCtrlReset(void)
383 pAppSvcHandle = NULL;
385 memset(szStreamingCookie, 0, STR_LEN_MAX);
388 int MpVideoServiceCtrlInitServiceParser(void* pAppServiceHandle, char* szMediaUri)
390 if(!pAppServiceHandle)
393 return MP_ERROR_PLAYER_TYPE;
398 MpVideoServiceCtrlReset();
400 pAppSvcHandle = (service_h)pAppServiceHandle;
402 if(!MpVideoServiceCtrlGetUri(pAppSvcHandle, szMediaUri))
404 VideoLogInfo("MP_ERROR_PLAYER_TYPE");
405 nPlayerType = MP_ERROR_PLAYER_TYPE;
409 if(MpUtilIsXMLUrl(szMediaUri))
411 if(!MpUtilParsingXML(szMediaUri))
413 VideoLogInfo("[ERR] Fail to get streaming URI path from XML.");
414 nPlayerType = MP_ERROR_PLAYER_TYPE;
418 VideoLogInfo("MP_STREAMING_PLAYER");
419 nPlayerType = MP_STREAMING_PLAYER;
423 if(strlen(szMediaUri) > 0)
425 int nResultPlayerType = 0;
427 nResultPlayerType = MpVideoServiceCtrlVideoUriType(szMediaUri);
429 if(nResultPlayerType == MP_ERROR_PLAYER_TYPE)
431 VideoLogInfo("MP_ERROR_PLAYER_TYPE");
432 nPlayerType = MP_ERROR_PLAYER_TYPE;
434 else if(nResultPlayerType == MP_VIDEO_PLAYER)
436 nPlayerType = MpVideoServiceCtrlCheckLauncher(pAppSvcHandle);
438 else if(nResultPlayerType == MP_STREAMING_PLAYER)
440 nPlayerType = MP_STREAMING_PLAYER;
441 MpVideoServiceCtrlCheckCookieForStreaming(pAppSvcHandle, szStreamingCookie);
451 int MpVideoServiceCtrlGetPlayerTypeWithoutLog(void)
453 if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
455 nPlayerType = MP_ERROR_PLAYER_TYPE;
461 int MpVideoServiceCtrlGetPlayerType(void)
465 if(MP_ERROR_PLAYER_TYPE > nPlayerType || MP_MAX_PLAYER_TYPE < nPlayerType)
467 nPlayerType = MP_ERROR_PLAYER_TYPE;
470 VideoLogInfo("nPlayerType : %d", nPlayerType);
475 void MpVideoServiceCtrlSetPlayerType(int nSetPlayerType)
477 VideoLogInfo("nSetPlayerType : %d", nSetPlayerType);
479 if(MP_ERROR_PLAYER_TYPE < nSetPlayerType || MP_MAX_PLAYER_TYPE > nSetPlayerType)
481 nPlayerType = nSetPlayerType;
485 char* MpVideoServiceCtrlGetCookieForStreaming(void)
489 if(strlen(szStreamingCookie) < 1)
491 VideoLogInfo("No exist streaming cookie.");
494 return szStreamingCookie;