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