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"
81 * MM_PLAYER_VIDEO_FPS:
83 #define MM_PLAYER_VIDEO_FPS "content_video_fps"
86 * MM_PLAYER_VIDEO_BITRATE:
88 #define MM_PLAYER_VIDEO_BITRATE "content_video_bitrate"
91 * MM_PLAYER_VIDEO_EVAS_SURFACE_SINK:
93 * get the video evas surface sink plugin name (string), It's guaranteed after calling mm_player_create()
96 #define MM_PLAYER_VIDEO_EVAS_SURFACE_SINK "display_evas_surface_sink"
100 * set memory pointer to play (data)
103 #define MM_PLAYER_MEMORY_SRC "profile_user_param"
105 * MM_PLAYER_PLAYBACK_COUNT
107 * can set playback count (int), Default value is 1 and -1 is for infinity playing until releasing it.
110 #define MM_PLAYER_PLAYBACK_COUNT "profile_play_count"
112 * MM_PLAYER_SUBTITLE_URI
114 * set the subtitle path (string)
116 #define MM_PLAYER_SUBTITLE_URI "subtitle_uri"
118 * MM_PLAYER_STREAMING_USER_AGENT
120 * set the streaming user agent (string)
122 #define MM_PLAYER_STREAMING_USER_AGENT "streaming_user_agent"
124 * MM_PLAYER_STREAMING_COOKIE
126 * set the streaming cookie (int)
128 #define MM_PLAYER_STREAMING_COOKIE "streaming_cookie"
130 * MM_PLAYER_VIDEO_CODEC
132 * codec the video data is stored in (string)
134 #define MM_PLAYER_VIDEO_CODEC "content_video_codec"
136 * MM_PLAYER_AUDIO_CODEC
138 * codec the audio data is stored in (string)
140 #define MM_PLAYER_AUDIO_CODEC "content_audio_codec"
142 * MM_PLAYER_AUDIO_BITRATE
144 * set the streaming proxy port (int)
146 #define MM_PLAYER_AUDIO_BITRATE "content_audio_bitrate"
148 * MM_PLAYER_AUDIO_CHANNEL
150 * the number of audio channel (int)
152 #define MM_PLAYER_AUDIO_CHANNEL "content_audio_channels"
154 * MM_PLAYER_AUDIO_SAMPLERATE
156 * audio samplerate (int)
158 #define MM_PLAYER_AUDIO_SAMPLERATE "content_audio_samplerate"
160 * MM_PLAYER_TEXT_TRACK_NUM
162 * track number inside a collection (int)
164 #define MM_PLAYER_TEXT_TRACK_NUM "content_text_track_num"
166 * MM_PLAYER_TAG_ARTIST
168 * person(s) responsible for the recording (string)
170 #define MM_PLAYER_TAG_ARTIST "tag_artist"
172 * MM_PLAYER_TAG_TITLE
176 #define MM_PLAYER_TAG_TITLE "tag_title"
178 * MM_PLAYER_TAG_ALBUM
180 * album containing this data (string)
182 #define MM_PLAYER_TAG_ALBUM "tag_album"
184 * MM_PLAYER_TAG_GENRE
186 * genre this data belongs to (string)
188 #define MM_PLAYER_TAG_GENRE "tag_genre"
190 * MM_PLAYER_TAG_AUTHOUR
194 #define MM_PLAYER_TAG_AUTHOUR "tag_author"
196 * MM_PLAYER_TAG_COPYRIGHT
198 * copyright notice of the data (string)
200 #define MM_PLAYER_TAG_COPYRIGHT "tag_copyright"
204 * date the data was created (string)
206 #define MM_PLAYER_TAG_DATE "tag_date"
208 * MM_PLAYER_TAG_DESCRIPRION
210 * short text describing the content of the data (string)
212 #define MM_PLAYER_TAG_DESCRIPRION "tag_description"
214 * MM_PLAYER_TAG_TRACK_NUM
216 * track number inside a collection (int)
218 #define MM_PLAYER_TAG_TRACK_NUM "tag_track_num"
223 * dynamic resolution change mode (int)
225 #define MM_PLAYER_DRC_MODE "drc_mode"
228 * MM_PLAYER_GAPLESS_MODE
230 * gapless playback mode (int)
232 #define MM_PLAYER_GAPLESS_MODE "gapless_mode"
235 * MM_PLAYER_ENABLE_VIDEO_DECODED_CB
237 * enable video decoded callback (int)
239 #define MM_PLAYER_ENABLE_VIDEO_DECODED_CB "enable_video_decoded_cb"
242 * MM_PLAYER_VIDEO_CODEC_TYPE
244 * video codec type (int)
246 #define MM_PLAYER_VIDEO_CODEC_TYPE "video_codec_type"
249 * MM_PLAYER_AUDIO_CODEC_TYPE
251 * audio codec type (int)
253 #define MM_PLAYER_AUDIO_CODEC_TYPE "audio_codec_type"
256 * MM_PLAYER_VIDEO_BUFFER_TOTAL_SIZE (int)
258 #define MM_PLAYER_VIDEO_BUFFER_TOTAL_SIZE "video_buffer_total_size"
261 * MM_PLAYER_VIDEO_BUFFER_EXTRA_SIZE (int)
263 #define MM_PLAYER_VIDEO_BUFFER_EXTRA_SIZE "video_buffer_extra_size"
266 * MM_PLAYER_PREBUFFER_MS
270 #define MM_PLAYER_PREBUFFER_MS "prebuffer_ms"
273 * MM_PLAYER_REBUFFER_MS
277 #define MM_PLAYER_REBUFFER_MS "rebuffer_ms"
279 * MM_PLAYER_AUDIO_OFFLOAD (int)
281 #define MM_PLAYER_AUDIO_OFFLOAD "audio_offload"
284 * MM_PLAYER_PITCH_CONTROL (int)
286 #define MM_PLAYER_PITCH_CONTROL "pitch_control"
289 * MM_PLAYER_PITCH_VALUE (double)
291 #define MM_PLAYER_PITCH_VALUE "pitch_value"
294 * MM_PLAYER_PCM_EXT_FORMAT (string)
296 #define MM_PLAYER_PCM_EXT_FORMAT "pcm_extraction_format"
299 * MM_PLAYER_PCM_EXT_CHANNELS (int)
301 #define MM_PLAYER_PCM_EXT_CHANNELS "pcm_extraction_channels"
304 * MM_PLAYER_PCM_EXT_SAMPLERATE (int)
306 #define MM_PLAYER_PCM_EXT_SAMPLERATE "pcm_extraction_samplerate"
308 #define BUFFER_MAX_PLANE_NUM (4)
311 * Enumerations of player state.
314 MM_PLAYER_STATE_NULL, /**< Player is created, but not realized yet */
315 MM_PLAYER_STATE_READY, /**< Player is ready to play media */
316 MM_PLAYER_STATE_PLAYING, /**< Player is now playing media */
317 MM_PLAYER_STATE_PAUSED, /**< Player is paused while playing media */
318 MM_PLAYER_STATE_NONE, /**< Player is not created yet */
319 MM_PLAYER_STATE_NUM, /**< Number of player states */
323 * Enumeration for attribute values types.
326 MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */
327 MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */
328 MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */
329 MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */
330 MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */
331 MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */
332 MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */
333 MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */
334 } mmplayer_attrs_type_e;
337 * Enumeration for attribute validation type.
340 MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */
341 MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */
342 MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */
343 MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */
344 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */
345 MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */
346 } mmplayer_attrs_valid_type_e;
349 * Enumeration for attribute access flag.
352 MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */
353 MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */
354 MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */
355 MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */
357 MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */
358 } mmplayer_attrs_flag_e;
361 * Enumeration of track types
364 MM_PLAYER_TRACK_TYPE_AUDIO = 0,
365 MM_PLAYER_TRACK_TYPE_VIDEO,
366 MM_PLAYER_TRACK_TYPE_TEXT,
367 MM_PLAYER_TRACK_TYPE_MAX
368 } mmplayer_track_type_e;
371 * Enumeration of runtime buffering mode
374 MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */
375 MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */
376 MM_PLAYER_BUFFERING_MODE_MAX,
377 } mmplayer_buffering_mode_e;
380 * Enumeration of media stream buffer status
383 MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN,
384 MM_PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW,
385 } mmplayer_media_stream_buffer_status_e;
388 * Enumeration for stream type.
391 MM_PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */
392 MM_PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */
393 MM_PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */
394 MM_PLAYER_STREAM_TYPE_TEXT, /**< Text type */
395 MM_PLAYER_STREAM_TYPE_MAX,
396 } mmplayer_stream_type_e;
399 MM_PLAYER_CODEC_TYPE_DEFAULT = 0, /**< codec is selected by the priority */
400 MM_PLAYER_CODEC_TYPE_HW, /**< HW codec can only be selected */
401 MM_PLAYER_CODEC_TYPE_SW, /**< SW codec can only be selected */
402 } mmplayer_video_codec_type_e;
405 MM_PLAYER_AUDIO_EXTRACT_DEFAULT = 0x00, /**< Sync with the playback clock and multichannel audio stream */
406 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK = 0x01, /**< No sync with the playback clock */
407 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE = 0x02, /**< Splits one interleaved multichannel audio stream into many mono audio streams */
408 MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_AND_DEINTERLEAVE = MM_PLAYER_AUDIO_EXTRACT_NO_SYNC_WITH_CLOCK | MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE,
409 MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK = 0x04, /**< With audio playback synchronously (experimental) */
410 MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE_WITH_PLAYBACK = MM_PLAYER_AUDIO_EXTRACT_DEINTERLEAVE | MM_PLAYER_AUDIO_EXTRACT_WITH_PLAYBACK,
411 } mmplayer_audio_extract_opt_e;
414 * Enumerations of video colorspace
417 MM_PLAYER_COLORSPACE_I420 = 0, /**< I420 format - planer */
418 MM_PLAYER_COLORSPACE_RGB888, /**< RGB888 pixel format */
419 MM_PLAYER_COLORSPACE_NV12_TILED, /**< Customized color format */
420 MM_PLAYER_COLORSPACE_NV12,
421 MM_PLAYER_COLORSPACE_BGRx, /**< BGRx pixel format */
422 MM_PLAYER_COLORSPACE_MAX = 0x7FFFFFFF
423 } mmplayer_video_color_space_e;
426 * Attribute validity structure
429 mmplayer_attrs_type_e type;
430 mmplayer_attrs_valid_type_e validity_type;
431 mmplayer_attrs_flag_e flag;
433 * a union that describes validity of the attribute.
434 * Only when type is 'MM_ATTRS_TYPE_INT' or 'MM_ATTRS_TYPE_DOUBLE',
435 * the attribute can have validity.
439 * Validity structure for integer array.
442 int *array; /**< a pointer of array */
443 int count; /**< size of array */
447 * Validity structure for integer range.
450 int min; /**< minimum range */
451 int max; /**< maximum range */
455 * Validity structure for double array.
458 double *array; /**< a pointer of array */
459 int count; /**< size of array */
463 * Validity structure for double range.
466 double min; /**< minimum range */
467 double max; /**< maximum range */
471 } mmplayer_attrs_info_t;
474 MMPixelFormatType format; /**< image format */
475 int width; /**< width of video buffer */
476 int height; /**< height of video buffer */
477 unsigned int timestamp; /**< timestamp of stream buffer (msec)*/
478 unsigned int length_total; /**< total length of stream buffer (in byte)*/
479 void *data[BUFFER_MAX_PLANE_NUM];
480 void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */
481 void *internal_buffer; /**< Internal buffer pointer */
482 int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */
483 int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */
484 int orientation; /**< orientation */
485 int bo_size; /**< TBM buffer object size */
486 int plane_num; /**< number of Plane */
487 } mmplayer_video_decoded_data_info_t;
495 bool is_little_endian;
496 guint64 channel_mask;
497 media_format_mimetype_e pcm_format;
498 } mmplayer_audio_decoded_data_info_t;
501 unsigned char *data; /* capture image buffer */
502 int size; /* capture image size */
503 mmplayer_video_color_space_e fmt; /* color space type */
504 unsigned int width; /* width of captured image */
505 unsigned int height; /* height of captured image */
506 unsigned int orientation; /* content orientation */
507 } mmplayer_video_capture_t;
510 * Video stream info in external demux case
515 unsigned int framerate_num;
516 unsigned int framerate_den;
519 unsigned char *codec_extradata;
520 unsigned int extradata_size;
521 unsigned int version;
522 } mmplayer_video_stream_info_t;
525 * Audio stream info in external demux case
530 unsigned int channels;
531 unsigned int sample_rate;
532 unsigned char *codec_extradata;
533 unsigned int extradata_size;
534 unsigned int version;
535 unsigned int user_info;
538 // unsigned int width;
539 // unsigned int depth;
540 // unsigned int endianness;
542 } mmplayer_audio_stream_info_t;
545 * Subtitle stream info in external demux case
548 typedef struct _SubtitleStreamInfo {
550 unsigned int codec_tag;
551 void *context; //for smpte text
552 } mmplayer_subtitle_stream_info_t;
555 * selected subtitle track number callback function type.
557 * @param track_num [in] Track number of subtitle
558 * @param user_param [in] User defined parameter
561 * @return This callback function have to return MM_ERROR_NONE.
563 typedef bool (*mm_player_track_selected_subtitle_language_callback)(int track_num, void *user_param);
566 * Called to notify the stream changed.
568 * @param user_data [in] The user data passed from the callback registration function
570 * @return This callback function have to return MM_ERROR_NONE.
572 typedef bool (*mm_player_stream_changed_callback)(void *user_param);
575 * Video decoded callback function type.
577 * @param stream [in] Reference pointer to video frame data
578 * @param stream_size [in] Size of video frame data
579 * @param user_param [in] User defined parameter which is passed when set
580 * video stream callback
581 * @param width [in] width of video frame
582 * @param height [in] height of video frame
584 * @return This callback function have to return MM_ERROR_NONE.
586 typedef bool (*mm_player_video_decoded_callback)(void *stream, void *user_param);
589 * Audio stream callback function type.
591 * @param stream [in] Reference pointer to audio frame data
592 * @param stream_size [in] Size of audio frame data
593 * @param user_param [in] User defined parameter which is passed when set
594 * audio stream callback
596 * @return This callback function have to return MM_ERROR_NONE.
598 typedef bool (*mm_player_video_capture_callback)(void *stream, int stream_size, void *user_param);
601 * Video frame render error callback function type.
603 * @param error_id [in] cause of error
604 * @param user_param [in] User defined parameter which is passed when set
605 * video frame render error callback
607 * @return This callback function have to return MM_ERROR_NONE.
609 typedef bool (*mm_player_video_frame_render_error_callback)(void *error_id, void *user_param);
612 * Audio stream callback function type.
614 * @param stream [in] Reference pointer to audio frame data
615 * @param user_param [in] User defined parameter which is passed when set
616 * audio stream callback
618 * @return This callback function have to return MM_ERROR_NONE.
620 typedef bool (*mm_player_audio_decoded_callback)(void *stream, void *user_param);
622 /*===========================================================================================
624 | GLOBAL FUNCTION PROTOTYPES |
626 ========================================================================================== */
629 * This function creates a player object for playing multimedia contents. \n
630 * The attributes of player are created to get/set some values with application. \n
631 * And, mutex, gstreamer and other resources are initialized at this time. \n
632 * If player is created, the state will become MM_PLAYER_STATE_NULL.
634 * @param player [out] Handle of player
636 * @return This function returns zero on success, or negative value with error code. \n
637 * Please refer 'mm_error.h' to know it in detail.
639 * @post MM_PLAYER_STATE_NULL
640 * @see mm_player_destroy
641 * @remark You can create multiple handles on a context at the same time. \n
642 * However, player cannot guarantee proper operation because of limitation of resources, \n
643 * such as audio device or display device.
647 char *g_err_attr_name = NULL;
649 if (mm_player_create(&g_player) != MM_ERROR_NONE) {
650 LOGE("failed to create player\n");
653 if (mm_player_set_attribute(g_player,
655 "profile_uri", filename, strlen(filename),
656 "display_overlay", (void *)&g_win.xid, sizeof(g_win.xid),
657 NULL) != MM_ERROR_NONE) {
658 LOGE("failed to set %s attribute\n", g_err_attr_name);
659 free(g_err_attr_name);
662 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
665 int mm_player_create(MMHandleType *player);
668 * This function releases player object and all resources which were created by mm_player_create(). \n
669 * And, player handle will also be destroyed.
671 * @param player [in] Handle of player
673 * @return This function returns zero on success, or negative value with error code.
674 * @pre Player state may be MM_PLAYER_STATE_NULL. \n
675 * But, it can be called in any state.
676 * @post Because handle is released, there is no any state.
677 * @see mm_player_create
678 * @remark This method can be called with a valid player handle from any state to \n
679 * completely shutdown the player operation.
683 if (mm_player_destroy(g_player) != MM_ERROR_NONE) {
684 LOGE("failed to destroy player\n");
688 int mm_player_destroy(MMHandleType player);
691 * This function parses uri and makes gstreamer pipeline by uri scheme. \n
692 * So, uri should be set before realizing with mm_player_set_attribute(). \n
694 * @param player [in] Handle of player
696 * @return This function returns zero on success, or negative value with error code.
698 * @pre Player state should be MM_PLAYER_STATE_NULL.
699 * @post player state will be MM_PLAYER_STATE_READY.
700 * @see mm_player_unrealize
704 if (mm_player_realize(g_player) != MM_ERROR_NONE) {
705 LOGE("failed to realize player\n");
709 int mm_player_realize(MMHandleType player);
712 * This function uninitializes player object. So, resources and allocated memory \n
713 * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n
714 * other contents, player should be created again after destruction or realized with new uri.
716 * @param player [in] Handle of player
718 * @return This function returns zero on success, or negative value with error code.
719 * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n
720 * But, it can be called in any state.
721 * @post Player state will be MM_PLAYER_STATE_NULL.
722 * @see mm_player_realize
723 * @remark This method can be called with a valid player handle from any state.
727 if (mm_player_unrealize(g_player) != MM_ERROR_NONE) {
728 LOGE("failed to unrealize player\n");
732 int mm_player_unrealize(MMHandleType player);
735 * This function is to abort pause state transition
736 * for unrealize or destroy.
738 int mm_player_abort_pause(MMHandleType player);
741 * This function is to get current state of player. \n
742 * Application have to check current state before doing some action.
744 * @param player [in] Handle of player
745 * @param state [out] current state of player on success
747 * @return This function returns zero on success, or negative value with error code.
749 * @see mmplayer_state_e
753 if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE) {
754 LOGE("failed to get state\n");
758 int mm_player_get_state(MMHandleType player, mmplayer_state_e *state);
761 * This function is to control logical volume.
763 int mm_player_set_volume(MMHandleType player, float volume);
766 * This function is to get current volume factor of player.
768 int mm_player_get_volume(MMHandleType player, float *volume);
771 * This function is to start playing media contents. Demux(parser), codec and related plugins are decided \n
772 * at this time. And, MM_MESSAGE_BEGIN_OF_STREAM will be posted through callback function registered \n
773 * by mm_player_set_message_callback().
775 * @param player [in] Handle of player
777 * @return This function returns zero on success, or negative value with error code.
780 * @pre Player state may be MM_PLAYER_STATE_READY.
781 * @post Player state will be MM_PLAYER_STATE_PLAYING.
782 * @see mm_player_stop
786 if (mm_player_start(g_player) != MM_ERROR_NONE)
788 LOGE("failed to start player\n");
792 int mm_player_start(MMHandleType player);
795 * This function is to stop playing media contents and it's different with pause. \n
796 * If mm_player_start() is called after this, content will be started again from the beginning. \n
797 * So, it can be used to close current playback.
799 * @param player [in] Handle of player
801 * @return This function returns zero on success, or negative value with error code.
803 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
804 * @post Player state will be MM_PLAYER_STATE_READY.
805 * @see mm_player_start
809 if (mm_player_stop(g_player) != MM_ERROR_NONE)
811 LOGE("failed to stop player\n");
815 int mm_player_stop(MMHandleType player);
818 * This function is to pause playing media contents.
820 * @param player [in] Handle of player.
822 * @return This function returns zero on success, or negative value with error code.
824 * @pre Player state may be MM_PLAYER_STATE_PLAYING.
825 * @post Player state will be MM_PLAYER_STATE_PAUSED.
826 * @see mm_player_resume
830 if (mm_player_pause(g_player) != MM_ERROR_NONE)
832 LOGE("failed to pause player\n");
836 int mm_player_pause(MMHandleType player);
839 * This function is to resume paused media contents.
841 * @param player [in] Handle of player.
843 * @return This function returns zero on success, or negative value with error code.
845 * @pre Player state may be MM_PLAYER_STATE_PAUSED.
846 * @post Player state will be MM_PLAYER_STATE_PLAYING.
847 * @see mm_player_pause
851 if (mm_player_resume(g_player) != MM_ERROR_NONE)
853 LOGE("failed to resume player\n");
857 int mm_player_resume(MMHandleType player);
860 * This function is to set the position for playback. \n
861 * So, it can be seeked to requested position. \n
863 * @param player [in] Handle of player
864 * @param pos [in] Position for playback
866 * @return This function returns zero on success, or negative value with error code.
867 * @see mm_player_get_position
868 * @remark the unit of time-based format is millisecond and other case is percent.
870 int mm_player_set_position(MMHandleType player, int64_t pos);
873 * This function is to get current position of playback content.
875 * @param player [in] Handle of player.
876 * @param format [in] Format of position.
877 * @param pos [out] contains current position on success or zero in case of failure.
879 * @return This function returns zero on success, or negative value with errors
880 * @see mm_player_set_position
881 * @remark the unit of time-based format is millisecond and other case is percent.
883 int mm_player_get_position(MMHandleType player, int64_t *pos);
886 * This function is to get the content time duration.
888 int mm_player_get_duration(MMHandleType player, int64_t *dur);
891 * This function is to get current buffer position of playback content.
893 * @param player [in] Handle of player.
894 * @param format [in] Format of position.
895 * @param start_pos [out] contains buffer start position on success or zero in case of failure.
896 * @param stop_pos [out] contains buffer current position on success or zero in case of failure.
898 * @return This function returns zero on success, or negative value with errors
899 * @see mm_player_set_position
900 * @remark the unit of time-based format is millisecond and other case is percent.
903 int start_pos = 0, stop_pos = 0;
905 mm_player_get_buffer_position(g_player, &start_pos, &end_pos );
907 LOGD("buffer position: [%d] ~ [%d] \%\n", start_pos, end_pos );
910 int mm_player_get_buffer_position(MMHandleType player, int *start_pos, int *end_pos);
913 * This function sets callback function for receiving messages from player.
914 * So, player can notify warning, error and normal cases to application.
916 * @param player [in] Handle of player.
917 * @param callback [in] Message callback function.
918 * @param user_param [in] User parameter which is passed to callback function.
920 * @return This function returns zero on success, or negative value with error code.
921 * @see MMMessageCallback
925 int msg_callback(int message, MMMessageParamType *param, void *user_param)
929 case MM_MESSAGE_ERROR:
933 case MM_MESSAGE_END_OF_STREAM:
937 case MM_MESSAGE_STATE_CHANGED:
941 case MM_MESSAGE_BEGIN_OF_STREAM:
951 mm_player_set_message_callback(g_player, msg_callback, (void *)g_player);
954 int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callback, void *user_param);
957 * This function is to mute volume of player
959 * @param player [in] Handle of player
960 * @param mute [in] mute value
962 * @return This function returns zero on success, or negative value with error code
963 * @see mm_player_get_mute
966 int mm_player_set_mute(MMHandleType player, bool mute);
969 * This function is to get mute value of player
971 * @param player [in] Handle of player
972 * @param mute [out] Sound is muted
974 * @return This function returns zero on success, or negative value with error code
975 * @see mm_player_set_mute
978 int mm_player_get_mute(MMHandleType player, bool *mute);
981 * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n
982 * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n
984 * @param player [in] Handle of player
985 * @param pos [in] postion to be adjusted
987 * @return This function returns zero on success, or negative value with error
989 * @see mm_player_adjust_subtitle_position
996 if (mm_player_adjust_subtitle_position(g_player, pos) != MM_ERROR_NONE)
998 LOGW("failed to adjust subtitle postion.\n");
1003 int mm_player_adjust_subtitle_position(MMHandleType player, int pos);
1006 * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n
1007 * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n
1008 * Player FW parses subtitle file and send text data including timestamp to application \n
1009 * through message callback with MM_MESSAGE_UPDATE_SUBTITLE will be. \n
1010 * So, application have to render it. And, subtitle can be supported only in a seprate file. \n
1011 * So, it's not supported for embedded case.
1013 * @param player [in] Handle of player
1014 * @param silent [in] silent(integer value except 0) or not silent(0)
1016 * @return This function returns zero on success, or negative value with error
1018 * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1022 mm_player_set_attribute(g_player,
1024 "subtitle_uri", g_subtitle_uri, strlen(g_subtitle_uri),
1028 if (mm_player_set_subtitle_silent(g_player, TRUE) != MM_ERROR_NONE)
1030 LOGW("failed to set subtitle silent\n");
1034 int mm_player_set_subtitle_silent(MMHandleType player, int silent);
1037 * This function is to get silent status of subtitle.
1039 * @param player [in] Handle of player
1040 * @param silent [out] subtitle silent property
1042 * @return This function returns zero on success, or negative value with error
1044 * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE
1050 if (mm_player_get_subtitle_silent(g_player, &silent) != MM_ERROR_NONE)
1052 LOGW("failed to set subtitle silent\n");
1056 int mm_player_get_subtitle_silent(MMHandleType player, int *silent);
1059 * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n
1060 * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n
1062 * @param player [in] Handle of player.
1063 * @param err_attr_name [out] Name of attribute which is failed to set
1064 * @param first_attribute_name [in] Name of the first attribute to set
1065 * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1066 * But, in the case of data or string type, it should be name/value/size.
1068 * @return This function returns zero on success, or negative value with error code.
1070 * @see mm_player_get_attribute
1071 * @remark This function must be terminated by NULL argument.
1072 * And, if this function is failed, err_attr_name param must be free.
1075 char *g_err_attr_name = NULL;
1077 if (mm_player_set_attribute(g_player,
1079 "profile_uri", filename, strlen(filename),
1080 "profile_play_count", count,
1081 NULL) != MM_ERROR_NONE) {
1082 LOGW("failed to set %s attribute\n", g_err_attr_name);
1083 free(g_err_attr_name);
1088 int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1091 * This function is to get attributes from player. Multiple attributes can be got simultaneously.
1093 * @param player [in] Handle of player.
1094 * @param err_attr_name [out] Name of attribute which is failed to get
1095 * @param first_attribute_name [in] Name of the first attribute to get
1096 * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL.
1097 * But, in the case of data or string type, it should be name/value/size.
1099 * @return This function returns zero on success, or negative value with error
1101 * @see mm_player_set_attribute
1102 * @remark This function must be terminated by NULL argument.
1103 * And, if this function is failed, err_attr_name param must be free.
1105 int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const char *first_attribute_name, ...)G_GNUC_NULL_TERMINATED;
1108 * This function is to get detail information of attribute.
1110 * @param player [in] Handle of player.
1111 * @param attribute_name [in] Name of the attribute to get
1112 * @param info [out] Attribute infomation
1114 * @return This function returns zero on success, or negative value with error
1117 * @see mm_player_set_attribute, mm_player_get_attribute
1121 if (mm_player_get_attribute_info(g_player, "display_method", &method_info) != MM_ERROR_NONE) {
1122 LOGW("failed to get info\n");
1125 LOGD("type:%d \n", method_info.type); //int, double..
1126 LOGD("flag:%d \n", method_info.flag); //readable, writable..
1127 LOGD("validity type:%d \n", method_info.validity_type); //range, array..
1129 if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE) {
1130 LOGD("range min:%d\n", method_info.int_range.min);
1131 LOGD("range max:%d\n", method_info.int_range.max);
1135 int mm_player_get_attribute_info(MMHandleType player, const char *attribute_name, mmplayer_attrs_info_t *info);
1138 * This function is to get the track count
1140 * @param player [in] handle of player.
1141 * @param track [in] type of the track type
1142 * @param info [out] the count of the track
1144 * @return This function returns zero on success, or negative value with error
1149 gint audio_count = 0;
1151 if (mm_player_get_track_count(g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE) {
1152 LOGW("failed to get audio track count\n");
1155 LOGD("audio track count : %d \n", audio_count);
1158 int mm_player_get_track_count(MMHandleType player, mmplayer_track_type_e type, int *count);
1161 * This function is to select the track
1163 * @param player [in] handle of player.
1164 * @param type [in] type of the track type
1165 * @param index [in] the index of the track
1167 * @return This function returns zero on success, or negative value with error
1170 int mm_player_select_track(MMHandleType player, mmplayer_track_type_e type, int index);
1173 * This function is to get the track language
1175 * @param player [in] handle of player.
1176 * @param type [in] type of the track type
1177 * @param index [in] the index of the track
1178 * @param code [out] language code in ISO 639-1(string)
1180 * @return This function returns zero on success, or negative value with error
1183 int mm_player_get_track_language_code(MMHandleType player, mmplayer_track_type_e type, int index, char **code);
1186 * This function is to get the current running track
1188 * @param player [in] handle of player.
1189 * @param type [in] type of the track type
1190 * @param index [out] the index of the track
1192 * @return This function returns zero on success, or negative value with error
1196 int mm_player_get_current_track(MMHandleType hplayer, mmplayer_track_type_e type, int *index);
1199 * This function is to set the subtitle path
1201 * @param player [in] handle of player
1202 * @param path [in] subtitle path
1204 * @return This function returns zero on success, or negative value with error code.
1206 int mm_player_set_external_subtitle_path(MMHandleType player, const char *path);
1209 * This function is to set uri.
1211 * @param player [in] handle of player
1212 * @param uri [in] uri
1213 * @return This function returns zero on success, or negative value with error code.
1215 int mm_player_set_uri(MMHandleType player, const char *uri);
1218 * This function is to set next uri.
1220 * @param player [in] handle of player
1221 * @param uri [in] uri
1222 * @return This function returns zero on success, or negative value with error code.
1224 int mm_player_set_next_uri(MMHandleType player, const char *uri);
1227 * This function is to get next uri.
1229 * @param player [in] handle of player
1230 * @param uri [out] uri
1231 * @return This function returns zero on success, or negative value with error code.
1233 int mm_player_get_next_uri(MMHandleType player, char **uri);
1236 * This function is to decrease reference count of internal buffer.
1238 * @param buffer [in] video callback internal buffer
1241 void mm_player_video_stream_internal_buffer_unref(void *buffer);
1243 /**mm_player_submit_packet
1244 * This function is to submit buffer to appsrc. \n
1245 * @param player [in] Handle of player.
1246 * @param buf [in] buffer to be submit in appsrc in external feeder case.
1247 * @param len [in] length of buffer.
1248 * @param pts [in] timestamp of buffer.
1249 * @param streamtype [in] stream type of buffer.
1250 * @return This function returns zero on success, or negative value with error code.
1252 int mm_player_submit_packet(MMHandleType player, media_packet_h packet);
1254 /**mm_player_set_video_info
1255 * This function is to set caps of src pad of video appsrc in external feeder case. \n
1256 * @param player [in] Handle of player.
1257 * @param media_format_h [in] Video stream info.
1258 * @return This function returns zero on success, or negative value with error code.
1260 int mm_player_set_video_info(MMHandleType player, media_format_h format);
1262 /**mm_player_set_audio_info
1263 * This function is to set caps of src pad of Audio appsrc in external feeder case. \n
1264 * @param player [in] Handle of player.
1265 * @param media_format_h [in] Audio stream info.
1266 * @return This function returns zero on success, or negative value with error code.
1268 int mm_player_set_audio_info(MMHandleType player, media_format_h format);
1270 /**mm_player_set_subtitle_info
1271 * This function is to set caps of src pad of subtitle appsrc in external feeder case. \n
1272 * @param player [in] Handle of player.
1273 * @param subtitle_stream_info [in] Subtitle stream info.
1274 * @return This function returns zero on success, or negative value with error code.
1276 int mm_player_set_subtitle_info(MMHandleType player, mmplayer_subtitle_stream_info_t *info);
1279 * This function is to set max size of buffer(appsrc).
1281 * @param player [in] Handle of player.
1282 * @param type [in] stream type
1283 * @param max_size [in] max bytes of buffer.
1285 * @return This function returns zero on success, or negative value with error
1288 int mm_player_set_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long max_size);
1291 * This function is to get max size of buffer(appsrc).
1293 * @param player [in] Handle of player.
1294 * @param type [in] stream type
1295 * @param max_size [out] max bytes of buffer.
1297 * @return This function returns zero on success, or negative value with error
1300 int mm_player_get_media_stream_buffer_max_size(MMHandleType player, mmplayer_stream_type_e type, unsigned long long *max_size);
1303 * This function is to set min percent of buffer(appsrc).
1305 * @param player [in] Handle of player.
1306 * @param type [in] stream type
1307 * @param min_percent [in] min percent of buffer.
1309 * @return This function returns zero on success, or negative value with error
1312 int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned min_percent);
1315 * This function is to get min percent of buffer(appsrc).
1317 * @param player [in] Handle of player.
1318 * @param type [in] stream type
1319 * @param min_percent [out] min percent of buffer.
1321 * @return This function returns zero on success, or negative value with error
1324 int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_stream_type_e type, unsigned int *min_percent);
1327 * This function set callback function for changing audio stream from player. \n
1328 * It's only supported when audio stream is included in file. \n
1330 * @param player [in] Handle of player.
1331 * @param callback [in] Audio stream changed callback function.
1332 * @param user_param [in] User parameter.
1334 * @return This function returns zero on success, or negative value with error
1336 * @see mm_player_stream_changed_callback
1339 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param);
1342 * This function is to get timeout value according to the content type for muse. \n
1343 * It's only supported when video stream is included in file. \n
1345 * @param player [in] Handle of player.
1346 * @param timeout [out] timeout value (sec).
1348 * @return This function returns zero on success, or negative value with error
1352 int mm_player_get_timeout(MMHandleType player, int *timeout);
1355 * This function is to set the dynamic resolution information. \n
1356 * It's only supported when video stream is included in file. \n
1358 * @param player [in] Handle of player.
1359 * @param drc [in] dynamic resolution info of media stream data
1361 * @return This function returns zero on success, or negative value with error
1365 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc);
1368 * This function is to release the video stream bo to reuse. \n
1369 * It's only supported when sw codec is used to decode video stream. \n
1371 * @param player [in] Handle of player.
1372 * @param bo [in] bo address to be released
1374 * @return This function returns zero on success, or negative value with error
1378 int mm_player_release_video_stream_bo(MMHandleType player, void *bo);
1381 * This function is to set sound stream info
1383 int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index);
1386 * This function is to manage the playback according to the external storage state
1388 int mm_player_manage_external_storage_state(MMHandleType player, int id, int state);
1391 * These functions are to set/get the max variant of HAS
1393 int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **var_info);
1394 int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, int width, int height);
1395 int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth, int *width, int *height);
1398 * These functions are to set/get the audio only mode
1400 int mm_player_set_audio_only(MMHandleType player, bool audio_only);
1401 int mm_player_get_audio_only(MMHandleType player, bool *audio_only);
1404 * These functions are to get the streaming bufferint time
1406 int mm_player_get_streaming_buffering_time(MMHandleType player, int *prebuffer_ms, int *rebuffer_ms);
1409 * These functions are to display the 360 video content
1411 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical);
1412 int mm_player_360_set_enabled(MMHandleType player, bool enabled);
1413 int mm_player_360_is_enabled(MMHandleType player, bool *enabled);
1415 int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch);
1416 int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch);
1418 int mm_player_360_set_zoom(MMHandleType player, float level);
1419 int mm_player_360_get_zoom(MMHandleType player, float *level);
1421 int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees);
1422 int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees);
1425 * This function is to set codec type
1427 int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type);
1430 * These functions are to apply the replaygain
1432 int mm_player_set_replaygain_enabled(MMHandleType player, bool enabled);
1433 int mm_player_is_replaygain_enabled(MMHandleType player, bool *enabled);
1436 * This function is to set/get video content ROI area
1438 int mm_player_set_video_roi_area(MMHandleType player, double scale_x, double scale_y, double scale_width, double scale_height);
1439 int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
1442 * This function is to set play speed for playback.
1444 * @param player [in] Handle of player.
1445 * @param ratio [in] Speed for playback.
1446 * @param streaming [in] If @c true, rate value can be set even if it is streaming playback.
1447 * @return This function returns zero on success, or negative value with error
1449 * @remark The current supported range is from -64x to 64x.
1450 * But, the quailty is dependent on codec performance.
1451 * And, the sound is muted under normal speed and more than double speed.
1455 int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming);
1458 * This function set callback function for receiving video stream from player.
1460 * @param player [in] Handle of player.
1461 * @param callback [in] Video stream callback function.
1462 * @param user_param [in] User parameter.
1464 * @return This function returns zero on success, or negative value with error
1469 int mm_player_set_video_decoded_callback(MMHandleType player, mm_player_video_decoded_callback callback, void *user_param);
1472 * This function set callback function for receiving audio stream from player.
1474 * @param player [in] Handle of player.
1475 * @param opt [in] audio extract option.
1476 * @param callback [in] audio stream callback function.
1477 * @param user_param [in] User parameter.
1479 * @return This function returns zero on success, or negative value with error
1482 * @see mm_player_audio_decoded_callback
1485 int mm_player_set_audio_decoded_callback(MMHandleType player, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
1488 * This function is to capture video frame.
1490 * @param player [in] Handle of player.
1492 * @return This function returns zero on success, or negative value with error
1495 * @remark Captured buffer is sent asynchronously through message callback with MM_MESSAGE_VIDEO_CAPTURED.
1496 * And, application should free the captured buffer directly.
1497 * @see MM_MESSAGE_VIDEO_CAPTURED
1500 int mm_player_do_video_capture(MMHandleType player);
1503 * This function changes the previous videosink plugin for a new one
1505 * @param player [in] Handle of player.
1506 * @param display_surface_type [in] display surface type to set
1507 * @param display_overlay [in] display overlay to set
1509 * @return This function returns zero on success, or negative value with error
1515 int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay);
1518 * This function set the application PID.
1520 * @param player [in] Handle of player
1521 * @param pid [in] application PID
1523 * @return This function returns zero on success, or negative value with error code.
1525 * @pre Player state should be MM_PLAYER_STATE_NULL.
1528 int mm_player_set_client_pid(MMHandleType player, int pid);
1538 #endif /* __MM_PLAYER_H__ */