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 * Enumerations of player state.
279 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
280 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
281 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
282 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
283 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
284 MM_PLAYER_STATE_NUM, /**< Number of player states */
288 * Enumeration for attribute values types.
291 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
292 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
293 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
294 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
295 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
296 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
297 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
298 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
299 } mmplayer_attrs_type_e;
302 * Enumeration for attribute validation type.
305 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
306 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
307 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
308 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
309 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
310 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
311 } mmplayer_attrs_valid_type_e;
314 * Enumeration for attribute access flag.
317 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
318 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
319 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
320 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
322 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
323 } mmplayer_attrs_flag_e;
326 * Enumeration of track types
329 MM_PLAYER_TRACK_TYPE_AUDIO = 0,
330 MM_PLAYER_TRACK_TYPE_VIDEO,
331 MM_PLAYER_TRACK_TYPE_TEXT,
332 MM_PLAYER_TRACK_TYPE_MAX
333 } mmplayer_track_type_e;
336 * Enumeration of runtime buffering mode
339 MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */
340 MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */
341 MM_PLAYER_BUFFERING_MODE_MAX,
342 } mmplayer_buffering_mode_e;
345 * Enumeration of media stream buffer status
348 MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN,
349 MM_PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW,
350 } mmplayer_media_stream_buffer_status_e;
353 * Enumeration for stream type.
356 MM_PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */
357 MM_PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */
358 MM_PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */
359 MM_PLAYER_STREAM_TYPE_TEXT, /**< Text type */
360 MM_PLAYER_STREAM_TYPE_MAX,
361 } mmplayer_stream_type_e;
364 MM_PLAYER_CODEC_TYPE_DEFAULT = 0, /**< codec is selected by the priority */
365 MM_PLAYER_CODEC_TYPE_HW, /**< HW codec can only be selected */
366 MM_PLAYER_CODEC_TYPE_SW, /**< SW codec can only be selected */
367 } mmplayer_video_codec_type_e;
370 MM_PLAYER_AUDIO_EXTRACT_DEFAULT = 0x00, /**< Sync with the playback clock and multichannel audio stream */
371 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK = 0x01, /**< No sync with the playback clock */
372 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE = 0x02, /**< Splits one interleaved multichannel audio stream into many mono audio streams */
373 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_AND_DEINTERLEAVE = MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK | MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE,
374 MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK = 0x04, /**< With audio playback synchronously (experimental) */
375 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE_WITH_PLAYBACK = MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE | MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK,
376 } mmplayer_audio_extract_opt_e;
379 * Enumerations of video colorspace
382 MM_PLAYER_COLORSPACE_I420 = 0, /**< I420 format - planer */
383 MM_PLAYER_COLORSPACE_RGB888, /**< RGB888 pixel format */
384 MM_PLAYER_COLORSPACE_NV12_TILED, /**< Customized color format */
385 MM_PLAYER_COLORSPACE_NV12,
386 MM_PLAYER_COLORSPACE_BGRx, /**< BGRx pixel format */
387 MM_PLAYER_COLORSPACE_MAX = 0x7FFFFFFF
388 } mmplayer_video_color_space_e;
391 * Attribute validity structure
394 mmplayer_attrs_type_e type;
395 mmplayer_attrs_valid_type_e validity_type;
396 mmplayer_attrs_flag_e flag;
398 * a union that describes validity of the attribute.
399 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
400 * the attribute can have validity.
404 * Validity structure for integer array.
407 int *array; /**< a pointer of array */
408 int count; /**< size of array */
412 * Validity structure for integer range.
415 int min; /**< minimum range */
416 int max; /**< maximum range */
420 * Validity structure for double array.
423 double *array; /**< a pointer of array */
424 int count; /**< size of array */
428 * Validity structure for double range.
431 double min; /**< minimum range */
432 double max; /**< maximum range */
436 } mmplayer_attrs_info_t;
439 MMPixelFormatType format; /**< image format */
440 int width; /**< width of video buffer */
441 int height; /**< height of video buffer */
442 unsigned int timestamp; /**< timestamp of stream buffer (msec)*/
443 unsigned int length_total; /**< total length of stream buffer (in byte)*/
444 void *data[BUFFER_MAX_PLANE_NUM];
445 void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
446 void *internal_buffer; /**< Internal buffer pointer */
447 int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */
448 int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */
449 int orientation; /**< orientation */
450 int bo_size; /**< TBM buffer object size */
451 int plane_num; /**< number of Plane */
452 } mmplayer_video_decoded_data_info_t;
460 bool is_little_endian;
461 guint64 channel_mask;
462 media_format_mimetype_e pcm_format;
463 } mmplayer_audio_decoded_data_info_t;
466 unsigned char *data; /* capture image buffer */
467 int size; /* capture image size */
468 mmplayer_video_color_space_e fmt; /* color space type */
469 unsigned int width; /* width of captured image */
470 unsigned int height; /* height of captured image */
471 unsigned int orientation; /* content orientation */
472 } mmplayer_video_capture_t;
475 * Video stream info in external demux case
480 unsigned int framerate_num;
481 unsigned int framerate_den;
484 unsigned char *codec_extradata;
485 unsigned int extradata_size;
486 unsigned int version;
487 } mmplayer_video_stream_info_t;
490 * Audio stream info in external demux case
495 unsigned int channels;
496 unsigned int sample_rate;
497 unsigned char *codec_extradata;
498 unsigned int extradata_size;
499 unsigned int version;
500 unsigned int user_info;
503 // unsigned int width;
504 // unsigned int depth;
505 // unsigned int endianness;
507 } mmplayer_audio_stream_info_t;
510 * Subtitle stream info in external demux case
513 typedef struct _SubtitleStreamInfo {
515 unsigned int codec_tag;
516 void *context; //for smpte text
517 } mmplayer_subtitle_stream_info_t;
520 * selected subtitle track number callback function type.
522 * @param track_num [in] Track number of subtitle
523 * @param user_param [in] User defined parameter
526 * @return This callback function have to return MM_ERROR_NONE.
528 typedef bool (*mm_player_track_selected_subtitle_language_callback)(int track_num, void *user_param);
531 * Buffer underrun / overflow data callback function type.
533 * @param status [in] buffer status
534 * @param user_param [in] User defined parameter which is passed when set
535 * to enough data callback or need data callback
537 * @return This callback function have to return MM_ERROR_NONE.
539 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);
542 * Buffer seek data callback function type.
544 * @param offset [in] offset for the buffer playback
545 * @param user_param [in] User defined parameter which is passed when set
546 * to seek data callback
548 * @return This callback function have to return MM_ERROR_NONE.
550 typedef bool (*mm_player_media_stream_seek_data_callback)(mmplayer_stream_type_e type, unsigned long long offset, void *user_param);
553 * Called to notify the stream changed.
555 * @param user_data [in] The user data passed from the callback registration function
557 * @return This callback function have to return MM_ERROR_NONE.
559 typedef bool (*mm_player_stream_changed_callback)(void *user_param);
562 * Video decoded callback function type.
564 * @param stream [in] Reference pointer to video frame data
565 * @param stream_size [in] Size of video frame data
566 * @param user_param [in] User defined parameter which is passed when set
567 * video stream callback
568 * @param width [in] width of video frame
569 * @param height [in] height of video frame
571 * @return This callback function have to return MM_ERROR_NONE.
573 typedef bool (*mm_player_video_decoded_callback)(void *stream, void *user_param);
576 * Audio stream callback function type.
578 * @param stream [in] Reference pointer to audio frame data
579 * @param stream_size [in] Size of audio frame data
580 * @param user_param [in] User defined parameter which is passed when set
581 * audio stream callback
583 * @return This callback function have to return MM_ERROR_NONE.
585 typedef bool (*mm_player_video_capture_callback)(void *stream, int stream_size, void *user_param);
588 * Video frame render error callback function type.
590 * @param error_id [in] cause of error
591 * @param user_param [in] User defined parameter which is passed when set
592 * video frame render error callback
594 * @return This callback function have to return MM_ERROR_NONE.
596 typedef bool (*mm_player_video_frame_render_error_callback)(void *error_id, void *user_param);
599 * Audio stream callback function type.
601 * @param stream [in] Reference pointer to audio frame data
602 * @param user_param [in] User defined parameter which is passed when set
603 * audio stream callback
605 * @return This callback function have to return MM_ERROR_NONE.
607 typedef bool (*mm_player_audio_decoded_callback)(void *stream, void *user_param);
609 /*===========================================================================================
611 | GLOBAL FUNCTION PROTOTYPES |
613 ========================================================================================== */
616 * This function creates a player object for playing multimedia contents. \n
617 * The attributes of player are created to get/set some values with application. \n
618 * And, mutex, gstreamer and other resources are initialized at this time. \n
619 * If player is created, the state will become MM_PLAYER_STATE_NULL.
621 * @param player [out] Handle of player
623 * @return This function returns zero on success, or negative value with error code. \n
624 * Please refer 'mm_error.h' to know it in detail.
626 * @post MM_PLAYER_STATE_NULL
627 * @see mm_player_destroy
628 * @remark You can create multiple handles on a context at the same time. \n
629 * However, player cannot guarantee proper operation because of limitation of resources, \n
630 * such as audio device or display device.
634 char *g_err_attr_name = NULL;
636 if (mm_player_create(&g_player) != MM_ERROR_NONE) {
637 LOGE("failed to create player\n");
640 if (mm_player_set_attribute(g_player,
642 "profile_uri", filename, strlen(filename),
643 "display_overlay", (void *)&g_win.xid, sizeof(g_win.xid),
644 NULL) != MM_ERROR_NONE) {
645 LOGE("failed to set %s attribute\n", g_err_attr_name);
646 free(g_err_attr_name);
649 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
652 int mm_player_create(MMHandleType *player);
655 * This function releases player object and all resources which were created by mm_player_create(). \n
656 * And, player handle will also be destroyed.
658 * @param player [in] Handle of player
660 * @return This function returns zero on success, or negative value with error code.
661 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
662 * But, it can be called in any state.
663 * @post Because handle is released, there is no any state.
664 * @see mm_player_create
665 * @remark This method can be called with a valid player handle from any state to \n
666 * completely shutdown the player operation.
670 if (mm_player_destroy(g_player) != MM_ERROR_NONE) {
671 LOGE("failed to destroy player\n");
675 int mm_player_destroy(MMHandleType player);
678 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
679 * So, uri should be set before realizing with mm_player_set_attribute(). \n
681 * @param player [in] Handle of player
683 * @return This function returns zero on success, or negative value with error code.
685 * @pre Player state should be MM_PLAYER_STATE_NULL.
686 * @post player state will be MM_PLAYER_STATE_READY.
687 * @see mm_player_unrealize
691 if (mm_player_realize(g_player) != MM_ERROR_NONE) {
692 LOGE("failed to realize player\n");
696 int mm_player_realize(MMHandleType player);
699 * This function uninitializes player object. So, resources and allocated memory \n
700 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
701 * other contents, player should be created again after destruction or realized with new uri.
703 * @param player [in] Handle of player
705 * @return This function returns zero on success, or negative value with error code.
706 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
707 * But, it can be called in any state.
708 * @post Player state will be MM_PLAYER_STATE_NULL.
709 * @see mm_player_realize
710 * @remark This method can be called with a valid player handle from any state.
714 if (mm_player_unrealize(g_player) != MM_ERROR_NONE) {
715 LOGE("failed to unrealize player\n");
719 int mm_player_unrealize(MMHandleType player);
722 * This function is to abort pause state transition
723 * for unrealize or destroy.
725 int mm_player_abort_pause(MMHandleType player);
728 * This function is to get current state of player. \n
729 * Application have to check current state before doing some action.
731 * @param player [in] Handle of player
732 * @param state [out] current state of player on success
734 * @return This function returns zero on success, or negative value with error code.
736 * @see mmplayer_state_e
740 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE) {
741 LOGE("failed to get state\n");
745 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state);
748 * This function is to control logical volume.
750 int mm_player_set_volume(MMHandleType player, float volume);
753 * This function is to get current volume factor of player.
755 int mm_player_get_volume(MMHandleType player, float *volume);
758 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
759 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
760 * by mm_player_set_message_callback().
762 * @param player [in] Handle of player
764 * @return This function returns zero on success, or negative value with error code.
767 * @pre Player state may be MM_PLAYER_STATE_READY.
768 * @post Player state will be MM_PLAYER_STATE_PLAYING.
769 * @see mm_player_stop
773 if (mm_player_start(g_player) != MM_ERROR_NONE)
775 LOGE("failed to start player\n");
779 int mm_player_start(MMHandleType player);
782 * This function is to stop playing media contents and it's different with pause. \n
783 * If mm_player_start() is called after this, content will be started again from the beginning. \n
784 * So, it can be used to close current playback.
786 * @param player [in] Handle of player
788 * @return This function returns zero on success, or negative value with error code.
790 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
791 * @post Player state will be MM_PLAYER_STATE_READY.
792 * @see mm_player_start
796 if (mm_player_stop(g_player) != MM_ERROR_NONE)
798 LOGE("failed to stop player\n");
802 int mm_player_stop(MMHandleType player);
805 * This function is to pause playing media contents.
807 * @param player [in] Handle of player.
809 * @return This function returns zero on success, or negative value with error code.
811 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
812 * @post Player state will be MM_PLAYER_STATE_PAUSED.
813 * @see mm_player_resume
817 if (mm_player_pause(g_player) != MM_ERROR_NONE)
819 LOGE("failed to pause player\n");
823 int mm_player_pause(MMHandleType player);
826 * This function is to resume paused media contents.
828 * @param player [in] Handle of player.
830 * @return This function returns zero on success, or negative value with error code.
832 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
833 * @post Player state will be MM_PLAYER_STATE_PLAYING.
834 * @see mm_player_pause
838 if (mm_player_resume(g_player) != MM_ERROR_NONE)
840 LOGE("failed to resume player\n");
844 int mm_player_resume(MMHandleType player);
847 * This function is to set the position for playback. \n
848 * So, it can be seeked to requested position. \n
850 * @param player [in] Handle of player
851 * @param pos [in] Position for playback
853 * @return This function returns zero on success, or negative value with error code.
854 * @see mm_player_get_position
855 * @remark the unit of time-based format is millisecond and other case is percent.
857 int mm_player_set_position(MMHandleType player, int64_t pos);
860 * This function is to get current position of playback content.
862 * @param player [in] Handle of player.
863 * @param format [in] Format of position.
864 * @param pos [out] contains current position on success or zero in case of failure.
866 * @return This function returns zero on success, or negative value with errors
867 * @see mm_player_set_position
868 * @remark the unit of time-based format is millisecond and other case is percent.
870 int mm_player_get_position(MMHandleType player, int64_t *pos);
873 * This function is to get the content time duration.
875 int mm_player_get_duration(MMHandleType player, int64_t *dur);
878 * This function is to get current buffer position of playback content.
880 * @param player [in] Handle of player.
881 * @param format [in] Format of position.
882 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
883 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
885 * @return This function returns zero on success, or negative value with errors
886 * @see mm_player_set_position
887 * @remark the unit of time-based format is millisecond and other case is percent.
890 int start_pos = 0, stop_pos = 0;
892 mm_player_get_buffer_position(g_player, &start_pos, &end_pos );
894 LOGD("buffer position: [%d] ~ [%d] \%\n", start_pos, end_pos );
897 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos);
900 * This function sets callback function for receiving messages from player.
901 * So, player can notify warning, error and normal cases to application.
903 * @param player [in] Handle of player.
904 * @param callback [in] Message callback function.
905 * @param user_param [in] User parameter which is passed to callback function.
907 * @return This function returns zero on success, or negative value with error code.
908 * @see MMMessageCallback
912 int msg_callback(int message, MMMessageParamType *param, void *user_param)
916 case MM_MESSAGE_ERROR:
920 case MM_MESSAGE_END_OF_STREAM:
924 case MM_MESSAGE_STATE_CHANGED:
928 case MM_MESSAGE_BEGIN_OF_STREAM:
938 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
941 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
944 * This function is to mute volume of player
946 * @param player [in] Handle of player
947 * @param mute [in] mute value
949 * @return This function returns zero on success, or negative value with error code
950 * @see mm_player_get_mute
953 int mm_player_set_mute(MMHandleType player, bool mute);
956 * This function is to get mute value of player
958 * @param player [in] Handle of player
959 * @param mute [out] Sound is muted
961 * @return This function returns zero on success, or negative value with error code
962 * @see mm_player_set_mute
965 int mm_player_get_mute(MMHandleType player, bool *mute);
968 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
969 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
971 * @param player [in] Handle of player
972 * @param pos [in] postion to be adjusted
974 * @return This function returns zero on success, or negative value with error
976 * @see mm_player_adjust_subtitle_position
983 if (mm_player_adjust_subtitle_position(g_player, pos) != MM_ERROR_NONE)
985 LOGW("failed to adjust subtitle postion.\n");
990 int mm_player_adjust_subtitle_position(MMHandleType player, int pos);
993 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
994 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
995 * Player FW parses subtitle file and send text data including timestamp to application \n
996 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
997 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
998 * So, it's not supported for embedded case.
1000 * @param player [in] Handle of player
1001 * @param silent [in] silent(integer value except 0) or not silent(0)
1003 * @return This function returns zero on success, or negative value with error
1005 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1009 mm_player_set_attribute(g_player,
1011 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
1015 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
1017 LOGW("failed to set subtitle silent\n");
1021 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
1024 * This function is to get silent status of subtitle.
1026 * @param player [in] Handle of player
1027 * @param silent [out] subtitle silent property
1029 * @return This function returns zero on success, or negative value with error
1031 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1037 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
1039 LOGW("failed to set subtitle silent\n");
1043 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
1046 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1047 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1049 * @param player [in] Handle of player.
1050 * @param err_attr_name [out] Name of attribute which is failed to set
1051 * @param first_attribute_name [in] Name of the first attribute to set
1052 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1053 * But, in the case of data or string type, it should be name/value/size.
1055 * @return This function returns zero on success, or negative value with error code.
1057 * @see mm_player_get_attribute
1058 * @remark This function must be terminated by NULL argument.
1059 * And, if this function is failed, err_attr_name param must be free.
1062 char *g_err_attr_name = NULL;
1064 if (mm_player_set_attribute(g_player,
1066 "profile_uri", filename, strlen(filename),
1067 "profile_play_count", count,
1068 NULL) != MM_ERROR_NONE) {
1069 LOGW("failed to set %s attribute\n", g_err_attr_name);
1070 free(g_err_attr_name);
1075 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1078 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1080 * @param player [in] Handle of player.
1081 * @param err_attr_name [out] Name of attribute which is failed to get
1082 * @param first_attribute_name [in] Name of the first attribute to get
1083 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1084 * But, in the case of data or string type, it should be name/value/size.
1086 * @return This function returns zero on success, or negative value with error
1088 * @see mm_player_set_attribute
1089 * @remark This function must be terminated by NULL argument.
1090 * And, if this function is failed, err_attr_name param must be free.
1092 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1095 * This function is to get detail information of attribute.
1097 * @param player [in] Handle of player.
1098 * @param attribute_name [in] Name of the attribute to get
1099 * @param info [out] Attribute infomation
1101 * @return This function returns zero on success, or negative value with error
1104 * @see mm_player_set_attribute, mm_player_get_attribute
1108 if (mm_player_get_attribute_info(g_player, "display_method", &method_info) != MM_ERROR_NONE) {
1109 LOGW("failed to get info\n");
1112 LOGD("type:%d \n", method_info.type); //int, double..
1113 LOGD("flag:%d \n", method_info.flag); //readable, writable..
1114 LOGD("validity type:%d \n", method_info.validity_type); //range, array..
1116 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE) {
1117 LOGD("range min:%d\n", method_info.int_range.min);
1118 LOGD("range max:%d\n", method_info.int_range.max);
1122 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info);
1125 * This function is to get the track count
1127 * @param player [in] handle of player.
1128 * @param track [in] type of the track type
1129 * @param info [out] the count of the track
1131 * @return This function returns zero on success, or negative value with error
1136 gint audio_count = 0;
1138 if (mm_player_get_track_count(g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE) {
1139 LOGW("failed to get audio track count\n");
1142 LOGD("audio track count : %d \n", audio_count);
1145 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count);
1148 * This function is to select the track
1150 * @param player [in] handle of player.
1151 * @param type [in] type of the track type
1152 * @param index [in] the index of the track
1154 * @return This function returns zero on success, or negative value with error
1157 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index);
1160 * This function is to get the track language
1162 * @param player [in] handle of player.
1163 * @param type [in] type of the track type
1164 * @param index [in] the index of the track
1165 * @param code [out] language code in ISO 639-1(string)
1167 * @return This function returns zero on success, or negative value with error
1170 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code);
1173 * This function is to get the current running track
1175 * @param player [in] handle of player.
1176 * @param type [in] type of the track type
1177 * @param index [out] the index of the track
1179 * @return This function returns zero on success, or negative value with error
1183 int mm_player_get_current_track(MMHandleType hplayer, mmplayer_track_type_e type, int *index);
1186 * This function is to set the subtitle path
1188 * @param player [in] handle of player
1189 * @param path [in] subtitle path
1191 * @return This function returns zero on success, or negative value with error code.
1193 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path);
1196 * This function is to set uri.
1198 * @param player [in] handle of player
1199 * @param uri [in] uri
1200 * @return This function returns zero on success, or negative value with error code.
1202 int mm_player_set_uri(MMHandleType player, const char *uri);
1205 * This function is to set next uri.
1207 * @param player [in] handle of player
1208 * @param uri [in] uri
1209 * @return This function returns zero on success, or negative value with error code.
1211 int mm_player_set_next_uri(MMHandleType player, const char *uri);
1214 * This function is to get next uri.
1216 * @param player [in] handle of player
1217 * @param uri [out] uri
1218 * @return This function returns zero on success, or negative value with error code.
1220 int mm_player_get_next_uri(MMHandleType player, char **uri);
1223 * This function is to decrease reference count of internal buffer.
1225 * @param buffer [in] video callback internal buffer
1228 void mm_player_video_stream_internal_buffer_unref(void *buffer);
1230 /**mm_player_submit_packet
1231 * This function is to submit buffer to appsrc. \n
1232 * @param player [in] Handle of player.
1233 * @param buf [in] buffer to be submit in appsrc in external feeder case.
1234 * @param len [in] length of buffer.
1235 * @param pts [in] timestamp of buffer.
1236 * @param streamtype [in] stream type of buffer.
1237 * @return This function returns zero on success, or negative value with error code.
1239 int mm_player_submit_packet(MMHandleType player, media_packet_h packet);
1241 /**mm_player_set_video_info
1242 * This function is to set caps of src pad of video appsrc in external feeder case. \n
1243 * @param player [in] Handle of player.
1244 * @param media_format_h [in] Video stream info.
1245 * @return This function returns zero on success, or negative value with error code.
1247 int mm_player_set_video_info(MMHandleType player, media_format_h format);
1249 /**mm_player_set_audio_info
1250 * This function is to set caps of src pad of Audio appsrc in external feeder case. \n
1251 * @param player [in] Handle of player.
1252 * @param media_format_h [in] Audio stream info.
1253 * @return This function returns zero on success, or negative value with error code.
1255 int mm_player_set_audio_info(MMHandleType player, media_format_h format);
1257 /**mm_player_set_subtitle_info
1258 * This function is to set caps of src pad of subtitle appsrc in external feeder case. \n
1259 * @param player [in] Handle of player.
1260 * @param subtitle_stream_info [in] Subtitle stream info.
1261 * @return This function returns zero on success, or negative value with error code.
1263 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *info);
1266 * This function set callback function for receiving need or enough data message from player.
1268 * @param player [in] Handle of player.
1269 * @param type [in] stream type
1270 * @param callback [in] data callback function for stream type.
1271 * @param user_param [in] User parameter.
1273 * @return This function returns zero on success, or negative value with error
1276 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);
1279 * This function set callback function for receiving seek data message from player.
1281 * @param player [in] Handle of player.
1282 * @param type [in] stream type
1283 * @param callback [in] Seek data callback function for stream type.
1284 * @param user_param [in] User parameter.
1286 * @return This function returns zero on success, or negative value with error
1289 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);
1292 * This function is to set max size of buffer(appsrc).
1294 * @param player [in] Handle of player.
1295 * @param type [in] stream type
1296 * @param max_size [in] max bytes of buffer.
1298 * @return This function returns zero on success, or negative value with error
1301 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size);
1304 * This function is to get max size of buffer(appsrc).
1306 * @param player [in] Handle of player.
1307 * @param type [in] stream type
1308 * @param max_size [out] max bytes of buffer.
1310 * @return This function returns zero on success, or negative value with error
1313 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size);
1316 * This function is to set min percent of buffer(appsrc).
1318 * @param player [in] Handle of player.
1319 * @param type [in] stream type
1320 * @param min_percent [in] min percent of buffer.
1322 * @return This function returns zero on success, or negative value with error
1325 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent);
1328 * This function is to get min percent of buffer(appsrc).
1330 * @param player [in] Handle of player.
1331 * @param type [in] stream type
1332 * @param min_percent [out] min percent of buffer.
1334 * @return This function returns zero on success, or negative value with error
1337 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent);
1340 * This function set callback function for changing audio stream from player. \n
1341 * It's only supported when audio stream is included in file. \n
1343 * @param player [in] Handle of player.
1344 * @param callback [in] Audio stream changed callback function.
1345 * @param user_param [in] User parameter.
1347 * @return This function returns zero on success, or negative value with error
1349 * @see mm_player_stream_changed_callback
1352 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param);
1355 * This function set callback function for changing video stream from player. \n
1356 * It's only supported when video stream is included in file. \n
1358 * @param player [in] Handle of player.
1359 * @param callback [in] Video stream changed callback function.
1360 * @param user_param [in] User parameter.
1362 * @return This function returns zero on success, or negative value with error
1364 * @see mm_player_stream_changed_callback
1366 int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param);
1369 * This function is to get timeout value according to the content type for muse. \n
1370 * It's only supported when video stream is included in file. \n
1372 * @param player [in] Handle of player.
1373 * @param timeout [out] timeout value (sec).
1375 * @return This function returns zero on success, or negative value with error
1379 int mm_player_get_timeout(MMHandleType player, int *timeout);
1382 * This function is to get the number of video output buffers. \n
1383 * It's only supported when video stream is included in file. \n
1385 * @param player [in] Handle of player.
1386 * @param num [out] num of buffers.
1387 * @param extra_num [out] extra num of buffers.
1389 * @return This function returns zero on success, or negative value with error
1393 int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num);
1396 * This function is to set the dynamic resolution information. \n
1397 * It's only supported when video stream is included in file. \n
1399 * @param player [in] Handle of player.
1400 * @param drc [in] dynamic resolution info of media stream data
1402 * @return This function returns zero on success, or negative value with error
1406 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc);
1409 * This function is to release the video stream bo to reuse. \n
1410 * It's only supported when sw codec is used to decode video stream. \n
1412 * @param player [in] Handle of player.
1413 * @param bo [in] bo address to be released
1415 * @return This function returns zero on success, or negative value with error
1419 int mm_player_release_video_stream_bo(MMHandleType player, void *bo);
1422 * This function is to set sound stream info
1424 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index);
1427 * This function is to manage the playback according to the external storage state
1429 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state);
1432 * These functions are to set/get the max variant of HAS
1434 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info);
1435 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height);
1436 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height);
1439 * These functions are to set/get the audio only mode
1441 int mm_player_set_audio_only(MMHandleType player, bool audio_only);
1442 int mm_player_get_audio_only(MMHandleType player, bool *audio_only);
1445 * These functions are to get the streaming bufferint time
1447 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms);
1450 * These functions are to display the 360 video content
1452 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical);
1453 int mm_player_360_set_enabled(MMHandleType player, bool enabled);
1454 int mm_player_360_is_enabled(MMHandleType player, bool *enabled);
1456 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch);
1457 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch);
1459 int mm_player_360_set_zoom(MMHandleType player, float level);
1460 int mm_player_360_get_zoom(MMHandleType player, float *level);
1462 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees);
1463 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees);
1466 * This function is to set codec type
1468 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type);
1471 * These functions are to apply the replaygain
1473 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled);
1474 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled);
1477 * This function is to set/get video content ROI area
1479 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height);
1480 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
1483 * This function is to set play speed for playback.
1485 * @param player [in] Handle of player.
1486 * @param ratio [in] Speed for playback.
1487 * @param streaming [in] If @c true, rate value can be set even if it is streaming playback.
1488 * @return This function returns zero on success, or negative value with error
1490 * @remark The current supported range is from -64x to 64x.
1491 * But, the quailty is dependent on codec performance.
1492 * And, the sound is muted under normal speed and more than double speed.
1496 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming);
1499 * This function set callback function for receiving video stream from player.
1501 * @param player [in] Handle of player.
1502 * @param callback [in] Video stream callback function.
1503 * @param user_param [in] User parameter.
1505 * @return This function returns zero on success, or negative value with error
1510 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param);
1513 * This function set callback function for receiving audio stream from player.
1515 * @param player [in] Handle of player.
1516 * @param opt [in] audio extract option.
1517 * @param callback [in] audio stream callback function.
1518 * @param user_param [in] User parameter.
1520 * @return This function returns zero on success, or negative value with error
1523 * @see mm_player_audio_decoded_callback
1526 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
1529 * This function is to capture video frame.
1531 * @param player [in] Handle of player.
1533 * @return This function returns zero on success, or negative value with error
1536 * @remark Captured buffer is sent asynchronously through message callback with MM_MESSAGE_VIDEO_CAPTURED.
1537 * And, application should free the captured buffer directly.
1538 * @see MM_MESSAGE_VIDEO_CAPTURED
1541 int mm_player_do_video_capture(MMHandleType player);
1544 * This function changes the previous videosink plugin for a new one
1546 * @param player [in] Handle of player.
1547 * @param display_surface_type [in] display surface type to set
1548 * @param display_overlay [in] display overlay to set
1550 * @return This function returns zero on success, or negative value with error
1556 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay);
1566 #endif /* __MM_PLAYER_H__ */