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>,
7 * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef __MM_PLAYER_H__
24 #define __MM_PLAYER_H__
27 /*===========================================================================================
31 ========================================================================================== */
36 #include <mm_message.h>
47 This part describes APIs used for playback of multimedia contents.
48 All multimedia contents are created by a media player through handle of playback.
49 In creating a player, it displays the player's status or information
50 by registering callback function.
53 In case of streaming playback, network has to be opend by using datanetwork API.
54 If proxy, cookies and the other attributes for streaming playback are needed,
55 set those attributes using mm_player_set_attribute() before create player.
58 The subtitle for local video playback is supported. Set "subtitle_uri" attribute
59 using mm_player_set_attribute() before the application creates the player.
60 Then the application could receive MMMessageParamType which includes subtitle string and duration.
63 Player can have 5 states, and each state can be changed by calling
64 described functions on "Figure1. State of Player".
67 @image html player_state.jpg "Figure1. State of Player" width=12cm
68 @image latex player_state.jpg "Figure1. State of Player" width=12cm
71 Most of functions which change player state work as synchronous. But, mm_player_start() should be used
72 asynchronously. Both mm_player_pause() and mm_player_resume() should also be used asynchronously
73 in the case of streaming data.
74 So, application have to confirm the result of those APIs through message callback function.
77 Note that "None" and Null" state could be reached from any state
78 by calling mm_player_destroy() and mm_player_unrealize().
83 <td><B>FUNCTION</B></td>
84 <td><B>PRE-STATE</B></td>
85 <td><B>POST-STATE</B></td>
86 <td><B>SYNC TYPE</B></td>
89 <td>mm_player_create()</td>
95 <td>mm_player_destroy()</td>
101 <td>mm_player_realize()</td>
107 <td>mm_player_unrealize()</td>
113 <td>mm_player_start()</td>
119 <td>mm_player_stop()</td>
125 <td>mm_player_pause()</td>
131 <td>mm_player_resume()</td>
137 <td>mm_player_set_message_callback()</td>
143 <td>mm_player_get_state()</td>
149 <td>mm_player_set_volume()</td>
155 <td>mm_player_get_volume()</td>
161 <td>mm_player_set_position()</td>
167 <td>mm_player_get_position()</td>
173 <td>mm_player_get_attribute()</td>
179 <td>mm_player_set_attribute()</td>
187 Following are the attributes supported in player which may be set after initialization. \n
188 Those are handled as a string.
198 <td>"profile_uri"</td>
203 <td>"content_duration"</td>
208 <td>"content_video_width"</td>
213 <td>"content_video_height"</td>
218 <td>"display_evas_do_scaling"</td>
223 <td>"display_evas_surface_sink"</td>
228 <td>"profile_user_param"</td>
233 <td>"profile_play_count"</td>
238 <td>"streaming_type"</td>
243 <td>"streaming_udp_timeout"</td>
248 <td>"streaming_user_agent"</td>
253 <td>"streaming_wap_profile"</td>
258 <td>"streaming_network_bandwidth"</td>
263 <td>"streaming_cookie"</td>
268 <td>"streaming_proxy_ip"</td>
273 <td>"streaming_proxy_port"</td>
278 <td>"display_overlay"</td>
283 <td>"display_overlay_ext"</td>
288 <td>"display_rotation"</td>
293 <td>"subtitle_uri"</td>
300 Following attributes are supported for playing stream data. Those value can be readable only and valid after starting playback.\n
301 Please use mm_fileinfo for local playback.
311 <td>"content_video_found"</td>
316 <td>"content_video_codec"</td>
321 <td>"content_video_track_num"</td>
326 <td>"content_audio_found"</td>
331 <td>"content_audio_codec"</td>
336 <td>"content_audio_bitrate"</td>
341 <td>"content_audio_channels"</td>
346 <td>"content_audio_samplerate"</td>
351 <td>"content_audio_track_num"</td>
356 <td>"tag_artist"</td>
376 <td>"tag_author"</td>
381 <td>"tag_copyright"</td>
391 <td>"tag_description"</td>
396 <td>"tag_track_num"</td>
405 /*===========================================================================================
407 | GLOBAL DEFINITIONS AND DECLARATIONS |
409 ========================================================================================== */
414 * uri to play (string)
417 #define MM_PLAYER_CONTENT_URI "profile_uri"
419 * MM_PLAYER_CONTENT_DURATION:
421 * get the duration (int) as millisecond, It's guaranteed after calling mm_player_start() or
422 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
425 #define MM_PLAYER_CONTENT_DURATION "content_duration"
427 * MM_PLAYER_VIDEO_ROTATION
429 * can change video angle (int)
430 * @see MMDisplayRotationType
432 #define MM_PLAYER_VIDEO_ROTATION "display_rotation"
434 * MM_PLAYER_VIDEO_WIDTH:
436 * get the video width (int), It's guaranteed after calling mm_player_start() or
437 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
440 #define MM_PLAYER_VIDEO_WIDTH "content_video_width"
442 * MM_PLAYER_VIDEO_HEIGHT:
444 * get the video height (int), It's guaranteed after calling mm_player_start() or
445 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
448 #define MM_PLAYER_VIDEO_HEIGHT "content_video_height"
450 * MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING:
452 * set whether or not to scale frames size for evas surface.
453 * if TRUE, it scales down width, height size of frames with given size.
454 * if FALSE, it does not scale down any frames.
457 #define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling"
459 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
461 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
464 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
468 * set memory pointer to play (data)
471 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
473 * MM_PLAYER_PLAYBACK_COUNT
475 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
478 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
480 * MM_PLAYER_SUBTITLE_URI
482 * set the subtitle path (string)
484 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
486 * MM_PLAYER_STREAMING_TYPE
488 * set the streaming type (int)
489 * @see MMStreamingType
491 #define MM_PLAYER_STREAMING_TYPE "streaming_type"
493 * MM_PLAYER_STREAMING_UDP_TIMEOUT
495 * set the streaming udp timeout(int)
497 #define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout"
499 * MM_PLAYER_STREAMING_USER_AGENT
501 * set the streaming user agent (string)
503 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
505 * MM_PLAYER_STREAMING_WAP_PROFILE
507 * set the streaming wap profile (int)
509 #define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile"
511 * MM_PLAYER_STREAMING_NET_BANDWIDTH
513 * set the streaming network bandwidth (int)
515 #define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth"
517 * MM_PLAYER_STREAMING_COOKIE
519 * set the streaming cookie (int)
521 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
523 * MM_PLAYER_STREAMING_PROXY_IP
525 * set the streaming proxy ip (string)
527 #define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip"
529 * MM_PLAYER_STREAMING_PROXY_PORT
531 * set the streaming proxy port (int)
533 #define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port"
535 * MM_PLAYER_VIDEO_CODEC
537 * codec the video data is stored in (string)
539 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
541 * MM_PLAYER_VIDEO_TRACK_NUM
543 * track number inside a collection (int)
545 #define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num"
547 * MM_PLAYER_AUDIO_CODEC
549 * codec the audio data is stored in (string)
551 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
553 * MM_PLAYER_AUDIO_BITRATE
555 * set the streaming proxy port (int)
557 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
559 * MM_PLAYER_AUDIO_CHANNEL
561 * the number of audio channel (int)
563 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
565 * MM_PLAYER_AUDIO_SAMPLERATE
567 * audio samplerate (int)
569 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
571 * MM_PLAYER_AUDIO_TRACK_NUM
573 * track number inside a collection (int)
575 #define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num"
577 * MM_PLAYER_TAG_ARTIST
579 * person(s) responsible for the recording (string)
581 #define MM_PLAYER_TAG_ARTIST "tag_artist"
583 * MM_PLAYER_TAG_ARTIST
587 #define MM_PLAYER_TAG_TITLE "tag_title"
589 * MM_PLAYER_TAG_ARTIST
591 * album containing this data (string)
593 #define MM_PLAYER_TAG_ALBUM "tag_album"
595 * MM_PLAYER_TAG_ARTIST
597 * genre this data belongs to (string)
599 #define MM_PLAYER_TAG_GENRE "tag_genre"
601 * MM_PLAYER_TAG_ARTIST
605 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
607 * MM_PLAYER_TAG_ARTIST
609 * copyright notice of the data (string)
611 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
613 * MM_PLAYER_TAG_ARTIST
615 * date the data was created (string)
617 #define MM_PLAYER_TAG_DATE "tag_date"
619 * MM_PLAYER_TAG_ARTIST
621 * short text describing the content of the data (string)
623 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
625 * MM_PLAYER_TAG_ARTIST
627 * track number inside a collection (int)
629 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
633 * progressive download mode (int)
635 #define MM_PLAYER_PD_MODE "pd_mode"
638 * Enumerations of player state.
641 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
642 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
643 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
644 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
645 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
646 MM_PLAYER_STATE_NUM, /**< Number of player states */
650 * Enumerations of position formats.
651 * Used while invoking mm_player_get_position/mm_player_set_position APIs
654 MM_PLAYER_POS_FORMAT_TIME, /**< Format for time based */
655 MM_PLAYER_POS_FORMAT_PERCENT, /**< Format for percentage */
656 MM_PLAYER_POS_FORMAT_NUM, /**< Number of position formats */
657 } MMPlayerPosFormatType;
660 * Enumeration for attribute values types.
663 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
664 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
665 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
666 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
667 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
668 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
669 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
670 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
674 * Enumeration for attribute validation type.
677 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
678 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
679 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
680 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
681 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
682 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
683 } MMPlayerAttrsValidType;
686 * Enumeration for attribute access flag.
689 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
690 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
691 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
692 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
694 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
698 * Enumeration for progressive download
701 MM_PLAYER_PD_MODE_NONE,
702 MM_PLAYER_PD_MODE_URI,
703 MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario
707 * Attribute validity structure
710 MMPlayerAttrsType type;
711 MMPlayerAttrsValidType validity_type;
712 MMPlayerAttrsFlag flag;
714 * a union that describes validity of the attribute.
715 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
716 * the attribute can have validity.
720 * Validity structure for integer array.
723 int *array; /**< a pointer of array */
724 int count; /**< size of array */
728 * Validity structure for integer range.
731 int min; /**< minimum range */
732 int max; /**< maximum range */
736 * Validity structure for double array.
739 double * array; /**< a pointer of array */
740 int count; /**< size of array */
744 * Validity structure for double range.
747 double min; /**< minimum range */
748 double max; /**< maximum range */
757 * @see mm_player_set_volume, mm_player_get_volume
760 float level[MM_VOLUME_CHANNEL_NUM]; /**< Relative volume factor for each channels */
761 } MMPlayerVolumeType;
764 * Audio stream callback function type.
766 * @param stream [in] Reference pointer to audio frame data
767 * @param stream_size [in] Size of audio frame data
768 * @param user_param [in] User defined parameter which is passed when set
769 * audio stream callback
771 * @return This callback function have to return MM_ERROR_NONE.
773 typedef bool (*mm_player_audio_stream_callback) (void *stream, int stream_size, void *user_param);
776 /*===========================================================================================
778 | GLOBAL FUNCTION PROTOTYPES |
780 ========================================================================================== */
783 * This function creates a player object for playing multimedia contents. \n
784 * The attributes of player are created to get/set some values with application. \n
785 * And, mutex, gstreamer and other resources are initialized at this time. \n
786 * If player is created, the state will become MM_PLAYER_STATE_NULL.
788 * @param player [out] Handle of player
790 * @return This function returns zero on success, or negative value with error code. \n
791 * Please refer 'mm_error.h' to know it in detail.
793 * @post MM_PLAYER_STATE_NULL
794 * @see mm_player_destroy
795 * @remark You can create multiple handles on a context at the same time. \n
796 * However, player cannot guarantee proper operation because of limitation of resources, \n
797 * such as audio device or display device.
801 char *g_err_attr_name = NULL;
803 if (mm_player_create(&g_player) != MM_ERROR_NONE)
805 printf("failed to create player\n");
808 if (mm_player_set_attribute(g_player,
810 "profile_uri", filename, strlen(filename),
811 "display_overlay", (void*)&g_win.xid, sizeof(g_win.xid),
812 NULL) != MM_ERROR_NONE)
814 printf("failed to set %s attribute\n", g_err_attr_name);
815 free(g_err_attr_name);
818 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
821 int mm_player_create(MMHandleType *player);
824 * This function releases player object and all resources which were created by mm_player_create(). \n
825 * And, player handle will also be destroyed.
827 * @param player [in] Handle of player
829 * @return This function returns zero on success, or negative value with error code.
830 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
831 * But, it can be called in any state.
832 * @post Because handle is released, there is no any state.
833 * @see mm_player_create
834 * @remark This method can be called with a valid player handle from any state to \n
835 * completely shutdown the player operation.
839 if (mm_player_destroy(g_player) != MM_ERROR_NONE)
841 printf("failed to destroy player\n");
845 int mm_player_destroy(MMHandleType player);
848 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
849 * So, uri should be set before realizing with mm_player_set_attribute(). \n
851 * @param player [in] Handle of player
853 * @return This function returns zero on success, or negative value with error code.
855 * @pre Player state should be MM_PLAYER_STATE_NULL.
856 * @post Player state will be MM_PLAYER_STATE_READY.
857 * @see mm_player_unrealize
861 if (mm_player_realize(g_player) != MM_ERROR_NONE)
863 printf("failed to realize player\n");
867 int mm_player_realize(MMHandleType player) ;
870 * This function uninitializes player object. So, resources and allocated memory \n
871 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
872 * other contents, player should be created again after destruction or realized with new uri.
874 * @param player [in] Handle of player
876 * @return This function returns zero on success, or negative value with error code.
877 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
878 * But, it can be called in any state.
879 * @post Player state will be MM_PLAYER_STATE_NULL.
880 * @see mm_player_realize
881 * @remark This method can be called with a valid player handle from any state.
885 if (mm_player_unrealize(g_player) != MM_ERROR_NONE)
887 printf("failed to unrealize player\n");
891 int mm_player_unrealize(MMHandleType player);
894 * This function is to get current state of player. \n
895 * Application have to check current state before doing some action.
897 * @param player [in] Handle of player
898 * @param state [out] current state of player on success
900 * @return This function returns zero on success, or negative value with error code.
902 * @see MMPlayerStateType
906 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE)
908 printf("failed to get state\n");
912 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state);
915 * This function is to set relative volume of player. \n
916 * So, It controls logical volume value. \n
917 * But, if developer want to change system volume, mm sound api should be used.
919 * @param player [in] Handle of player
920 * @param volume [in] Volume factor of each channel
922 * @return This function returns zero on success, or negative value with error code.
923 * @see MMPlayerVolumeType, mm_player_get_volume
924 * @remark The range of factor range is from 0 to 1.0. (1.0 = 100%) And, default value is 1.0.
927 MMPlayerVolumeType volume;
930 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
931 volume.level[i] = MM_VOLUME_LEVEL_MAX;
933 if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
935 printf("failed to set volume\n");
939 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume);
942 * This function is to get current volume factor of player.
944 * @param player [in] Handle of player.
945 * @param volume [out] Volume factor of each channel.
947 * @return This function returns zero on success, or negative value with error code.
949 * @see MMPlayerVolumeType, mm_player_set_volume
953 MMPlayerVolumeType volume;
956 if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE)
958 printf("failed to get volume\n");
961 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
962 printf("channel[%d] = %d \n", i, volume.level[i]);
965 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume);
968 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
969 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
970 * by mm_player_set_message_callback().
972 * @param player [in] Handle of player
974 * @return This function returns zero on success, or negative value with error code.
977 * @pre Player state may be MM_PLAYER_STATE_READY.
978 * @post Player state will be MM_PLAYER_STATE_PLAYING.
979 * @see mm_player_stop
983 if (mm_player_start(g_player) != MM_ERROR_NONE)
985 printf("failed to start player\n");
989 int mm_player_start(MMHandleType player);
992 * This function is to stop playing media contents and it's different with pause. \n
993 * If mm_player_start() is called after this, content will be started again from the beginning. \n
994 * So, it can be used to close current playback.
996 * @param player [in] Handle of player
998 * @return This function returns zero on success, or negative value with error code.
1000 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1001 * @post Player state will be MM_PLAYER_STATE_READY.
1002 * @see mm_player_start
1006 if (mm_player_stop(g_player) != MM_ERROR_NONE)
1008 printf("failed to stop player\n");
1012 int mm_player_stop(MMHandleType player);
1015 * This function is to pause playing media contents.
1017 * @param player [in] Handle of player.
1019 * @return This function returns zero on success, or negative value with error code.
1021 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1022 * @post Player state will be MM_PLAYER_STATE_PAUSED.
1023 * @see mm_player_resume
1027 if (mm_player_pause(g_player) != MM_ERROR_NONE)
1029 printf("failed to pause player\n");
1033 int mm_player_pause(MMHandleType player);
1036 * This function is to resume paused media contents.
1038 * @param player [in] Handle of player.
1040 * @return This function returns zero on success, or negative value with error code.
1042 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
1043 * @post Player state will be MM_PLAYER_STATE_PLAYING.
1044 * @see mm_player_pause
1048 if (mm_player_resume(g_player) != MM_ERROR_NONE)
1050 printf("failed to resume player\n");
1054 int mm_player_resume(MMHandleType player);
1057 * This function is to set the position for playback. \n
1058 * So, it can be seeked to requested position. \n
1060 * @param player [in] Handle of player
1061 * @param format [in] Format of position.
1062 * @param pos [in] Position for playback
1064 * @return This function returns zero on success, or negative value with error code.
1065 * @see MMPlayerPosFormatType, mm_player_get_position
1066 * @remark the unit of time-based format is millisecond and other case is percent.
1069 int position = 1000; //1sec
1071 if (mm_player_set_position(g_player, MM_PLAYER_POS_FORMAT_TIME, position) != MM_ERROR_NONE)
1073 g_print("failed to set position\n");
1077 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1080 * This function is to get current position of playback content.
1082 * @param player [in] Handle of player.
1083 * @param format [in] Format of position.
1084 * @param pos [out] contains current position on success or zero in case of failure.
1086 * @return This function returns zero on success, or negative value with errors
1087 * @see MMPlayerPosFormatType, mm_player_set_position
1088 * @remark the unit of time-based format is millisecond and other case is percent.
1094 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1096 mm_player_get_attribute(g_player, &g_err_name, "content_duration", &duration, NULL);
1098 printf("pos: [%d/%d] msec\n", position, duration);
1101 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos);
1104 * This function is to get current buffer position of playback content.
1106 * @param player [in] Handle of player.
1107 * @param format [in] Format of position.
1108 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
1109 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
1111 * @return This function returns zero on success, or negative value with errors
1112 * @see MMPlayerPosFormatType, mm_player_set_position
1113 * @remark the unit of time-based format is millisecond and other case is percent.
1116 int start_pos = 0, stop_pos = 0;
1118 mm_player_get_buffer_position(g_player, MM_PLAYER_POS_FORMAT_PERCENT, &start_pos, &stop_pos );
1120 printf("buffer position: [%d] ~ [%d] \%\n", start_pos, stop_pos );
1123 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int *start_pos, int *stop_pos);
1126 * This function is to activate the section repeat. If it's set, selected section will be played \n
1127 * continually before deactivating it by mm_player_deactivate_section_repeat(). \n
1128 * The unit for setting is millisecond.
1130 * @param player [in] Handle of player.
1131 * @param start_pos [in] start position.
1132 * @param end_pos [in] end position.
1134 * @return This function returns zero on success, or negative value with error code.
1135 * @see mm_player_deactivate_section_repeat
1140 int endtime = 4000; //msec
1142 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1144 mm_player_activate_section_repeat(g_player, position, position+endtime);
1147 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos);
1150 * This function is to deactivate the section repeat.
1152 * @param player [in] Handle of player.
1154 * @return This function returns zero on success, or negative value with error code.
1155 * @see mm_player_activate_section_repeat
1159 if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE)
1161 printf("failed to deactivate section repeat\n");
1165 int mm_player_deactivate_section_repeat(MMHandleType player);
1168 * This function sets callback function for receiving messages from player.
1169 * So, player can notify warning, error and normal cases to application.
1171 * @param player [in] Handle of player.
1172 * @param callback [in] Message callback function.
1173 * @param user_param [in] User parameter which is passed to callback function.
1175 * @return This function returns zero on success, or negative value with error code.
1176 * @see MMMessageCallback
1180 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1184 case MM_MESSAGE_ERROR:
1188 case MM_MESSAGE_END_OF_STREAM:
1192 case MM_MESSAGE_STATE_CHANGED:
1196 case MM_MESSAGE_BEGIN_OF_STREAM:
1206 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
1209 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1212 * This function set callback function for receiving audio stream from player. \n
1213 * So, application can get raw audio data and modify it. \n
1214 * But, if callback don't return or holds it for long time, performance can be deteriorated. \n
1215 * It's only supported when audio stream is included in file. \n
1216 * So, if there is video stream or DRM content, it can't be used.
1218 * @param player [in] Handle of player.
1219 * @param callback [in] Audio stream callback function.
1220 * @param user_param [in] User parameter.
1222 * @return This function returns zero on success, or negative value with error
1224 * @see mm_player_audio_stream_callback
1225 * @remark It can be used for audio playback only.
1228 bool audio_callback(void *stream, int stream_size, void *user_param)
1230 printf("audio stream callback\n");
1233 mm_player_set_audio_stream_callback(g_player, audio_callback, NULL);
1236 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param);
1239 * This function is to mute volume of player
1241 * @param player [in] Handle of player
1242 * @param mute [in] Mute(1) or not mute(0)
1244 * @return This function returns zero on success, or negative value with error code
1245 * @see mm_player_get_mute
1249 if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE)
1251 printf("failed to set mute\n");
1255 int mm_player_set_mute(MMHandleType player, int mute);
1258 * This function is to get mute value of player
1260 * @param player [in] Handle of player
1261 * @param mute [out] Sound is muted
1263 * @return This function returns zero on success, or negative value with error code
1264 * @see mm_player_set_mute
1270 if (mm_player_get_mute(g_player, &mute) != MM_ERROR_NONE)
1272 printf("failed to get mute\n");
1275 printf("mute status:%d\n", mute);
1278 int mm_player_get_mute(MMHandleType player, int *mute);
1281 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
1282 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
1284 * @param player [in] Handle of player
1285 * @param pos [in] postion to be adjusted
1287 * @return This function returns zero on success, or negative value with error
1289 * @see mm_player_adjust_subtitle_position
1296 if (mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, pos) != MM_ERROR_NONE)
1298 printf("failed to adjust subtitle postion.\n");
1303 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1306 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
1307 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
1308 * Player FW parses subtitle file and send text data including timestamp to application \n
1309 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
1310 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
1311 * So, it's not supported for embedded case.
1313 * @param player [in] Handle of player
1314 * @param silent [in] silent(integer value except 0) or not silent(0)
1316 * @return This function returns zero on success, or negative value with error
1318 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1322 mm_player_set_attribute(g_player,
1324 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
1328 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
1330 printf("failed to set subtitle silent\n");
1334 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
1337 * This function is to get silent status of subtitle.
1339 * @param player [in] Handle of player
1340 * @param silent [out] subtitle silent property
1342 * @return This function returns zero on success, or negative value with error
1344 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1350 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
1352 printf("failed to set subtitle silent\n");
1356 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
1359 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1360 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1362 * @param player [in] Handle of player.
1363 * @param err_attr_name [out] Name of attribute which is failed to set
1364 * @param first_attribute_name [in] Name of the first attribute to set
1365 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1366 * But, in the case of data or string type, it should be name/value/size.
1368 * @return This function returns zero on success, or negative value with error code.
1370 * @see mm_player_get_attribute
1371 * @remark This function must be terminated by NULL argument.
1372 * And, if this function is failed, err_attr_name param must be free.
1375 char *g_err_attr_name = NULL;
1377 if (mm_player_set_attribute(g_player,
1379 "profile_uri", filename, strlen(filename),
1380 "profile_play_count", count,
1381 NULL) != MM_ERROR_NONE)
1383 printf("failed to set %s attribute\n", g_err_attr_name);
1384 free(g_err_attr_name);
1389 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1392 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1394 * @param player [in] Handle of player.
1395 * @param err_attr_name [out] Name of attribute which is failed to get
1396 * @param first_attribute_name [in] Name of the first attribute to get
1397 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1398 * But, in the case of data or string type, it should be name/value/size.
1400 * @return This function returns zero on success, or negative value with error
1402 * @see mm_player_set_attribute
1403 * @remark This function must be terminated by NULL argument.
1404 * And, if this function is failed, err_attr_name param must be free.
1407 char *g_err_attr_name = NULL;
1409 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
1411 printf("failed to set %s attribute\n", g_err_attr_name);
1412 free(g_err_attr_name);
1416 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1419 * This function is to get detail information of attribute.
1421 * @param player [in] Handle of player.
1422 * @param attribute_name [in] Name of the attribute to get
1423 * @param info [out] Attribute infomation
1425 * @return This function returns zero on success, or negative value with error
1428 * @see mm_player_set_attribute, mm_player_get_attribute
1432 if (mm_player_get_attribute_info (g_player, "display_method", &method_info) != MM_ERROR_NONE)
1434 printf("failed to get info\n");
1437 printf("type:%d \n", method_info.type); //int, double..
1438 printf("flag:%d \n", method_info.flag); //readable, writable..
1439 printf("validity type:%d \n", method_info.validity_type); //range, array..
1441 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE)
1443 printf("range min:%d\n", method_info.int_range.min);
1444 printf("range max:%d\n", method_info.int_range.max);
1448 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info);
1450 * This function is to get download position and total size of progressive download
1452 * @param player [in] Handle of player.
1453 * @param current_pos [in] Download position currently (bytes)
1454 * @param total_size [in] Total size of file (bytes)
1456 * @return This function returns zero on success, or negative value with error code.
1462 guint64 current_pos = 0LLU;
1463 guint64 total_size = 0LLU;
1465 if (mm_player_get_pd_status(g_player, ¤t_pos, &total_size, NULL) != MM_ERROR_NONE)
1467 printf("current download pos = %llu, total size = %llu\n", current_pos, total_size);
1471 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size);
1474 * This function sets callback function for receiving messages of PD downloader.
1476 * @param player [in] Handle of player.
1477 * @param callback [in] Message callback function.
1478 * @param user_param [in] User parameter which is passed to callback function.
1480 * @return This function returns zero on success, or negative value with error code.
1485 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1489 case MM_MESSAGE_PD_DOWNLOADER_START:
1490 printf("Progressive download is started...\n");
1492 case MM_MESSAGE_PD_DOWNLOADER_END:
1493 printf("Progressive download is ended...\n");
1501 mm_player_set_pd_message_callback(g_player, msg_callback, NULL);
1504 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1514 #endif /* __MM_PLAYER_H__ */