4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #ifndef __MM_PLAYER_H__
23 #define __MM_PLAYER_H__
26 /*===========================================================================================
30 ========================================================================================== */
35 #include <mm_message.h>
46 This part describes APIs used for playback of multimedia contents.
47 All multimedia contents are created by a media player through handle of playback.
48 In creating a player, it displays the player's status or information
49 by registering callback function.
52 In case of streaming playback, network has to be opend by using datanetwork API.
53 If proxy, cookies and the other attributes for streaming playback are needed,
54 set those attributes using mm_player_set_attribute() before create player.
57 The subtitle for local video playback is supported. Set "subtitle_uri" attribute
58 using mm_player_set_attribute() before the application creates the player.
59 Then the application could receive MMMessageParamType which includes subtitle string and duration.
62 Player can have 5 states, and each state can be changed by calling
63 described functions on "Figure1. State of Player".
66 @image html player_state.jpg "Figure1. State of Player" width=12cm
67 @image latex player_state.jpg "Figure1. State of Player" width=12cm
70 Most of functions which change player state work as synchronous. But, mm_player_start() should be used
71 asynchronously. Both mm_player_pause() and mm_player_resume() should also be used asynchronously
72 in the case of streaming data.
73 So, application have to confirm the result of those APIs through message callback function.
76 Note that "None" and Null" state could be reached from any state
77 by calling mm_player_destroy() and mm_player_unrealize().
82 <td><B>FUNCTION</B></td>
83 <td><B>PRE-STATE</B></td>
84 <td><B>POST-STATE</B></td>
85 <td><B>SYNC TYPE</B></td>
88 <td>mm_player_create()</td>
94 <td>mm_player_destroy()</td>
100 <td>mm_player_realize()</td>
106 <td>mm_player_unrealize()</td>
112 <td>mm_player_start()</td>
118 <td>mm_player_stop()</td>
124 <td>mm_player_pause()</td>
130 <td>mm_player_resume()</td>
136 <td>mm_player_set_message_callback()</td>
142 <td>mm_player_get_state()</td>
148 <td>mm_player_set_volume()</td>
154 <td>mm_player_get_volume()</td>
160 <td>mm_player_set_position()</td>
166 <td>mm_player_get_position()</td>
172 <td>mm_player_get_attribute()</td>
178 <td>mm_player_set_attribute()</td>
186 Following are the attributes supported in player which may be set after initialization. \n
187 Those are handled as a string.
197 <td>"profile_uri"</td>
202 <td>"content_duration"</td>
207 <td>"content_video_width"</td>
212 <td>"content_video_height"</td>
217 <td>"display_evas_do_scaling"</td>
222 <td>"display_evas_surface_sink"</td>
227 <td>"profile_user_param"</td>
232 <td>"profile_play_count"</td>
237 <td>"streaming_type"</td>
242 <td>"streaming_udp_timeout"</td>
247 <td>"streaming_user_agent"</td>
252 <td>"streaming_wap_profile"</td>
257 <td>"streaming_network_bandwidth"</td>
262 <td>"streaming_cookie"</td>
267 <td>"streaming_proxy_ip"</td>
272 <td>"streaming_proxy_port"</td>
277 <td>"display_overlay"</td>
282 <td>"display_rotation"</td>
287 <td>"subtitle_uri"</td>
294 Following attributes are supported for playing stream data. Those value can be readable only and valid after starting playback.\n
295 Please use mm_fileinfo for local playback.
305 <td>"content_video_found"</td>
310 <td>"content_video_codec"</td>
315 <td>"content_video_track_num"</td>
320 <td>"content_audio_found"</td>
325 <td>"content_audio_codec"</td>
330 <td>"content_audio_bitrate"</td>
335 <td>"content_audio_channels"</td>
340 <td>"content_audio_samplerate"</td>
345 <td>"content_audio_track_num"</td>
350 <td>"content_text_track_num"</td>
355 <td>"tag_artist"</td>
375 <td>"tag_author"</td>
380 <td>"tag_copyright"</td>
390 <td>"tag_description"</td>
395 <td>"tag_track_num"</td>
404 /*===========================================================================================
406 | GLOBAL DEFINITIONS AND DECLARATIONS |
408 ========================================================================================== */
413 * uri to play (string)
416 #define MM_PLAYER_CONTENT_URI "profile_uri"
418 * MM_PLAYER_CONTENT_DURATION:
420 * get the duration (int) as millisecond, It's guaranteed after calling mm_player_start() or
421 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
424 #define MM_PLAYER_CONTENT_DURATION "content_duration"
426 * MM_PLAYER_VIDEO_ROTATION
428 * can change video angle (int)
429 * @see MMDisplayRotationType
431 #define MM_PLAYER_VIDEO_ROTATION "display_rotation"
433 * MM_PLAYER_VIDEO_WIDTH:
435 * get the video width (int), It's guaranteed after calling mm_player_start() or
436 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
439 #define MM_PLAYER_VIDEO_WIDTH "content_video_width"
441 * MM_PLAYER_VIDEO_HEIGHT:
443 * get the video height (int), It's guaranteed after calling mm_player_start() or
444 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
447 #define MM_PLAYER_VIDEO_HEIGHT "content_video_height"
449 * MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING:
451 * set whether or not to scale frames size for evas surface.
452 * if TRUE, it scales down width, height size of frames with given size.
453 * if FALSE, it does not scale down any frames.
456 #define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling"
458 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
460 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
463 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
467 * set memory pointer to play (data)
470 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
472 * MM_PLAYER_PLAYBACK_COUNT
474 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
477 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
479 * MM_PLAYER_SUBTITLE_URI
481 * set the subtitle path (string)
483 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
485 * MM_PLAYER_STREAMING_TYPE
487 * set the streaming type (int)
488 * @see MMStreamingType
490 #define MM_PLAYER_STREAMING_TYPE "streaming_type"
492 * MM_PLAYER_STREAMING_UDP_TIMEOUT
494 * set the streaming udp timeout(int)
496 #define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout"
498 * MM_PLAYER_STREAMING_USER_AGENT
500 * set the streaming user agent (string)
502 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
504 * MM_PLAYER_STREAMING_WAP_PROFILE
506 * set the streaming wap profile (int)
508 #define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile"
510 * MM_PLAYER_STREAMING_NET_BANDWIDTH
512 * set the streaming network bandwidth (int)
514 #define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth"
516 * MM_PLAYER_STREAMING_COOKIE
518 * set the streaming cookie (int)
520 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
522 * MM_PLAYER_STREAMING_PROXY_IP
524 * set the streaming proxy ip (string)
526 #define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip"
528 * MM_PLAYER_STREAMING_PROXY_PORT
530 * set the streaming proxy port (int)
532 #define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port"
534 * MM_PLAYER_VIDEO_CODEC
536 * codec the video data is stored in (string)
538 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
540 * MM_PLAYER_VIDEO_TRACK_NUM
542 * track number inside a collection (int)
544 #define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num"
546 * MM_PLAYER_AUDIO_CODEC
548 * codec the audio data is stored in (string)
550 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
552 * MM_PLAYER_AUDIO_BITRATE
554 * set the streaming proxy port (int)
556 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
558 * MM_PLAYER_AUDIO_CHANNEL
560 * the number of audio channel (int)
562 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
564 * MM_PLAYER_AUDIO_SAMPLERATE
566 * audio samplerate (int)
568 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
570 * MM_PLAYER_AUDIO_TRACK_NUM
572 * track number inside a collection (int)
574 #define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num"
576 * MM_PLAYER_TEXT_TRACK_NUM
578 * track number inside a collection (int)
580 #define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num"
582 * MM_PLAYER_TAG_ARTIST
584 * person(s) responsible for the recording (string)
586 #define MM_PLAYER_TAG_ARTIST "tag_artist"
588 * MM_PLAYER_TAG_ARTIST
592 #define MM_PLAYER_TAG_TITLE "tag_title"
594 * MM_PLAYER_TAG_ARTIST
596 * album containing this data (string)
598 #define MM_PLAYER_TAG_ALBUM "tag_album"
600 * MM_PLAYER_TAG_ARTIST
602 * genre this data belongs to (string)
604 #define MM_PLAYER_TAG_GENRE "tag_genre"
606 * MM_PLAYER_TAG_ARTIST
610 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
612 * MM_PLAYER_TAG_ARTIST
614 * copyright notice of the data (string)
616 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
618 * MM_PLAYER_TAG_ARTIST
620 * date the data was created (string)
622 #define MM_PLAYER_TAG_DATE "tag_date"
624 * MM_PLAYER_TAG_ARTIST
626 * short text describing the content of the data (string)
628 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
630 * MM_PLAYER_TAG_ARTIST
632 * track number inside a collection (int)
634 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
638 * progressive download mode (int)
640 #define MM_PLAYER_PD_MODE "pd_mode"
643 * Enumerations of player state.
646 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
647 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
648 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
649 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
650 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
651 MM_PLAYER_STATE_NUM, /**< Number of player states */
655 * Enumerations of position formats.
656 * Used while invoking mm_player_get_position/mm_player_set_position APIs
659 MM_PLAYER_POS_FORMAT_TIME, /**< Format for time based */
660 MM_PLAYER_POS_FORMAT_PERCENT, /**< Format for percentage */
661 MM_PLAYER_POS_FORMAT_NUM, /**< Number of position formats */
662 } MMPlayerPosFormatType;
665 * Enumeration for attribute values types.
668 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
669 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
670 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
671 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
672 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
673 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
674 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
675 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
679 * Enumeration for attribute validation type.
682 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
683 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
684 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
685 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
686 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
687 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
688 } MMPlayerAttrsValidType;
691 * Enumeration for attribute access flag.
694 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
695 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
696 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
697 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
699 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
703 * Enumeration for progressive download
706 MM_PLAYER_PD_MODE_NONE,
707 MM_PLAYER_PD_MODE_URI,
708 MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario
712 * Enumeration of track types
715 MM_PLAYER_TRACK_TYPE_AUDIO,
716 MM_PLAYER_TRACK_TYPE_VIDEO,
717 MM_PLAYER_TRACK_TYPE_TEXT
721 * Attribute validity structure
724 MMPlayerAttrsType type;
725 MMPlayerAttrsValidType validity_type;
726 MMPlayerAttrsFlag flag;
728 * a union that describes validity of the attribute.
729 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
730 * the attribute can have validity.
734 * Validity structure for integer array.
737 int *array; /**< a pointer of array */
738 int count; /**< size of array */
742 * Validity structure for integer range.
745 int min; /**< minimum range */
746 int max; /**< maximum range */
750 * Validity structure for double array.
753 double * array; /**< a pointer of array */
754 int count; /**< size of array */
758 * Validity structure for double range.
761 double min; /**< minimum range */
762 double max; /**< maximum range */
771 * @see mm_player_set_volume, mm_player_get_volume
774 float level[MM_VOLUME_CHANNEL_NUM]; /**< Relative volume factor for each channels */
775 } MMPlayerVolumeType;
778 * Audio stream callback function type.
780 * @param stream [in] Reference pointer to audio frame data
781 * @param stream_size [in] Size of audio frame data
782 * @param user_param [in] User defined parameter which is passed when set
783 * audio stream callback
785 * @return This callback function have to return MM_ERROR_NONE.
787 typedef bool (*mm_player_audio_stream_callback) (void *stream, int stream_size, void *user_param);
790 /*===========================================================================================
792 | GLOBAL FUNCTION PROTOTYPES |
794 ========================================================================================== */
797 * This function creates a player object for playing multimedia contents. \n
798 * The attributes of player are created to get/set some values with application. \n
799 * And, mutex, gstreamer and other resources are initialized at this time. \n
800 * If player is created, the state will become MM_PLAYER_STATE_NULL.
802 * @param player [out] Handle of player
804 * @return This function returns zero on success, or negative value with error code. \n
805 * Please refer 'mm_error.h' to know it in detail.
807 * @post MM_PLAYER_STATE_NULL
808 * @see mm_player_destroy
809 * @remark You can create multiple handles on a context at the same time. \n
810 * However, player cannot guarantee proper operation because of limitation of resources, \n
811 * such as audio device or display device.
815 char *g_err_attr_name = NULL;
817 if (mm_player_create(&g_player) != MM_ERROR_NONE)
819 printf("failed to create player\n");
822 if (mm_player_set_attribute(g_player,
824 "profile_uri", filename, strlen(filename),
825 "display_overlay", (void*)&g_win.xid, sizeof(g_win.xid),
826 NULL) != MM_ERROR_NONE)
828 printf("failed to set %s attribute\n", g_err_attr_name);
829 free(g_err_attr_name);
832 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
835 int mm_player_create(MMHandleType *player);
838 * This function releases player object and all resources which were created by mm_player_create(). \n
839 * And, player handle will also be destroyed.
841 * @param player [in] Handle of player
843 * @return This function returns zero on success, or negative value with error code.
844 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
845 * But, it can be called in any state.
846 * @post Because handle is released, there is no any state.
847 * @see mm_player_create
848 * @remark This method can be called with a valid player handle from any state to \n
849 * completely shutdown the player operation.
853 if (mm_player_destroy(g_player) != MM_ERROR_NONE)
855 printf("failed to destroy player\n");
859 int mm_player_destroy(MMHandleType player);
862 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
863 * So, uri should be set before realizing with mm_player_set_attribute(). \n
865 * @param player [in] Handle of player
867 * @return This function returns zero on success, or negative value with error code.
869 * @pre Player state should be MM_PLAYER_STATE_NULL.
870 * @post Player state will be MM_PLAYER_STATE_READY.
871 * @see mm_player_unrealize
875 if (mm_player_realize(g_player) != MM_ERROR_NONE)
877 printf("failed to realize player\n");
881 int mm_player_realize(MMHandleType player) ;
884 * This function uninitializes player object. So, resources and allocated memory \n
885 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
886 * other contents, player should be created again after destruction or realized with new uri.
888 * @param player [in] Handle of player
890 * @return This function returns zero on success, or negative value with error code.
891 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
892 * But, it can be called in any state.
893 * @post Player state will be MM_PLAYER_STATE_NULL.
894 * @see mm_player_realize
895 * @remark This method can be called with a valid player handle from any state.
899 if (mm_player_unrealize(g_player) != MM_ERROR_NONE)
901 printf("failed to unrealize player\n");
905 int mm_player_unrealize(MMHandleType player);
908 * This function is to get current state of player. \n
909 * Application have to check current state before doing some action.
911 * @param player [in] Handle of player
912 * @param state [out] current state of player on success
914 * @return This function returns zero on success, or negative value with error code.
916 * @see MMPlayerStateType
920 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE)
922 printf("failed to get state\n");
926 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state);
929 * This function is to set relative volume of player. \n
930 * So, It controls logical volume value. \n
931 * But, if developer want to change system volume, mm sound api should be used.
933 * @param player [in] Handle of player
934 * @param volume [in] Volume factor of each channel
936 * @return This function returns zero on success, or negative value with error code.
937 * @see MMPlayerVolumeType, mm_player_get_volume
938 * @remark The range of factor range is from 0 to 1.0. (1.0 = 100%) And, default value is 1.0.
941 MMPlayerVolumeType volume;
944 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
945 volume.level[i] = MM_VOLUME_LEVEL_MAX;
947 if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
949 printf("failed to set volume\n");
953 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume);
956 * This function is to get current volume factor of player.
958 * @param player [in] Handle of player.
959 * @param volume [out] Volume factor of each channel.
961 * @return This function returns zero on success, or negative value with error code.
963 * @see MMPlayerVolumeType, mm_player_set_volume
967 MMPlayerVolumeType volume;
970 if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE)
972 printf("failed to get volume\n");
975 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
976 printf("channel[%d] = %d \n", i, volume.level[i]);
979 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume);
982 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
983 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
984 * by mm_player_set_message_callback().
986 * @param player [in] Handle of player
988 * @return This function returns zero on success, or negative value with error code.
991 * @pre Player state may be MM_PLAYER_STATE_READY.
992 * @post Player state will be MM_PLAYER_STATE_PLAYING.
993 * @see mm_player_stop
997 if (mm_player_start(g_player) != MM_ERROR_NONE)
999 printf("failed to start player\n");
1003 int mm_player_start(MMHandleType player);
1006 * This function is to stop playing media contents and it's different with pause. \n
1007 * If mm_player_start() is called after this, content will be started again from the beginning. \n
1008 * So, it can be used to close current playback.
1010 * @param player [in] Handle of player
1012 * @return This function returns zero on success, or negative value with error code.
1014 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1015 * @post Player state will be MM_PLAYER_STATE_READY.
1016 * @see mm_player_start
1020 if (mm_player_stop(g_player) != MM_ERROR_NONE)
1022 printf("failed to stop player\n");
1026 int mm_player_stop(MMHandleType player);
1029 * This function is to pause playing media contents.
1031 * @param player [in] Handle of player.
1033 * @return This function returns zero on success, or negative value with error code.
1035 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1036 * @post Player state will be MM_PLAYER_STATE_PAUSED.
1037 * @see mm_player_resume
1041 if (mm_player_pause(g_player) != MM_ERROR_NONE)
1043 printf("failed to pause player\n");
1047 int mm_player_pause(MMHandleType player);
1050 * This function is to resume paused media contents.
1052 * @param player [in] Handle of player.
1054 * @return This function returns zero on success, or negative value with error code.
1056 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
1057 * @post Player state will be MM_PLAYER_STATE_PLAYING.
1058 * @see mm_player_pause
1062 if (mm_player_resume(g_player) != MM_ERROR_NONE)
1064 printf("failed to resume player\n");
1068 int mm_player_resume(MMHandleType player);
1071 * This function is to set the position for playback. \n
1072 * So, it can be seeked to requested position. \n
1074 * @param player [in] Handle of player
1075 * @param format [in] Format of position.
1076 * @param pos [in] Position for playback
1078 * @return This function returns zero on success, or negative value with error code.
1079 * @see MMPlayerPosFormatType, mm_player_get_position
1080 * @remark the unit of time-based format is millisecond and other case is percent.
1083 int position = 1000; //1sec
1085 if (mm_player_set_position(g_player, MM_PLAYER_POS_FORMAT_TIME, position) != MM_ERROR_NONE)
1087 g_print("failed to set position\n");
1091 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1094 * This function is to get current position of playback content.
1096 * @param player [in] Handle of player.
1097 * @param format [in] Format of position.
1098 * @param pos [out] contains current position on success or zero in case of failure.
1100 * @return This function returns zero on success, or negative value with errors
1101 * @see MMPlayerPosFormatType, mm_player_set_position
1102 * @remark the unit of time-based format is millisecond and other case is percent.
1108 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1110 mm_player_get_attribute(g_player, &g_err_name, "content_duration", &duration, NULL);
1112 printf("pos: [%d/%d] msec\n", position, duration);
1115 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos);
1118 * This function is to get current buffer position of playback content.
1120 * @param player [in] Handle of player.
1121 * @param format [in] Format of position.
1122 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
1123 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
1125 * @return This function returns zero on success, or negative value with errors
1126 * @see MMPlayerPosFormatType, mm_player_set_position
1127 * @remark the unit of time-based format is millisecond and other case is percent.
1130 int start_pos = 0, stop_pos = 0;
1132 mm_player_get_buffer_position(g_player, MM_PLAYER_POS_FORMAT_PERCENT, &start_pos, &stop_pos );
1134 printf("buffer position: [%d] ~ [%d] \%\n", start_pos, stop_pos );
1137 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int *start_pos, int *stop_pos);
1140 * This function is to activate the section repeat. If it's set, selected section will be played \n
1141 * continually before deactivating it by mm_player_deactivate_section_repeat(). \n
1142 * The unit for setting is millisecond.
1144 * @param player [in] Handle of player.
1145 * @param start_pos [in] start position.
1146 * @param end_pos [in] end position.
1148 * @return This function returns zero on success, or negative value with error code.
1149 * @see mm_player_deactivate_section_repeat
1154 int endtime = 4000; //msec
1156 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1158 mm_player_activate_section_repeat(g_player, position, position+endtime);
1161 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos);
1164 * This function is to deactivate the section repeat.
1166 * @param player [in] Handle of player.
1168 * @return This function returns zero on success, or negative value with error code.
1169 * @see mm_player_activate_section_repeat
1173 if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE)
1175 printf("failed to deactivate section repeat\n");
1179 int mm_player_deactivate_section_repeat(MMHandleType player);
1182 * This function sets callback function for receiving messages from player.
1183 * So, player can notify warning, error and normal cases to application.
1185 * @param player [in] Handle of player.
1186 * @param callback [in] Message callback function.
1187 * @param user_param [in] User parameter which is passed to callback function.
1189 * @return This function returns zero on success, or negative value with error code.
1190 * @see MMMessageCallback
1194 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1198 case MM_MESSAGE_ERROR:
1202 case MM_MESSAGE_END_OF_STREAM:
1206 case MM_MESSAGE_STATE_CHANGED:
1210 case MM_MESSAGE_BEGIN_OF_STREAM:
1220 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
1223 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1226 * This function set callback function for receiving audio stream from player. \n
1227 * So, application can get raw audio data and modify it. \n
1228 * But, if callback don't return or holds it for long time, performance can be deteriorated. \n
1229 * It's only supported when audio stream is included in file. \n
1230 * So, if there is video stream or DRM content, it can't be used.
1232 * @param player [in] Handle of player.
1233 * @param callback [in] Audio stream callback function.
1234 * @param user_param [in] User parameter.
1236 * @return This function returns zero on success, or negative value with error
1238 * @see mm_player_audio_stream_callback
1239 * @remark It can be used for audio playback only.
1242 bool audio_callback(void *stream, int stream_size, void *user_param)
1244 printf("audio stream callback\n");
1247 mm_player_set_audio_stream_callback(g_player, audio_callback, NULL);
1250 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param);
1253 * This function is to mute volume of player
1255 * @param player [in] Handle of player
1256 * @param mute [in] Mute(1) or not mute(0)
1258 * @return This function returns zero on success, or negative value with error code
1259 * @see mm_player_get_mute
1263 if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE)
1265 printf("failed to set mute\n");
1269 int mm_player_set_mute(MMHandleType player, int mute);
1272 * This function is to get mute value of player
1274 * @param player [in] Handle of player
1275 * @param mute [out] Sound is muted
1277 * @return This function returns zero on success, or negative value with error code
1278 * @see mm_player_set_mute
1284 if (mm_player_get_mute(g_player, &mute) != MM_ERROR_NONE)
1286 printf("failed to get mute\n");
1289 printf("mute status:%d\n", mute);
1292 int mm_player_get_mute(MMHandleType player, int *mute);
1295 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
1296 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
1298 * @param player [in] Handle of player
1299 * @param pos [in] postion to be adjusted
1301 * @return This function returns zero on success, or negative value with error
1303 * @see mm_player_adjust_subtitle_position
1310 if (mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, pos) != MM_ERROR_NONE)
1312 printf("failed to adjust subtitle postion.\n");
1317 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1320 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
1321 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
1322 * Player FW parses subtitle file and send text data including timestamp to application \n
1323 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
1324 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
1325 * So, it's not supported for embedded case.
1327 * @param player [in] Handle of player
1328 * @param silent [in] silent(integer value except 0) or not silent(0)
1330 * @return This function returns zero on success, or negative value with error
1332 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1336 mm_player_set_attribute(g_player,
1338 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
1342 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
1344 printf("failed to set subtitle silent\n");
1348 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
1351 * This function is to get silent status of subtitle.
1353 * @param player [in] Handle of player
1354 * @param silent [out] subtitle silent property
1356 * @return This function returns zero on success, or negative value with error
1358 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1364 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
1366 printf("failed to set subtitle silent\n");
1370 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
1373 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1374 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1376 * @param player [in] Handle of player.
1377 * @param err_attr_name [out] Name of attribute which is failed to set
1378 * @param first_attribute_name [in] Name of the first attribute to set
1379 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1380 * But, in the case of data or string type, it should be name/value/size.
1382 * @return This function returns zero on success, or negative value with error code.
1384 * @see mm_player_get_attribute
1385 * @remark This function must be terminated by NULL argument.
1386 * And, if this function is failed, err_attr_name param must be free.
1389 char *g_err_attr_name = NULL;
1391 if (mm_player_set_attribute(g_player,
1393 "profile_uri", filename, strlen(filename),
1394 "profile_play_count", count,
1395 NULL) != MM_ERROR_NONE)
1397 printf("failed to set %s attribute\n", g_err_attr_name);
1398 free(g_err_attr_name);
1403 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1406 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1408 * @param player [in] Handle of player.
1409 * @param err_attr_name [out] Name of attribute which is failed to get
1410 * @param first_attribute_name [in] Name of the first attribute to get
1411 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1412 * But, in the case of data or string type, it should be name/value/size.
1414 * @return This function returns zero on success, or negative value with error
1416 * @see mm_player_set_attribute
1417 * @remark This function must be terminated by NULL argument.
1418 * And, if this function is failed, err_attr_name param must be free.
1421 char *g_err_attr_name = NULL;
1423 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
1425 printf("failed to set %s attribute\n", g_err_attr_name);
1426 free(g_err_attr_name);
1430 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1433 * This function is to get detail information of attribute.
1435 * @param player [in] Handle of player.
1436 * @param attribute_name [in] Name of the attribute to get
1437 * @param info [out] Attribute infomation
1439 * @return This function returns zero on success, or negative value with error
1442 * @see mm_player_set_attribute, mm_player_get_attribute
1446 if (mm_player_get_attribute_info (g_player, "display_method", &method_info) != MM_ERROR_NONE)
1448 printf("failed to get info\n");
1451 printf("type:%d \n", method_info.type); //int, double..
1452 printf("flag:%d \n", method_info.flag); //readable, writable..
1453 printf("validity type:%d \n", method_info.validity_type); //range, array..
1455 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE)
1457 printf("range min:%d\n", method_info.int_range.min);
1458 printf("range max:%d\n", method_info.int_range.max);
1462 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info);
1465 * This function is to get download position and total size of progressive download
1467 * @param player [in] Handle of player.
1468 * @param current_pos [in] Download position currently (bytes)
1469 * @param total_size [in] Total size of file (bytes)
1471 * @return This function returns zero on success, or negative value with error code.
1477 guint64 current_pos = 0LLU;
1478 guint64 total_size = 0LLU;
1480 if (mm_player_get_pd_status(g_player, ¤t_pos, &total_size, NULL) != MM_ERROR_NONE)
1482 printf("current download pos = %llu, total size = %llu\n", current_pos, total_size);
1486 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size);
1489 * This function sets callback function for receiving messages of PD downloader.
1491 * @param player [in] Handle of player.
1492 * @param callback [in] Message callback function.
1493 * @param user_param [in] User parameter which is passed to callback function.
1495 * @return This function returns zero on success, or negative value with error code.
1500 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1504 case MM_MESSAGE_PD_DOWNLOADER_START:
1505 printf("Progressive download is started...\n");
1507 case MM_MESSAGE_PD_DOWNLOADER_END:
1508 printf("Progressive download is ended...\n");
1516 mm_player_set_pd_message_callback(g_player, msg_callback, NULL);
1519 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1522 * This function is to get the track count
1524 * @param player [in] handle of player.
1525 * @param track_type [in] type of the track type
1526 * @param info [out] the count of the track
1528 * @return This function returns zero on success, or negative value with error
1535 gint audio_count = 0;
1537 if (mm_player_get_track_count (g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE)
1539 printf("failed to get audio track count\n");
1542 printf("audio track count : %d \n", audio_count);
1545 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType track_type, int *count);
1548 * This function is to ignore session
1550 * @param player [in] handle of player
1552 * @return This function returns MM_ERROR_NONE on success, or negative value with error code.
1554 int mm_player_ignore_session(MMHandleType player);
1557 * This function is to set zoom level.
1559 * @param player [in] handle of player.
1560 * @param level [in] level of zoom
1562 * @return This function returns zero on success, or negative value with error
1568 int mm_player_set_display_zoom(MMHandleType player, float level);
1571 * This function is to get zoom level.
1573 * @param player [in] handle of player.
1574 * @param type [out] current level of zoom
1576 * @return This function returns zero on success, or negative value with error
1582 int mm_player_get_display_zoom(MMHandleType player, float *level);
1585 * This function is to set the start position of zoom
1587 * @param player [in] handle of player
1588 * @param x [in] start x position
1589 * @param y [in] start y position
1591 * @return This function returns zero on success, or negative value with error
1597 int mm_player_set_display_zoom_start_position(MMHandleType player, int x, int y);
1600 * This function is to get the start position of zoom
1602 * @param player [in] handle of player
1603 * @param x [out] start x position
1604 * @param y [out] start y position
1606 * @return This function returns zero on success, or negative value with error
1612 int mm_player_get_display_zoom_start_position(MMHandleType player, int *x, int *y);
1621 #endif /* __MM_PLAYER_H__ */