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