Tizen 2.1 base
[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>, YoungHwan An <younghwan_.an@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <gst/gst.h>
23 #include <string.h>
24
25 #include <mm_types.h>
26 #include <mm_message.h>
27
28 #include "mm_player.h"
29 #include "mm_player_priv.h"
30 #include "mm_player_attrs.h"
31 #include "mm_player_utils.h"
32 #include "mm_player_ini.h"
33 #include "mm_debug.h"
34 #include "mm_player_capture.h"
35
36 int mm_player_create(MMHandleType *player)
37 {
38         int result = MM_ERROR_NONE;
39         mm_player_t* new_player = NULL;
40
41         debug_log("\n");
42
43         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
44
45         if (!g_thread_supported ())
46         g_thread_init (NULL);
47
48         MMTA_INIT();
49
50         __ta__("mm_player_ini_load",
51         result = mm_player_ini_load();
52         )
53         if(result != MM_ERROR_NONE)
54                 return result;
55
56         __ta__("mm_player_audio_effect_ini_load",
57         result = mm_player_audio_effect_ini_load();
58         )
59         if(result != MM_ERROR_NONE)
60                 return result;
61
62         /* alloc player structure */
63         new_player = g_malloc(sizeof(mm_player_t));
64         if ( ! new_player )
65         {
66                 debug_critical("Cannot allocate memory for player\n");
67                 goto ERROR;
68         }
69         memset(new_player, 0, sizeof(mm_player_t));
70
71         /* create player lock */
72         new_player->cmd_lock = g_mutex_new();
73
74         if ( ! new_player->cmd_lock )
75         {
76                 debug_critical("failed to create player lock\n");
77                 goto ERROR;
78         }
79
80         /* create msg callback lock */
81         new_player->msg_cb_lock = g_mutex_new();
82
83         if ( ! new_player->msg_cb_lock )
84         {
85                 debug_critical("failed to create msg cb lock\n");
86                 goto ERROR;
87         }
88         __ta__("[KPI] create media player service",
89         result = _mmplayer_create_player((MMHandleType)new_player);
90         )
91
92         if(result != MM_ERROR_NONE)
93                 goto ERROR;
94
95         *player = (MMHandleType)new_player;
96
97         return result;
98
99 ERROR:
100
101         if ( new_player )
102         {
103                 if (new_player->cmd_lock)
104                 {
105                         g_mutex_free(new_player->cmd_lock);
106                         new_player->cmd_lock = NULL;
107                 }
108
109                 _mmplayer_destroy( (MMHandleType)new_player );
110                 MMPLAYER_FREEIF( new_player );
111         }
112
113         *player = (MMHandleType)0;
114         return MM_ERROR_PLAYER_NO_FREE_SPACE; // are you sure?
115 }
116
117 int  mm_player_destroy(MMHandleType player)
118 {
119         int result = MM_ERROR_NONE;
120
121         debug_log("\n");
122
123         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
124
125         MMPLAYER_CMD_LOCK( player );
126
127         __ta__("[KPI] destroy media player service",
128         result = _mmplayer_destroy(player);
129         )
130
131         MMPLAYER_CMD_UNLOCK( player );
132
133         if (((mm_player_t*)player)->cmd_lock)
134         {
135                 g_mutex_free(((mm_player_t*)player)->cmd_lock);
136                 ((mm_player_t*)player)->cmd_lock = NULL;
137         }
138
139         memset( (mm_player_t*)player, 0x00, sizeof(mm_player_t) );
140
141         /* free player */
142         g_free( (void*)player );
143
144         MMTA_ACUM_ITEM_SHOW_RESULT_TO(MMTA_SHOW_FILE);
145
146         MMTA_RELEASE();
147
148         return result;
149 }
150
151
152 int mm_player_realize(MMHandleType player)
153 {
154         int result = MM_ERROR_NONE;
155
156         debug_log("\n");
157
158         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
159
160         MMPLAYER_CMD_LOCK( player );
161
162         __ta__("[KPI] initialize media player service",
163         result = _mmplayer_realize(player);
164         )
165
166         MMPLAYER_CMD_UNLOCK( player );
167
168         return result;
169 }
170
171
172 int mm_player_unrealize(MMHandleType player)
173 {
174         int result = MM_ERROR_NONE;
175
176         debug_log("\n");
177
178         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
179
180         MMPLAYER_CMD_LOCK( player );
181
182         __ta__("[KPI] cleanup media player service",
183         result = _mmplayer_unrealize(player);
184         )
185
186         MMPLAYER_CMD_UNLOCK( player );
187
188         return result;
189 }
190
191
192 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
193 {
194         int result = MM_ERROR_NONE;
195
196         debug_log("\n");
197
198         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
199
200         MMPLAYER_CMD_LOCK( player );
201
202         result = _mmplayer_set_message_callback(player, callback, user_param);
203
204         MMPLAYER_CMD_UNLOCK( player );
205
206         return result;
207 }
208
209 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param)
210 {
211         int result = MM_ERROR_NONE;
212
213         debug_log("\n");
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         debug_log("\n");
227
228         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
229
230         MMPLAYER_CMD_LOCK( player );
231
232         result = _mmplayer_set_audiostream_cb(player, callback, user_param);
233
234         MMPLAYER_CMD_UNLOCK( player );
235
236         return result;
237 }
238
239
240 int mm_player_set_audio_buffer_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param)
241 {
242         int result = MM_ERROR_NONE;
243
244         debug_log("\n");
245
246         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
247
248         MMPLAYER_CMD_LOCK( player );
249
250         result = _mmplayer_set_audiobuffer_cb(player, callback, user_param);
251
252         MMPLAYER_CMD_UNLOCK( player );
253
254         return result;
255 }
256
257 int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_stream_callback callback, void *user_param)
258 {
259         int result = MM_ERROR_NONE;
260
261         debug_log("\n");
262
263         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
264
265         MMPLAYER_CMD_LOCK( player );
266
267     result = _mmplayer_set_videostream_cb(player, callback, user_param);
268
269         MMPLAYER_CMD_UNLOCK( player );
270
271         return result;
272 }
273
274 int mm_player_set_video_frame_render_error_callback(MMHandleType player, mm_player_video_frame_render_error_callback callback, void *user_param)
275 {
276         int result = MM_ERROR_NONE;
277
278         debug_log("\n");
279
280         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
281
282         MMPLAYER_CMD_LOCK( player );
283
284         result = _mmplayer_set_videoframe_render_error_cb(player, callback, user_param);
285
286         MMPLAYER_CMD_UNLOCK( player );
287
288         return result;
289 }
290
291 int mm_player_do_video_capture(MMHandleType player)
292 {
293         int result = MM_ERROR_NONE;
294
295         debug_log("\n");
296
297         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
298
299         MMPLAYER_CMD_LOCK( player );
300
301         result = _mmplayer_do_video_capture(player);
302
303         MMPLAYER_CMD_UNLOCK( player );
304
305         return result;
306 }
307
308 int mm_player_set_buffer_need_data_callback(MMHandleType player, mm_player_buffer_need_data_callback callback, void * user_param)
309 {
310         int result = MM_ERROR_NONE;
311
312         debug_log("\n");
313
314         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
315
316         MMPLAYER_CMD_LOCK( player );
317
318     result = _mmplayer_set_buffer_need_data_cb(player, callback, user_param);
319
320         MMPLAYER_CMD_UNLOCK( player );
321
322         return result;
323 }
324
325
326 int mm_player_set_buffer_enough_data_callback(MMHandleType player, mm_player_buffer_enough_data_callback callback, void * user_param)
327 {
328         int result = MM_ERROR_NONE;
329
330         debug_log("\n");
331
332         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
333
334         MMPLAYER_CMD_LOCK( player );
335
336     result = _mmplayer_set_buffer_enough_data_cb(player, callback, user_param);
337
338         MMPLAYER_CMD_UNLOCK( player );
339
340         return result;
341 }
342
343
344 int mm_player_set_buffer_seek_data_callback(MMHandleType player, mm_player_buffer_seek_data_callback callback, void * user_param)
345 {
346         int result = MM_ERROR_NONE;
347
348         debug_log("\n");
349
350         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
351
352         MMPLAYER_CMD_LOCK( player );
353
354     result = _mmplayer_set_buffer_seek_data_cb(player, callback, user_param);
355
356         MMPLAYER_CMD_UNLOCK( player );
357
358         return result;
359 }
360
361
362 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume)
363 {
364         int result = MM_ERROR_NONE;
365
366         debug_log("\n");
367
368         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
369         return_val_if_fail(volume, MM_ERROR_INVALID_ARGUMENT);
370
371         MMPLAYER_CMD_LOCK( player );
372
373         result = _mmplayer_set_volume(player, *volume);
374
375         MMPLAYER_CMD_UNLOCK( player );
376
377         return result;
378 }
379
380
381 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume)
382 {
383         int result = MM_ERROR_NONE;
384
385         debug_log("\n");
386
387         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
388         return_val_if_fail(volume, MM_ERROR_INVALID_ARGUMENT);
389
390         MMPLAYER_CMD_LOCK( player );
391
392         result = _mmplayer_get_volume(player, volume);
393
394         MMPLAYER_CMD_UNLOCK( player );
395
396         return result;
397 }
398
399
400 int mm_player_set_mute(MMHandleType player, int mute)
401 {
402         int result = MM_ERROR_NONE;
403
404         debug_log("\n");
405
406         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
407
408         MMPLAYER_CMD_LOCK( player );
409
410         result = _mmplayer_set_mute(player, mute);
411
412         MMPLAYER_CMD_UNLOCK( player );
413
414         return result;
415 }
416
417
418 int mm_player_get_mute(MMHandleType player, int *mute)
419 {
420         int result = MM_ERROR_NONE;
421
422         debug_log("\n");
423
424         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
425         return_val_if_fail(mute, MM_ERROR_INVALID_ARGUMENT);
426
427         MMPLAYER_CMD_LOCK( player );
428
429         result = _mmplayer_get_mute(player, mute);
430
431         MMPLAYER_CMD_UNLOCK( player );
432
433         return result;
434 }
435
436
437 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state)
438 {
439         int result = MM_ERROR_NONE;
440
441         debug_log("\n");
442
443         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
444         return_val_if_fail(state, MM_ERROR_COMMON_INVALID_ARGUMENT);
445
446         *state = MM_PLAYER_STATE_NULL;
447
448         result = _mmplayer_get_state(player, (int*)state);
449
450         return result;
451 }
452
453 /* NOTE : Not supported */
454 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
455 {
456         int result = MM_ERROR_NONE;
457
458         debug_log("\n");
459
460         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
461
462         return MM_ERROR_NOT_SUPPORT_API;
463 }
464
465 int mm_player_push_buffer(MMHandleType player, unsigned char *buf, int size)
466 {
467         int result = MM_ERROR_NONE;
468
469         debug_log("\n");
470
471         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
472
473         //MMPLAYER_CMD_LOCK( player );
474
475         //MMTA_ACUM_ITEM_BEGIN("[KPI] start media player service", false);
476         result = _mmplayer_push_buffer(player, buf, size);
477
478         //MMPLAYER_CMD_UNLOCK( player );
479
480         return result;
481 }
482
483
484 int mm_player_start(MMHandleType player)
485 {
486         int result = MM_ERROR_NONE;
487
488         debug_log("\n");
489
490         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
491
492         MMPLAYER_CMD_LOCK( player );
493
494         MMTA_ACUM_ITEM_BEGIN("[KPI] start media player service", false);
495         result = _mmplayer_start(player);
496
497         MMPLAYER_CMD_UNLOCK( player );
498
499         return result;
500 }
501
502
503 int  mm_player_stop(MMHandleType player)
504 {
505         int result = MM_ERROR_NONE;
506
507         debug_log("\n");
508
509         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
510
511         MMPLAYER_CMD_LOCK( player );
512
513         __ta__("[KPI] stop media player service",
514         result = _mmplayer_stop(player);
515         )
516
517         MMPLAYER_CMD_UNLOCK( player );
518
519         return result;
520 }
521
522
523 int mm_player_pause(MMHandleType player)
524 {
525         int result = MM_ERROR_NONE;
526
527         debug_log("\n");
528
529         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
530
531         MMPLAYER_CMD_LOCK( player );
532
533         __ta__("[KPI] pause media player service",
534         result = _mmplayer_pause(player);
535         )
536
537         MMPLAYER_CMD_UNLOCK( player );
538
539         return result;
540 }
541
542
543 int mm_player_resume(MMHandleType player)
544 {
545         int result = MM_ERROR_NONE;
546
547         debug_log("\n");
548
549         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
550
551         MMPLAYER_CMD_LOCK( player );
552
553         __ta__("[KPI] resume media player service",
554         result = _mmplayer_resume(player);
555         )
556
557         MMPLAYER_CMD_UNLOCK( player );
558
559         return result;
560 }
561
562
563 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos)
564 {
565         int result = MM_ERROR_NONE;
566
567         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
568
569         MMPLAYER_CMD_LOCK( player );
570
571         result = _mmplayer_activate_section_repeat(player, start_pos, end_pos);
572
573         MMPLAYER_CMD_UNLOCK( player );
574
575         return result;
576 }
577
578
579 int mm_player_deactivate_section_repeat(MMHandleType player)
580 {
581         int result = MM_ERROR_NONE;
582
583         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
584
585         MMPLAYER_CMD_LOCK( player );
586
587         result = _mmplayer_deactivate_section_repeat(player);
588
589         MMPLAYER_CMD_UNLOCK( player );
590
591         return result;
592 }
593
594
595 int mm_player_set_play_speed(MMHandleType player, float rate)
596 {
597         int result = MM_ERROR_NONE;
598
599         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
600
601         MMPLAYER_CMD_LOCK( player );
602
603         result = _mmplayer_set_playspeed(player, rate);
604
605         MMPLAYER_CMD_UNLOCK( player );
606
607         return result;
608 }
609
610
611 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
612 {
613         int result = MM_ERROR_NONE;
614
615         debug_log("\n");
616
617         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
618
619         if (format >= MM_PLAYER_POS_FORMAT_NUM)
620         {
621                 debug_error("wrong format\n");
622                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
623         }
624
625         MMPLAYER_CMD_LOCK( player );
626
627         result = _mmplayer_set_position(player, format, pos);
628
629         MMPLAYER_CMD_UNLOCK( player );
630
631         return result;
632 }
633
634
635 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos)
636 {
637         int result = MM_ERROR_NONE;
638
639         debug_log("\n");
640
641         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
642         return_val_if_fail(pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
643
644         if (format >= MM_PLAYER_POS_FORMAT_NUM)
645         {
646                 debug_error("wrong format\n");
647                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
648         }
649
650         MMPLAYER_CMD_LOCK( player );
651
652         result = _mmplayer_get_position(player, (int)format, (unsigned long*)pos);
653
654         MMPLAYER_CMD_UNLOCK( player );
655
656         return result;
657 }
658
659 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int  *start_pos, int  *stop_pos)
660 {
661         int result = MM_ERROR_NONE;
662
663         debug_log("\n");
664
665         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
666         return_val_if_fail(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
667
668         MMPLAYER_CMD_LOCK( player );
669
670         result = _mmplayer_get_buffer_position(player, (int)format, (unsigned long*)start_pos, (unsigned long*)stop_pos );
671
672         MMPLAYER_CMD_UNLOCK( player );
673
674         return result;
675 }
676
677 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos)
678 {
679         int result = MM_ERROR_NONE;
680
681         debug_log("\n");
682
683         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
684
685         if (format >= MM_PLAYER_POS_FORMAT_NUM)
686         {
687                 debug_error("wrong format\n");
688                 return MM_ERROR_COMMON_INVALID_ARGUMENT;
689         }
690
691         MMPLAYER_CMD_LOCK( player );
692
693         result = _mmplayer_adjust_subtitle_postion(player, format, pos);
694
695         MMPLAYER_CMD_UNLOCK( player );
696
697         return result;
698 }
699
700
701 int mm_player_set_subtitle_silent(MMHandleType player, int silent)
702 {
703         int result = MM_ERROR_NONE;
704
705         debug_log("\n");
706
707         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
708
709         MMPLAYER_CMD_LOCK( player );
710
711         result = _mmplayer_set_subtitle_silent(player, silent);
712
713         MMPLAYER_CMD_UNLOCK( player );
714
715         return result;
716 }
717
718
719 int mm_player_get_subtitle_silent(MMHandleType player, int* silent)
720 {
721         int result = MM_ERROR_NONE;
722
723         debug_log("\n");
724
725         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
726
727         MMPLAYER_CMD_LOCK( player );
728
729         result = _mmplayer_get_subtitle_silent(player, silent);
730
731         MMPLAYER_CMD_UNLOCK( player );
732
733         return result;
734 }
735
736
737 int mm_player_set_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
738 {
739         int result = MM_ERROR_NONE;
740         va_list var_args;
741
742         debug_log("\n");
743
744         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
745         return_val_if_fail(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
746
747         va_start (var_args, first_attribute_name);
748         result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args);
749         va_end (var_args);
750
751         return result;
752 }
753
754
755 int mm_player_get_attribute(MMHandleType player,  char **err_attr_name, const char *first_attribute_name, ...)
756 {
757         int result = MM_ERROR_NONE;
758         va_list var_args;
759
760         debug_log("\n");
761
762         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
763         return_val_if_fail(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
764
765         va_start (var_args, first_attribute_name);
766         result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args);
767         va_end (var_args);
768
769         return result;
770 }
771
772
773 int mm_player_get_attribute_info(MMHandleType player,  const char *attribute_name, MMPlayerAttrsInfo *info)
774 {
775         int result = MM_ERROR_NONE;
776         debug_log("\n");
777
778         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
779         return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT);
780         return_val_if_fail(info, MM_ERROR_COMMON_INVALID_ARGUMENT);
781
782         result = _mmplayer_get_attributes_info((MMHandleType)player, attribute_name, info);
783
784         return result;
785 }
786
787 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size)
788 {
789         int result = MM_ERROR_NONE;
790
791         debug_log("\n");
792
793         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
794         return_val_if_fail(current_pos, MM_ERROR_COMMON_INVALID_ARGUMENT);
795         return_val_if_fail(total_size, MM_ERROR_COMMON_INVALID_ARGUMENT);
796
797         result = _mmplayer_get_pd_downloader_status(player, current_pos, total_size);
798
799         return result;
800 }
801
802 int mm_player_get_track_count(MMHandleType player,  MMPlayerTrackType track_type, int *count)
803 {
804         int result = MM_ERROR_NONE;
805
806         debug_log("\n");
807
808         return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
809         return_val_if_fail(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
810
811         result = _mmplayer_get_track_count(player, track_type, count);
812
813         return result;
814
815 }