apply FSL(Flora Software License)
[apps/core/preloaded/video-player.git] / src / mp-video-player-mgr.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *     http://www.tizenopensource.org/license
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <mm.h>
18 #include <mm_error.h>
19 #include <mm_sound.h>
20
21 #include <string.h>
22 #include <stdlib.h>
23 #include <sys/stat.h>
24
25 #include "mp-video-log.h"
26 #include "mp-video-player-mgr.h"
27
28 #define MAX_PATH_LEN 2048
29
30 static int nAntiShock = 0;
31 static MMHandleType playerHandle = 0;
32
33 bool MpPlayerMgrIsActive(void)
34 {
35         return playerHandle ? true : false;
36 }
37
38 void MpPlayerMgrSetMessageCallback(MMMessageCallback Callback, void *pUserData)
39 {
40         VideoLogInfo("");
41
42         if (!pUserData) {
43                 VideoLogInfo("[ERR]");
44                 return;
45         }
46
47         if (!MpPlayerMgrIsActive()) {
48                 VideoLogInfo("[ERR]");
49                 return;
50         }
51
52         if (mm_player_set_message_callback(playerHandle, Callback, pUserData) !=
53             MM_ERROR_NONE) {
54                 VideoLogInfo("[ERR]");
55                 return;
56         }
57 }
58
59 bool MpPlayerMgrSetAudioCallback(mm_player_audio_stream_callback CallBack,
60                                  void *pUserData)
61 {
62         VideoLogInfo("");
63
64         if (!pUserData) {
65                 VideoLogInfo("[ERR]");
66                 return false;
67         }
68
69         if (!MpPlayerMgrIsActive()) {
70                 VideoLogInfo("[ERR]");
71                 return false;
72         }
73
74         if (mm_player_set_audio_stream_callback
75             (playerHandle, CallBack, pUserData) != MM_ERROR_NONE) {
76                 VideoLogInfo("[ERR]");
77                 return false;
78         }
79
80         return true;
81 }
82
83 bool MpPlayerMgrCreate(const char *szPath)
84 {
85         VideoLogInfo("");
86
87         if (!szPath) {
88                 VideoLogInfo("[ERR] Not correct Meida URI.");
89                 return false;
90         }
91
92         int nPathLength = strlen(szPath);
93         int nErr = MM_ERROR_NONE;
94         char *pErrName = NULL;
95
96         VideoLogInfo(" Media path (%s)", szPath);
97
98         if (nPathLength > 0 && nPathLength < MAX_PATH_LEN) {
99                 nErr = mm_player_create(&playerHandle);
100                 if (nErr != MM_ERROR_NONE) {
101                         VideoLogInfo
102                             ("[ERR] Fail to create player handle. (MMF Error code : %x)",
103                              nErr);
104                         return false;
105                 }
106
107                 nErr =
108                     mm_player_set_attribute(playerHandle, &pErrName,
109                                             "profile_uri", szPath,
110                                             strlen(szPath), NULL);
111
112                 if (nErr != MM_ERROR_NONE) {
113                         VideoLogInfo("[ERR] (%x):: Fail to set attribute ",
114                                      nErr, pErrName);
115                         free(pErrName);
116                         return false;
117                 }
118
119         } else {
120                 VideoLogInfo("[ERR] File path is too long.");
121                 return false;
122         }
123
124         if (nAntiShock) {
125                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
126                                                "sound_fadeup", 1, NULL);
127                 if (nErr != MM_ERROR_NONE) {
128                         VideoLogInfo("[ERR] (%x):: Fail to set attribute ",
129                                      nErr, pErrName);
130                         free(pErrName);
131                         return false;
132                 }
133                 nAntiShock = 0;
134         } else {
135                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
136                                                "sound_fadeup", 0, NULL);
137                 if (nErr != MM_ERROR_NONE) {
138                         VideoLogInfo("[ERR] (%x):: Fail to set attribute ",
139                                      nErr, pErrName);
140                         free(pErrName);
141                         return false;
142                 }
143                 nAntiShock = 1;
144         }
145
146         nErr = mm_player_set_attribute(playerHandle, &pErrName,
147                                        "sound_volume_type",
148                                        MM_SOUND_VOLUME_TYPE_MEDIA, NULL);
149         if (nErr != MM_ERROR_NONE) {
150                 VideoLogInfo("[ERR] (%x):: Fail to set attribute ", nErr,
151                              pErrName);
152                 free(pErrName);
153                 return false;
154         }
155
156         return true;
157 }
158
159 bool MpPlayerMgrDestroy(void)
160 {
161         VideoLogInfo("");
162
163         if (!MpPlayerMgrIsActive()) {
164                 VideoLogInfo("[ERR]");
165                 return false;
166         }
167
168         int nErr = mm_player_destroy(playerHandle);
169         if (nErr != MM_ERROR_NONE) {
170                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
171                 return false;
172         }
173
174         playerHandle = 0;
175
176         return true;
177 }
178
179 bool MpPlayerMgrRealize(void)
180 {
181         VideoLogInfo("");
182
183         if (!MpPlayerMgrIsActive()) {
184                 VideoLogInfo("[ERR]");
185                 return false;
186         }
187
188         int nErr = mm_player_realize(playerHandle);
189         if (nErr != MM_ERROR_NONE) {
190                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
191                 return false;
192         }
193
194         return true;
195 }
196
197 bool MpPlayerMgrUnrealize(void)
198 {
199         VideoLogInfo("");
200
201         if (!MpPlayerMgrIsActive()) {
202                 VideoLogInfo("[ERR]");
203                 return false;
204         }
205
206         int nErr = mm_player_unrealize(playerHandle);
207         if (nErr != MM_ERROR_NONE) {
208                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
209                 return false;
210         }
211
212         return true;
213 }
214
215 bool MpPlayerMgrPlay(void)
216 {
217         VideoLogInfo("");
218
219         if (!MpPlayerMgrIsActive()) {
220                 VideoLogInfo("[ERR]");
221                 return false;
222         }
223
224         int nErr = mm_player_start(playerHandle);
225         if (nErr != MM_ERROR_NONE) {
226                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
227                 return false;
228         }
229
230         return true;
231 }
232
233 bool MpPlayerMgrStop(void)
234 {
235         VideoLogInfo("");
236
237         if (!MpPlayerMgrIsActive()) {
238                 VideoLogInfo("[ERR]");
239                 return false;
240         }
241
242         int nErr = mm_player_stop(playerHandle);
243         if (nErr != MM_ERROR_NONE) {
244                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
245                 return false;
246         }
247
248         return true;
249 }
250
251 bool MpPlayerMgrResume(void)
252 {
253         VideoLogInfo("");
254
255         if (!MpPlayerMgrIsActive()) {
256                 VideoLogInfo("[ERR]");
257                 return false;
258         }
259
260         char *pErrName = NULL;
261         int nErr = MM_ERROR_NONE;
262
263         if (nAntiShock) {
264                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
265                                                "sound_fadeup", 1, NULL);
266                 if (nErr != MM_ERROR_NONE) {
267                         VideoLogInfo
268                             ("[ERR] Error code : 0x%x - Fail to set attribute ",
269                              nErr, pErrName);
270                         free(pErrName);
271                         return false;
272                 }
273
274                 nAntiShock = 0;
275         } else {
276                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
277                                                "sound_fadeup", 0, NULL);
278                 if (nErr != MM_ERROR_NONE) {
279                         VideoLogInfo
280                             ("[ERR] Error code : 0x%x - Fail to set attribute ",
281                              nErr, pErrName);
282                         free(pErrName);
283                         return false;
284                 }
285
286                 nAntiShock = 0;
287         }
288
289         nErr = mm_player_resume(playerHandle);
290         if (nErr != MM_ERROR_NONE) {
291                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
292                 return false;
293         }
294
295         return true;
296 }
297
298 bool MpPlayerMgrPause(void)
299 {
300         VideoLogInfo("");
301
302         if (!MpPlayerMgrIsActive()) {
303                 VideoLogInfo("[ERR]");
304                 return false;
305         }
306
307         int nErr = mm_player_pause(playerHandle);
308         if (nErr != MM_ERROR_NONE) {
309                 VideoLogInfo("[ERR] Error code : 0x%x", nErr);
310                 return false;
311         }
312
313         return true;
314 }
315
316 int MpPlayerMgrGetPosition(void)
317 {
318         if (!MpPlayerMgrIsActive()) {
319                 return 0;
320         }
321
322         int nPos = 0;
323         int nErr = 0;
324
325         nErr = mm_player_get_position(playerHandle, MM_PLAYER_POS_FORMAT_TIME,
326                                       &nPos);
327         if (nErr != MM_ERROR_NONE) {
328                 VideoLogInfo("[ERR] Error code : 0x%x ", nErr);
329                 return 0;
330         }
331
332         return nPos;
333 }
334
335 void MpPlayerMgrSetPosition(unsigned int nPos)
336 {
337         VideoLogInfo("");
338
339         if (!MpPlayerMgrIsActive()) {
340                 VideoLogInfo("[ERR]");
341                 return;
342         }
343
344         VideoLogInfo("Set position - %d", nPos);
345
346         int nErr = 0;
347
348         nErr = mm_player_set_position(playerHandle, MM_PLAYER_POS_FORMAT_TIME,
349                                       (int)nPos);
350         if (nErr != MM_ERROR_NONE) {
351                 VideoLogInfo("[ERR] Error code : 0x%x ", nErr);
352         }
353 }
354
355 bool MpPlayerMgrGetVisible(void)
356 {
357         VideoLogInfo("");
358
359         if (!MpPlayerMgrIsActive()) {
360                 VideoLogInfo("[ERR]");
361                 return false;
362         }
363
364         int nErr = MM_ERROR_NONE;
365         int nVisible = 0;
366         char *pErrName = NULL;
367
368         nErr =
369             mm_player_get_attribute(playerHandle, &pErrName, "display_visible",
370                                     &nVisible, NULL);
371         if (nErr != MM_ERROR_NONE) {
372                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute.",
373                              nErr, pErrName);
374                 free(pErrName);
375                 return false;
376         }
377
378         return (bool) nVisible;
379 }
380
381 void MpPlayerMgrSetVisible(bool bEnabled)
382 {
383         VideoLogInfo("");
384
385         if (!MpPlayerMgrIsActive()) {
386                 VideoLogInfo("[ERR]");
387                 return;
388         }
389
390         if (MpPlayerMgrGetVisible() == bEnabled) {
391                 VideoLogInfo("[ERR]");
392                 return;
393         }
394
395         int nErr = MM_ERROR_NONE;
396         char *pErrName = NULL;
397
398         nErr =
399             mm_player_set_attribute(playerHandle, &pErrName, "display_visible",
400                                     (int)bEnabled, NULL);
401         if (nErr != MM_ERROR_NONE) {
402                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
403                              nErr, pErrName);
404                 free(pErrName);
405         }
406 }
407
408 void MpPlayerMgrSetMute(bool bMuteEnable)
409 {
410         VideoLogInfo("");
411
412         if (!MpPlayerMgrIsActive()) {
413                 VideoLogInfo("[ERR]");
414                 return;
415         }
416
417         if (mm_player_set_mute(playerHandle, (int)bMuteEnable) != MM_ERROR_NONE) {
418                 VideoLogInfo("[ERR]");
419         }
420 }
421
422 bool MpPlayerMgrGetMute(void)
423 {
424         VideoLogInfo("");
425
426         if (!MpPlayerMgrIsActive()) {
427                 VideoLogInfo("[ERR]");
428                 return FALSE;
429         }
430
431         bool bIsMute = FALSE;
432
433         if (mm_player_get_mute(playerHandle, (int *)&bIsMute) != MM_ERROR_NONE) {
434                 VideoLogInfo("[ERR]");
435                 return FALSE;
436         }
437
438         return bIsMute;
439 }
440
441 bool MpPlayerMgrSetBtHeadset(bool bEnable, char *szAddress)
442 {
443         VideoLogInfo("");
444
445         VideoLogInfo("bt headset enable(%d)", bEnable);
446         VideoLogInfo("============================================");
447         VideoLogInfo("bluetooth headset enable(%d), addr(%s)", bEnable,
448                      szAddress);
449         VideoLogInfo("============================================");
450
451         if (!MpPlayerMgrIsActive()) {
452                 VideoLogInfo("[ERR]");
453                 return false;
454         }
455
456         MMBluetoothType BluetoothParam;
457         memset(&BluetoothParam, 0, sizeof(MMBluetoothType));
458
459         if (bEnable) {
460                 BluetoothParam.mode = 1;
461
462                 if (szAddress) {
463                         strncpy(BluetoothParam.addr, szAddress,
464                                 BT_ADDR_LEN - 1);
465                 } else {
466                         VideoLogInfo("[ERR]");
467                         return false;
468                 }
469
470                 VideoLogInfo("address : %s", szAddress);
471         }
472
473         return true;
474 }
475
476 int MpPlayerMgrGetStreamingType(void)
477 {
478         VideoLogInfo("");
479
480         if (!MpPlayerMgrIsActive()) {
481                 VideoLogInfo("[ERR]");
482                 return false;
483         }
484
485         int nErr = MM_ERROR_NONE;
486         char *pErrName = NULL;
487         int streaming_type = STREAMING_SERVICE_NONE;
488
489         nErr =
490             mm_player_get_attribute(playerHandle, &pErrName, "streaming_type",
491                                     &streaming_type, NULL);
492
493         if (nErr != MM_ERROR_NONE) {
494                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute ",
495                              nErr, pErrName);
496                 free(pErrName);
497                 return false;
498         }
499
500         return (int)streaming_type;
501 }
502
503 void MpPlayerMgrSetProgressiveDownload(int nFileSize)
504 {
505         VideoLogInfo("");
506
507         if (!MpPlayerMgrIsActive()) {
508                 VideoLogInfo("[ERR]");
509                 return;
510         }
511
512         int nErr = MM_ERROR_NONE;
513         char *pErrName = NULL;
514
515         nErr = mm_player_set_attribute(playerHandle, &pErrName, "pd_enable", 1,
516                                        "pd_full_content_size", nFileSize, NULL);
517         if (nErr != MM_ERROR_NONE) {
518                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
519                              nErr, pErrName);
520                 free(pErrName);
521         }
522 }
523
524 void MpPlayerMgrSetDownloadComplete(void)
525 {
526         VideoLogInfo("");
527
528         if (!MpPlayerMgrIsActive()) {
529                 VideoLogInfo("[ERR]");
530                 return;
531         }
532
533         int nErr = MM_ERROR_NONE;
534         char *pErrName = NULL;
535
536         nErr =
537             mm_player_set_attribute(playerHandle, &pErrName, "pd_down_complete",
538                                     1, NULL);
539         if (nErr != MM_ERROR_NONE) {
540                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
541                              nErr, pErrName);
542                 free(pErrName);
543         }
544 }
545
546 void MpPlayerMgrSetProgressTimerInterval(int nInterval)
547 {
548         VideoLogInfo("");
549
550         if (!MpPlayerMgrIsActive()) {
551                 VideoLogInfo("[ERR]");
552                 return;
553         }
554
555         char *pErrName = NULL;
556         int nErr = MM_ERROR_NONE;
557
558         nErr = mm_player_set_attribute(playerHandle, &pErrName,
559                                        "profile_progress_interval", nInterval,
560                                        NULL);
561         if (nErr != MM_ERROR_NONE) {
562                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
563                              nErr, pErrName);
564                 free(pErrName);
565         }
566 }
567
568 int MpPlayerMgrGetPdduration(void)
569 {
570         VideoLogInfo("");
571
572         if (!MpPlayerMgrIsActive()) {
573                 VideoLogInfo("[ERR]");
574                 return false;
575         }
576
577         int nDuration = -1;
578         char *pErrName = NULL;
579         int nErr = MM_ERROR_NONE;
580
581         nErr =
582             mm_player_get_attribute(playerHandle, &pErrName, "content_duration",
583                                     &nDuration, NULL);
584         if (nErr != MM_ERROR_NONE) {
585                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute ",
586                              nErr, pErrName);
587                 free(pErrName);
588                 return false;
589         }
590
591         return nDuration;
592 }
593
594 int MpPlayerMgrGetDuration(char *szFilePath)
595 {
596         VideoLogInfo("%s", szFilePath);
597
598         if (!MpPlayerMgrIsActive()) {
599                 VideoLogInfo("[ERR]");
600                 return false;
601         }
602
603         int nDuration = -1;
604         char *pErrName = NULL;
605         int nErr = MM_ERROR_NONE;
606
607         nErr =
608             mm_player_get_attribute(playerHandle, &pErrName, "content_duration",
609                                     &nDuration, NULL);
610         if (nErr != MM_ERROR_NONE) {
611                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute ",
612                              nErr, pErrName);
613                 free(pErrName);
614                 return false;
615         }
616
617         return nDuration;
618 }
619
620 bool MpPlayerMgrSetRatioVideoScreenSize(MpPlayerMgrDisplayMethod ScreenSize)
621 {
622         VideoLogInfo("Screen size : %d", ScreenSize);
623
624         if (!MpPlayerMgrIsActive()) {
625                 VideoLogInfo("[ERR]");
626                 return false;
627         }
628
629         char *pErrName = NULL;
630         int nErr = MM_ERROR_NONE;
631
632         nErr =
633             mm_player_set_attribute(playerHandle, &pErrName, "display_method",
634                                     ScreenSize, NULL);
635         if (nErr != MM_ERROR_NONE) {
636                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
637                              nErr, pErrName);
638                 free(pErrName);
639                 return false;
640         }
641
642         return true;
643 }
644
645 bool MpPlayerMgrSetOverlayXid(void *pOverlayXid)
646 {
647         if (!MpPlayerMgrIsActive()) {
648                 VideoLogInfo("[ERR]");
649                 return false;
650         }
651
652         if (!pOverlayXid) {
653                 VideoLogInfo("[ERR]");
654                 return false;
655         }
656
657         int nErr = MM_ERROR_NONE;
658         char *pErrName = NULL;
659
660         VideoLogInfo("XID : %d", *((int *)pOverlayXid));
661
662         nErr =
663             mm_player_set_attribute(playerHandle, &pErrName, "display_overlay",
664                                     pOverlayXid, sizeof(int),
665                                     "display_rotation",
666                                     MM_DISPLAY_ROTATION_NONE, NULL);
667
668         if (nErr != MM_ERROR_NONE) {
669                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
670                              nErr, pErrName);
671                 free(pErrName);
672                 return false;
673         }
674
675         return true;
676 }
677
678 bool MpPlayerMgrSetSoundPriority(void)
679 {
680         VideoLogInfo("");
681
682         if (!MpPlayerMgrIsActive()) {
683                 VideoLogInfo("[ERR]");
684                 return false;
685         }
686
687         char *pErrName = NULL;
688         int nErr = MM_ERROR_NONE;
689
690         nErr = mm_player_set_attribute(playerHandle, &pErrName,
691                                        "sound_volume_type",
692                                        MM_SOUND_VOLUME_TYPE_MEDIA, NULL);
693         if (nErr != MM_ERROR_NONE) {
694                 VideoLogInfo
695                     ("[ERR] Error code : 0x%x -  Fail to set attribute ", nErr,
696                      pErrName);
697                 free(pErrName);
698                 return false;
699         }
700
701         return true;
702 }
703
704 int MpPlayerMgrGetVideoWidthResolution(void)
705 {
706         VideoLogInfo("");
707
708         if (!MpPlayerMgrIsActive()) {
709                 VideoLogInfo("[ERR]");
710                 return false;
711         }
712
713         char *pErrName = NULL;
714         int nWidth = 0;
715         int nErr = MM_ERROR_NONE;
716
717         nErr = mm_player_get_attribute(playerHandle, &pErrName,
718                                        "content_video_width", &nWidth, NULL);
719         if (nErr != MM_ERROR_NONE) {
720                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute ",
721                              nErr, pErrName);
722                 free(pErrName);
723                 return false;
724         }
725
726         return nWidth;
727 }
728
729 int MpPlayerMgrGetVideoHeightResolution(void)
730 {
731         VideoLogInfo("");
732
733         if (!MpPlayerMgrIsActive()) {
734                 VideoLogInfo("[ERR]");
735                 return false;
736         }
737
738         char *pErrName = NULL;
739         int nHeight = 0;
740         int nErr = MM_ERROR_NONE;
741
742         nErr = mm_player_get_attribute(playerHandle, &pErrName,
743                                        "content_video_height", &nHeight, NULL);
744         if (nErr != MM_ERROR_NONE) {
745                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to get attribute ",
746                              nErr, pErrName);
747                 free(pErrName);
748                 return false;
749         }
750
751         return nHeight;
752 }
753
754 bool MpPlayerMgrSetSubtitleSilent(bool bSilent)
755 {
756         VideoLogInfo("");
757
758         if (!MpPlayerMgrIsActive()) {
759                 VideoLogInfo("[ERR]");
760                 return false;
761         }
762
763         int nErr = mm_player_set_subtitle_silent(playerHandle, (int)bSilent);
764         if (nErr != MM_ERROR_NONE) {
765                 VideoLogInfo("[ERR] Error code : 0x%x - ", nErr);
766                 return false;
767         }
768
769         return true;
770 }
771
772 bool MpPlayerMgrSetSubtitle(const char *szSubtitlePath)
773 {
774         VideoLogInfo("%s", szSubtitlePath);
775
776         if (!MpPlayerMgrIsActive()) {
777                 VideoLogInfo("[ERR]");
778                 return false;
779         }
780
781         if (!szSubtitlePath) {
782                 VideoLogInfo("[ERR] subtitle path is null.");
783                 return false;
784         }
785
786         char *pErrName = NULL;
787
788         int nErr = 0;
789         nErr = mm_player_set_attribute(playerHandle, &pErrName, "subtitle_uri",
790                                        (const char *)szSubtitlePath,
791                                        strlen(szSubtitlePath), NULL);
792         if (nErr != MM_ERROR_NONE) {
793                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
794                              nErr, pErrName);
795                 free(pErrName);
796                 return false;
797         } else {
798                 VideoLogInfo("Success to set subtitle.");
799         }
800
801         return true;
802 }
803
804 int MpPlayerMgrSetBluetoothHeadset(char *szBlutoothAddress, int nMode)
805 {
806         VideoLogInfo("");
807
808         return 1;
809 }
810
811 int MpPlayerMgrSetDisplayArea(int nX, int nY, int nWidth, int nHeight)
812 {
813         VideoLogInfo("");
814
815         if (!MpPlayerMgrIsActive()) {
816                 VideoLogInfo("[ERR]");
817                 return false;
818         }
819
820         char *pErrName = NULL;
821
822         int nErr = 0;
823         nErr = mm_player_set_attribute(playerHandle, &pErrName, "display_roi_x",
824                                        nX, "display_roi_y", nY,
825                                        "display_roi_width", nWidth,
826                                        "display_roi_height", nHeight, NULL);
827         if (nErr != MM_ERROR_NONE) {
828                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
829                              nErr, pErrName);
830                 free(pErrName);
831                 return false;
832         }
833
834         return true;
835 }
836
837 int MpPlayerMgrSetVerticalOverlayPos(int nY)
838 {
839         VideoLogInfo("");
840
841         if (!MpPlayerMgrIsActive()) {
842                 VideoLogInfo("[ERR]");
843                 return false;
844         }
845
846         char *pErrName = NULL;
847
848         int nErr = 0;
849         nErr = mm_player_set_attribute(playerHandle, &pErrName, "display_roi_y",
850                                        nY, NULL);
851         if (nErr != MM_ERROR_NONE) {
852                 VideoLogInfo("[ERR] Error code : 0x%x - Fail to set attribute ",
853                              nErr, pErrName);
854                 free(pErrName);
855                 return false;
856         }
857
858         return true;
859 }
860
861 bool MpPlayerMgrSetUseragentForStreaming(const char *szUserAgent)
862 {
863         VideoLogInfo("");
864
865         if (!MpPlayerMgrIsActive()) {
866                 VideoLogInfo("[ERR]");
867                 return false;
868         }
869
870         if (!szUserAgent) {
871                 VideoLogInfo("[ERR]");
872                 return false;
873         }
874
875         int nErr = MM_ERROR_NONE;
876         char *pErrName = NULL;
877
878         if (strlen(szUserAgent) > 0) {
879                 VideoLogInfo("User agent (%s)", szUserAgent);
880                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
881                                                "streaming_user_agent",
882                                                szUserAgent, strlen(szUserAgent),
883                                                NULL);
884
885                 if (nErr != MM_ERROR_NONE) {
886                         VideoLogInfo("[ERR] (%x):: Fail to set attribute [%s]",
887                                      nErr, pErrName);
888                         free(pErrName);
889                         return false;
890                 }
891         } else {
892                 VideoLogInfo("No have useragnet value.");
893                 return true;
894         }
895
896         return true;
897 }
898
899 bool MpPlayerMgrSetProxAddressForStreaming(const char *szProxyAddress)
900 {
901         VideoLogInfo("");
902
903         if (!MpPlayerMgrIsActive()) {
904                 VideoLogInfo("[ERR]");
905                 return false;
906         }
907
908         if (!szProxyAddress) {
909                 VideoLogInfo("[ERR]");
910                 return false;
911         }
912
913         int nErr = MM_ERROR_NONE;
914         char *pErrName = NULL;
915
916         if (strlen(szProxyAddress) > 0) {
917                 VideoLogInfo("Proxy Setting (%s)", szProxyAddress);
918                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
919                                                "streaming_proxy",
920                                                szProxyAddress,
921                                                strlen(szProxyAddress), NULL);
922
923                 if (nErr != MM_ERROR_NONE) {
924                         VideoLogInfo("[ERR] (%x):: Fail to set attribute [%s]",
925                                      nErr, pErrName);
926                         free(pErrName);
927                         return false;
928                 }
929         }
930         return true;
931 }
932
933 bool MpPlayerMgrSetCookieForStreaming(const char *szCookie)
934 {
935         VideoLogInfo("");
936
937         if (!MpPlayerMgrIsActive()) {
938                 VideoLogInfo("[ERR]");
939                 return false;
940         }
941
942         if (!szCookie) {
943                 VideoLogInfo("[ERR]");
944                 return false;
945         }
946
947         int nErr = MM_ERROR_NONE;
948         char *pErrName = NULL;
949
950         if (strlen(szCookie) > 0) {
951                 VideoLogInfo("Cookie (%s)", szCookie);
952                 nErr = mm_player_set_attribute(playerHandle, &pErrName,
953                                                "streaming_cookie", szCookie,
954                                                strlen(szCookie), NULL);
955
956                 if (nErr != MM_ERROR_NONE) {
957                         VideoLogInfo("[ERR] (%x):: Fail to set attribute [%s]",
958                                      nErr, pErrName);
959
960                         if (pErrName)
961                                 free(pErrName);
962
963                         return false;
964                 }
965         } else {
966                 VideoLogInfo("No have useragnet value.");
967                 return true;
968         }
969
970         return true;
971 }
972
973
974 int MpPlayerMgrGetBufferingPosition(void)
975 {
976         if (!MpPlayerMgrIsActive()) {
977                 VideoLogInfo("[ERR]");
978                 return false;
979         }
980
981         int nErr = MM_ERROR_NONE;
982
983         int startPos = 0, stopPos = 0;
984         nErr = mm_player_get_buffer_position(playerHandle,
985                                              MM_PLAYER_POS_FORMAT_PERCENT,
986                                              &startPos, &stopPos);
987         if (nErr != MM_ERROR_NONE) {
988                 VideoLogInfo("[ERR]");
989                 return -1;
990         }
991
992         return stopPos;
993 }