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_overlay_ext"</td>
287 <td>"display_rotation"</td>
292 <td>"subtitle_uri"</td>
299 Following attributes are supported for playing stream data. Those value can be readable only and valid after starting playback.\n
300 Please use mm_fileinfo for local playback.
310 <td>"content_video_found"</td>
315 <td>"content_video_codec"</td>
320 <td>"content_video_track_num"</td>
325 <td>"content_audio_found"</td>
330 <td>"content_audio_codec"</td>
335 <td>"content_audio_bitrate"</td>
340 <td>"content_audio_channels"</td>
345 <td>"content_audio_samplerate"</td>
350 <td>"content_audio_track_num"</td>
355 <td>"content_text_track_num"</td>
360 <td>"tag_artist"</td>
380 <td>"tag_author"</td>
385 <td>"tag_copyright"</td>
395 <td>"tag_description"</td>
400 <td>"tag_track_num"</td>
409 /*===========================================================================================
411 | GLOBAL DEFINITIONS AND DECLARATIONS |
413 ========================================================================================== */
418 * uri to play (string)
421 #define MM_PLAYER_CONTENT_URI "profile_uri"
423 * MM_PLAYER_CONTENT_DURATION:
425 * get the duration (int) as millisecond, It's guaranteed after calling mm_player_start() or
426 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
429 #define MM_PLAYER_CONTENT_DURATION "content_duration"
431 * MM_PLAYER_VIDEO_ROTATION
433 * can change video angle (int)
434 * @see MMDisplayRotationType
436 #define MM_PLAYER_VIDEO_ROTATION "display_rotation"
438 * MM_PLAYER_VIDEO_WIDTH:
440 * get the video width (int), It's guaranteed after calling mm_player_start() or
441 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
444 #define MM_PLAYER_VIDEO_WIDTH "content_video_width"
446 * MM_PLAYER_VIDEO_HEIGHT:
448 * get the video height (int), It's guaranteed after calling mm_player_start() or
449 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
452 #define MM_PLAYER_VIDEO_HEIGHT "content_video_height"
454 * MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING:
456 * set whether or not to scale frames size for evas surface.
457 * if TRUE, it scales down width, height size of frames with given size.
458 * if FALSE, it does not scale down any frames.
461 #define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling"
463 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
465 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
468 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
472 * set memory pointer to play (data)
475 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
477 * MM_PLAYER_PLAYBACK_COUNT
479 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
482 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
484 * MM_PLAYER_SUBTITLE_URI
486 * set the subtitle path (string)
488 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
490 * MM_PLAYER_STREAMING_TYPE
492 * set the streaming type (int)
493 * @see MMStreamingType
495 #define MM_PLAYER_STREAMING_TYPE "streaming_type"
497 * MM_PLAYER_STREAMING_UDP_TIMEOUT
499 * set the streaming udp timeout(int)
501 #define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout"
503 * MM_PLAYER_STREAMING_USER_AGENT
505 * set the streaming user agent (string)
507 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
509 * MM_PLAYER_STREAMING_WAP_PROFILE
511 * set the streaming wap profile (int)
513 #define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile"
515 * MM_PLAYER_STREAMING_NET_BANDWIDTH
517 * set the streaming network bandwidth (int)
519 #define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth"
521 * MM_PLAYER_STREAMING_COOKIE
523 * set the streaming cookie (int)
525 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
527 * MM_PLAYER_STREAMING_PROXY_IP
529 * set the streaming proxy ip (string)
531 #define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip"
533 * MM_PLAYER_STREAMING_PROXY_PORT
535 * set the streaming proxy port (int)
537 #define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port"
539 * MM_PLAYER_VIDEO_CODEC
541 * codec the video data is stored in (string)
543 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
545 * MM_PLAYER_VIDEO_TRACK_NUM
547 * track number inside a collection (int)
549 #define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num"
551 * MM_PLAYER_AUDIO_CODEC
553 * codec the audio data is stored in (string)
555 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
557 * MM_PLAYER_AUDIO_BITRATE
559 * set the streaming proxy port (int)
561 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
563 * MM_PLAYER_AUDIO_CHANNEL
565 * the number of audio channel (int)
567 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
569 * MM_PLAYER_AUDIO_SAMPLERATE
571 * audio samplerate (int)
573 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
575 * MM_PLAYER_AUDIO_TRACK_NUM
577 * track number inside a collection (int)
579 #define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num"
581 * MM_PLAYER_TEXT_TRACK_NUM
583 * track number inside a collection (int)
585 #define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num"
587 * MM_PLAYER_TAG_ARTIST
589 * person(s) responsible for the recording (string)
591 #define MM_PLAYER_TAG_ARTIST "tag_artist"
593 * MM_PLAYER_TAG_ARTIST
597 #define MM_PLAYER_TAG_TITLE "tag_title"
599 * MM_PLAYER_TAG_ARTIST
601 * album containing this data (string)
603 #define MM_PLAYER_TAG_ALBUM "tag_album"
605 * MM_PLAYER_TAG_ARTIST
607 * genre this data belongs to (string)
609 #define MM_PLAYER_TAG_GENRE "tag_genre"
611 * MM_PLAYER_TAG_ARTIST
615 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
617 * MM_PLAYER_TAG_ARTIST
619 * copyright notice of the data (string)
621 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
623 * MM_PLAYER_TAG_ARTIST
625 * date the data was created (string)
627 #define MM_PLAYER_TAG_DATE "tag_date"
629 * MM_PLAYER_TAG_ARTIST
631 * short text describing the content of the data (string)
633 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
635 * MM_PLAYER_TAG_ARTIST
637 * track number inside a collection (int)
639 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
643 * progressive download mode (int)
645 #define MM_PLAYER_PD_MODE "pd_mode"
648 * Enumerations of player state.
651 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
652 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
653 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
654 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
655 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
656 MM_PLAYER_STATE_NUM, /**< Number of player states */
660 * Enumerations of position formats.
661 * Used while invoking mm_player_get_position/mm_player_set_position APIs
664 MM_PLAYER_POS_FORMAT_TIME, /**< Format for time based */
665 MM_PLAYER_POS_FORMAT_PERCENT, /**< Format for percentage */
666 MM_PLAYER_POS_FORMAT_NUM, /**< Number of position formats */
667 } MMPlayerPosFormatType;
670 * Enumeration for attribute values types.
673 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
674 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
675 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
676 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
677 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
678 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
679 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
680 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
684 * Enumeration for attribute validation type.
687 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
688 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
689 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
690 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
691 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
692 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
693 } MMPlayerAttrsValidType;
696 * Enumeration for attribute access flag.
699 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
700 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
701 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
702 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
704 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
708 * Enumeration for progressive download
711 MM_PLAYER_PD_MODE_NONE,
712 MM_PLAYER_PD_MODE_URI,
713 MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario
717 * Enumeration of track types
720 MM_PLAYER_TRACK_TYPE_AUDIO,
721 MM_PLAYER_TRACK_TYPE_VIDEO,
722 MM_PLAYER_TRACK_TYPE_TEXT
726 * Attribute validity structure
729 MMPlayerAttrsType type;
730 MMPlayerAttrsValidType validity_type;
731 MMPlayerAttrsFlag flag;
733 * a union that describes validity of the attribute.
734 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
735 * the attribute can have validity.
739 * Validity structure for integer array.
742 int *array; /**< a pointer of array */
743 int count; /**< size of array */
747 * Validity structure for integer range.
750 int min; /**< minimum range */
751 int max; /**< maximum range */
755 * Validity structure for double array.
758 double * array; /**< a pointer of array */
759 int count; /**< size of array */
763 * Validity structure for double range.
766 double min; /**< minimum range */
767 double max; /**< maximum range */
776 * @see mm_player_set_volume, mm_player_get_volume
779 float level[MM_VOLUME_CHANNEL_NUM]; /**< Relative volume factor for each channels */
780 } MMPlayerVolumeType;
783 * Audio stream callback function type.
785 * @param stream [in] Reference pointer to audio frame data
786 * @param stream_size [in] Size of audio frame data
787 * @param user_param [in] User defined parameter which is passed when set
788 * audio stream callback
790 * @return This callback function have to return MM_ERROR_NONE.
792 typedef bool (*mm_player_audio_stream_callback) (void *stream, int stream_size, void *user_param);
795 /*===========================================================================================
797 | GLOBAL FUNCTION PROTOTYPES |
799 ========================================================================================== */
802 * This function creates a player object for playing multimedia contents. \n
803 * The attributes of player are created to get/set some values with application. \n
804 * And, mutex, gstreamer and other resources are initialized at this time. \n
805 * If player is created, the state will become MM_PLAYER_STATE_NULL.
807 * @param player [out] Handle of player
809 * @return This function returns zero on success, or negative value with error code. \n
810 * Please refer 'mm_error.h' to know it in detail.
812 * @post MM_PLAYER_STATE_NULL
813 * @see mm_player_destroy
814 * @remark You can create multiple handles on a context at the same time. \n
815 * However, player cannot guarantee proper operation because of limitation of resources, \n
816 * such as audio device or display device.
820 char *g_err_attr_name = NULL;
822 if (mm_player_create(&g_player) != MM_ERROR_NONE)
824 printf("failed to create player\n");
827 if (mm_player_set_attribute(g_player,
829 "profile_uri", filename, strlen(filename),
830 "display_overlay", (void*)&g_win.xid, sizeof(g_win.xid),
831 NULL) != MM_ERROR_NONE)
833 printf("failed to set %s attribute\n", g_err_attr_name);
834 free(g_err_attr_name);
837 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
840 int mm_player_create(MMHandleType *player);
843 * This function releases player object and all resources which were created by mm_player_create(). \n
844 * And, player handle will also be destroyed.
846 * @param player [in] Handle of player
848 * @return This function returns zero on success, or negative value with error code.
849 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
850 * But, it can be called in any state.
851 * @post Because handle is released, there is no any state.
852 * @see mm_player_create
853 * @remark This method can be called with a valid player handle from any state to \n
854 * completely shutdown the player operation.
858 if (mm_player_destroy(g_player) != MM_ERROR_NONE)
860 printf("failed to destroy player\n");
864 int mm_player_destroy(MMHandleType player);
867 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
868 * So, uri should be set before realizing with mm_player_set_attribute(). \n
870 * @param player [in] Handle of player
872 * @return This function returns zero on success, or negative value with error code.
874 * @pre Player state should be MM_PLAYER_STATE_NULL.
875 * @post Player state will be MM_PLAYER_STATE_READY.
876 * @see mm_player_unrealize
880 if (mm_player_realize(g_player) != MM_ERROR_NONE)
882 printf("failed to realize player\n");
886 int mm_player_realize(MMHandleType player) ;
889 * This function uninitializes player object. So, resources and allocated memory \n
890 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
891 * other contents, player should be created again after destruction or realized with new uri.
893 * @param player [in] Handle of player
895 * @return This function returns zero on success, or negative value with error code.
896 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
897 * But, it can be called in any state.
898 * @post Player state will be MM_PLAYER_STATE_NULL.
899 * @see mm_player_realize
900 * @remark This method can be called with a valid player handle from any state.
904 if (mm_player_unrealize(g_player) != MM_ERROR_NONE)
906 printf("failed to unrealize player\n");
910 int mm_player_unrealize(MMHandleType player);
913 * This function is to get current state of player. \n
914 * Application have to check current state before doing some action.
916 * @param player [in] Handle of player
917 * @param state [out] current state of player on success
919 * @return This function returns zero on success, or negative value with error code.
921 * @see MMPlayerStateType
925 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE)
927 printf("failed to get state\n");
931 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state);
934 * This function is to set relative volume of player. \n
935 * So, It controls logical volume value. \n
936 * But, if developer want to change system volume, mm sound api should be used.
938 * @param player [in] Handle of player
939 * @param volume [in] Volume factor of each channel
941 * @return This function returns zero on success, or negative value with error code.
942 * @see MMPlayerVolumeType, mm_player_get_volume
943 * @remark The range of factor range is from 0 to 1.0. (1.0 = 100%) And, default value is 1.0.
946 MMPlayerVolumeType volume;
949 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
950 volume.level[i] = MM_VOLUME_LEVEL_MAX;
952 if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
954 printf("failed to set volume\n");
958 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume);
961 * This function is to get current volume factor of player.
963 * @param player [in] Handle of player.
964 * @param volume [out] Volume factor of each channel.
966 * @return This function returns zero on success, or negative value with error code.
968 * @see MMPlayerVolumeType, mm_player_set_volume
972 MMPlayerVolumeType volume;
975 if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE)
977 printf("failed to get volume\n");
980 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
981 printf("channel[%d] = %d \n", i, volume.level[i]);
984 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume);
987 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
988 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
989 * by mm_player_set_message_callback().
991 * @param player [in] Handle of player
993 * @return This function returns zero on success, or negative value with error code.
996 * @pre Player state may be MM_PLAYER_STATE_READY.
997 * @post Player state will be MM_PLAYER_STATE_PLAYING.
998 * @see mm_player_stop
1002 if (mm_player_start(g_player) != MM_ERROR_NONE)
1004 printf("failed to start player\n");
1008 int mm_player_start(MMHandleType player);
1011 * This function is to stop playing media contents and it's different with pause. \n
1012 * If mm_player_start() is called after this, content will be started again from the beginning. \n
1013 * So, it can be used to close current playback.
1015 * @param player [in] Handle of player
1017 * @return This function returns zero on success, or negative value with error code.
1019 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1020 * @post Player state will be MM_PLAYER_STATE_READY.
1021 * @see mm_player_start
1025 if (mm_player_stop(g_player) != MM_ERROR_NONE)
1027 printf("failed to stop player\n");
1031 int mm_player_stop(MMHandleType player);
1034 * This function is to pause playing media contents.
1036 * @param player [in] Handle of player.
1038 * @return This function returns zero on success, or negative value with error code.
1040 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1041 * @post Player state will be MM_PLAYER_STATE_PAUSED.
1042 * @see mm_player_resume
1046 if (mm_player_pause(g_player) != MM_ERROR_NONE)
1048 printf("failed to pause player\n");
1052 int mm_player_pause(MMHandleType player);
1055 * This function is to resume paused media contents.
1057 * @param player [in] Handle of player.
1059 * @return This function returns zero on success, or negative value with error code.
1061 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
1062 * @post Player state will be MM_PLAYER_STATE_PLAYING.
1063 * @see mm_player_pause
1067 if (mm_player_resume(g_player) != MM_ERROR_NONE)
1069 printf("failed to resume player\n");
1073 int mm_player_resume(MMHandleType player);
1076 * This function is to set the position for playback. \n
1077 * So, it can be seeked to requested position. \n
1079 * @param player [in] Handle of player
1080 * @param format [in] Format of position.
1081 * @param pos [in] Position for playback
1083 * @return This function returns zero on success, or negative value with error code.
1084 * @see MMPlayerPosFormatType, mm_player_get_position
1085 * @remark the unit of time-based format is millisecond and other case is percent.
1088 int position = 1000; //1sec
1090 if (mm_player_set_position(g_player, MM_PLAYER_POS_FORMAT_TIME, position) != MM_ERROR_NONE)
1092 g_print("failed to set position\n");
1096 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1099 * This function is to get current position of playback content.
1101 * @param player [in] Handle of player.
1102 * @param format [in] Format of position.
1103 * @param pos [out] contains current position on success or zero in case of failure.
1105 * @return This function returns zero on success, or negative value with errors
1106 * @see MMPlayerPosFormatType, mm_player_set_position
1107 * @remark the unit of time-based format is millisecond and other case is percent.
1113 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1115 mm_player_get_attribute(g_player, &g_err_name, "content_duration", &duration, NULL);
1117 printf("pos: [%d/%d] msec\n", position, duration);
1120 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos);
1123 * This function is to get current buffer position of playback content.
1125 * @param player [in] Handle of player.
1126 * @param format [in] Format of position.
1127 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
1128 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
1130 * @return This function returns zero on success, or negative value with errors
1131 * @see MMPlayerPosFormatType, mm_player_set_position
1132 * @remark the unit of time-based format is millisecond and other case is percent.
1135 int start_pos = 0, stop_pos = 0;
1137 mm_player_get_buffer_position(g_player, MM_PLAYER_POS_FORMAT_PERCENT, &start_pos, &stop_pos );
1139 printf("buffer position: [%d] ~ [%d] \%\n", start_pos, stop_pos );
1142 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int *start_pos, int *stop_pos);
1145 * This function is to activate the section repeat. If it's set, selected section will be played \n
1146 * continually before deactivating it by mm_player_deactivate_section_repeat(). \n
1147 * The unit for setting is millisecond.
1149 * @param player [in] Handle of player.
1150 * @param start_pos [in] start position.
1151 * @param end_pos [in] end position.
1153 * @return This function returns zero on success, or negative value with error code.
1154 * @see mm_player_deactivate_section_repeat
1159 int endtime = 4000; //msec
1161 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1163 mm_player_activate_section_repeat(g_player, position, position+endtime);
1166 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos);
1169 * This function is to deactivate the section repeat.
1171 * @param player [in] Handle of player.
1173 * @return This function returns zero on success, or negative value with error code.
1174 * @see mm_player_activate_section_repeat
1178 if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE)
1180 printf("failed to deactivate section repeat\n");
1184 int mm_player_deactivate_section_repeat(MMHandleType player);
1187 * This function sets callback function for receiving messages from player.
1188 * So, player can notify warning, error and normal cases to application.
1190 * @param player [in] Handle of player.
1191 * @param callback [in] Message callback function.
1192 * @param user_param [in] User parameter which is passed to callback function.
1194 * @return This function returns zero on success, or negative value with error code.
1195 * @see MMMessageCallback
1199 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1203 case MM_MESSAGE_ERROR:
1207 case MM_MESSAGE_END_OF_STREAM:
1211 case MM_MESSAGE_STATE_CHANGED:
1215 case MM_MESSAGE_BEGIN_OF_STREAM:
1225 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
1228 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1231 * This function set callback function for receiving audio stream from player. \n
1232 * So, application can get raw audio data and modify it. \n
1233 * But, if callback don't return or holds it for long time, performance can be deteriorated. \n
1234 * It's only supported when audio stream is included in file. \n
1235 * So, if there is video stream or DRM content, it can't be used.
1237 * @param player [in] Handle of player.
1238 * @param callback [in] Audio stream callback function.
1239 * @param user_param [in] User parameter.
1241 * @return This function returns zero on success, or negative value with error
1243 * @see mm_player_audio_stream_callback
1244 * @remark It can be used for audio playback only.
1247 bool audio_callback(void *stream, int stream_size, void *user_param)
1249 printf("audio stream callback\n");
1252 mm_player_set_audio_stream_callback(g_player, audio_callback, NULL);
1255 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param);
1258 * This function is to mute volume of player
1260 * @param player [in] Handle of player
1261 * @param mute [in] Mute(1) or not mute(0)
1263 * @return This function returns zero on success, or negative value with error code
1264 * @see mm_player_get_mute
1268 if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE)
1270 printf("failed to set mute\n");
1274 int mm_player_set_mute(MMHandleType player, int mute);
1277 * This function is to get mute value of player
1279 * @param player [in] Handle of player
1280 * @param mute [out] Sound is muted
1282 * @return This function returns zero on success, or negative value with error code
1283 * @see mm_player_set_mute
1289 if (mm_player_get_mute(g_player, &mute) != MM_ERROR_NONE)
1291 printf("failed to get mute\n");
1294 printf("mute status:%d\n", mute);
1297 int mm_player_get_mute(MMHandleType player, int *mute);
1300 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
1301 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
1303 * @param player [in] Handle of player
1304 * @param pos [in] postion to be adjusted
1306 * @return This function returns zero on success, or negative value with error
1308 * @see mm_player_adjust_subtitle_position
1315 if (mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, pos) != MM_ERROR_NONE)
1317 printf("failed to adjust subtitle postion.\n");
1322 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1325 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
1326 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
1327 * Player FW parses subtitle file and send text data including timestamp to application \n
1328 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
1329 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
1330 * So, it's not supported for embedded case.
1332 * @param player [in] Handle of player
1333 * @param silent [in] silent(integer value except 0) or not silent(0)
1335 * @return This function returns zero on success, or negative value with error
1337 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1341 mm_player_set_attribute(g_player,
1343 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
1347 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
1349 printf("failed to set subtitle silent\n");
1353 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
1356 * This function is to get silent status of subtitle.
1358 * @param player [in] Handle of player
1359 * @param silent [out] subtitle silent property
1361 * @return This function returns zero on success, or negative value with error
1363 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1369 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
1371 printf("failed to set subtitle silent\n");
1375 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
1378 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1379 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1381 * @param player [in] Handle of player.
1382 * @param err_attr_name [out] Name of attribute which is failed to set
1383 * @param first_attribute_name [in] Name of the first attribute to set
1384 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1385 * But, in the case of data or string type, it should be name/value/size.
1387 * @return This function returns zero on success, or negative value with error code.
1389 * @see mm_player_get_attribute
1390 * @remark This function must be terminated by NULL argument.
1391 * And, if this function is failed, err_attr_name param must be free.
1394 char *g_err_attr_name = NULL;
1396 if (mm_player_set_attribute(g_player,
1398 "profile_uri", filename, strlen(filename),
1399 "profile_play_count", count,
1400 NULL) != MM_ERROR_NONE)
1402 printf("failed to set %s attribute\n", g_err_attr_name);
1403 free(g_err_attr_name);
1408 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1411 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1413 * @param player [in] Handle of player.
1414 * @param err_attr_name [out] Name of attribute which is failed to get
1415 * @param first_attribute_name [in] Name of the first attribute to get
1416 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1417 * But, in the case of data or string type, it should be name/value/size.
1419 * @return This function returns zero on success, or negative value with error
1421 * @see mm_player_set_attribute
1422 * @remark This function must be terminated by NULL argument.
1423 * And, if this function is failed, err_attr_name param must be free.
1426 char *g_err_attr_name = NULL;
1428 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
1430 printf("failed to set %s attribute\n", g_err_attr_name);
1431 free(g_err_attr_name);
1435 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1438 * This function is to get detail information of attribute.
1440 * @param player [in] Handle of player.
1441 * @param attribute_name [in] Name of the attribute to get
1442 * @param info [out] Attribute infomation
1444 * @return This function returns zero on success, or negative value with error
1447 * @see mm_player_set_attribute, mm_player_get_attribute
1451 if (mm_player_get_attribute_info (g_player, "display_method", &method_info) != MM_ERROR_NONE)
1453 printf("failed to get info\n");
1456 printf("type:%d \n", method_info.type); //int, double..
1457 printf("flag:%d \n", method_info.flag); //readable, writable..
1458 printf("validity type:%d \n", method_info.validity_type); //range, array..
1460 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE)
1462 printf("range min:%d\n", method_info.int_range.min);
1463 printf("range max:%d\n", method_info.int_range.max);
1467 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info);
1470 * This function is to get download position and total size of progressive download
1472 * @param player [in] Handle of player.
1473 * @param current_pos [in] Download position currently (bytes)
1474 * @param total_size [in] Total size of file (bytes)
1476 * @return This function returns zero on success, or negative value with error code.
1482 guint64 current_pos = 0LLU;
1483 guint64 total_size = 0LLU;
1485 if (mm_player_get_pd_status(g_player, ¤t_pos, &total_size, NULL) != MM_ERROR_NONE)
1487 printf("current download pos = %llu, total size = %llu\n", current_pos, total_size);
1491 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size);
1494 * This function sets callback function for receiving messages of PD downloader.
1496 * @param player [in] Handle of player.
1497 * @param callback [in] Message callback function.
1498 * @param user_param [in] User parameter which is passed to callback function.
1500 * @return This function returns zero on success, or negative value with error code.
1505 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1509 case MM_MESSAGE_PD_DOWNLOADER_START:
1510 printf("Progressive download is started...\n");
1512 case MM_MESSAGE_PD_DOWNLOADER_END:
1513 printf("Progressive download is ended...\n");
1521 mm_player_set_pd_message_callback(g_player, msg_callback, NULL);
1524 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1527 * This function is to get the track count
1529 * @param player [in] handle of player.
1530 * @param track_type [in] type of the track type
1531 * @param info [out] the count of the track
1533 * @return This function returns zero on success, or negative value with error
1540 gint audio_count = 0;
1542 if (mm_player_get_track_count (g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE)
1544 printf("failed to get audio track count\n");
1547 printf("audio track count : %d \n", audio_count);
1550 int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType track_type, int *count);
1561 #endif /* __MM_PLAYER_H__ */