[0.6.128] refactoring about set position
[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, 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         MMPLAYER_CMD_LOCK(player);
433
434         result = _mmplayer_set_position(player, pos);
435
436         MMPLAYER_CMD_UNLOCK(player);
437
438         return result;
439 }
440
441 int mm_player_get_position(MMHandleType player, int64_t *pos)
442 {
443         int result = MM_ERROR_NONE;
444
445         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
446         MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
447
448         MMPLAYER_CMD_LOCK(player);
449
450         result = _mmplayer_get_position(player, pos);
451
452         MMPLAYER_CMD_UNLOCK(player);
453
454         return result;
455 }
456
457 int mm_player_get_duration(MMHandleType player, int64_t *dur)
458 {
459         int result = MM_ERROR_NONE;
460
461         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
462         MMPLAYER_RETURN_VAL_IF_FAIL(dur, MM_ERROR_COMMON_INVALID_ARGUMENT);
463
464         MMPLAYER_CMD_LOCK(player);
465
466         result = _mmplayer_get_duration(player, dur);
467
468         MMPLAYER_CMD_UNLOCK(player);
469
470         return result;
471 }
472
473
474 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, unsigned long *start_pos, unsigned long *stop_pos)
475 {
476         int result = MM_ERROR_NONE;
477
478         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
479         MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
480
481         MMPLAYER_CMD_LOCK(player);
482
483         result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos);
484
485         MMPLAYER_CMD_UNLOCK(player);
486
487         return result;
488 }
489
490 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
491 {
492         int result = MM_ERROR_NONE;
493
494         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
495
496         MMPLAYER_CMD_LOCK(player);
497
498         result = _mmplayer_set_external_subtitle_path(player, path);
499
500         MMPLAYER_CMD_UNLOCK(player);
501         return result;
502 }
503
504 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
505 {
506         int result = MM_ERROR_NONE;
507
508         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
509
510         if (format >= MM_PLAYER_POS_FORMAT_NUM) {
511                 LOGE("wrong format(%d) \n", format);
512                 return MM_ERROR_INVALID_ARGUMENT;
513         }
514
515         MMPLAYER_CMD_LOCK(player);
516
517         result = _mmplayer_adjust_subtitle_postion(player, format, pos);
518
519         MMPLAYER_CMD_UNLOCK(player);
520
521         return result;
522 }
523
524 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
525 {
526         int result = MM_ERROR_NONE;
527
528         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
529
530         MMPLAYER_CMD_LOCK(player);
531
532         result = _mmplayer_set_subtitle_silent(player, silent);
533
534         MMPLAYER_CMD_UNLOCK(player);
535
536         return result;
537 }
538
539 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
540 {
541         int result = MM_ERROR_NONE;
542
543         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
544
545         MMPLAYER_CMD_LOCK(player);
546
547         result = _mmplayer_get_subtitle_silent(player, silent);
548
549         MMPLAYER_CMD_UNLOCK(player);
550
551         return result;
552 }
553
554 int mm_player_set_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
555 {
556         int result = MM_ERROR_NONE;
557         va_list var_args;
558
559         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
560         MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
561
562         va_start(var_args, first_attribute_name);
563         result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
564         va_end(var_args);
565
566         return result;
567 }
568
569 int mm_player_get_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
570 {
571         int result = MM_ERROR_NONE;
572         va_list var_args;
573
574         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
575         MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
576
577         va_start(var_args, first_attribute_name);
578         result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
579         va_end(var_args);
580
581         return result;
582 }
583
584 int mm_player_get_attribute_info(MMHandleType player,  const char *attribute_name, MMPlayerAttrsInfo *info)
585 {
586         int result = MM_ERROR_NONE;
587
588
589         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
590         MMPLAYER_RETURN_VAL_IF_FAIL(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
591         MMPLAYER_RETURN_VAL_IF_FAIL(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
592
593         result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
594
595         return result;
596 }
597
598 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
599 {
600         int result = MM_ERROR_NONE;
601
602         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
603         MMPLAYER_RETURN_VAL_IF_FAIL(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
604         MMPLAYER_RETURN_VAL_IF_FAIL(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
605
606         result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
607
608         return result;
609 }
610
611 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
612 {
613         int result = MM_ERROR_NONE;
614
615         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
616         MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
617
618         MMPLAYER_CMD_LOCK(player);
619
620         result = _mmplayer_get_track_count(player, type, count);
621
622         MMPLAYER_CMD_UNLOCK(player);
623
624         return result;
625 }
626
627 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
628 {
629         int result = MM_ERROR_NONE;
630
631         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
632
633         MMPLAYER_CMD_LOCK(player);
634
635         result = _mmplayer_select_track(player, type, index);
636
637         MMPLAYER_CMD_UNLOCK(player);
638
639         return result;
640 }
641 #ifdef _MULTI_TRACK
642 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
643 {
644         int result = MM_ERROR_NONE;
645
646         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
647
648         MMPLAYER_CMD_LOCK(player);
649
650         result = _mmplayer_track_add_subtitle_language(player, index);
651
652         MMPLAYER_CMD_UNLOCK(player);
653
654         return result;
655 }
656
657 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
658 {
659         int result = MM_ERROR_NONE;
660
661         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
662
663         MMPLAYER_CMD_LOCK(player);
664
665         result = _mmplayer_track_remove_subtitle_language(player, index);
666
667         MMPLAYER_CMD_UNLOCK(player);
668
669         return result;
670
671 }
672 #endif
673 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
674 {
675         int result = MM_ERROR_NONE;
676
677         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
678         MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
679
680         MMPLAYER_CMD_LOCK(player);
681
682         result = _mmplayer_get_current_track(player, type, index);
683
684         MMPLAYER_CMD_UNLOCK(player);
685
686         return result;
687 }
688
689 int mm_player_get_track_language_code(MMHandleType player,  MMPlayerTrackType type, int index, char **code)
690 {
691         int result = MM_ERROR_NONE;
692
693         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
694
695         MMPLAYER_CMD_LOCK(player);
696
697         result = _mmplayer_get_track_language_code(player, type, index, code);
698
699         MMPLAYER_CMD_UNLOCK(player);
700
701         return result;
702 }
703
704 int mm_player_set_video_share_master_clock(MMHandleType player, int64_t clock, int64_t clock_delta,
705                                                                                         int64_t video_time, int64_t media_clock, int64_t audio_time)
706 {
707         int result = MM_ERROR_NONE;
708
709         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
710
711         MMPLAYER_CMD_LOCK(player);
712
713         result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
714
715         MMPLAYER_CMD_UNLOCK(player);
716
717         return result;
718 }
719
720 int mm_player_get_video_share_master_clock(MMHandleType player, int64_t *video_time, int64_t *media_clock, int64_t *audio_time)
721 {
722         int result = MM_ERROR_NONE;
723
724         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
725         MMPLAYER_RETURN_VAL_IF_FAIL(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
726         MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
727         MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
728
729         MMPLAYER_CMD_LOCK(player);
730
731         result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
732
733         MMPLAYER_CMD_UNLOCK(player);
734
735         return result;
736 }
737
738 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
739 {
740         int result = MM_ERROR_NONE;
741
742         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
743
744         MMPLAYER_CMD_LOCK(player);
745
746         result = _mmplayer_set_video_hub_download_mode(player, mode);
747
748         MMPLAYER_CMD_UNLOCK(player);
749
750         return result;
751 }
752
753 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
754 {
755         int result = MM_ERROR_NONE;
756
757         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
758
759         MMPLAYER_CMD_LOCK(player);
760
761         result = _mmplayer_enable_sync_handler(player, enable);
762
763         MMPLAYER_CMD_UNLOCK(player);
764
765         return result;
766 }
767
768 int mm_player_set_uri(MMHandleType player, const char *uri)
769 {
770         int result = MM_ERROR_NONE;
771
772         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
773
774         MMPLAYER_CMD_LOCK(player);
775
776         result = _mmplayer_set_uri(player, uri);
777
778         MMPLAYER_CMD_UNLOCK(player);
779
780         return result;
781
782 }
783
784 int mm_player_set_next_uri(MMHandleType player, const char *uri)
785 {
786         int result = MM_ERROR_NONE;
787
788         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
789
790         MMPLAYER_CMD_LOCK(player);
791
792         result = _mmplayer_set_next_uri(player, uri, FALSE);
793
794         MMPLAYER_CMD_UNLOCK(player);
795
796         return result;
797
798 }
799
800 int mm_player_get_next_uri(MMHandleType player, char **uri)
801 {
802         int result = MM_ERROR_NONE;
803
804         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
805
806         MMPLAYER_CMD_LOCK(player);
807
808         result = _mmplayer_get_next_uri(player, uri);
809
810         MMPLAYER_CMD_UNLOCK(player);
811
812         return result;
813
814 }
815 #ifdef _MULTI_TRACK
816 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
817 {
818         int result = MM_ERROR_NONE;
819
820         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
821
822         MMPLAYER_CMD_LOCK(player);
823
824         result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
825
826         MMPLAYER_CMD_UNLOCK(player);
827
828         return result;
829 }
830 #endif
831
832 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
833 {
834         int result = MM_ERROR_NONE;
835
836         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
837         MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT);
838
839         MMPLAYER_CMD_LOCK(player);
840
841         result = _mmplayer_has_closed_caption(player, exist);
842
843         MMPLAYER_CMD_UNLOCK(player);
844
845         return result;
846 }
847
848 void mm_player_video_stream_internal_buffer_unref(void *buffer)
849 {
850         _mm_player_video_stream_internal_buffer_unref(buffer);
851 }
852
853 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
854 {
855
856         int result = MM_ERROR_NONE;
857
858         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
859
860         /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
861         //MMPLAYER_CMD_LOCK(player);
862
863         result = _mmplayer_submit_packet(player, packet);
864
865         //MMPLAYER_CMD_UNLOCK(player);
866
867         return result;
868 }
869
870 int mm_player_set_video_info(MMHandleType player, media_format_h format)
871 {
872         int result = MM_ERROR_NONE;
873
874         LOGD("\n");
875
876         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
877
878         MMPLAYER_CMD_LOCK(player);
879
880         result = _mmplayer_set_video_info(player, format);
881
882         MMPLAYER_CMD_UNLOCK(player);
883
884         return result;
885
886 }
887
888 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
889 {
890         int result = MM_ERROR_NONE;
891
892         LOGD("\n");
893
894         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
895
896         MMPLAYER_CMD_LOCK(player);
897
898         result = _mmplayer_set_audio_info(player, format);
899
900         MMPLAYER_CMD_UNLOCK(player);
901
902         return result;
903 }
904
905 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
906 {
907         int result = MM_ERROR_NONE;
908
909         LOGD("\n");
910
911         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
912
913         MMPLAYER_CMD_LOCK(player);
914
915         result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
916
917         MMPLAYER_CMD_UNLOCK(player);
918
919         return result;
920 }
921
922 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
923 {
924         int result = MM_ERROR_NONE;
925
926         LOGD("\n");
927
928         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
929
930         MMPLAYER_CMD_LOCK(player);
931
932         result = _mmplayer_set_media_stream_max_size(player, type, max_size);
933
934         MMPLAYER_CMD_UNLOCK(player);
935
936         return result;
937 }
938
939 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
940 {
941         int result = MM_ERROR_NONE;
942         guint64 _max_size = 0;
943
944         LOGD("\n");
945
946         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
947         MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
948
949         MMPLAYER_CMD_LOCK(player);
950
951         result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
952         *max_size = _max_size;
953
954         MMPLAYER_CMD_UNLOCK(player);
955
956         return result;
957 }
958
959 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
960 {
961         int result = MM_ERROR_NONE;
962
963         LOGD("\n");
964
965         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
966
967         MMPLAYER_CMD_LOCK(player);
968
969         result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
970
971         MMPLAYER_CMD_UNLOCK(player);
972
973         return result;
974 }
975
976 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
977 {
978         int result = MM_ERROR_NONE;
979
980         LOGD("\n");
981
982         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
983         MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
984
985         MMPLAYER_CMD_LOCK(player);
986
987         result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
988
989         MMPLAYER_CMD_UNLOCK(player);
990
991         return result;
992 }
993
994 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
995 {
996         int result = MM_ERROR_NONE;
997
998         LOGD("\n");
999
1000         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1001
1002         MMPLAYER_CMD_LOCK(player);
1003
1004         result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1005
1006         MMPLAYER_CMD_UNLOCK(player);
1007
1008         return result;
1009 }
1010
1011 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1012 {
1013         int result = MM_ERROR_NONE;
1014
1015         LOGD("\n");
1016
1017         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1018
1019         MMPLAYER_CMD_LOCK(player);
1020
1021         result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1022
1023         MMPLAYER_CMD_UNLOCK(player);
1024
1025         return result;
1026 }
1027
1028 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1029 {
1030         int result = MM_ERROR_NONE;
1031
1032         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1033
1034         MMPLAYER_CMD_LOCK(player);
1035
1036         result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1037
1038         MMPLAYER_CMD_UNLOCK(player);
1039
1040         return result;
1041 }
1042
1043 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1044 {
1045         int result = MM_ERROR_NONE;
1046
1047         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1048
1049         MMPLAYER_CMD_LOCK(player);
1050
1051         result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1052
1053         MMPLAYER_CMD_UNLOCK(player);
1054
1055         return result;
1056 }
1057
1058 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1059 {
1060         int result = MM_ERROR_NONE;
1061
1062         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1063
1064         MMPLAYER_CMD_LOCK(player);
1065
1066         result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1067
1068         MMPLAYER_CMD_UNLOCK(player);
1069
1070         return result;
1071 }
1072
1073 int mm_player_get_timeout(MMHandleType player, int *timeout)
1074 {
1075         int result = MM_ERROR_NONE;
1076
1077         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1078         MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1079
1080         MMPLAYER_CMD_LOCK(player);
1081
1082         result = _mmplayer_get_timeout(player, timeout);
1083
1084         MMPLAYER_CMD_UNLOCK(player);
1085
1086         return result;
1087 }
1088
1089 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1090 {
1091         int result = MM_ERROR_NONE;
1092
1093         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1094         MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1095
1096         MMPLAYER_CMD_LOCK(player);
1097
1098         result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1099
1100         MMPLAYER_CMD_UNLOCK(player);
1101
1102         return result;
1103 }
1104
1105 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1106 {
1107         int result = MM_ERROR_NONE;
1108
1109         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1110
1111         MMPLAYER_CMD_LOCK(player);
1112
1113         result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1114
1115         MMPLAYER_CMD_UNLOCK(player);
1116
1117         return result;
1118 }
1119
1120 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1121 {
1122         int result = MM_ERROR_NONE;
1123
1124         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1125         MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1126
1127         //MMPLAYER_CMD_LOCK(player);
1128
1129         result = _mmplayer_video_stream_release_bo(player, bo);
1130
1131         //MMPLAYER_CMD_UNLOCK(player);
1132
1133         return result;
1134 }
1135
1136 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1137 {
1138         int result = MM_ERROR_NONE;
1139
1140         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1141
1142         MMPLAYER_CMD_LOCK(player);
1143
1144         result = _mmplayer_set_file_buffering_path(player, file_path);
1145
1146         MMPLAYER_CMD_UNLOCK(player);
1147
1148         return result;
1149 }
1150
1151 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1152 {
1153         int result = MM_ERROR_NONE;
1154
1155         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1156         MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1157
1158         MMPLAYER_CMD_LOCK(player);
1159
1160         result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1161
1162         MMPLAYER_CMD_UNLOCK(player);
1163
1164         return result;
1165 }
1166
1167 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state)
1168 {
1169         int result = MM_ERROR_NONE;
1170
1171         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1172
1173         MMPLAYER_CMD_LOCK(player);
1174
1175         result = _mmplayer_manage_external_storage_state(player, id, state);
1176
1177         MMPLAYER_CMD_UNLOCK(player);
1178
1179         return result;
1180 }
1181
1182 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1183 {
1184         int result = MM_ERROR_NONE;
1185
1186         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1187         MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1188
1189         MMPLAYER_CMD_LOCK(player);
1190
1191         result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1192
1193         MMPLAYER_CMD_UNLOCK(player);
1194
1195         return result;
1196 }
1197
1198 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1199 {
1200         int result = MM_ERROR_NONE;
1201
1202         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1203
1204         MMPLAYER_CMD_LOCK(player);
1205
1206         result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1207
1208         MMPLAYER_CMD_UNLOCK(player);
1209
1210         return result;
1211 }
1212
1213 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1214 {
1215         int result = MM_ERROR_NONE;
1216
1217         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1218         MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1219
1220         MMPLAYER_CMD_LOCK(player);
1221
1222         result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1223
1224         MMPLAYER_CMD_UNLOCK(player);
1225
1226         return result;
1227 }
1228
1229 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1230 {
1231         int result = MM_ERROR_NONE;
1232         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1233
1234         MMPLAYER_CMD_LOCK(player);
1235
1236         result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1237
1238         MMPLAYER_CMD_UNLOCK(player);
1239
1240         return result;
1241 }
1242
1243 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1244 {
1245         int result = MM_ERROR_NONE;
1246
1247         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1248         MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1249
1250         MMPLAYER_CMD_LOCK(player);
1251
1252         result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1253
1254         MMPLAYER_CMD_UNLOCK(player);
1255
1256         return result;
1257 }
1258
1259 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1260 {
1261         int result = MM_ERROR_NONE;
1262         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1263
1264         MMPLAYER_CMD_LOCK(player);
1265
1266         result = _mmplayer_set_audio_only(player, audio_only);
1267
1268         MMPLAYER_CMD_UNLOCK(player);
1269
1270         return result;
1271 }
1272
1273 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1274 {
1275         int result = MM_ERROR_NONE;
1276
1277         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1278         MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1279
1280         MMPLAYER_CMD_LOCK(player);
1281
1282         result = _mmplayer_get_audio_only(player, audio_only);
1283
1284         MMPLAYER_CMD_UNLOCK(player);
1285
1286         return result;
1287 }
1288
1289 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
1290 {
1291         int result = MM_ERROR_NONE;
1292
1293         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1294         MMPLAYER_RETURN_VAL_IF_FAIL(is_spherical, MM_ERROR_INVALID_ARGUMENT);
1295
1296         MMPLAYER_CMD_LOCK(player);
1297
1298         result = _mmplayer_360_is_content_spherical(player, is_spherical);
1299
1300         MMPLAYER_CMD_UNLOCK(player);
1301
1302         return result;
1303 }
1304
1305 int mm_player_360_set_enabled(MMHandleType player, bool enabled)
1306 {
1307         int result = MM_ERROR_NONE;
1308         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1309
1310         MMPLAYER_CMD_LOCK(player);
1311
1312         result = _mmplayer_360_set_enabled(player, enabled);
1313
1314         MMPLAYER_CMD_UNLOCK(player);
1315
1316         return result;
1317 }
1318
1319 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1320 {
1321         int result = MM_ERROR_NONE;
1322
1323         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1324         MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1325
1326         MMPLAYER_CMD_LOCK(player);
1327
1328         result = _mmplayer_360_is_enabled(player, enabled);
1329
1330         MMPLAYER_CMD_UNLOCK(player);
1331
1332         return result;
1333 }
1334
1335 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1336 {
1337         int result = MM_ERROR_NONE;
1338         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1339
1340         MMPLAYER_CMD_LOCK(player);
1341
1342         result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1343
1344         MMPLAYER_CMD_UNLOCK(player);
1345
1346         return result;
1347 }
1348
1349 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1350 {
1351         int result = MM_ERROR_NONE;
1352
1353         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1354         MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1355
1356         MMPLAYER_CMD_LOCK(player);
1357
1358         result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1359
1360         MMPLAYER_CMD_UNLOCK(player);
1361
1362         return result;
1363 }
1364
1365 int mm_player_360_set_zoom(MMHandleType player, float level)
1366 {
1367         int result = MM_ERROR_NONE;
1368         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1369
1370         MMPLAYER_CMD_LOCK(player);
1371
1372         result = _mmplayer_360_set_zoom(player, level);
1373
1374         MMPLAYER_CMD_UNLOCK(player);
1375
1376         return result;
1377 }
1378
1379 int mm_player_360_get_zoom(MMHandleType player, float *level)
1380 {
1381         int result = MM_ERROR_NONE;
1382
1383         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1384         MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1385
1386         MMPLAYER_CMD_LOCK(player);
1387
1388         result = _mmplayer_360_get_zoom(player, level);
1389
1390         MMPLAYER_CMD_UNLOCK(player);
1391
1392         return result;
1393 }
1394
1395 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1396 {
1397         int result = MM_ERROR_NONE;
1398         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1399
1400         MMPLAYER_CMD_LOCK(player);
1401
1402         result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1403
1404         MMPLAYER_CMD_UNLOCK(player);
1405
1406         return result;
1407 }
1408
1409 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1410 {
1411         int result = MM_ERROR_NONE;
1412
1413         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1414         MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1415
1416         MMPLAYER_CMD_LOCK(player);
1417
1418         result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1419
1420         MMPLAYER_CMD_UNLOCK(player);
1421
1422         return result;
1423 }
1424
1425 int mm_player_set_codec_type(MMHandleType player, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type)
1426 {
1427         int result = MM_ERROR_NONE;
1428
1429         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1430
1431         MMPLAYER_CMD_LOCK(player);
1432
1433         result = _mmplayer_set_codec_type(player, stream_type, codec_type);
1434
1435         MMPLAYER_CMD_UNLOCK(player);
1436
1437         return result;
1438 }
1439
1440 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled)
1441 {
1442         int result = MM_ERROR_NONE;
1443
1444         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1445
1446         MMPLAYER_CMD_LOCK(player);
1447
1448         result = _mmplayer_set_replaygain_enabled(player, enabled);
1449
1450         MMPLAYER_CMD_UNLOCK(player);
1451
1452         return result;
1453 }
1454
1455 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled)
1456 {
1457         int result = MM_ERROR_NONE;
1458
1459         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1460         MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1461
1462         MMPLAYER_CMD_LOCK(player);
1463
1464         result = _mmplayer_is_replaygain_enabled(player, enabled);
1465
1466         MMPLAYER_CMD_UNLOCK(player);
1467
1468         return result;
1469 }