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