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