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