Merge branch 'tizen_4.0' into 'tizen'
[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_video_stream_internal_buffer_unref(void *buffer)
926 {
927         _mm_player_video_stream_internal_buffer_unref(buffer);
928 }
929
930 int mm_player_submit_packet(MMHandleType player, media_packet_h packet)
931 {
932
933         int result = MM_ERROR_NONE;
934
935         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
936
937         /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */
938         //MMPLAYER_CMD_LOCK(player);
939
940         result = _mmplayer_submit_packet(player, packet);
941
942         //MMPLAYER_CMD_UNLOCK(player);
943
944         return result;
945 }
946
947 int mm_player_set_video_info(MMHandleType player, media_format_h format)
948 {
949         int result = MM_ERROR_NONE;
950
951         LOGD("\n");
952
953         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
954
955         MMPLAYER_CMD_LOCK(player);
956
957         result = _mmplayer_set_video_info(player, format);
958
959         MMPLAYER_CMD_UNLOCK(player);
960
961         return result;
962
963 }
964
965 int mm_player_set_audio_info(MMHandleType player, media_format_h format)
966 {
967         int result = MM_ERROR_NONE;
968
969         LOGD("\n");
970
971         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
972
973         MMPLAYER_CMD_LOCK(player);
974
975         result = _mmplayer_set_audio_info(player, format);
976
977         MMPLAYER_CMD_UNLOCK(player);
978
979         return result;
980 }
981
982 int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info)
983 {
984         int result = MM_ERROR_NONE;
985
986         LOGD("\n");
987
988         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
989
990         MMPLAYER_CMD_LOCK(player);
991
992         result = _mmplayer_set_subtitle_info(player, subtitle_stream_info);
993
994         MMPLAYER_CMD_UNLOCK(player);
995
996         return result;
997 }
998
999 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size)
1000 {
1001         int result = MM_ERROR_NONE;
1002
1003         LOGD("\n");
1004
1005         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1006
1007         MMPLAYER_CMD_LOCK(player);
1008
1009         result = _mmplayer_set_media_stream_max_size(player, type, max_size);
1010
1011         MMPLAYER_CMD_UNLOCK(player);
1012
1013         return result;
1014 }
1015
1016 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size)
1017 {
1018         int result = MM_ERROR_NONE;
1019         guint64 _max_size = 0;
1020
1021         LOGD("\n");
1022
1023         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1024         MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT);
1025
1026         MMPLAYER_CMD_LOCK(player);
1027
1028         result = _mmplayer_get_media_stream_max_size(player, type, &_max_size);
1029         *max_size = _max_size;
1030
1031         MMPLAYER_CMD_UNLOCK(player);
1032
1033         return result;
1034 }
1035
1036 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent)
1037 {
1038         int result = MM_ERROR_NONE;
1039
1040         LOGD("\n");
1041
1042         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1043
1044         MMPLAYER_CMD_LOCK(player);
1045
1046         result = _mmplayer_set_media_stream_min_percent(player, type, min_percent);
1047
1048         MMPLAYER_CMD_UNLOCK(player);
1049
1050         return result;
1051 }
1052
1053 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent)
1054 {
1055         int result = MM_ERROR_NONE;
1056
1057         LOGD("\n");
1058
1059         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1060         MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT);
1061
1062         MMPLAYER_CMD_LOCK(player);
1063
1064         result = _mmplayer_get_media_stream_min_percent(player, type, min_percent);
1065
1066         MMPLAYER_CMD_UNLOCK(player);
1067
1068         return result;
1069 }
1070
1071 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param)
1072 {
1073         int result = MM_ERROR_NONE;
1074
1075         LOGD("\n");
1076
1077         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1078
1079         MMPLAYER_CMD_LOCK(player);
1080
1081         result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
1082
1083         MMPLAYER_CMD_UNLOCK(player);
1084
1085         return result;
1086 }
1087
1088 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param)
1089 {
1090         int result = MM_ERROR_NONE;
1091
1092         LOGD("\n");
1093
1094         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1095
1096         MMPLAYER_CMD_LOCK(player);
1097
1098         result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
1099
1100         MMPLAYER_CMD_UNLOCK(player);
1101
1102         return result;
1103 }
1104
1105 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1106 {
1107         int result = MM_ERROR_NONE;
1108
1109         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1110
1111         MMPLAYER_CMD_LOCK(player);
1112
1113         result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param);
1114
1115         MMPLAYER_CMD_UNLOCK(player);
1116
1117         return result;
1118 }
1119
1120 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
1121 {
1122         int result = MM_ERROR_NONE;
1123
1124         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1125
1126         MMPLAYER_CMD_LOCK(player);
1127
1128         result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
1129
1130         MMPLAYER_CMD_UNLOCK(player);
1131
1132         return result;
1133 }
1134
1135 int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel)
1136 {
1137         int result = MM_ERROR_NONE;
1138
1139         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1140
1141         MMPLAYER_CMD_LOCK(player);
1142
1143         result = _mmplayer_set_pcm_spec(player, samplerate, channel);
1144
1145         MMPLAYER_CMD_UNLOCK(player);
1146
1147         return result;
1148 }
1149
1150 int mm_player_get_timeout(MMHandleType player, int *timeout)
1151 {
1152         int result = MM_ERROR_NONE;
1153
1154         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1155         MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT);
1156
1157         MMPLAYER_CMD_LOCK(player);
1158
1159         result = _mmplayer_get_timeout(player, timeout);
1160
1161         MMPLAYER_CMD_UNLOCK(player);
1162
1163         return result;
1164 }
1165
1166 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
1167 {
1168         int result = MM_ERROR_NONE;
1169
1170         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1171         MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
1172
1173         MMPLAYER_CMD_LOCK(player);
1174
1175         result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
1176
1177         MMPLAYER_CMD_UNLOCK(player);
1178
1179         return result;
1180 }
1181
1182 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
1183 {
1184         int result = MM_ERROR_NONE;
1185
1186         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1187
1188         MMPLAYER_CMD_LOCK(player);
1189
1190         result = _mmplayer_set_media_stream_dynamic_resolution(player, drc);
1191
1192         MMPLAYER_CMD_UNLOCK(player);
1193
1194         return result;
1195 }
1196
1197 int mm_player_release_video_stream_bo(MMHandleType player, void* bo)
1198 {
1199         int result = MM_ERROR_NONE;
1200
1201         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1202         MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT);
1203
1204         //MMPLAYER_CMD_LOCK(player);
1205
1206         result = _mmplayer_video_stream_release_bo(player, bo);
1207
1208         //MMPLAYER_CMD_UNLOCK(player);
1209
1210         return result;
1211 }
1212
1213 int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path)
1214 {
1215         int result = MM_ERROR_NONE;
1216
1217         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1218
1219         MMPLAYER_CMD_LOCK(player);
1220
1221         result = _mmplayer_set_file_buffering_path(player, file_path);
1222
1223         MMPLAYER_CMD_UNLOCK(player);
1224
1225         return result;
1226 }
1227
1228 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index)
1229 {
1230         int result = MM_ERROR_NONE;
1231
1232         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1233         MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT);
1234
1235         MMPLAYER_CMD_LOCK(player);
1236
1237         _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus);
1238         result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL);
1239
1240         MMPLAYER_CMD_UNLOCK(player);
1241
1242         return result;
1243 }
1244
1245 int mm_player_manage_external_storage_state(MMHandleType player, int state)
1246 {
1247         int result = MM_ERROR_NONE;
1248
1249         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1250
1251         MMPLAYER_CMD_LOCK(player);
1252
1253         result = _mmplayer_manage_external_storage_state(player, state);
1254
1255         MMPLAYER_CMD_UNLOCK(player);
1256
1257         return result;
1258 }
1259
1260 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info)
1261 {
1262         int result = MM_ERROR_NONE;
1263
1264         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1265         MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT);
1266
1267         MMPLAYER_CMD_LOCK(player);
1268
1269         result = _mmplayer_get_adaptive_variant_info(player, num, var_info);
1270
1271         MMPLAYER_CMD_UNLOCK(player);
1272
1273         return result;
1274 }
1275
1276 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height)
1277 {
1278         int result = MM_ERROR_NONE;
1279
1280         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1281
1282         MMPLAYER_CMD_LOCK(player);
1283
1284         result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height);
1285
1286         MMPLAYER_CMD_UNLOCK(player);
1287
1288         return result;
1289 }
1290
1291 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height)
1292 {
1293         int result = MM_ERROR_NONE;
1294
1295         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1296         MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT);
1297
1298         MMPLAYER_CMD_LOCK(player);
1299
1300         result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height);
1301
1302         MMPLAYER_CMD_UNLOCK(player);
1303
1304         return result;
1305 }
1306
1307 int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, int rebuffer_ms)
1308 {
1309         int result = MM_ERROR_NONE;
1310         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1311
1312         MMPLAYER_CMD_LOCK(player);
1313
1314         result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1315
1316         MMPLAYER_CMD_UNLOCK(player);
1317
1318         return result;
1319 }
1320
1321 int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms)
1322 {
1323         int result = MM_ERROR_NONE;
1324
1325         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1326         MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT);
1327
1328         MMPLAYER_CMD_LOCK(player);
1329
1330         result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms);
1331
1332         MMPLAYER_CMD_UNLOCK(player);
1333
1334         return result;
1335 }
1336
1337 int mm_player_set_audio_only(MMHandleType player, bool audio_only)
1338 {
1339         int result = MM_ERROR_NONE;
1340         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1341
1342         MMPLAYER_CMD_LOCK(player);
1343
1344         result = _mmplayer_set_audio_only(player, audio_only);
1345
1346         MMPLAYER_CMD_UNLOCK(player);
1347
1348         return result;
1349 }
1350
1351 int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
1352 {
1353         int result = MM_ERROR_NONE;
1354
1355         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1356         MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
1357
1358         MMPLAYER_CMD_LOCK(player);
1359
1360         result = _mmplayer_get_audio_only(player, audio_only);
1361
1362         MMPLAYER_CMD_UNLOCK(player);
1363
1364         return result;
1365 }
1366
1367 int mm_player_360_set_enable(MMHandleType player, bool enable)
1368 {
1369         int result = MM_ERROR_NONE;
1370         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1371
1372         MMPLAYER_CMD_LOCK(player);
1373
1374         result = _mmplayer_360_set_enable(player, enable);
1375
1376         MMPLAYER_CMD_UNLOCK(player);
1377
1378         return result;
1379 }
1380
1381 int mm_player_360_is_enabled(MMHandleType player, bool *enabled)
1382 {
1383         int result = MM_ERROR_NONE;
1384
1385         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1386         MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT);
1387
1388         MMPLAYER_CMD_LOCK(player);
1389
1390         result = _mmplayer_360_is_enabled(player, enabled);
1391
1392         MMPLAYER_CMD_UNLOCK(player);
1393
1394         return result;
1395 }
1396
1397 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch)
1398 {
1399         int result = MM_ERROR_NONE;
1400         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1401
1402         MMPLAYER_CMD_LOCK(player);
1403
1404         result = _mmplayer_360_set_direction_of_view(player, yaw, pitch);
1405
1406         MMPLAYER_CMD_UNLOCK(player);
1407
1408         return result;
1409 }
1410
1411 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch)
1412 {
1413         int result = MM_ERROR_NONE;
1414
1415         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1416         MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT);
1417
1418         MMPLAYER_CMD_LOCK(player);
1419
1420         result = _mmplayer_360_get_direction_of_view(player, yaw, pitch);
1421
1422         MMPLAYER_CMD_UNLOCK(player);
1423
1424         return result;
1425 }
1426
1427 int mm_player_360_set_zoom(MMHandleType player, float level)
1428 {
1429         int result = MM_ERROR_NONE;
1430         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1431
1432         MMPLAYER_CMD_LOCK(player);
1433
1434         result = _mmplayer_360_set_zoom(player, level);
1435
1436         MMPLAYER_CMD_UNLOCK(player);
1437
1438         return result;
1439 }
1440
1441 int mm_player_360_get_zoom(MMHandleType player, float *level)
1442 {
1443         int result = MM_ERROR_NONE;
1444
1445         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1446         MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT);
1447
1448         MMPLAYER_CMD_LOCK(player);
1449
1450         result = _mmplayer_360_get_zoom(player, level);
1451
1452         MMPLAYER_CMD_UNLOCK(player);
1453
1454         return result;
1455 }
1456
1457 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees)
1458 {
1459         int result = MM_ERROR_NONE;
1460         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1461
1462         MMPLAYER_CMD_LOCK(player);
1463
1464         result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees);
1465
1466         MMPLAYER_CMD_UNLOCK(player);
1467
1468         return result;
1469 }
1470
1471 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees)
1472 {
1473         int result = MM_ERROR_NONE;
1474
1475         MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1476         MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT);
1477
1478         MMPLAYER_CMD_LOCK(player);
1479
1480         result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees);
1481
1482         MMPLAYER_CMD_UNLOCK(player);
1483
1484         return result;
1485 }