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