[0.6.68] Merge branch 'tizen' into tizen_4.0
[platform/core/multimedia/libmm-player.git] / src / mm_player.c
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include <gst/gst.h>
24 #include <string.h>
25
26 #include <dlog.h>
27 #include <mm_types.h>
28 #include <mm_message.h>
29
30 #include "mm_player.h"
31 #include "mm_player_priv.h"
32 #include "mm_player_attrs.h"
33 #include "mm_player_utils.h"
34 #include "mm_player_ini.h"
35 #include "mm_player_capture.h"
36 #include "mm_player_tracks.h"
37 #include "mm_player_es.h"
38 #include "mm_player_sound_focus.h"
39 #include "mm_player_360.h"
40
41 int mm_player_create(MMHandleType *player)
42 {
43         int result = MM_ERROR_PLAYER_INTERNAL;
44         mm_player_t* new_player = NULL;
45
46         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
47
48         /* alloc player structure */
49         new_player = g_malloc(sizeof(mm_player_t));
50         if (!new_player) {
51                 LOGE("Cannot allocate memory for player\n");
52                 result = MM_ERROR_PLAYER_RESOURCE_LIMIT;
53                 goto ERROR;
54         }
55         memset(new_player, 0, sizeof(mm_player_t));
56
57         /* create player lock */
58         g_mutex_init(&new_player->cmd_lock);
59
60         /* create player lock */
61         g_mutex_init(&new_player->playback_lock);
62
63         /* load ini files */
64         if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
65                 LOGE("can't load ini");
66                 goto ERROR;
67         }
68
69         if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) {
70                 LOGE("can't load audio ini");
71                 goto ERROR;
72         }
73
74         /* create player */
75         result = _mmplayer_create_player((MMHandleType)new_player);
76         if (result != MM_ERROR_NONE) {
77                 LOGE("failed to create player");
78                 if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT)
79                         result = MM_ERROR_PLAYER_INTERNAL;
80                 goto ERROR;
81         }
82
83         *player = (MMHandleType)new_player;
84
85         return MM_ERROR_NONE;
86
87 ERROR:
88
89         if (new_player) {
90                 _mmplayer_destroy((MMHandleType)new_player);
91                 g_mutex_clear(&new_player->cmd_lock);
92                 g_mutex_clear(&new_player->playback_lock);
93
94                 MMPLAYER_FREEIF(new_player);
95         }
96
97         *player = (MMHandleType)0;
98         return result; /* MM_ERROR_PLAYER_INTERNAL or MM_ERROR_PLAYER_RESOURCE_LIMIT */
99 }
100
101 int  mm_player_destroy(MMHandleType player)
102 {
103         int result = MM_ERROR_NONE;
104
105         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
106
107         MMPLAYER_CMD_LOCK(player);
108
109         result = _mmplayer_destroy(player);
110
111         MMPLAYER_CMD_UNLOCK(player);
112
113         g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
114         g_mutex_clear(&((mm_player_t*)player)->playback_lock);
115
116         memset((mm_player_t*)player, 0x00, sizeof(mm_player_t));
117
118         /* free player */
119         g_free((void*)player);
120
121         return result;
122 }
123
124 int mm_player_sound_register(MMHandleType player, int pid)
125 {
126         int result = MM_ERROR_NONE;
127
128         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
129
130         MMPLAYER_CMD_LOCK(player);
131
132         result = _mmplayer_sound_register_with_pid(player, pid);
133
134         MMPLAYER_CMD_UNLOCK(player);
135
136         return result;
137 }
138
139 int mm_player_get_client_pid(MMHandleType player, int* pid)
140 {
141         int result = MM_ERROR_NONE;
142
143         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
144         MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT);
145
146         MMPLAYER_CMD_LOCK(player);
147
148         result = _mmplayer_get_client_pid(player, pid);
149
150         MMPLAYER_CMD_UNLOCK(player);
151
152         return result;
153 }
154
155 int mm_player_realize(MMHandleType player)
156 {
157         int result = MM_ERROR_NONE;
158
159         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
160
161         MMPLAYER_CMD_LOCK(player);
162
163         result = _mmplayer_realize(player);
164
165         MMPLAYER_CMD_UNLOCK(player);
166
167         return result;
168 }
169
170 int mm_player_unrealize(MMHandleType player)
171 {
172         int result = MM_ERROR_NONE;
173
174         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
175
176         MMPLAYER_CMD_LOCK(player);
177
178         result = _mmplayer_unrealize(player);
179
180         MMPLAYER_CMD_UNLOCK(player);
181
182         return result;
183 }
184
185 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
186 {
187         int result = MM_ERROR_NONE;
188
189         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
190
191         MMPLAYER_CMD_LOCK(player);
192
193         result = _mmplayer_set_message_callback(player, callback, user_param);
194
195         MMPLAYER_CMD_UNLOCK(player);
196
197         return result;
198 }
199
200 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
201 {
202         int result = MM_ERROR_NONE;
203
204         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
205
206         result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
207
208         return result;
209 }
210
211 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
212 {
213         int result = MM_ERROR_NONE;
214
215         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
216
217         MMPLAYER_CMD_LOCK(player);
218
219         result = _mmplayer_set_audiostream_cb(player, callback, user_param);
220
221         MMPLAYER_CMD_UNLOCK(player);
222
223         return result;
224 }
225
226 int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param)
227 {
228         int result = MM_ERROR_NONE;
229
230         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
231
232         MMPLAYER_CMD_LOCK(player);
233
234         result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param);
235
236         MMPLAYER_CMD_UNLOCK(player);
237
238         return result;
239 }
240
241 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
242 {
243         int result = MM_ERROR_NONE;
244
245         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
246
247         MMPLAYER_CMD_LOCK(player);
248
249         result = _mmplayer_set_videostream_cb(player, callback, user_param);
250
251         MMPLAYER_CMD_UNLOCK(player);
252
253         return result;
254 }
255
256 int mm_player_do_video_capture(MMHandleType player)
257 {
258         int result = MM_ERROR_NONE;
259
260         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
261
262         MMPLAYER_CMD_LOCK(player);
263
264         result = _mmplayer_do_video_capture(player);
265
266         MMPLAYER_CMD_UNLOCK(player);
267
268         return result;
269 }
270
271 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
272 {
273         int result = MM_ERROR_NONE;
274
275         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
276         MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
277
278         MMPLAYER_CMD_LOCK(player);
279
280         result = _mmplayer_set_volume(player, *volume);
281
282         MMPLAYER_CMD_UNLOCK(player);
283
284         return result;
285 }
286
287 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
288 {
289         int result = MM_ERROR_NONE;
290
291         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
292         MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
293
294         MMPLAYER_CMD_LOCK(player);
295
296         result = _mmplayer_get_volume(player, volume);
297
298         MMPLAYER_CMD_UNLOCK(player);
299
300         return result;
301 }
302
303 int mm_player_set_mute(MMHandleType player, int mute)
304 {
305         int result = MM_ERROR_NONE;
306
307         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
308
309         MMPLAYER_CMD_LOCK(player);
310
311         result = _mmplayer_set_mute(player, mute);
312
313         MMPLAYER_CMD_UNLOCK(player);
314
315         return result;
316 }
317
318 int mm_player_get_mute(MMHandleType player, int *mute)
319 {
320         int result = MM_ERROR_NONE;
321
322         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
323         MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
324
325         MMPLAYER_CMD_LOCK(player);
326
327         result = _mmplayer_get_mute(player, mute);
328
329         MMPLAYER_CMD_UNLOCK(player);
330
331         return result;
332 }
333
334 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
335 {
336         int result = MM_ERROR_NONE;
337
338         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
339         MMPLAYER_RETURN_VAL_IF_FAIL(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
340
341         *state = MM_PLAYER_STATE_NULL;
342
343         result = _mmplayer_get_state(player, (int*)state);
344
345         return result;
346 }
347
348 /* NOTE : It does not support some use cases, eg using colorspace converter */
349 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
350 {
351         int result = MM_ERROR_NONE;
352
353         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
354
355         MMPLAYER_CMD_LOCK(player);
356
357         result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
358
359         MMPLAYER_CMD_UNLOCK(player);
360
361         return result;
362 }
363
364 int mm_player_start(MMHandleType player)
365 {
366         int result = MM_ERROR_NONE;
367
368         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
369
370         MMPLAYER_CMD_LOCK(player);
371
372         result = _mmplayer_start(player);
373
374         MMPLAYER_CMD_UNLOCK(player);
375
376         return result;
377 }
378
379 int  mm_player_stop(MMHandleType player)
380 {
381         int result = MM_ERROR_NONE;
382
383         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
384
385         MMPLAYER_CMD_LOCK(player);
386
387         result = _mmplayer_stop(player);
388
389         MMPLAYER_CMD_UNLOCK(player);
390
391         return result;
392 }
393
394 int mm_player_pause(MMHandleType player)
395 {
396         int result = MM_ERROR_NONE;
397
398         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
399
400         MMPLAYER_CMD_LOCK(player);
401
402         result = _mmplayer_pause(player);
403
404         MMPLAYER_CMD_UNLOCK(player);
405
406         return result;
407 }
408
409 int mm_player_resume(MMHandleType player)
410 {
411         int result = MM_ERROR_NONE;
412
413         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
414
415         MMPLAYER_CMD_LOCK(player);
416
417         result = _mmplayer_resume(player);
418
419         MMPLAYER_CMD_UNLOCK(player);
420
421         return result;
422 }
423
424 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
425 {
426         int result = MM_ERROR_NONE;
427
428         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
429
430         MMPLAYER_CMD_LOCK(player);
431
432         result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
433
434         MMPLAYER_CMD_UNLOCK(player);
435
436         return result;
437 }
438
439 int mm_player_deactivate_section_repeat(MMHandleType player)
440 {
441         int result = MM_ERROR_NONE;
442
443         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
444
445         MMPLAYER_CMD_LOCK(player);
446
447         result = _mmplayer_deactivate_section_repeat(player);
448
449         MMPLAYER_CMD_UNLOCK(player);
450
451         return result;
452 }
453
454 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming)
455 {
456         int result = MM_ERROR_NONE;
457
458         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
459
460         MMPLAYER_CMD_LOCK(player);
461
462         result = _mmplayer_set_playspeed(player, rate, streaming);
463
464         MMPLAYER_CMD_UNLOCK(player);
465
466         return result;
467 }
468
469 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
470 {
471         int result = MM_ERROR_NONE;
472
473         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
474
475         if (format >= MM_PLAYER_POS_FORMAT_NUM) {
476                 LOGE("wrong format\n");
477                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
478         }
479
480         MMPLAYER_CMD_LOCK(player);
481
482         result = _mmplayer_set_position(player, format, pos);
483
484         MMPLAYER_CMD_UNLOCK(player);
485
486         return result;
487 }
488
489 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *pos)
490 {
491         int result = MM_ERROR_NONE;
492
493         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
494         MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
495
496         if (format >= MM_PLAYER_POS_FORMAT_NUM) {
497                 LOGE("wrong format\n");
498                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
499         }
500
501         MMPLAYER_CMD_LOCK(player);
502
503         result = _mmplayer_get_position(player, (int)format, pos);
504
505         MMPLAYER_CMD_UNLOCK(player);
506
507         return result;
508 }
509
510 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
511 {
512         int result = MM_ERROR_NONE;
513
514         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
515         MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
516
517         MMPLAYER_CMD_LOCK(player);
518
519         result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
520
521         MMPLAYER_CMD_UNLOCK(player);
522
523         return result;
524 }
525
526 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
527 {
528         int result = MM_ERROR_NONE;
529
530         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
531
532         MMPLAYER_CMD_LOCK(player);
533
534         result = _mmplayer_set_external_subtitle_path(player, path);
535
536         MMPLAYER_CMD_UNLOCK(player);
537         return result;
538 }
539
540 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
541 {
542         int result = MM_ERROR_NONE;
543
544         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
545
546         if (format >= MM_PLAYER_POS_FORMAT_NUM) {
547                 LOGE("wrong format(%d) \n", format);
548                 return MM_ERROR_INVALID_ARGUMENT;
549         }
550
551         MMPLAYER_CMD_LOCK(player);
552
553         result = _mmplayer_adjust_subtitle_postion(player, format, pos);
554
555         MMPLAYER_CMD_UNLOCK(player);
556
557         return result;
558 }
559
560 int mm_player_adjust_video_position(MMHandleType player, int offset)
561 {
562         int result = MM_ERROR_NONE;
563         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
564         MMPLAYER_CMD_LOCK(player);
565
566         result = _mmplayer_adjust_video_postion(player, offset);
567
568         MMPLAYER_CMD_UNLOCK(player);
569
570         return result;
571 }
572
573 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
574 {
575         int result = MM_ERROR_NONE;
576
577         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
578
579         MMPLAYER_CMD_LOCK(player);
580
581         result = _mmplayer_set_subtitle_silent(player, silent);
582
583         MMPLAYER_CMD_UNLOCK(player);
584
585         return result;
586 }
587
588 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
589 {
590         int result = MM_ERROR_NONE;
591
592         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
593
594         MMPLAYER_CMD_LOCK(player);
595
596         result = _mmplayer_get_subtitle_silent(player, silent);
597
598         MMPLAYER_CMD_UNLOCK(player);
599
600         return result;
601 }
602
603 int mm_player_set_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
604 {
605         int result = MM_ERROR_NONE;
606         va_list var_args;
607
608         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
609         MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
610
611         va_start(var_args, first_attribute_name);
612         result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
613         va_end(var_args);
614
615         return result;
616 }
617
618 int mm_player_get_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
619 {
620         int result = MM_ERROR_NONE;
621         va_list var_args;
622
623         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
624         MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
625
626         va_start(var_args, first_attribute_name);
627         result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
628         va_end(var_args);
629
630         return result;
631 }
632
633 int mm_player_get_attribute_info(MMHandleType player,  const char *attribute_name, MMPlayerAttrsInfo *info)
634 {
635         int result = MM_ERROR_NONE;
636
637
638         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
639         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
640         MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
641
642         result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
643
644         return result;
645 }
646
647 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
648 {
649         int result = MM_ERROR_NONE;
650
651         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
652         MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
653         MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
654
655         result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
656
657         return result;
658 }
659
660 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
661 {
662         int result = MM_ERROR_NONE;
663
664         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
665         MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
666
667         MMPLAYER_CMD_LOCK(player);
668
669         result = _mmplayer_get_track_count(player, type, count);
670
671         MMPLAYER_CMD_UNLOCK(player);
672
673         return result;
674 }
675
676 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
677 {
678         int result = MM_ERROR_NONE;
679
680         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
681
682         MMPLAYER_CMD_LOCK(player);
683
684         result = _mmplayer_select_track(player, type, index);
685
686         MMPLAYER_CMD_UNLOCK(player);
687
688         return result;
689 }
690 #ifdef _MULTI_TRACK
691 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
692 {
693         int result = MM_ERROR_NONE;
694
695         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
696
697         MMPLAYER_CMD_LOCK(player);
698
699         result = _mmplayer_track_add_subtitle_language(player, index);
700
701         MMPLAYER_CMD_UNLOCK(player);
702
703         return result;
704 }
705
706 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
707 {
708         int result = MM_ERROR_NONE;
709
710         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
711
712         MMPLAYER_CMD_LOCK(player);
713
714         result = _mmplayer_track_remove_subtitle_language(player, index);
715
716         MMPLAYER_CMD_UNLOCK(player);
717
718         return result;
719
720 }
721 #endif
722 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
723 {
724         int result = MM_ERROR_NONE;
725
726         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
727         MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
728
729         MMPLAYER_CMD_LOCK(player);
730
731         result = _mmplayer_get_current_track(player, type, index);
732
733         MMPLAYER_CMD_UNLOCK(player);
734
735         return result;
736 }
737
738 int mm_player_get_track_language_code(MMHandleType player,  MMPlayerTrackType type, int index, char **code)
739 {
740         int result = MM_ERROR_NONE;
741
742         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
743
744         MMPLAYER_CMD_LOCK(player);
745
746         result = _mmplayer_get_track_language_code(player, type, index, code);
747
748         MMPLAYER_CMD_UNLOCK(player);
749
750         return result;
751 }
752
753 int mm_player_set_video_share_master_clock(MMHandleType player,
754                                                 long long clock,
755                                                 long long clock_delta,
756                                                 long long video_time,
757                                                 long long media_clock,
758                                                 long long audio_time)
759 {
760         int result = MM_ERROR_NONE;
761
762         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
763
764         MMPLAYER_CMD_LOCK(player);
765
766         result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
767
768         MMPLAYER_CMD_UNLOCK(player);
769
770         return result;
771 }
772
773 int mm_player_get_video_share_master_clock(MMHandleType player,
774                                                 long long *video_time,
775                                                 long long *media_clock,
776                                                 long long *audio_time)
777 {
778         int result = MM_ERROR_NONE;
779
780         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
781         MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
782         MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
783         MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
784
785         MMPLAYER_CMD_LOCK(player);
786
787         result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
788
789         MMPLAYER_CMD_UNLOCK(player);
790
791         return result;
792 }
793
794 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
795 {
796         int result = MM_ERROR_NONE;
797
798         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
799         MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
800
801         MMPLAYER_CMD_LOCK(player);
802
803         result = _mmplayer_get_video_rotate_angle(player, angle);
804
805         MMPLAYER_CMD_UNLOCK(player);
806
807         return result;
808 }
809
810 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
811 {
812         int result = MM_ERROR_NONE;
813
814         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
815
816         MMPLAYER_CMD_LOCK(player);
817
818         result = _mmplayer_set_video_hub_download_mode(player, mode);
819
820         MMPLAYER_CMD_UNLOCK(player);
821
822         return result;
823 }
824
825 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
826 {
827         int result = MM_ERROR_NONE;
828
829         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
830
831         MMPLAYER_CMD_LOCK(player);
832
833         result = _mmplayer_enable_sync_handler(player, enable);
834
835         MMPLAYER_CMD_UNLOCK(player);
836
837         return result;
838 }
839
840 int mm_player_set_uri(MMHandleType player, const char *uri)
841 {
842         int result = MM_ERROR_NONE;
843
844         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
845
846         MMPLAYER_CMD_LOCK(player);
847
848         result = _mmplayer_set_uri(player, uri);
849
850         MMPLAYER_CMD_UNLOCK(player);
851
852         return result;
853
854 }
855
856 int mm_player_set_next_uri(MMHandleType player, const char *uri)
857 {
858         int result = MM_ERROR_NONE;
859
860         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
861
862         MMPLAYER_CMD_LOCK(player);
863
864         result = _mmplayer_set_next_uri(player, uri, FALSE);
865
866         MMPLAYER_CMD_UNLOCK(player);
867
868         return result;
869
870 }
871
872 int mm_player_get_next_uri(MMHandleType player, char **uri)
873 {
874         int result = MM_ERROR_NONE;
875
876         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
877
878         MMPLAYER_CMD_LOCK(player);
879
880         result = _mmplayer_get_next_uri(player, uri);
881
882         MMPLAYER_CMD_UNLOCK(player);
883
884         return result;
885
886 }
887 #ifdef _MULTI_TRACK
888 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
889 {
890         int result = MM_ERROR_NONE;
891
892         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
893
894         MMPLAYER_CMD_LOCK(player);
895
896         result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
897
898         MMPLAYER_CMD_UNLOCK(player);
899
900         return result;
901 }
902 #endif
903
904 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
905 {
906         int result = MM_ERROR_NONE;
907
908         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
909         MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
910
911         MMPLAYER_CMD_LOCK(player);
912
913         result = _mmplayer_has_closed_caption(player, exist);
914
915         MMPLAYER_CMD_UNLOCK(player);
916
917         return result;
918 }
919
920 void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer)
921 {
922         void * result;
923         result = _mm_player_media_packet_video_stream_internal_buffer_ref(buffer);
924
925         return result;
926 }
927
928 void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer)
929 {
930         _mm_player_media_packet_video_stream_internal_buffer_unref(buffer);
931 }
932
933 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
934 {
935
936         int result = MM_ERROR_NONE;
937
938         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
939
940         /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
941         //MMPLAYER_CMD_LOCK(player);
942
943         result = _mmplayer_submit_packet(player, packet);
944
945         //MMPLAYER_CMD_UNLOCK(player);
946
947         return result;
948 }
949
950 int mm_player_set_video_info(MMHandleType player, media_format_h format)
951 {
952         int result = MM_ERROR_NONE;
953
954         LOGD("\n");
955
956         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
957
958         MMPLAYER_CMD_LOCK(player);
959
960         result = _mmplayer_set_video_info(player, format);
961
962         MMPLAYER_CMD_UNLOCK(player);
963
964         return result;
965
966 }
967
968 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
969 {
970         int result = MM_ERROR_NONE;
971
972         LOGD("\n");
973
974         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
975
976         MMPLAYER_CMD_LOCK(player);
977
978         result = _mmplayer_set_audio_info(player, format);
979
980         MMPLAYER_CMD_UNLOCK(player);
981
982         return result;
983 }
984
985 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
986 {
987         int result = MM_ERROR_NONE;
988
989         LOGD("\n");
990
991         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
992
993         MMPLAYER_CMD_LOCK(player);
994
995         result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
996
997         MMPLAYER_CMD_UNLOCK(player);
998
999         return result;
1000 }
1001
1002 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1003 {
1004         int result = MM_ERROR_NONE;
1005
1006         LOGD("\n");
1007
1008         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1009
1010         MMPLAYER_CMD_LOCK(player);
1011
1012         result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1013
1014         MMPLAYER_CMD_UNLOCK(player);
1015
1016         return result;
1017 }
1018
1019 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1020 {
1021         int result = MM_ERROR_NONE;
1022         guint64 _max_size = 0;
1023
1024         LOGD("\n");
1025
1026         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1027         MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1028
1029         MMPLAYER_CMD_LOCK(player);
1030
1031         result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1032         *max_size = _max_size;
1033
1034         MMPLAYER_CMD_UNLOCK(player);
1035
1036         return result;
1037 }
1038
1039 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1040 {
1041         int result = MM_ERROR_NONE;
1042
1043         LOGD("\n");
1044
1045         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1046
1047         MMPLAYER_CMD_LOCK(player);
1048
1049         result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1050
1051         MMPLAYER_CMD_UNLOCK(player);
1052
1053         return result;
1054 }
1055
1056 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1057 {
1058         int result = MM_ERROR_NONE;
1059
1060         LOGD("\n");
1061
1062         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1063         MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1064
1065         MMPLAYER_CMD_LOCK(player);
1066
1067         result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1068
1069         MMPLAYER_CMD_UNLOCK(player);
1070
1071         return result;
1072 }
1073
1074 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1075 {
1076         int result = MM_ERROR_NONE;
1077
1078         LOGD("\n");
1079
1080         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1081
1082         MMPLAYER_CMD_LOCK(player);
1083
1084         result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1085
1086         MMPLAYER_CMD_UNLOCK(player);
1087
1088         return result;
1089 }
1090
1091 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1092 {
1093         int result = MM_ERROR_NONE;
1094
1095         LOGD("\n");
1096
1097         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1098
1099         MMPLAYER_CMD_LOCK(player);
1100
1101         result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1102
1103         MMPLAYER_CMD_UNLOCK(player);
1104
1105         return result;
1106 }
1107
1108 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1109 {
1110         int result = MM_ERROR_NONE;
1111
1112         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1113
1114         MMPLAYER_CMD_LOCK(player);
1115
1116         result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1117
1118         MMPLAYER_CMD_UNLOCK(player);
1119
1120         return result;
1121 }
1122
1123 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1124 {
1125         int result = MM_ERROR_NONE;
1126
1127         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1128
1129         MMPLAYER_CMD_LOCK(player);
1130
1131         result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1132
1133         MMPLAYER_CMD_UNLOCK(player);
1134
1135         return result;
1136 }
1137
1138 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1139 {
1140         int result = MM_ERROR_NONE;
1141
1142         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1143
1144         MMPLAYER_CMD_LOCK(player);
1145
1146         result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1147
1148         MMPLAYER_CMD_UNLOCK(player);
1149
1150         return result;
1151 }
1152
1153 int mm_player_get_timeout(MMHandleType player, int *timeout)
1154 {
1155         int result = MM_ERROR_NONE;
1156
1157         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1158         MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1159
1160         MMPLAYER_CMD_LOCK(player);
1161
1162         result = _mmplayer_get_timeout(player, timeout);
1163
1164         MMPLAYER_CMD_UNLOCK(player);
1165
1166         return result;
1167 }
1168
1169 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1170 {
1171         int result = MM_ERROR_NONE;
1172
1173         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1174         MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1175
1176         MMPLAYER_CMD_LOCK(player);
1177
1178         result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1179
1180         MMPLAYER_CMD_UNLOCK(player);
1181
1182         return result;
1183 }
1184
1185 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1186 {
1187         int result = MM_ERROR_NONE;
1188
1189         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1190
1191         MMPLAYER_CMD_LOCK(player);
1192
1193         result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1194
1195         MMPLAYER_CMD_UNLOCK(player);
1196
1197         return result;
1198 }
1199
1200 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1201 {
1202         int result = MM_ERROR_NONE;
1203
1204         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1205         MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1206
1207         //MMPLAYER_CMD_LOCK(player);
1208
1209         result = _mmplayer_video_stream_release_bo(player, bo);
1210
1211         //MMPLAYER_CMD_UNLOCK(player);
1212
1213         return result;
1214 }
1215
1216 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1217 {
1218         int result = MM_ERROR_NONE;
1219
1220         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1221
1222         MMPLAYER_CMD_LOCK(player);
1223
1224         result = _mmplayer_set_file_buffering_path(player, file_path);
1225
1226         MMPLAYER_CMD_UNLOCK(player);
1227
1228         return result;
1229 }
1230
1231 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1232 {
1233         int result = MM_ERROR_NONE;
1234
1235         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1236         MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1237
1238         MMPLAYER_CMD_LOCK(player);
1239
1240         _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1241         result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1242
1243         MMPLAYER_CMD_UNLOCK(player);
1244
1245         return result;
1246 }
1247
1248 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1249 {
1250         int result = MM_ERROR_NONE;
1251
1252         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1253
1254         MMPLAYER_CMD_LOCK(player);
1255
1256         result = _mmplayer_manage_external_storage_state(player, state);
1257
1258         MMPLAYER_CMD_UNLOCK(player);
1259
1260         return result;
1261 }
1262
1263 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1264 {
1265         int result = MM_ERROR_NONE;
1266
1267         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1268         MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1269
1270         MMPLAYER_CMD_LOCK(player);
1271
1272         result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1273
1274         MMPLAYER_CMD_UNLOCK(player);
1275
1276         return result;
1277 }
1278
1279 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1280 {
1281         int result = MM_ERROR_NONE;
1282
1283         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1284
1285         MMPLAYER_CMD_LOCK(player);
1286
1287         result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1288
1289         MMPLAYER_CMD_UNLOCK(player);
1290
1291         return result;
1292 }
1293
1294 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1295 {
1296         int result = MM_ERROR_NONE;
1297
1298         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1299         MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1300
1301         MMPLAYER_CMD_LOCK(player);
1302
1303         result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1304
1305         MMPLAYER_CMD_UNLOCK(player);
1306
1307         return result;
1308 }
1309
1310 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1311 {
1312         int result = MM_ERROR_NONE;
1313         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1314
1315         MMPLAYER_CMD_LOCK(player);
1316
1317         result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1318
1319         MMPLAYER_CMD_UNLOCK(player);
1320
1321         return result;
1322 }
1323
1324 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1325 {
1326         int result = MM_ERROR_NONE;
1327
1328         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1329         MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1330
1331         MMPLAYER_CMD_LOCK(player);
1332
1333         result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1334
1335         MMPLAYER_CMD_UNLOCK(player);
1336
1337         return result;
1338 }
1339
1340 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1341 {
1342         int result = MM_ERROR_NONE;
1343         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1344
1345         MMPLAYER_CMD_LOCK(player);
1346
1347         result = _mmplayer_set_audio_only(player, audio_only);
1348
1349         MMPLAYER_CMD_UNLOCK(player);
1350
1351         return result;
1352 }
1353
1354 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1355 {
1356         int result = MM_ERROR_NONE;
1357
1358         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1359         MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1360
1361         MMPLAYER_CMD_LOCK(player);
1362
1363         result = _mmplayer_get_audio_only(player, audio_only);
1364
1365         MMPLAYER_CMD_UNLOCK(player);
1366
1367         return result;
1368 }
1369
1370 int mm_player_360_set_enable(MMHandleType player, bool enable)
1371 {
1372         int result = MM_ERROR_NONE;
1373         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1374
1375         MMPLAYER_CMD_LOCK(player);
1376
1377         result = _mmplayer_360_set_enable(player, enable);
1378
1379         MMPLAYER_CMD_UNLOCK(player);
1380
1381         return result;
1382 }
1383
1384 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1385 {
1386         int result = MM_ERROR_NONE;
1387
1388         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1389         MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1390
1391         MMPLAYER_CMD_LOCK(player);
1392
1393         result = _mmplayer_360_is_enabled(player, enabled);
1394
1395         MMPLAYER_CMD_UNLOCK(player);
1396
1397         return result;
1398 }
1399
1400 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1401 {
1402         int result = MM_ERROR_NONE;
1403         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1404
1405         MMPLAYER_CMD_LOCK(player);
1406
1407         result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1408
1409         MMPLAYER_CMD_UNLOCK(player);
1410
1411         return result;
1412 }
1413
1414 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1415 {
1416         int result = MM_ERROR_NONE;
1417
1418         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1419         MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1420
1421         MMPLAYER_CMD_LOCK(player);
1422
1423         result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1424
1425         MMPLAYER_CMD_UNLOCK(player);
1426
1427         return result;
1428 }
1429
1430 int mm_player_360_set_zoom(MMHandleType player, float level)
1431 {
1432         int result = MM_ERROR_NONE;
1433         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1434
1435         MMPLAYER_CMD_LOCK(player);
1436
1437         result = _mmplayer_360_set_zoom(player, level);
1438
1439         MMPLAYER_CMD_UNLOCK(player);
1440
1441         return result;
1442 }
1443
1444 int mm_player_360_get_zoom(MMHandleType player, float *level)
1445 {
1446         int result = MM_ERROR_NONE;
1447
1448         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1449         MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1450
1451         MMPLAYER_CMD_LOCK(player);
1452
1453         result = _mmplayer_360_get_zoom(player, level);
1454
1455         MMPLAYER_CMD_UNLOCK(player);
1456
1457         return result;
1458 }
1459
1460 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1461 {
1462         int result = MM_ERROR_NONE;
1463         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1464
1465         MMPLAYER_CMD_LOCK(player);
1466
1467         result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1468
1469         MMPLAYER_CMD_UNLOCK(player);
1470
1471         return result;
1472 }
1473
1474 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1475 {
1476         int result = MM_ERROR_NONE;
1477
1478         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1479         MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1480
1481         MMPLAYER_CMD_LOCK(player);
1482
1483         result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1484
1485         MMPLAYER_CMD_UNLOCK(player);
1486
1487         return result;
1488 }