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>"streaming_timeout"</td>
283 <td>"display_overlay"</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>"content_text_track_num"</td>
361 <td>"tag_artist"</td>
381 <td>"tag_author"</td>
386 <td>"tag_copyright"</td>
396 <td>"tag_description"</td>
401 <td>"tag_track_num"</td>
410 /*===========================================================================================
412 | GLOBAL DEFINITIONS AND DECLARATIONS |
414 ========================================================================================== */
419 * uri to play (string)
422 #define MM_PLAYER_CONTENT_URI "profile_uri"
424 * MM_PLAYER_CONTENT_DURATION:
426 * get the duration (int) as millisecond, It's guaranteed after calling mm_player_start() or
427 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
430 #define MM_PLAYER_CONTENT_DURATION "content_duration"
432 * MM_PLAYER_VIDEO_ROTATION
434 * can change video angle (int)
435 * @see MMDisplayRotationType
437 #define MM_PLAYER_VIDEO_ROTATION "display_rotation"
439 * MM_PLAYER_VIDEO_WIDTH:
441 * get the video width (int), It's guaranteed after calling mm_player_start() or
442 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
445 #define MM_PLAYER_VIDEO_WIDTH "content_video_width"
447 * MM_PLAYER_VIDEO_HEIGHT:
449 * get the video height (int), It's guaranteed after calling mm_player_start() or
450 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
453 #define MM_PLAYER_VIDEO_HEIGHT "content_video_height"
455 * MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING:
457 * set whether or not to scale frames size for evas surface.
458 * if TRUE, it scales down width, height size of frames with given size.
459 * if FALSE, it does not scale down any frames.
462 #define MM_PLAYER_VIDEO_EVAS_SURFACE_DO_SCALING "display_evas_do_scaling"
464 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
466 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
469 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
473 * set memory pointer to play (data)
476 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
478 * MM_PLAYER_PLAYBACK_COUNT
480 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
483 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
485 * MM_PLAYER_SUBTITLE_URI
487 * set the subtitle path (string)
489 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
491 * MM_PLAYER_STREAMING_TYPE
493 * set the streaming type (int)
494 * @see MMStreamingType
496 #define MM_PLAYER_STREAMING_TYPE "streaming_type"
498 * MM_PLAYER_STREAMING_UDP_TIMEOUT
500 * set the streaming udp timeout(int)
502 #define MM_PLAYER_STREAMING_UDP_TIMEOUT "streaming_udp_timeout"
504 * MM_PLAYER_STREAMING_USER_AGENT
506 * set the streaming user agent (string)
508 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
510 * MM_PLAYER_STREAMING_WAP_PROFILE
512 * set the streaming wap profile (int)
514 #define MM_PLAYER_STREAMING_WAP_PROFILE "streaming_wap_profile"
516 * MM_PLAYER_STREAMING_NET_BANDWIDTH
518 * set the streaming network bandwidth (int)
520 #define MM_PLAYER_STREAMING_NET_BANDWIDTH "streaming_network_bandwidth"
522 * MM_PLAYER_STREAMING_COOKIE
524 * set the streaming cookie (int)
526 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
528 * MM_PLAYER_STREAMING_PROXY_IP
530 * set the streaming proxy ip (string)
532 #define MM_PLAYER_STREAMING_PROXY_IP "streaming_proxy_ip"
534 * MM_PLAYER_STREAMING_PROXY_PORT
536 * set the streaming proxy port (int)
538 #define MM_PLAYER_STREAMING_PROXY_PORT "streaming_proxy_port"
540 * MM_PLAYER_STREAMING_TIMEOUT
542 * set the streaming timeout (int)
544 #define MM_PLAYER_STREAMING_TIMEOUT "streaming_timeout"
546 * MM_PLAYER_VIDEO_CODEC
548 * codec the video data is stored in (string)
550 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
552 * MM_PLAYER_VIDEO_TRACK_NUM
554 * track number inside a collection (int)
556 #define MM_PLAYER_VIDEO_TRACK_NUM "content_video_track_num"
558 * MM_PLAYER_AUDIO_CODEC
560 * codec the audio data is stored in (string)
562 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
564 * MM_PLAYER_AUDIO_BITRATE
566 * set the streaming proxy port (int)
568 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
570 * MM_PLAYER_AUDIO_CHANNEL
572 * the number of audio channel (int)
574 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
576 * MM_PLAYER_AUDIO_SAMPLERATE
578 * audio samplerate (int)
580 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
582 * MM_PLAYER_AUDIO_TRACK_NUM
584 * track number inside a collection (int)
586 #define MM_PLAYER_AUDIO_TRACK_NUM "content_audio_track_num"
588 * MM_PLAYER_TEXT_TRACK_NUM
590 * track number inside a collection (int)
592 #define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num"
594 * MM_PLAYER_TAG_ARTIST
596 * person(s) responsible for the recording (string)
598 #define MM_PLAYER_TAG_ARTIST "tag_artist"
600 * MM_PLAYER_TAG_ARTIST
604 #define MM_PLAYER_TAG_TITLE "tag_title"
606 * MM_PLAYER_TAG_ARTIST
608 * album containing this data (string)
610 #define MM_PLAYER_TAG_ALBUM "tag_album"
612 * MM_PLAYER_TAG_ARTIST
614 * genre this data belongs to (string)
616 #define MM_PLAYER_TAG_GENRE "tag_genre"
618 * MM_PLAYER_TAG_ARTIST
622 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
624 * MM_PLAYER_TAG_ARTIST
626 * copyright notice of the data (string)
628 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
630 * MM_PLAYER_TAG_ARTIST
632 * date the data was created (string)
634 #define MM_PLAYER_TAG_DATE "tag_date"
636 * MM_PLAYER_TAG_ARTIST
638 * short text describing the content of the data (string)
640 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
642 * MM_PLAYER_TAG_ARTIST
644 * track number inside a collection (int)
646 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
650 * progressive download mode (int)
652 #define MM_PLAYER_PD_MODE "pd_mode"
654 #define BUFFER_MAX_PLANE_NUM (4)
657 MMPixelFormatType format; /**< image format */
658 int width; /**< width of video buffer */
659 int height; /**< height of video buffer */
660 unsigned int timestamp; /**< timestamp of stream buffer (msec)*/
661 unsigned int length_total; /**< total length of stream buffer (in byte)*/
663 void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
664 void *internal_buffer; /**< Internal buffer pointer */
665 int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */
666 int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */
667 }MMPlayerVideoStreamDataType;
670 * Enumerations of player state.
673 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
674 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
675 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
676 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
677 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
678 MM_PLAYER_STATE_NUM, /**< Number of player states */
682 * Enumerations of position formats.
683 * Used while invoking mm_player_get_position/mm_player_set_position APIs
686 MM_PLAYER_POS_FORMAT_TIME, /**< Format for time based */
687 MM_PLAYER_POS_FORMAT_PERCENT, /**< Format for percentage */
688 MM_PLAYER_POS_FORMAT_NUM, /**< Number of position formats */
689 } MMPlayerPosFormatType;
692 * Enumeration for attribute values types.
695 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
696 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
697 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
698 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
699 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
700 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
701 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
702 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
706 * Enumeration for attribute validation type.
709 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
710 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
711 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
712 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
713 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
714 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
715 } MMPlayerAttrsValidType;
718 * Enumeration for attribute access flag.
721 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
722 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
723 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
724 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
726 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
730 * Enumeration for progressive download
733 MM_PLAYER_PD_MODE_NONE,
734 MM_PLAYER_PD_MODE_URI,
735 MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario
739 * Enumeration of track types
742 MM_PLAYER_TRACK_TYPE_AUDIO = 0,
743 MM_PLAYER_TRACK_TYPE_VIDEO,
744 MM_PLAYER_TRACK_TYPE_TEXT,
745 MM_PLAYER_TRACK_TYPE_MAX
749 * Enumeration of runtime buffering mode
752 MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */
753 MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */
754 MM_PLAYER_BUFFERING_MODE_SLINK, /**< If buffering is occurred, player will adjust buffer setting and no more buffering will be occurred again. */
755 MM_PLAYER_BUFFERING_MODE_MAX = MM_PLAYER_BUFFERING_MODE_SLINK,
756 }MMPlayerBufferingMode;
759 * Enumeration of audio channel for video share
763 MM_PLAYER_AUDIO_CH_MONO_LEFT = 0,
764 MM_PLAYER_AUDIO_CH_MONO_RIGHT,
765 MM_PLAYER_AUDIO_CH_STEREO,
766 } MMPlayerAudioChannel;
769 * Edge Properties of the text.
773 MM_PLAYER_EDGE_RAISED,
774 MM_PLAYER_EDGE_DEPRESSED,
775 MM_PLAYER_EDGE_UNIFORM,
776 MM_PLAYER_EDGE_DROPSHADOW
777 } MMPlayerSubtitleEdge;
781 * Attribute validity structure
784 MMPlayerAttrsType type;
785 MMPlayerAttrsValidType validity_type;
786 MMPlayerAttrsFlag flag;
788 * a union that describes validity of the attribute.
789 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
790 * the attribute can have validity.
794 * Validity structure for integer array.
797 int *array; /**< a pointer of array */
798 int count; /**< size of array */
802 * Validity structure for integer range.
805 int min; /**< minimum range */
806 int max; /**< maximum range */
810 * Validity structure for double array.
813 double * array; /**< a pointer of array */
814 int count; /**< size of array */
818 * Validity structure for double range.
821 double min; /**< minimum range */
822 double max; /**< maximum range */
831 * @see mm_player_set_volume, mm_player_get_volume
834 float level[MM_VOLUME_CHANNEL_NUM]; /**< Relative volume factor for each channels */
835 } MMPlayerVolumeType;
838 * Audio stream callback function type.
840 * @param stream [in] Reference pointer to audio frame data
841 * @param stream_size [in] Size of audio frame data
842 * @param user_param [in] User defined parameter which is passed when set
843 * audio stream callback
845 * @return This callback function have to return MM_ERROR_NONE.
847 typedef bool (*mm_player_audio_stream_callback) (void *stream, int stream_size, void *user_param);
851 * selected subtitle track number callback function type.
853 * @param track_num [in] Track number of subtitle
854 * @param user_param [in] User defined parameter
857 * @return This callback function have to return MM_ERROR_NONE.
859 typedef bool (*mm_player_track_selected_subtitle_language_callback)(int track_num, void *user_param);
862 /*===========================================================================================
864 | GLOBAL FUNCTION PROTOTYPES |
866 ========================================================================================== */
869 * This function creates a player object for playing multimedia contents. \n
870 * The attributes of player are created to get/set some values with application. \n
871 * And, mutex, gstreamer and other resources are initialized at this time. \n
872 * If player is created, the state will become MM_PLAYER_STATE_NULL.
874 * @param player [out] Handle of player
876 * @return This function returns zero on success, or negative value with error code. \n
877 * Please refer 'mm_error.h' to know it in detail.
879 * @post MM_PLAYER_STATE_NULL
880 * @see mm_player_destroy
881 * @remark You can create multiple handles on a context at the same time. \n
882 * However, player cannot guarantee proper operation because of limitation of resources, \n
883 * such as audio device or display device.
887 char *g_err_attr_name = NULL;
889 if (mm_player_create(&g_player) != MM_ERROR_NONE)
891 debug_error("failed to create player\n");
894 if (mm_player_set_attribute(g_player,
896 "profile_uri", filename, strlen(filename),
897 "display_overlay", (void*)&g_win.xid, sizeof(g_win.xid),
898 NULL) != MM_ERROR_NONE)
900 debug_error("failed to set %s attribute\n", g_err_attr_name);
901 free(g_err_attr_name);
904 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
907 int mm_player_create(MMHandleType *player);
910 * This function releases player object and all resources which were created by mm_player_create(). \n
911 * And, player handle will also be destroyed.
913 * @param player [in] Handle of player
915 * @return This function returns zero on success, or negative value with error code.
916 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
917 * But, it can be called in any state.
918 * @post Because handle is released, there is no any state.
919 * @see mm_player_create
920 * @remark This method can be called with a valid player handle from any state to \n
921 * completely shutdown the player operation.
925 if (mm_player_destroy(g_player) != MM_ERROR_NONE)
927 debug_error("failed to destroy player\n");
931 int mm_player_destroy(MMHandleType player);
934 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
935 * So, uri should be set before realizing with mm_player_set_attribute(). \n
937 * @param player [in] Handle of player
939 * @return This function returns zero on success, or negative value with error code.
941 * @pre Player state should be MM_PLAYER_STATE_NULL.
942 * @post Player state will be MM_PLAYER_STATE_READY.
943 * @see mm_player_unrealize
947 if (mm_player_realize(g_player) != MM_ERROR_NONE)
949 debug_error("failed to realize player\n");
953 int mm_player_realize(MMHandleType player) ;
956 * This function uninitializes player object. So, resources and allocated memory \n
957 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
958 * other contents, player should be created again after destruction or realized with new uri.
960 * @param player [in] Handle of player
962 * @return This function returns zero on success, or negative value with error code.
963 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
964 * But, it can be called in any state.
965 * @post Player state will be MM_PLAYER_STATE_NULL.
966 * @see mm_player_realize
967 * @remark This method can be called with a valid player handle from any state.
971 if (mm_player_unrealize(g_player) != MM_ERROR_NONE)
973 debug_error("failed to unrealize player\n");
977 int mm_player_unrealize(MMHandleType player);
980 * This function is to get current state of player. \n
981 * Application have to check current state before doing some action.
983 * @param player [in] Handle of player
984 * @param state [out] current state of player on success
986 * @return This function returns zero on success, or negative value with error code.
988 * @see MMPlayerStateType
992 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE)
994 debug_error("failed to get state\n");
998 int mm_player_get_state(MMHandleType player, MMPlayerStateType *state);
1001 * This function is to set relative volume of player. \n
1002 * So, It controls logical volume value. \n
1003 * But, if developer want to change system volume, mm sound api should be used.
1005 * @param player [in] Handle of player
1006 * @param volume [in] Volume factor of each channel
1008 * @return This function returns zero on success, or negative value with error code.
1009 * @see MMPlayerVolumeType, mm_player_get_volume
1010 * @remark The range of factor range is from 0 to 1.0. (1.0 = 100%) And, default value is 1.0.
1013 MMPlayerVolumeType volume;
1016 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
1017 volume.level[i] = MM_VOLUME_LEVEL_MAX;
1019 if (mm_player_set_volume(g_player, &volume) != MM_ERROR_NONE)
1021 debug_error("failed to set volume\n");
1025 int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume);
1028 * This function is to get current volume factor of player.
1030 * @param player [in] Handle of player.
1031 * @param volume [out] Volume factor of each channel.
1033 * @return This function returns zero on success, or negative value with error code.
1035 * @see MMPlayerVolumeType, mm_player_set_volume
1039 MMPlayerVolumeType volume;
1042 if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE)
1044 debug_warning("failed to get volume\n");
1047 for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
1048 debug_log("channel[%d] = %d \n", i, volume.level[i]);
1051 int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume);
1054 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
1055 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
1056 * by mm_player_set_message_callback().
1058 * @param player [in] Handle of player
1060 * @return This function returns zero on success, or negative value with error code.
1063 * @pre Player state may be MM_PLAYER_STATE_READY.
1064 * @post Player state will be MM_PLAYER_STATE_PLAYING.
1065 * @see mm_player_stop
1069 if (mm_player_start(g_player) != MM_ERROR_NONE)
1071 debug_error("failed to start player\n");
1075 int mm_player_start(MMHandleType player);
1078 * This function is to stop playing media contents and it's different with pause. \n
1079 * If mm_player_start() is called after this, content will be started again from the beginning. \n
1080 * So, it can be used to close current playback.
1082 * @param player [in] Handle of player
1084 * @return This function returns zero on success, or negative value with error code.
1086 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1087 * @post Player state will be MM_PLAYER_STATE_READY.
1088 * @see mm_player_start
1092 if (mm_player_stop(g_player) != MM_ERROR_NONE)
1094 debug_error("failed to stop player\n");
1098 int mm_player_stop(MMHandleType player);
1101 * This function is to pause playing media contents.
1103 * @param player [in] Handle of player.
1105 * @return This function returns zero on success, or negative value with error code.
1107 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
1108 * @post Player state will be MM_PLAYER_STATE_PAUSED.
1109 * @see mm_player_resume
1113 if (mm_player_pause(g_player) != MM_ERROR_NONE)
1115 debug_error("failed to pause player\n");
1119 int mm_player_pause(MMHandleType player);
1122 * This function is to resume paused media contents.
1124 * @param player [in] Handle of player.
1126 * @return This function returns zero on success, or negative value with error code.
1128 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
1129 * @post Player state will be MM_PLAYER_STATE_PLAYING.
1130 * @see mm_player_pause
1134 if (mm_player_resume(g_player) != MM_ERROR_NONE)
1136 debug_error("failed to resume player\n");
1140 int mm_player_resume(MMHandleType player);
1143 * This function is to set the position for playback. \n
1144 * So, it can be seeked to requested position. \n
1146 * @param player [in] Handle of player
1147 * @param format [in] Format of position.
1148 * @param pos [in] Position for playback
1150 * @return This function returns zero on success, or negative value with error code.
1151 * @see MMPlayerPosFormatType, mm_player_get_position
1152 * @remark the unit of time-based format is millisecond and other case is percent.
1155 int position = 1000; //1sec
1157 if (mm_player_set_position(g_player, MM_PLAYER_POS_FORMAT_TIME, position) != MM_ERROR_NONE)
1159 debug_error("failed to set position\n");
1163 int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1166 * This function is to get current position of playback content.
1168 * @param player [in] Handle of player.
1169 * @param format [in] Format of position.
1170 * @param pos [out] contains current position on success or zero in case of failure.
1172 * @return This function returns zero on success, or negative value with errors
1173 * @see MMPlayerPosFormatType, mm_player_set_position
1174 * @remark the unit of time-based format is millisecond and other case is percent.
1180 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1182 mm_player_get_attribute(g_player, &g_err_name, "content_duration", &duration, NULL);
1184 debug_log("pos: [%d/%d] msec\n", position, duration);
1187 int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, int *pos);
1190 * This function is to get current buffer position of playback content.
1192 * @param player [in] Handle of player.
1193 * @param format [in] Format of position.
1194 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
1195 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
1197 * @return This function returns zero on success, or negative value with errors
1198 * @see MMPlayerPosFormatType, mm_player_set_position
1199 * @remark the unit of time-based format is millisecond and other case is percent.
1202 int start_pos = 0, stop_pos = 0;
1204 mm_player_get_buffer_position(g_player, MM_PLAYER_POS_FORMAT_PERCENT, &start_pos, &stop_pos );
1206 debug_log("buffer position: [%d] ~ [%d] \%\n", start_pos, stop_pos );
1209 int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType format, int *start_pos, int *stop_pos);
1212 * This function is to activate the section repeat. If it's set, selected section will be played \n
1213 * continually before deactivating it by mm_player_deactivate_section_repeat(). \n
1214 * The unit for setting is millisecond.
1216 * @param player [in] Handle of player.
1217 * @param start_pos [in] start position.
1218 * @param end_pos [in] end position.
1220 * @return This function returns zero on success, or negative value with error code.
1221 * @see mm_player_deactivate_section_repeat
1226 int endtime = 4000; //msec
1228 mm_player_get_position(g_player, MM_PLAYER_POS_FORMAT_TIME, &position);
1230 mm_player_activate_section_repeat(g_player, position, position+endtime);
1233 int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int end_pos);
1236 * This function is to deactivate the section repeat.
1238 * @param player [in] Handle of player.
1240 * @return This function returns zero on success, or negative value with error code.
1241 * @see mm_player_activate_section_repeat
1245 if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE)
1247 debug_warning("failed to deactivate section repeat\n");
1251 int mm_player_deactivate_section_repeat(MMHandleType player);
1254 * This function sets callback function for receiving messages from player.
1255 * So, player can notify warning, error and normal cases to application.
1257 * @param player [in] Handle of player.
1258 * @param callback [in] Message callback function.
1259 * @param user_param [in] User parameter which is passed to callback function.
1261 * @return This function returns zero on success, or negative value with error code.
1262 * @see MMMessageCallback
1266 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1270 case MM_MESSAGE_ERROR:
1274 case MM_MESSAGE_END_OF_STREAM:
1278 case MM_MESSAGE_STATE_CHANGED:
1282 case MM_MESSAGE_BEGIN_OF_STREAM:
1292 mm_player_set_message_callback(g_player, msg_callback, (void*)g_player);
1295 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1298 * This function set callback function for receiving audio stream from player. \n
1299 * So, application can get raw audio data and modify it. \n
1300 * But, if callback don't return or holds it for long time, performance can be deteriorated. \n
1301 * It's only supported when audio stream is included in file. \n
1302 * So, if there is video stream or DRM content, it can't be used.
1304 * @param player [in] Handle of player.
1305 * @param callback [in] Audio stream callback function.
1306 * @param user_param [in] User parameter.
1308 * @return This function returns zero on success, or negative value with error
1310 * @see mm_player_audio_stream_callback
1311 * @remark It can be used for audio playback only.
1314 bool audio_callback(void *stream, int stream_size, void *user_param)
1316 debug_log("audio stream callback\n");
1319 mm_player_set_audio_stream_callback(g_player, audio_callback, NULL);
1322 int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param);
1325 * This function is to mute volume of player
1327 * @param player [in] Handle of player
1328 * @param mute [in] Mute(1) or not mute(0)
1330 * @return This function returns zero on success, or negative value with error code
1331 * @see mm_player_get_mute
1335 if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE)
1337 debug_warning("failed to set mute\n");
1341 int mm_player_set_mute(MMHandleType player, int mute);
1344 * This function is to get mute value of player
1346 * @param player [in] Handle of player
1347 * @param mute [out] Sound is muted
1349 * @return This function returns zero on success, or negative value with error code
1350 * @see mm_player_set_mute
1356 if (mm_player_get_mute(g_player, &mute) != MM_ERROR_NONE)
1358 debug_warning("failed to get mute\n");
1361 debug_log("mute status:%d\n", mute);
1364 int mm_player_get_mute(MMHandleType player, int *mute);
1367 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
1368 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
1370 * @param player [in] Handle of player
1371 * @param pos [in] postion to be adjusted
1373 * @return This function returns zero on success, or negative value with error
1375 * @see mm_player_adjust_subtitle_position
1382 if (mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, pos) != MM_ERROR_NONE)
1384 debug_warning("failed to adjust subtitle postion.\n");
1389 int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos);
1392 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1393 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1395 * @param player [in] Handle of player.
1396 * @param err_attr_name [out] Name of attribute which is failed to set
1397 * @param first_attribute_name [in] Name of the first attribute to set
1398 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1399 * But, in the case of data or string type, it should be name/value/size.
1401 * @return This function returns zero on success, or negative value with error code.
1403 * @see mm_player_get_attribute
1404 * @remark This function must be terminated by NULL argument.
1405 * And, if this function is failed, err_attr_name param must be free.
1408 char *g_err_attr_name = NULL;
1410 if (mm_player_set_attribute(g_player,
1412 "profile_uri", filename, strlen(filename),
1413 "profile_play_count", count,
1414 NULL) != MM_ERROR_NONE)
1416 debug_warning("failed to set %s attribute\n", g_err_attr_name);
1417 free(g_err_attr_name);
1422 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1425 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1427 * @param player [in] Handle of player.
1428 * @param err_attr_name [out] Name of attribute which is failed to get
1429 * @param first_attribute_name [in] Name of the first attribute to get
1430 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1431 * But, in the case of data or string type, it should be name/value/size.
1433 * @return This function returns zero on success, or negative value with error
1435 * @see mm_player_set_attribute
1436 * @remark This function must be terminated by NULL argument.
1437 * And, if this function is failed, err_attr_name param must be free.
1440 char *g_err_attr_name = NULL;
1442 if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE)
1444 debug_warning("failed to set %s attribute\n", g_err_attr_name);
1445 free(g_err_attr_name);
1449 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1452 * This function is to get detail information of attribute.
1454 * @param player [in] Handle of player.
1455 * @param attribute_name [in] Name of the attribute to get
1456 * @param info [out] Attribute infomation
1458 * @return This function returns zero on success, or negative value with error
1461 * @see mm_player_set_attribute, mm_player_get_attribute
1465 if (mm_player_get_attribute_info (g_player, "display_method", &method_info) != MM_ERROR_NONE)
1467 debug_warning("failed to get info\n");
1470 debug_log("type:%d \n", method_info.type); //int, double..
1471 debug_log("flag:%d \n", method_info.flag); //readable, writable..
1472 debug_log("validity type:%d \n", method_info.validity_type); //range, array..
1474 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE)
1476 debug_log("range min:%d\n", method_info.int_range.min);
1477 debug_log("range max:%d\n", method_info.int_range.max);
1481 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, MMPlayerAttrsInfo *info);
1484 * This function is to get download position and total size of progressive download
1486 * @param player [in] Handle of player.
1487 * @param current_pos [in] Download position currently (bytes)
1488 * @param total_size [in] Total size of file (bytes)
1490 * @return This function returns zero on success, or negative value with error code.
1496 guint64 current_pos = 0LLU;
1497 guint64 total_size = 0LLU;
1499 if (mm_player_get_pd_status(g_player, ¤t_pos, &total_size, NULL) != MM_ERROR_NONE)
1501 debug_log("current download pos = %llu, total size = %llu\n", current_pos, total_size);
1505 int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 *total_size);
1508 * This function sets callback function for receiving messages of PD downloader.
1510 * @param player [in] Handle of player.
1511 * @param callback [in] Message callback function.
1512 * @param user_param [in] User parameter which is passed to callback function.
1514 * @return This function returns zero on success, or negative value with error code.
1519 int msg_callback(int message, MMMessageParamType *param, void *user_param)
1523 case MM_MESSAGE_PD_DOWNLOADER_START:
1524 debug_log("Progressive download is started...\n");
1526 case MM_MESSAGE_PD_DOWNLOADER_END:
1527 debug_log("Progressive download is ended...\n");
1535 mm_player_set_pd_message_callback(g_player, msg_callback, NULL);
1538 int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
1541 * This function is to set the start position of zoom
1543 * @param player [in] handle of player
1544 * @param level [in] level of zoom
1545 * @param x [in] start x position
1546 * @param y [in] start y position
1548 * @return This function returns zero on success, or negative value with error
1554 int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y);
1557 * This function is to get the start position of zoom
1559 * @param player [in] handle of player
1560 * @param type [out] current level of zoom
1561 * @param x [out] start x position
1562 * @param y [out] start y position
1564 * @return This function returns zero on success, or negative value with error
1570 int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y);
1573 * This function is to set the subtitle path
1575 * @param player [in] handle of player
1576 * @param path [in] subtitle path
1578 * @return This function returns zero on success, or negative value with error code.
1583 int mm_player_set_external_subtitle_path(MMHandleType player, const char* path);
1586 * This function is to set audio channel
1588 * @param player [in] handle of player
1589 * @param ch [in] audio channel
1590 * @return This function returns zero on success, or negative value with error code.
1595 int mm_player_gst_set_audio_channel(MMHandleType player, MMPlayerAudioChannel ch);
1598 * This function is to set uri.
1600 * @param player [in] handle of player
1601 * @param uri [in] uri
1602 * @return This function returns zero on success, or negative value with error code.
1607 int mm_player_set_uri(MMHandleType player, const char *uri);
1610 * This function is to set next uri.
1612 * @param player [in] handle of player
1613 * @param uri [in] uri
1614 * @return This function returns zero on success, or negative value with error code.
1619 int mm_player_set_next_uri(MMHandleType player, const char *uri);
1622 * This function is to get next uri.
1624 * @param player [in] handle of player
1625 * @param uri [out] uri
1626 * @return This function returns zero on success, or negative value with error code.
1631 int mm_player_get_next_uri(MMHandleType player, char **uri);
1633 int mm_player_enable_media_packet_video_stream(MMHandleType player, bool enable);
1644 #endif /* __MM_PLAYER_H__ */