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>
37 #include <media_packet.h>
43 /*===========================================================================================
45 | GLOBAL DEFINITIONS AND DECLARATIONS |
47 ========================================================================================== */
52 * uri to play (string)
55 #define MM_PLAYER_CONTENT_URI "profile_uri"
57 * MM_PLAYER_VIDEO_ROTATION
59 * can change video angle (int)
60 * @see MMDisplayRotationType
62 #define MM_PLAYER_VIDEO_ROTATION "display_rotation"
64 * MM_PLAYER_VIDEO_WIDTH:
66 * get the video width (int), It's guaranteed after calling mm_player_start() or
67 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
70 #define MM_PLAYER_VIDEO_WIDTH "content_video_width"
72 * MM_PLAYER_VIDEO_HEIGHT:
74 * get the video height (int), It's guaranteed after calling mm_player_start() or
75 * receiving MM_MESSAGE_BEGIN_OF_STREAM.
78 #define MM_PLAYER_VIDEO_HEIGHT "content_video_height"
80 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
82 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
85 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
89 * set memory pointer to play (data)
92 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
94 * MM_PLAYER_PLAYBACK_COUNT
96 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
99 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
101 * MM_PLAYER_SUBTITLE_URI
103 * set the subtitle path (string)
105 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
107 * MM_PLAYER_STREAMING_USER_AGENT
109 * set the streaming user agent (string)
111 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
113 * MM_PLAYER_STREAMING_COOKIE
115 * set the streaming cookie (int)
117 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
119 * MM_PLAYER_VIDEO_CODEC
121 * codec the video data is stored in (string)
123 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
125 * MM_PLAYER_AUDIO_CODEC
127 * codec the audio data is stored in (string)
129 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
131 * MM_PLAYER_AUDIO_BITRATE
133 * set the streaming proxy port (int)
135 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
137 * MM_PLAYER_AUDIO_CHANNEL
139 * the number of audio channel (int)
141 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
143 * MM_PLAYER_AUDIO_SAMPLERATE
145 * audio samplerate (int)
147 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
149 * MM_PLAYER_TEXT_TRACK_NUM
151 * track number inside a collection (int)
153 #define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num"
155 * MM_PLAYER_TAG_ARTIST
157 * person(s) responsible for the recording (string)
159 #define MM_PLAYER_TAG_ARTIST "tag_artist"
161 * MM_PLAYER_TAG_TITLE
165 #define MM_PLAYER_TAG_TITLE "tag_title"
167 * MM_PLAYER_TAG_ALBUM
169 * album containing this data (string)
171 #define MM_PLAYER_TAG_ALBUM "tag_album"
173 * MM_PLAYER_TAG_GENRE
175 * genre this data belongs to (string)
177 #define MM_PLAYER_TAG_GENRE "tag_genre"
179 * MM_PLAYER_TAG_AUTHOUR
183 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
185 * MM_PLAYER_TAG_COPYRIGHT
187 * copyright notice of the data (string)
189 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
193 * date the data was created (string)
195 #define MM_PLAYER_TAG_DATE "tag_date"
197 * MM_PLAYER_TAG_DESCRIPRION
199 * short text describing the content of the data (string)
201 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
203 * MM_PLAYER_TAG_TRACK_NUM
205 * track number inside a collection (int)
207 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
212 * dynamic resolution change mode (int)
214 #define MM_PLAYER_DRC_MODE "drc_mode"
217 * MM_PLAYER_GAPLESS_MODE
219 * gapless playback mode (int)
221 #define MM_PLAYER_GAPLESS_MODE "gapless_mode"
224 * MM_PLAYER_ENABLE_VIDEO_DECODED_CB
226 * enable video decoded callback (int)
228 #define MM_PLAYER_ENABLE_VIDEO_DECODED_CB "enable_video_decoded_cb"
231 * MM_PLAYER_VIDEO_CODEC_TYPE
233 * video codec type (int)
235 #define MM_PLAYER_VIDEO_CODEC_TYPE "video_codec_type"
238 * MM_PLAYER_AUDIO_CODEC_TYPE
240 * audio codec type (int)
242 #define MM_PLAYER_AUDIO_CODEC_TYPE "audio_codec_type"
245 * MM_PLAYER_PREBUFFER_MS
249 #define MM_PLAYER_PREBUFFER_MS "prebuffer_ms"
252 * MM_PLAYER_REBUFFER_MS
256 #define MM_PLAYER_REBUFFER_MS "rebuffer_ms"
258 * MM_PLAYER_AUDIO_OFFLOAD (int)
260 #define MM_PLAYER_AUDIO_OFFLOAD "audio_offload"
263 * MM_PLAYER_PITCH_CONTROL (int)
265 #define MM_PLAYER_PITCH_CONTROL "pitch_control"
268 * MM_PLAYER_PITCH_VALUE (double)
270 #define MM_PLAYER_PITCH_VALUE "pitch_value"
273 #define BUFFER_MAX_PLANE_NUM (4)
276 MMPixelFormatType format; /**< image format */
277 int width; /**< width of video buffer */
278 int height; /**< height of video buffer */
279 unsigned int timestamp; /**< timestamp of stream buffer (msec)*/
280 unsigned int length_total; /**< total length of stream buffer (in byte)*/
281 void *data[BUFFER_MAX_PLANE_NUM];
282 void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
283 void *internal_buffer; /**< Internal buffer pointer */
284 int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */
285 int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */
286 int orientation; /**< orientation */
287 int bo_size; /**< TBM buffer object size */
288 int plane_num; /**< number of Plane */
289 } mmplayer_video_decoded_data_info_t;
292 * Enumerations of player state.
295 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
296 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
297 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
298 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
299 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
300 MM_PLAYER_STATE_NUM, /**< Number of player states */
304 * Enumeration for attribute values types.
307 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
308 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
309 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
310 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
311 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
312 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
313 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
314 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
315 } mmplayer_attrs_type_e;
318 * Enumeration for attribute validation type.
321 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
322 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
323 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
324 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
325 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
326 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
327 } mmplayer_attrs_valid_type_e;
330 * Enumeration for attribute access flag.
333 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
334 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
335 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
336 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
338 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
339 } mmplayer_attrs_flag_e;
342 * Enumeration of track types
345 MM_PLAYER_TRACK_TYPE_AUDIO = 0,
346 MM_PLAYER_TRACK_TYPE_VIDEO,
347 MM_PLAYER_TRACK_TYPE_TEXT,
348 MM_PLAYER_TRACK_TYPE_MAX
349 } mmplayer_track_type_e;
352 * Enumeration of runtime buffering mode
355 MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */
356 MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */
357 MM_PLAYER_BUFFERING_MODE_MAX,
358 } mmplayer_buffering_mode_e;
361 * Enumeration of media stream buffer status
364 MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN,
365 MM_PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW,
366 } mmplayer_media_stream_buffer_status_e;
369 * Enumeration for stream type.
372 MM_PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */
373 MM_PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */
374 MM_PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */
375 MM_PLAYER_STREAM_TYPE_TEXT, /**< Text type */
376 MM_PLAYER_STREAM_TYPE_MAX,
377 } mmplayer_stream_type_e;
380 MM_PLAYER_CODEC_TYPE_DEFAULT = 0, /**< codec is selected by the priority */
381 MM_PLAYER_CODEC_TYPE_HW, /**< HW codec can only be selected */
382 MM_PLAYER_CODEC_TYPE_SW, /**< SW codec can only be selected */
383 } mmplayer_video_codec_type_e;
386 MM_PLAYER_AUDIO_EXTRACT_DEFAULT = 0x00, /**< Sync with the playback clock and multichannel audio stream */
387 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK = 0x01, /**< No sync with the playback clock */
388 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE = 0x02, /**< Splits one interleaved multichannel audio stream into many mono audio streams */
389 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_AND_DEINTERLEAVE = MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK | MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE,
390 MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK = 0x04, /**< With audio playback synchronously (experimental) */
391 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE_WITH_PLAYBACK = MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE | MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK,
392 } mmplayer_audio_extract_opt_e;
395 * Attribute validity structure
398 mmplayer_attrs_type_e type;
399 mmplayer_attrs_valid_type_e validity_type;
400 mmplayer_attrs_flag_e flag;
402 * a union that describes validity of the attribute.
403 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
404 * the attribute can have validity.
408 * Validity structure for integer array.
411 int *array; /**< a pointer of array */
412 int count; /**< size of array */
416 * Validity structure for integer range.
419 int min; /**< minimum range */
420 int max; /**< maximum range */
424 * Validity structure for double array.
427 double *array; /**< a pointer of array */
428 int count; /**< size of array */
432 * Validity structure for double range.
435 double min; /**< minimum range */
436 double max; /**< maximum range */
440 } mmplayer_attrs_info_t;
443 * Video stream info in external demux case
448 unsigned int framerate_num;
449 unsigned int framerate_den;
452 unsigned char *codec_extradata;
453 unsigned int extradata_size;
454 unsigned int version;
455 } mmplayer_video_stream_info_t;
458 * Audio stream info in external demux case
463 unsigned int channels;
464 unsigned int sample_rate;
465 unsigned char *codec_extradata;
466 unsigned int extradata_size;
467 unsigned int version;
468 unsigned int user_info;
471 // unsigned int width;
472 // unsigned int depth;
473 // unsigned int endianness;
475 } mmplayer_audio_stream_info_t;
478 * Subtitle stream info in external demux case
481 typedef struct _SubtitleStreamInfo {
483 unsigned int codec_tag;
484 void *context; //for smpte text
485 } mmplayer_subtitle_stream_info_t;
488 * selected subtitle track number callback function type.
490 * @param track_num [in] Track number of subtitle
491 * @param user_param [in] User defined parameter
494 * @return This callback function have to return MM_ERROR_NONE.
496 typedef bool (*mm_player_track_selected_subtitle_language_callback)(int track_num, void *user_param);
499 * Buffer underrun / overflow data callback function type.
501 * @param status [in] buffer status
502 * @param user_param [in] User defined parameter which is passed when set
503 * to enough data callback or need data callback
505 * @return This callback function have to return MM_ERROR_NONE.
507 typedef bool (*mm_player_media_stream_buffer_status_callback)(mmplayer_stream_type_e type, mmplayer_media_stream_buffer_status_e status, unsigned long long bytes, void *user_param);
510 * Buffer seek data callback function type.
512 * @param offset [in] offset for the buffer playback
513 * @param user_param [in] User defined parameter which is passed when set
514 * to seek data callback
516 * @return This callback function have to return MM_ERROR_NONE.
518 typedef bool (*mm_player_media_stream_seek_data_callback)(mmplayer_stream_type_e type, unsigned long long offset, void *user_param);
521 * Called to notify the stream changed.
523 * @param user_data [in] The user data passed from the callback registration function
525 * @return This callback function have to return MM_ERROR_NONE.
527 typedef bool (*mm_player_stream_changed_callback)(void *user_param);
530 /*===========================================================================================
532 | GLOBAL FUNCTION PROTOTYPES |
534 ========================================================================================== */
537 * This function creates a player object for playing multimedia contents. \n
538 * The attributes of player are created to get/set some values with application. \n
539 * And, mutex, gstreamer and other resources are initialized at this time. \n
540 * If player is created, the state will become MM_PLAYER_STATE_NULL.
542 * @param player [out] Handle of player
544 * @return This function returns zero on success, or negative value with error code. \n
545 * Please refer 'mm_error.h' to know it in detail.
547 * @post MM_PLAYER_STATE_NULL
548 * @see mm_player_destroy
549 * @remark You can create multiple handles on a context at the same time. \n
550 * However, player cannot guarantee proper operation because of limitation of resources, \n
551 * such as audio device or display device.
555 char *g_err_attr_name = NULL;
557 if (mm_player_create(&g_player) != MM_ERROR_NONE) {
558 LOGE("failed to create player\n");
561 if (mm_player_set_attribute(g_player,
563 "profile_uri", filename, strlen(filename),
564 "display_overlay", (void *)&g_win.xid, sizeof(g_win.xid),
565 NULL) != MM_ERROR_NONE) {
566 LOGE("failed to set %s attribute\n", g_err_attr_name);
567 free(g_err_attr_name);
570 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
573 int mm_player_create(MMHandleType *player);
576 * This function releases player object and all resources which were created by mm_player_create(). \n
577 * And, player handle will also be destroyed.
579 * @param player [in] Handle of player
581 * @return This function returns zero on success, or negative value with error code.
582 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
583 * But, it can be called in any state.
584 * @post Because handle is released, there is no any state.
585 * @see mm_player_create
586 * @remark This method can be called with a valid player handle from any state to \n
587 * completely shutdown the player operation.
591 if (mm_player_destroy(g_player) != MM_ERROR_NONE) {
592 LOGE("failed to destroy player\n");
596 int mm_player_destroy(MMHandleType player);
599 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
600 * So, uri should be set before realizing with mm_player_set_attribute(). \n
602 * @param player [in] Handle of player
604 * @return This function returns zero on success, or negative value with error code.
606 * @pre Player state should be MM_PLAYER_STATE_NULL.
607 * @post player state will be MM_PLAYER_STATE_READY.
608 * @see mm_player_unrealize
612 if (mm_player_realize(g_player) != MM_ERROR_NONE) {
613 LOGE("failed to realize player\n");
617 int mm_player_realize(MMHandleType player);
620 * This function uninitializes player object. So, resources and allocated memory \n
621 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
622 * other contents, player should be created again after destruction or realized with new uri.
624 * @param player [in] Handle of player
626 * @return This function returns zero on success, or negative value with error code.
627 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
628 * But, it can be called in any state.
629 * @post Player state will be MM_PLAYER_STATE_NULL.
630 * @see mm_player_realize
631 * @remark This method can be called with a valid player handle from any state.
635 if (mm_player_unrealize(g_player) != MM_ERROR_NONE) {
636 LOGE("failed to unrealize player\n");
640 int mm_player_unrealize(MMHandleType player);
643 * This function is to abort pause state transition
644 * for unrealize or destroy.
646 int mm_player_abort_pause(MMHandleType player);
649 * This function is to get current state of player. \n
650 * Application have to check current state before doing some action.
652 * @param player [in] Handle of player
653 * @param state [out] current state of player on success
655 * @return This function returns zero on success, or negative value with error code.
657 * @see mmplayer_state_e
661 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE) {
662 LOGE("failed to get state\n");
666 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state);
669 * This function is to control logical volume.
671 int mm_player_set_volume(MMHandleType player, float volume);
674 * This function is to get current volume factor of player.
676 int mm_player_get_volume(MMHandleType player, float *volume);
679 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
680 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
681 * by mm_player_set_message_callback().
683 * @param player [in] Handle of player
685 * @return This function returns zero on success, or negative value with error code.
688 * @pre Player state may be MM_PLAYER_STATE_READY.
689 * @post Player state will be MM_PLAYER_STATE_PLAYING.
690 * @see mm_player_stop
694 if (mm_player_start(g_player) != MM_ERROR_NONE)
696 LOGE("failed to start player\n");
700 int mm_player_start(MMHandleType player);
703 * This function is to stop playing media contents and it's different with pause. \n
704 * If mm_player_start() is called after this, content will be started again from the beginning. \n
705 * So, it can be used to close current playback.
707 * @param player [in] Handle of player
709 * @return This function returns zero on success, or negative value with error code.
711 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
712 * @post Player state will be MM_PLAYER_STATE_READY.
713 * @see mm_player_start
717 if (mm_player_stop(g_player) != MM_ERROR_NONE)
719 LOGE("failed to stop player\n");
723 int mm_player_stop(MMHandleType player);
726 * This function is to pause playing media contents.
728 * @param player [in] Handle of player.
730 * @return This function returns zero on success, or negative value with error code.
732 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
733 * @post Player state will be MM_PLAYER_STATE_PAUSED.
734 * @see mm_player_resume
738 if (mm_player_pause(g_player) != MM_ERROR_NONE)
740 LOGE("failed to pause player\n");
744 int mm_player_pause(MMHandleType player);
747 * This function is to resume paused media contents.
749 * @param player [in] Handle of player.
751 * @return This function returns zero on success, or negative value with error code.
753 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
754 * @post Player state will be MM_PLAYER_STATE_PLAYING.
755 * @see mm_player_pause
759 if (mm_player_resume(g_player) != MM_ERROR_NONE)
761 LOGE("failed to resume player\n");
765 int mm_player_resume(MMHandleType player);
768 * This function is to set the position for playback. \n
769 * So, it can be seeked to requested position. \n
771 * @param player [in] Handle of player
772 * @param pos [in] Position for playback
774 * @return This function returns zero on success, or negative value with error code.
775 * @see mm_player_get_position
776 * @remark the unit of time-based format is millisecond and other case is percent.
778 int mm_player_set_position(MMHandleType player, int64_t pos);
781 * This function is to get current position of playback content.
783 * @param player [in] Handle of player.
784 * @param format [in] Format of position.
785 * @param pos [out] contains current position on success or zero in case of failure.
787 * @return This function returns zero on success, or negative value with errors
788 * @see mm_player_set_position
789 * @remark the unit of time-based format is millisecond and other case is percent.
791 int mm_player_get_position(MMHandleType player, int64_t *pos);
794 * This function is to get the content time duration.
796 int mm_player_get_duration(MMHandleType player, int64_t *dur);
799 * This function is to get current buffer position of playback content.
801 * @param player [in] Handle of player.
802 * @param format [in] Format of position.
803 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
804 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
806 * @return This function returns zero on success, or negative value with errors
807 * @see mm_player_set_position
808 * @remark the unit of time-based format is millisecond and other case is percent.
811 int start_pos = 0, stop_pos = 0;
813 mm_player_get_buffer_position(g_player, &start_pos, &end_pos );
815 LOGD("buffer position: [%d] ~ [%d] \%\n", start_pos, end_pos );
818 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos);
821 * This function sets callback function for receiving messages from player.
822 * So, player can notify warning, error and normal cases to application.
824 * @param player [in] Handle of player.
825 * @param callback [in] Message callback function.
826 * @param user_param [in] User parameter which is passed to callback function.
828 * @return This function returns zero on success, or negative value with error code.
829 * @see MMMessageCallback
833 int msg_callback(int message, MMMessageParamType *param, void *user_param)
837 case MM_MESSAGE_ERROR:
841 case MM_MESSAGE_END_OF_STREAM:
845 case MM_MESSAGE_STATE_CHANGED:
849 case MM_MESSAGE_BEGIN_OF_STREAM:
859 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
862 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
865 * This function is to mute volume of player
867 * @param player [in] Handle of player
868 * @param mute [in] mute value
870 * @return This function returns zero on success, or negative value with error code
871 * @see mm_player_get_mute
874 int mm_player_set_mute(MMHandleType player, bool mute);
877 * This function is to get mute value of player
879 * @param player [in] Handle of player
880 * @param mute [out] Sound is muted
882 * @return This function returns zero on success, or negative value with error code
883 * @see mm_player_set_mute
886 int mm_player_get_mute(MMHandleType player, bool *mute);
889 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
890 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
892 * @param player [in] Handle of player
893 * @param pos [in] postion to be adjusted
895 * @return This function returns zero on success, or negative value with error
897 * @see mm_player_adjust_subtitle_position
904 if (mm_player_adjust_subtitle_position(g_player, pos) != MM_ERROR_NONE)
906 LOGW("failed to adjust subtitle postion.\n");
911 int mm_player_adjust_subtitle_position(MMHandleType player, int pos);
914 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
915 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
916 * Player FW parses subtitle file and send text data including timestamp to application \n
917 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
918 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
919 * So, it's not supported for embedded case.
921 * @param player [in] Handle of player
922 * @param silent [in] silent(integer value except 0) or not silent(0)
924 * @return This function returns zero on success, or negative value with error
926 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
930 mm_player_set_attribute(g_player,
932 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
936 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
938 LOGW("failed to set subtitle silent\n");
942 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
945 * This function is to get silent status of subtitle.
947 * @param player [in] Handle of player
948 * @param silent [out] subtitle silent property
950 * @return This function returns zero on success, or negative value with error
952 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
958 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
960 LOGW("failed to set subtitle silent\n");
964 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
967 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
968 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
970 * @param player [in] Handle of player.
971 * @param err_attr_name [out] Name of attribute which is failed to set
972 * @param first_attribute_name [in] Name of the first attribute to set
973 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
974 * But, in the case of data or string type, it should be name/value/size.
976 * @return This function returns zero on success, or negative value with error code.
978 * @see mm_player_get_attribute
979 * @remark This function must be terminated by NULL argument.
980 * And, if this function is failed, err_attr_name param must be free.
983 char *g_err_attr_name = NULL;
985 if (mm_player_set_attribute(g_player,
987 "profile_uri", filename, strlen(filename),
988 "profile_play_count", count,
989 NULL) != MM_ERROR_NONE) {
990 LOGW("failed to set %s attribute\n", g_err_attr_name);
991 free(g_err_attr_name);
996 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
999 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1001 * @param player [in] Handle of player.
1002 * @param err_attr_name [out] Name of attribute which is failed to get
1003 * @param first_attribute_name [in] Name of the first attribute to get
1004 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1005 * But, in the case of data or string type, it should be name/value/size.
1007 * @return This function returns zero on success, or negative value with error
1009 * @see mm_player_set_attribute
1010 * @remark This function must be terminated by NULL argument.
1011 * And, if this function is failed, err_attr_name param must be free.
1013 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1016 * This function is to get detail information of attribute.
1018 * @param player [in] Handle of player.
1019 * @param attribute_name [in] Name of the attribute to get
1020 * @param info [out] Attribute infomation
1022 * @return This function returns zero on success, or negative value with error
1025 * @see mm_player_set_attribute, mm_player_get_attribute
1029 if (mm_player_get_attribute_info(g_player, "display_method", &method_info) != MM_ERROR_NONE) {
1030 LOGW("failed to get info\n");
1033 LOGD("type:%d \n", method_info.type); //int, double..
1034 LOGD("flag:%d \n", method_info.flag); //readable, writable..
1035 LOGD("validity type:%d \n", method_info.validity_type); //range, array..
1037 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE) {
1038 LOGD("range min:%d\n", method_info.int_range.min);
1039 LOGD("range max:%d\n", method_info.int_range.max);
1043 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info);
1046 * This function is to get the track count
1048 * @param player [in] handle of player.
1049 * @param track [in] type of the track type
1050 * @param info [out] the count of the track
1052 * @return This function returns zero on success, or negative value with error
1057 gint audio_count = 0;
1059 if (mm_player_get_track_count(g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE) {
1060 LOGW("failed to get audio track count\n");
1063 LOGD("audio track count : %d \n", audio_count);
1066 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count);
1069 * This function is to select the track
1071 * @param player [in] handle of player.
1072 * @param type [in] type of the track type
1073 * @param index [in] the index of the track
1075 * @return This function returns zero on success, or negative value with error
1078 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index);
1081 * This function is to get the track language
1083 * @param player [in] handle of player.
1084 * @param type [in] type of the track type
1085 * @param index [in] the index of the track
1086 * @param code [out] language code in ISO 639-1(string)
1088 * @return This function returns zero on success, or negative value with error
1091 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code);
1094 * This function is to get the current running track
1096 * @param player [in] handle of player.
1097 * @param type [in] type of the track type
1098 * @param index [out] the index of the track
1100 * @return This function returns zero on success, or negative value with error
1104 int mm_player_get_current_track(MMHandleType hplayer, mmplayer_track_type_e type, int *index);
1107 * This function is to set the subtitle path
1109 * @param player [in] handle of player
1110 * @param path [in] subtitle path
1112 * @return This function returns zero on success, or negative value with error code.
1114 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path);
1117 * This function is to set uri.
1119 * @param player [in] handle of player
1120 * @param uri [in] uri
1121 * @return This function returns zero on success, or negative value with error code.
1123 int mm_player_set_uri(MMHandleType player, const char *uri);
1126 * This function is to set next uri.
1128 * @param player [in] handle of player
1129 * @param uri [in] uri
1130 * @return This function returns zero on success, or negative value with error code.
1132 int mm_player_set_next_uri(MMHandleType player, const char *uri);
1135 * This function is to get next uri.
1137 * @param player [in] handle of player
1138 * @param uri [out] uri
1139 * @return This function returns zero on success, or negative value with error code.
1141 int mm_player_get_next_uri(MMHandleType player, char **uri);
1144 * This function is to decrease reference count of internal buffer.
1146 * @param buffer [in] video callback internal buffer
1149 void mm_player_video_stream_internal_buffer_unref(void *buffer);
1151 /**mm_player_submit_packet
1152 * This function is to submit buffer to appsrc. \n
1153 * @param player [in] Handle of player.
1154 * @param buf [in] buffer to be submit in appsrc in external feeder case.
1155 * @param len [in] length of buffer.
1156 * @param pts [in] timestamp of buffer.
1157 * @param streamtype [in] stream type of buffer.
1158 * @return This function returns zero on success, or negative value with error code.
1160 int mm_player_submit_packet(MMHandleType player, media_packet_h packet);
1162 /**mm_player_set_video_info
1163 * This function is to set caps of src pad of video appsrc in external feeder case. \n
1164 * @param player [in] Handle of player.
1165 * @param media_format_h [in] Video stream info.
1166 * @return This function returns zero on success, or negative value with error code.
1168 int mm_player_set_video_info(MMHandleType player, media_format_h format);
1170 /**mm_player_set_audio_info
1171 * This function is to set caps of src pad of Audio appsrc in external feeder case. \n
1172 * @param player [in] Handle of player.
1173 * @param media_format_h [in] Audio stream info.
1174 * @return This function returns zero on success, or negative value with error code.
1176 int mm_player_set_audio_info(MMHandleType player, media_format_h format);
1178 /**mm_player_set_subtitle_info
1179 * This function is to set caps of src pad of subtitle appsrc in external feeder case. \n
1180 * @param player [in] Handle of player.
1181 * @param subtitle_stream_info [in] Subtitle stream info.
1182 * @return This function returns zero on success, or negative value with error code.
1184 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *info);
1187 * This function set callback function for receiving need or enough data message from player.
1189 * @param player [in] Handle of player.
1190 * @param type [in] stream type
1191 * @param callback [in] data callback function for stream type.
1192 * @param user_param [in] User parameter.
1194 * @return This function returns zero on success, or negative value with error
1197 int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_buffer_status_callback callback, void *user_param);
1200 * This function set callback function for receiving seek data message from player.
1202 * @param player [in] Handle of player.
1203 * @param type [in] stream type
1204 * @param callback [in] Seek data callback function for stream type.
1205 * @param user_param [in] User parameter.
1207 * @return This function returns zero on success, or negative value with error
1210 int mm_player_set_media_stream_seek_data_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_seek_data_callback callback, void *user_param);
1213 * This function is to set max size of buffer(appsrc).
1215 * @param player [in] Handle of player.
1216 * @param type [in] stream type
1217 * @param max_size [in] max bytes of buffer.
1219 * @return This function returns zero on success, or negative value with error
1222 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size);
1225 * This function is to get max size of buffer(appsrc).
1227 * @param player [in] Handle of player.
1228 * @param type [in] stream type
1229 * @param max_size [out] max bytes of buffer.
1231 * @return This function returns zero on success, or negative value with error
1234 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size);
1237 * This function is to set min percent of buffer(appsrc).
1239 * @param player [in] Handle of player.
1240 * @param type [in] stream type
1241 * @param min_percent [in] min percent of buffer.
1243 * @return This function returns zero on success, or negative value with error
1246 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent);
1249 * This function is to get min percent of buffer(appsrc).
1251 * @param player [in] Handle of player.
1252 * @param type [in] stream type
1253 * @param min_percent [out] min percent of buffer.
1255 * @return This function returns zero on success, or negative value with error
1258 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent);
1261 * This function set callback function for changing audio stream from player. \n
1262 * It's only supported when audio stream is included in file. \n
1264 * @param player [in] Handle of player.
1265 * @param callback [in] Audio stream changed callback function.
1266 * @param user_param [in] User parameter.
1268 * @return This function returns zero on success, or negative value with error
1270 * @see mm_player_stream_changed_callback
1273 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param);
1276 * This function set callback function for changing video stream from player. \n
1277 * It's only supported when video stream is included in file. \n
1279 * @param player [in] Handle of player.
1280 * @param callback [in] Video stream changed callback function.
1281 * @param user_param [in] User parameter.
1283 * @return This function returns zero on success, or negative value with error
1285 * @see mm_player_stream_changed_callback
1287 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param);
1290 * This function is to get timeout value according to the content type for muse. \n
1291 * It's only supported when video stream is included in file. \n
1293 * @param player [in] Handle of player.
1294 * @param timeout [out] timeout value (sec).
1296 * @return This function returns zero on success, or negative value with error
1300 int mm_player_get_timeout(MMHandleType player, int *timeout);
1303 * This function is to get the number of video output buffers. \n
1304 * It's only supported when video stream is included in file. \n
1306 * @param player [in] Handle of player.
1307 * @param num [out] num of buffers.
1308 * @param extra_num [out] extra num of buffers.
1310 * @return This function returns zero on success, or negative value with error
1314 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num);
1317 * This function is to set the dynamic resolution information. \n
1318 * It's only supported when video stream is included in file. \n
1320 * @param player [in] Handle of player.
1321 * @param drc [in] dynamic resolution info of media stream data
1323 * @return This function returns zero on success, or negative value with error
1327 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc);
1330 * This function is to release the video stream bo to reuse. \n
1331 * It's only supported when sw codec is used to decode video stream. \n
1333 * @param player [in] Handle of player.
1334 * @param bo [in] bo address to be released
1336 * @return This function returns zero on success, or negative value with error
1340 int mm_player_release_video_stream_bo(MMHandleType player, void *bo);
1343 * This function is to set sound stream info
1345 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index);
1348 * This function is to manage the playback according to the external storage state
1350 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state);
1353 * These functions are to set/get the max variant of HAS
1355 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info);
1356 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height);
1357 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height);
1360 * These functions are to set/get the audio only mode
1362 int mm_player_set_audio_only(MMHandleType player, bool audio_only);
1363 int mm_player_get_audio_only(MMHandleType player, bool *audio_only);
1366 * These functions are to get the streaming bufferint time
1368 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms);
1371 * These functions are to display the 360 video content
1373 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical);
1374 int mm_player_360_set_enabled(MMHandleType player, bool enabled);
1375 int mm_player_360_is_enabled(MMHandleType player, bool *enabled);
1377 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch);
1378 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch);
1380 int mm_player_360_set_zoom(MMHandleType player, float level);
1381 int mm_player_360_get_zoom(MMHandleType player, float *level);
1383 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees);
1384 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees);
1387 * This function is to set codec type
1389 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type);
1392 * These functions are to apply the replaygain
1394 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled);
1395 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled);
1398 * This function is to set/get video content ROI area
1400 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height);
1401 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
1411 #endif /* __MM_PLAYER_H__ */