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