Update to version tizen 2.3 API base on Gstreamer 1.x
[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 <mm_types.h>
27 #include <mm_message.h>
28
29 #include "mm_player.h"
30 #include "mm_player_priv.h"
31 #include "mm_player_attrs.h"
32 #include "mm_player_utils.h"
33 #include "mm_player_ini.h"
34 #include "mm_debug.h"
35 #include "mm_player_capture.h"
36 #include "mm_player_tracks.h"
37
38 int mm_player_create(MMHandleType *player)
39 {
40         int result = MM_ERROR_NONE;
41         mm_player_t* new_player = NULL;
42
43         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
44
45 //      if (!g_thread_supported ())
46 //              g_thread_init (NULL); g_thread_init has been deprecated since version 2.32 and should not be used in newly-written code. This function is no longer necessary. The GLib threading system is automatically initialized at the start of your program.
47
48         /* alloc player structure */
49         new_player = g_malloc(sizeof(mm_player_t));
50         if ( ! new_player )
51         {
52                 debug_error("Cannot allocate memory for player\n");
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         if (!(&new_player->cmd_lock))
61         {
62                 debug_error("failed to create player lock\n");
63                 goto ERROR;
64         }
65
66         /* create player lock */
67         g_mutex_init(&new_player->playback_lock);
68
69         if (!(&new_player->playback_lock) )
70         {
71                 debug_error("failed to create playback_lock\n");
72                 goto ERROR;
73         }
74
75         /* create msg callback lock */
76         g_mutex_init(&new_player->msg_cb_lock);
77
78         if (!(&new_player->msg_cb_lock))
79         {
80                 debug_error("failed to create msg cb lock\n");
81                 goto ERROR;
82         }
83
84         /* load ini files */
85         result = mm_player_ini_load(&new_player->ini);
86         if(result != MM_ERROR_NONE)
87         {
88                 debug_error("can't load ini");
89                 goto ERROR;
90         }
91
92         result = mm_player_audio_effect_ini_load(&new_player->ini);
93         if(result != MM_ERROR_NONE)
94         {
95                 debug_error("can't load audio ini");
96                 goto ERROR;
97         }
98
99
100         /* create player */
101         result = _mmplayer_create_player((MMHandleType)new_player);
102
103         if(result != MM_ERROR_NONE)
104         {
105                 debug_error("failed to create player");
106                 goto ERROR;
107         }
108
109         *player = (MMHandleType)new_player;
110
111         return result;
112
113 ERROR:
114
115         if ( new_player )
116         {
117                 if (&new_player->cmd_lock)
118                 {
119                         g_mutex_clear(&new_player->cmd_lock);
120                 }
121
122                 if (&new_player->playback_lock)
123                 {
124                         g_mutex_clear(&new_player->playback_lock);
125                 }
126
127                 _mmplayer_destroy( (MMHandleType)new_player );
128
129                 MMPLAYER_FREEIF( new_player );
130         }
131
132         *player = (MMHandleType)0;
133         return MM_ERROR_PLAYER_NO_FREE_SPACE; // are you sure?
134 }
135
136 int  mm_player_destroy(MMHandleType player)
137 {
138         int result = MM_ERROR_NONE;
139
140         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
141
142         MMPLAYER_CMD_LOCK( player );
143
144         result = _mmplayer_destroy(player);
145
146         MMPLAYER_CMD_UNLOCK( player );
147
148         if (&((mm_player_t*)player)->cmd_lock)
149         {
150                 g_mutex_clear(&((mm_player_t*)player)->cmd_lock);
151         }
152
153         if (&((mm_player_t*)player)->playback_lock)
154         {
155                 g_mutex_clear(&((mm_player_t*)player)->playback_lock);
156         }
157
158         memset( (mm_player_t*)player, 0x00, sizeof(mm_player_t) );
159
160         /* free player */
161         g_free( (void*)player );
162
163         return result;
164 }
165
166 int mm_player_realize(MMHandleType player)
167 {
168         int result = MM_ERROR_NONE;
169
170         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
171
172         MMPLAYER_CMD_LOCK( player );
173
174         result = _mmplayer_realize(player);
175
176         MMPLAYER_CMD_UNLOCK( player );
177
178         return result;
179 }
180
181 int mm_player_unrealize(MMHandleType player)
182 {
183         int result = MM_ERROR_NONE;
184
185         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
186
187         MMPLAYER_CMD_LOCK( player );
188
189         result = _mmplayer_unrealize(player);
190
191         MMPLAYER_CMD_UNLOCK( player );
192
193         return result;
194 }
195
196 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
197 {
198         int result = MM_ERROR_NONE;
199
200         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
201
202         MMPLAYER_CMD_LOCK( player );
203
204         result = _mmplayer_set_message_callback(player, callback, user_param);
205
206         MMPLAYER_CMD_UNLOCK( player );
207
208         return result;
209 }
210
211 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
212 {
213         int result = MM_ERROR_NONE;
214
215         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
216
217         result = _mm_player_set_pd_downloader_message_cb(player, callback, user_param);
218
219         return result;
220 }
221
222 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
223 {
224         int result = MM_ERROR_NONE;
225
226         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
227
228         MMPLAYER_CMD_LOCK( player );
229
230         result = _mmplayer_set_audiostream_cb(player, callback, user_param);
231
232         MMPLAYER_CMD_UNLOCK( player );
233
234         return result;
235 }
236
237 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
238 {
239         int result = MM_ERROR_NONE;
240
241         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
242
243         MMPLAYER_CMD_LOCK( player );
244
245         result = _mmplayer_set_videostream_cb(player, callback, user_param);
246
247         MMPLAYER_CMD_UNLOCK( player );
248
249         return result;
250 }
251
252 int mm_player_set_video_frame_render_error_callback(MMHandleType player, mm_player_video_frame_render_error_callback callback, void *user_param)
253 {
254         int result = MM_ERROR_NONE;
255
256         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
257
258         MMPLAYER_CMD_LOCK( player );
259
260         result = _mmplayer_set_videoframe_render_error_cb(player, callback, user_param);
261
262         MMPLAYER_CMD_UNLOCK( player );
263
264         return result;
265 }
266
267 int mm_player_do_video_capture(MMHandleType player)
268 {
269         int result = MM_ERROR_NONE;
270
271         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
272
273         MMPLAYER_CMD_LOCK( player );
274
275         result = _mmplayer_do_video_capture(player);
276
277         MMPLAYER_CMD_UNLOCK( player );
278
279         return result;
280 }
281
282 int mm_player_set_prepare_buffering_time(MMHandleType player, int second)
283 {
284         int result = MM_ERROR_NONE;
285
286         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
287
288         MMPLAYER_CMD_LOCK( player );
289
290         result = _mmplayer_set_prepare_buffering_time(player, second);
291
292         MMPLAYER_CMD_UNLOCK( player );
293
294         return result;
295 }
296
297 int mm_player_set_runtime_buffering_mode(MMHandleType player, MMPlayerBufferingMode mode, int second)
298 {
299         int result = MM_ERROR_NONE;
300
301         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
302
303         MMPLAYER_CMD_LOCK( player );
304
305         result = _mmplayer_set_runtime_buffering_mode(player, mode, second);
306
307         MMPLAYER_CMD_UNLOCK( player );
308
309         return result;
310 }
311
312 int mm_player_set_buffer_need_data_callback(MMHandleType player, mm_player_buffer_need_data_callback callback, void * user_param)
313 {
314         int result = MM_ERROR_NONE;
315
316         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
317
318         MMPLAYER_CMD_LOCK( player );
319
320         result = _mmplayer_set_buffer_need_data_cb(player, callback, user_param);
321
322         MMPLAYER_CMD_UNLOCK( player );
323
324         return result;
325 }
326
327 int mm_player_set_buffer_enough_data_callback(MMHandleType player, mm_player_buffer_enough_data_callback callback, void * user_param)
328 {
329         int result = MM_ERROR_NONE;
330
331         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
332
333         MMPLAYER_CMD_LOCK( player );
334
335         result = _mmplayer_set_buffer_enough_data_cb(player, callback, user_param);
336
337         MMPLAYER_CMD_UNLOCK( player );
338
339         return result;
340 }
341
342
343 int mm_player_set_buffer_seek_data_callback(MMHandleType player, mm_player_buffer_seek_data_callback callback, void * user_param)
344 {
345         int result = MM_ERROR_NONE;
346
347         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
348
349         MMPLAYER_CMD_LOCK( player );
350
351         result = _mmplayer_set_buffer_seek_data_cb(player, callback, user_param);
352
353         MMPLAYER_CMD_UNLOCK( player );
354
355         return result;
356 }
357
358 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
359 {
360         int result = MM_ERROR_NONE;
361
362         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
363         return_val_if_fail(volume, MM_ERROR_INVALID_ARGUMENT);
364
365         MMPLAYER_CMD_LOCK( player );
366
367         result = _mmplayer_set_volume(player, *volume);
368
369         MMPLAYER_CMD_UNLOCK( player );
370
371         return result;
372 }
373
374 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
375 {
376         int result = MM_ERROR_NONE;
377
378         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
379         return_val_if_fail(volume, MM_ERROR_INVALID_ARGUMENT);
380
381         MMPLAYER_CMD_LOCK( player );
382
383         result = _mmplayer_get_volume(player, volume);
384
385         MMPLAYER_CMD_UNLOCK( player );
386
387         return result;
388 }
389
390 int mm_player_set_mute(MMHandleType player, int mute)
391 {
392         int result = MM_ERROR_NONE;
393
394         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
395
396         MMPLAYER_CMD_LOCK( player );
397
398         result = _mmplayer_set_mute(player, mute);
399
400         MMPLAYER_CMD_UNLOCK( player );
401
402         return result;
403 }
404
405 int mm_player_get_mute(MMHandleType player, int *mute)
406 {
407         int result = MM_ERROR_NONE;
408
409         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
410         return_val_if_fail(mute, MM_ERROR_INVALID_ARGUMENT);
411
412         MMPLAYER_CMD_LOCK( player );
413
414         result = _mmplayer_get_mute(player, mute);
415
416         MMPLAYER_CMD_UNLOCK( player );
417
418         return result;
419 }
420
421 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
422 {
423         int result = MM_ERROR_NONE;
424
425         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
426         return_val_if_fail(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
427
428         *state = MM_PLAYER_STATE_NULL;
429
430         result = _mmplayer_get_state(player, (int*)state);
431
432         return result;
433 }
434
435 /* NOTE : It does not support some use cases, eg using colorspace converter */
436 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
437 {
438         int result = MM_ERROR_NONE;
439
440         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
441
442         MMPLAYER_CMD_LOCK( player );
443
444         result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
445
446         MMPLAYER_CMD_UNLOCK( player );
447
448         return result;
449 }
450
451 int mm_player_push_buffer(MMHandleType player, unsigned char *buf, int size)
452 {
453         int result = MM_ERROR_NONE;
454
455         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
456
457         //MMPLAYER_CMD_LOCK( player );
458
459         result = _mmplayer_push_buffer(player, buf, size);
460
461         //MMPLAYER_CMD_UNLOCK( player );
462
463         return result;
464 }
465
466 int mm_player_start(MMHandleType player)
467 {
468         int result = MM_ERROR_NONE;
469
470         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
471
472         MMPLAYER_CMD_LOCK( player );
473
474         result = _mmplayer_start(player);
475
476         MMPLAYER_CMD_UNLOCK( player );
477
478         return result;
479 }
480
481 int  mm_player_stop(MMHandleType player)
482 {
483         int result = MM_ERROR_NONE;
484
485         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
486
487         MMPLAYER_CMD_LOCK( player );
488
489         result = _mmplayer_stop(player);
490
491         MMPLAYER_CMD_UNLOCK( player );
492
493         return result;
494 }
495
496 int mm_player_pause(MMHandleType player)
497 {
498         int result = MM_ERROR_NONE;
499
500         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
501
502         MMPLAYER_CMD_LOCK( player );
503
504         result = _mmplayer_pause(player);
505
506         MMPLAYER_CMD_UNLOCK( player );
507
508         return result;
509 }
510
511 int mm_player_resume(MMHandleType player)
512 {
513         int result = MM_ERROR_NONE;
514
515         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
516
517         MMPLAYER_CMD_LOCK( player );
518
519         result = _mmplayer_resume(player);
520
521         MMPLAYER_CMD_UNLOCK( player );
522
523         return result;
524 }
525
526 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
527 {
528         int result = MM_ERROR_NONE;
529
530         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
531
532         MMPLAYER_CMD_LOCK( player );
533
534         result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
535
536         MMPLAYER_CMD_UNLOCK( player );
537
538         return result;
539 }
540
541 int mm_player_deactivate_section_repeat(MMHandleType player)
542 {
543         int result = MM_ERROR_NONE;
544
545         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
546
547         MMPLAYER_CMD_LOCK( player );
548
549         result = _mmplayer_deactivate_section_repeat(player);
550
551         MMPLAYER_CMD_UNLOCK( player );
552
553         return result;
554 }
555
556 int mm_player_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch)
557 {
558         int result = MM_ERROR_NONE;
559
560         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
561         MMPLAYER_CMD_LOCK( player );
562
563         result = _mmplayer_gst_set_audio_channel(player, ch);
564
565         MMPLAYER_CMD_UNLOCK( player );
566         return result;
567 }
568
569 int mm_player_set_play_speed(MMHandleType player, float rate)
570 {
571         int result = MM_ERROR_NONE;
572
573         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
574
575         MMPLAYER_CMD_LOCK( player );
576
577         result = _mmplayer_set_playspeed(player, rate);
578
579         MMPLAYER_CMD_UNLOCK( player );
580
581         return result;
582 }
583
584 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
585 {
586         int result = MM_ERROR_NONE;
587
588         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
589
590         if (format >= MM_PLAYER_POS_FORMAT_NUM)
591         {
592                 debug_error("wrong format\n");
593                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
594         }
595
596         MMPLAYER_CMD_LOCK( player );
597
598         result = _mmplayer_set_position(player, format, pos);
599
600         MMPLAYER_CMD_UNLOCK( player );
601
602         return result;
603 }
604
605 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos)
606 {
607         int result = MM_ERROR_NONE;
608
609         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
610         return_val_if_fail(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
611
612         if (format >= MM_PLAYER_POS_FORMAT_NUM)
613         {
614                 debug_error("wrong format\n");
615                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
616         }
617
618         MMPLAYER_CMD_LOCK( player );
619
620         result = _mmplayer_get_position(player, (int)format, (unsigned long*)pos);
621
622         MMPLAYER_CMD_UNLOCK( player );
623
624         return result;
625 }
626
627 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int  *start_pos, int  *stop_pos)
628 {
629         int result = MM_ERROR_NONE;
630
631         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
632         return_val_if_fail(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
633
634         MMPLAYER_CMD_LOCK( player );
635
636         result = _mmplayer_get_buffer_position(player, (int)format, (unsigned long*)start_pos, (unsigned long*)stop_pos );
637
638         MMPLAYER_CMD_UNLOCK( player );
639
640         return result;
641 }
642
643 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path)
644 {
645         int result = MM_ERROR_NONE;
646
647         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
648
649         MMPLAYER_CMD_LOCK( player );
650
651         result = _mmplayer_set_external_subtitle_path(player, path);
652
653         MMPLAYER_CMD_UNLOCK( player );
654         return result;
655 }
656
657 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
658 {
659         int result = MM_ERROR_NONE;
660
661         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
662
663         if (format >= MM_PLAYER_POS_FORMAT_NUM)
664         {
665                 debug_error("wrong format(%d) \n", format);
666                 return MM_ERROR_INVALID_ARGUMENT;
667         }
668
669         MMPLAYER_CMD_LOCK( player );
670
671         result = _mmplayer_adjust_subtitle_postion(player, format, pos);
672
673         MMPLAYER_CMD_UNLOCK( player );
674
675         return result;
676 }
677
678 int mm_player_adjust_video_position(MMHandleType player, int offset)
679 {
680         int result = MM_ERROR_NONE;
681         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
682         MMPLAYER_CMD_LOCK( player );
683
684         result = _mmplayer_adjust_video_postion(player, offset);
685
686         MMPLAYER_CMD_UNLOCK( player );
687
688         return result;
689 }
690
691 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
692 {
693         int result = MM_ERROR_NONE;
694
695         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
696
697         MMPLAYER_CMD_LOCK( player );
698
699         result = _mmplayer_set_subtitle_silent(player, silent);
700
701         MMPLAYER_CMD_UNLOCK( player );
702
703         return result;
704 }
705
706 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
707 {
708         int result = MM_ERROR_NONE;
709
710         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
711
712         MMPLAYER_CMD_LOCK( player );
713
714         result = _mmplayer_get_subtitle_silent(player, silent);
715
716         MMPLAYER_CMD_UNLOCK( player );
717
718         return result;
719 }
720
721 int mm_player_set_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
722 {
723         int result = MM_ERROR_NONE;
724         va_list var_args;
725
726         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
727         return_val_if_fail(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
728
729         va_start (var_args, first_attribute_name);
730         result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
731         va_end (var_args);
732
733         return result;
734 }
735
736 int mm_player_get_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
737 {
738         int result = MM_ERROR_NONE;
739         va_list var_args;
740
741         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
742         return_val_if_fail(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
743
744         va_start (var_args, first_attribute_name);
745         result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
746         va_end (var_args);
747
748         return result;
749 }
750
751 int mm_player_get_attribute_info(MMHandleType player,  const char *attribute_name, MMPlayerAttrsInfo *info)
752 {
753         int result = MM_ERROR_NONE;
754
755
756         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
757         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
758         return_val_if_fail(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
759
760         result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
761
762         return result;
763 }
764
765 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
766 {
767         int result = MM_ERROR_NONE;
768
769         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
770         return_val_if_fail(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
771         return_val_if_fail(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
772
773         result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
774
775         return result;
776 }
777
778 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int *count)
779 {
780         int result = MM_ERROR_NONE;
781
782         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
783         return_val_if_fail(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
784
785         MMPLAYER_CMD_LOCK( player );
786
787         result = _mmplayer_get_track_count(player, type, count);
788
789         MMPLAYER_CMD_UNLOCK( player );
790
791         return result;
792 }
793
794 int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index)
795 {
796         int result = MM_ERROR_NONE;
797
798         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
799
800         MMPLAYER_CMD_LOCK( player );
801
802         result = _mmplayer_select_track(player, type, index);
803
804         MMPLAYER_CMD_UNLOCK( player );
805
806         return result;
807 }
808 #ifdef _MULTI_TRACK
809 int mm_player_track_add_subtitle_language(MMHandleType player, int index)
810 {
811         int result = MM_ERROR_NONE;
812
813         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
814
815         MMPLAYER_CMD_LOCK( player );
816
817         result = _mmplayer_track_add_subtitle_language(player, index);
818
819         MMPLAYER_CMD_UNLOCK( player );
820
821         return result;
822 }
823
824 int mm_player_track_remove_subtitle_language(MMHandleType player, int index)
825 {
826         int result = MM_ERROR_NONE;
827
828         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
829
830         MMPLAYER_CMD_LOCK( player );
831
832         result = _mmplayer_track_remove_subtitle_language(player, index);
833
834         MMPLAYER_CMD_UNLOCK( player );
835
836         return result;
837
838 }
839 #endif
840 int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int *index)
841 {
842         int result = MM_ERROR_NONE;
843
844         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
845         return_val_if_fail(index, MM_ERROR_COMMON_INVALID_ARGUMENT);
846
847         MMPLAYER_CMD_LOCK( player );
848
849         result = _mmplayer_get_current_track(player, type, index);
850
851         MMPLAYER_CMD_UNLOCK( player );
852
853         return result;
854 }
855
856 int mm_player_get_track_language_code(MMHandleType player,  MMPlayerTrackType type, int index, char **code)
857 {
858         int result = MM_ERROR_NONE;
859
860         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
861
862         MMPLAYER_CMD_LOCK( player );
863
864         result = _mmplayer_get_track_language_code(player, type, index, code);
865
866         MMPLAYER_CMD_UNLOCK( player );
867
868         return result;
869 }
870
871 int mm_player_ignore_session(MMHandleType player)
872 {
873         int result = MM_ERROR_NONE;
874
875         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
876
877 //      result = _mmplayer_asm_ignore_session(player);
878
879         return result;
880 }
881
882 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y)
883 {
884         int result = MM_ERROR_NONE;
885
886         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
887
888         MMPLAYER_CMD_LOCK( player );
889
890         result = _mmplayer_set_display_zoom(player, level, x, y);
891
892         MMPLAYER_CMD_UNLOCK( player );
893
894         return result;
895 }
896
897 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y)
898 {
899         int result = MM_ERROR_NONE;
900
901         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
902         return_val_if_fail(level, MM_ERROR_COMMON_INVALID_ARGUMENT);
903
904         MMPLAYER_CMD_LOCK( player );
905
906         result = _mmplayer_get_display_zoom(player, level, x, y);
907
908         MMPLAYER_CMD_UNLOCK( player );
909
910         return result;
911 }
912
913
914 int mm_player_use_system_clock(MMHandleType player)
915 {
916         int result = MM_ERROR_NONE;
917
918         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
919
920         MMPLAYER_CMD_LOCK( player );
921
922         result = _mmplayer_use_system_clock(player);
923
924         MMPLAYER_CMD_UNLOCK( player );
925
926         return result;
927 }
928
929 int mm_player_set_video_share_master_clock(MMHandleType player,
930                                                 long long clock,
931                                                 long long clock_delta,
932                                                 long long video_time,
933                                                 long long media_clock,
934                                                 long long audio_time)
935 {
936         int result = MM_ERROR_NONE;
937
938         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
939
940         MMPLAYER_CMD_LOCK( player );
941
942         result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time);
943
944         MMPLAYER_CMD_UNLOCK( player );
945
946         return result;
947 }
948
949 int mm_player_get_video_share_master_clock(MMHandleType player,
950                                                 long long *video_time,
951                                                 long long *media_clock,
952                                                 long long *audio_time)
953 {
954         int result = MM_ERROR_NONE;
955
956         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
957         return_val_if_fail(video_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
958         return_val_if_fail(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT);
959         return_val_if_fail(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT);
960
961         MMPLAYER_CMD_LOCK( player );
962
963         result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time);
964
965         MMPLAYER_CMD_UNLOCK( player );
966
967         return result;
968 }
969
970 int mm_player_get_video_rotate_angle(MMHandleType player, int *angle)
971 {
972         int result = MM_ERROR_NONE;
973
974         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
975         return_val_if_fail(angle, MM_ERROR_COMMON_INVALID_ARGUMENT);
976
977         MMPLAYER_CMD_LOCK( player );
978
979         result = _mmplayer_get_video_rotate_angle(player, angle);
980
981         MMPLAYER_CMD_UNLOCK( player );
982
983         return result;
984 }
985
986 int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode)
987 {
988         int result = MM_ERROR_NONE;
989
990         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
991
992         MMPLAYER_CMD_LOCK( player );
993
994         result = _mmplayer_set_video_hub_download_mode(player, mode);
995
996         MMPLAYER_CMD_UNLOCK( player );
997
998         return result;
999 }
1000
1001 int mm_player_enable_sync_handler(MMHandleType player, bool enable)
1002 {
1003         int result = MM_ERROR_NONE;
1004
1005         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1006
1007         MMPLAYER_CMD_LOCK( player );
1008
1009         result = _mmplayer_enable_sync_handler(player, enable);
1010
1011         MMPLAYER_CMD_UNLOCK( player );
1012
1013         return result;
1014 }
1015
1016 int mm_player_set_uri(MMHandleType player, const char *uri)
1017 {
1018         int result = MM_ERROR_NONE;
1019
1020         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1021
1022         MMPLAYER_CMD_LOCK( player );
1023
1024         result = _mmplayer_set_uri(player, uri);
1025
1026         MMPLAYER_CMD_UNLOCK( player );
1027
1028         return result;
1029
1030 }
1031
1032 int mm_player_set_next_uri(MMHandleType player, const char *uri)
1033 {
1034         int result = MM_ERROR_NONE;
1035
1036         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1037
1038         MMPLAYER_CMD_LOCK( player );
1039
1040         result = _mmplayer_set_next_uri(player, uri, FALSE);
1041
1042         MMPLAYER_CMD_UNLOCK( player );
1043
1044         return result;
1045
1046 }
1047
1048 int mm_player_get_next_uri(MMHandleType player, char **uri)
1049 {
1050         int result = MM_ERROR_NONE;
1051
1052         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1053
1054         MMPLAYER_CMD_LOCK( player );
1055
1056         result = _mmplayer_get_next_uri(player, uri);
1057
1058         MMPLAYER_CMD_UNLOCK( player );
1059
1060         return result;
1061
1062 }
1063 #ifdef _MULTI_TRACK
1064 int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param)
1065 {
1066         int result = MM_ERROR_NONE;
1067
1068         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1069
1070         MMPLAYER_CMD_LOCK( player );
1071
1072         result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param);
1073
1074         MMPLAYER_CMD_UNLOCK( player );
1075
1076         return result;
1077 }
1078 #endif
1079
1080 int mm_player_has_closed_caption(MMHandleType player, bool *exist)
1081 {
1082         int result = MM_ERROR_NONE;
1083
1084         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1085         return_val_if_fail(exist, MM_ERROR_INVALID_ARGUMENT);
1086
1087         MMPLAYER_CMD_LOCK( player );
1088
1089         result = _mmplayer_has_closed_caption(player, exist);
1090
1091         MMPLAYER_CMD_UNLOCK( player );
1092
1093         return result;
1094 }
1095
1096 int mm_player_enable_media_packet_video_stream(MMHandleType player, bool enable)
1097 {
1098         int result = MM_ERROR_NONE;
1099
1100         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
1101         return_val_if_fail(enable, MM_ERROR_INVALID_ARGUMENT);
1102
1103         MMPLAYER_CMD_LOCK( player );
1104
1105         result = _mmplayer_enable_media_packet_video_stream(player, enable);
1106
1107         MMPLAYER_CMD_UNLOCK( player );
1108
1109         return result;
1110 }