[0.6.70] modify video stream cb
[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_video_stream_internal_buffer_unref(void *buffer)
921 {
922         _mm_player_video_stream_internal_buffer_unref(buffer);
923 }
924
925 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
926 {
927
928         int result = MM_ERROR_NONE;
929
930         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
931
932         /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
933         //MMPLAYER_CMD_LOCK(player);
934
935         result = _mmplayer_submit_packet(player, packet);
936
937         //MMPLAYER_CMD_UNLOCK(player);
938
939         return result;
940 }
941
942 int mm_player_set_video_info(MMHandleType player, media_format_h format)
943 {
944         int result = MM_ERROR_NONE;
945
946         LOGD("\n");
947
948         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
949
950         MMPLAYER_CMD_LOCK(player);
951
952         result = _mmplayer_set_video_info(player, format);
953
954         MMPLAYER_CMD_UNLOCK(player);
955
956         return result;
957
958 }
959
960 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
961 {
962         int result = MM_ERROR_NONE;
963
964         LOGD("\n");
965
966         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
967
968         MMPLAYER_CMD_LOCK(player);
969
970         result = _mmplayer_set_audio_info(player, format);
971
972         MMPLAYER_CMD_UNLOCK(player);
973
974         return result;
975 }
976
977 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
978 {
979         int result = MM_ERROR_NONE;
980
981         LOGD("\n");
982
983         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
984
985         MMPLAYER_CMD_LOCK(player);
986
987         result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
988
989         MMPLAYER_CMD_UNLOCK(player);
990
991         return result;
992 }
993
994 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
995 {
996         int result = MM_ERROR_NONE;
997
998         LOGD("\n");
999
1000         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1001
1002         MMPLAYER_CMD_LOCK(player);
1003
1004         result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1005
1006         MMPLAYER_CMD_UNLOCK(player);
1007
1008         return result;
1009 }
1010
1011 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1012 {
1013         int result = MM_ERROR_NONE;
1014         guint64 _max_size = 0;
1015
1016         LOGD("\n");
1017
1018         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1019         MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1020
1021         MMPLAYER_CMD_LOCK(player);
1022
1023         result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1024         *max_size = _max_size;
1025
1026         MMPLAYER_CMD_UNLOCK(player);
1027
1028         return result;
1029 }
1030
1031 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1032 {
1033         int result = MM_ERROR_NONE;
1034
1035         LOGD("\n");
1036
1037         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1038
1039         MMPLAYER_CMD_LOCK(player);
1040
1041         result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1042
1043         MMPLAYER_CMD_UNLOCK(player);
1044
1045         return result;
1046 }
1047
1048 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1049 {
1050         int result = MM_ERROR_NONE;
1051
1052         LOGD("\n");
1053
1054         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1055         MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1056
1057         MMPLAYER_CMD_LOCK(player);
1058
1059         result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1060
1061         MMPLAYER_CMD_UNLOCK(player);
1062
1063         return result;
1064 }
1065
1066 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1067 {
1068         int result = MM_ERROR_NONE;
1069
1070         LOGD("\n");
1071
1072         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1073
1074         MMPLAYER_CMD_LOCK(player);
1075
1076         result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1077
1078         MMPLAYER_CMD_UNLOCK(player);
1079
1080         return result;
1081 }
1082
1083 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1084 {
1085         int result = MM_ERROR_NONE;
1086
1087         LOGD("\n");
1088
1089         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1090
1091         MMPLAYER_CMD_LOCK(player);
1092
1093         result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1094
1095         MMPLAYER_CMD_UNLOCK(player);
1096
1097         return result;
1098 }
1099
1100 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1101 {
1102         int result = MM_ERROR_NONE;
1103
1104         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1105
1106         MMPLAYER_CMD_LOCK(player);
1107
1108         result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1109
1110         MMPLAYER_CMD_UNLOCK(player);
1111
1112         return result;
1113 }
1114
1115 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1116 {
1117         int result = MM_ERROR_NONE;
1118
1119         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1120
1121         MMPLAYER_CMD_LOCK(player);
1122
1123         result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1124
1125         MMPLAYER_CMD_UNLOCK(player);
1126
1127         return result;
1128 }
1129
1130 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1131 {
1132         int result = MM_ERROR_NONE;
1133
1134         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1135
1136         MMPLAYER_CMD_LOCK(player);
1137
1138         result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1139
1140         MMPLAYER_CMD_UNLOCK(player);
1141
1142         return result;
1143 }
1144
1145 int mm_player_get_timeout(MMHandleType player, int *timeout)
1146 {
1147         int result = MM_ERROR_NONE;
1148
1149         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1150         MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1151
1152         MMPLAYER_CMD_LOCK(player);
1153
1154         result = _mmplayer_get_timeout(player, timeout);
1155
1156         MMPLAYER_CMD_UNLOCK(player);
1157
1158         return result;
1159 }
1160
1161 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1162 {
1163         int result = MM_ERROR_NONE;
1164
1165         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1166         MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1167
1168         MMPLAYER_CMD_LOCK(player);
1169
1170         result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1171
1172         MMPLAYER_CMD_UNLOCK(player);
1173
1174         return result;
1175 }
1176
1177 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1178 {
1179         int result = MM_ERROR_NONE;
1180
1181         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1182
1183         MMPLAYER_CMD_LOCK(player);
1184
1185         result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1186
1187         MMPLAYER_CMD_UNLOCK(player);
1188
1189         return result;
1190 }
1191
1192 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1193 {
1194         int result = MM_ERROR_NONE;
1195
1196         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1197         MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1198
1199         //MMPLAYER_CMD_LOCK(player);
1200
1201         result = _mmplayer_video_stream_release_bo(player, bo);
1202
1203         //MMPLAYER_CMD_UNLOCK(player);
1204
1205         return result;
1206 }
1207
1208 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1209 {
1210         int result = MM_ERROR_NONE;
1211
1212         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1213
1214         MMPLAYER_CMD_LOCK(player);
1215
1216         result = _mmplayer_set_file_buffering_path(player, file_path);
1217
1218         MMPLAYER_CMD_UNLOCK(player);
1219
1220         return result;
1221 }
1222
1223 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1224 {
1225         int result = MM_ERROR_NONE;
1226
1227         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1228         MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1229
1230         MMPLAYER_CMD_LOCK(player);
1231
1232         _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1233         result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1234
1235         MMPLAYER_CMD_UNLOCK(player);
1236
1237         return result;
1238 }
1239
1240 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1241 {
1242         int result = MM_ERROR_NONE;
1243
1244         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1245
1246         MMPLAYER_CMD_LOCK(player);
1247
1248         result = _mmplayer_manage_external_storage_state(player, state);
1249
1250         MMPLAYER_CMD_UNLOCK(player);
1251
1252         return result;
1253 }
1254
1255 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1256 {
1257         int result = MM_ERROR_NONE;
1258
1259         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1260         MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1261
1262         MMPLAYER_CMD_LOCK(player);
1263
1264         result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1265
1266         MMPLAYER_CMD_UNLOCK(player);
1267
1268         return result;
1269 }
1270
1271 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1272 {
1273         int result = MM_ERROR_NONE;
1274
1275         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1276
1277         MMPLAYER_CMD_LOCK(player);
1278
1279         result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1280
1281         MMPLAYER_CMD_UNLOCK(player);
1282
1283         return result;
1284 }
1285
1286 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1287 {
1288         int result = MM_ERROR_NONE;
1289
1290         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1291         MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1292
1293         MMPLAYER_CMD_LOCK(player);
1294
1295         result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1296
1297         MMPLAYER_CMD_UNLOCK(player);
1298
1299         return result;
1300 }
1301
1302 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1303 {
1304         int result = MM_ERROR_NONE;
1305         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1306
1307         MMPLAYER_CMD_LOCK(player);
1308
1309         result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1310
1311         MMPLAYER_CMD_UNLOCK(player);
1312
1313         return result;
1314 }
1315
1316 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1317 {
1318         int result = MM_ERROR_NONE;
1319
1320         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1321         MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1322
1323         MMPLAYER_CMD_LOCK(player);
1324
1325         result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1326
1327         MMPLAYER_CMD_UNLOCK(player);
1328
1329         return result;
1330 }
1331
1332 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1333 {
1334         int result = MM_ERROR_NONE;
1335         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1336
1337         MMPLAYER_CMD_LOCK(player);
1338
1339         result = _mmplayer_set_audio_only(player, audio_only);
1340
1341         MMPLAYER_CMD_UNLOCK(player);
1342
1343         return result;
1344 }
1345
1346 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1347 {
1348         int result = MM_ERROR_NONE;
1349
1350         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1351         MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1352
1353         MMPLAYER_CMD_LOCK(player);
1354
1355         result = _mmplayer_get_audio_only(player, audio_only);
1356
1357         MMPLAYER_CMD_UNLOCK(player);
1358
1359         return result;
1360 }
1361
1362 int mm_player_360_set_enable(MMHandleType player, bool enable)
1363 {
1364         int result = MM_ERROR_NONE;
1365         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1366
1367         MMPLAYER_CMD_LOCK(player);
1368
1369         result = _mmplayer_360_set_enable(player, enable);
1370
1371         MMPLAYER_CMD_UNLOCK(player);
1372
1373         return result;
1374 }
1375
1376 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1377 {
1378         int result = MM_ERROR_NONE;
1379
1380         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1381         MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1382
1383         MMPLAYER_CMD_LOCK(player);
1384
1385         result = _mmplayer_360_is_enabled(player, enabled);
1386
1387         MMPLAYER_CMD_UNLOCK(player);
1388
1389         return result;
1390 }
1391
1392 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1393 {
1394         int result = MM_ERROR_NONE;
1395         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1396
1397         MMPLAYER_CMD_LOCK(player);
1398
1399         result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1400
1401         MMPLAYER_CMD_UNLOCK(player);
1402
1403         return result;
1404 }
1405
1406 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1407 {
1408         int result = MM_ERROR_NONE;
1409
1410         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1411         MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1412
1413         MMPLAYER_CMD_LOCK(player);
1414
1415         result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1416
1417         MMPLAYER_CMD_UNLOCK(player);
1418
1419         return result;
1420 }
1421
1422 int mm_player_360_set_zoom(MMHandleType player, float level)
1423 {
1424         int result = MM_ERROR_NONE;
1425         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1426
1427         MMPLAYER_CMD_LOCK(player);
1428
1429         result = _mmplayer_360_set_zoom(player, level);
1430
1431         MMPLAYER_CMD_UNLOCK(player);
1432
1433         return result;
1434 }
1435
1436 int mm_player_360_get_zoom(MMHandleType player, float *level)
1437 {
1438         int result = MM_ERROR_NONE;
1439
1440         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1441         MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1442
1443         MMPLAYER_CMD_LOCK(player);
1444
1445         result = _mmplayer_360_get_zoom(player, level);
1446
1447         MMPLAYER_CMD_UNLOCK(player);
1448
1449         return result;
1450 }
1451
1452 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1453 {
1454         int result = MM_ERROR_NONE;
1455         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1456
1457         MMPLAYER_CMD_LOCK(player);
1458
1459         result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1460
1461         MMPLAYER_CMD_UNLOCK(player);
1462
1463         return result;
1464 }
1465
1466 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1467 {
1468         int result = MM_ERROR_NONE;
1469
1470         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1471         MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1472
1473         MMPLAYER_CMD_LOCK(player);
1474
1475         result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1476
1477         MMPLAYER_CMD_UNLOCK(player);
1478
1479         return result;
1480 }