diff options
author | Eunhae Choi <eunhae1.choi@samsung.com> | 2017-09-12 18:46:07 +0900 |
---|---|---|
committer | Eunhae Choi <eunhae1.choi@samsung.com> | 2017-09-12 19:43:56 +0900 |
commit | 1fd57ac068fb3bf50dcfd4aeab59455829c5c36c (patch) | |
tree | 22605ff54cbbbdf6058188d9b9d863a56266e27e | |
parent | 209c5477dbbc31977ebb4646793f39d0afedbe3a (diff) | |
parent | f3a684ad1c3cfba4e70815c4c15304d23a644f5e (diff) | |
download | libmm-player-1fd57ac068fb3bf50dcfd4aeab59455829c5c36c.tar.gz libmm-player-1fd57ac068fb3bf50dcfd4aeab59455829c5c36c.tar.bz2 libmm-player-1fd57ac068fb3bf50dcfd4aeab59455829c5c36c.zip |
[0.6.68] Merge branch 'tizen' into tizen_4.0submit/tizen_4.0/20170913.041751accepted/tizen/4.0/unified/20170913.153818
Change-Id: I18874a714a2063ec39dc3a3856f34ef096b8a4b3
-rw-r--r-- | packaging/libmm-player.spec | 2 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/include/mm_player.h | 610 | ||||
-rw-r--r-- | src/include/mm_player_360.h | 50 | ||||
-rw-r--r-- | src/include/mm_player_priv.h | 13 | ||||
-rw-r--r-- | src/include/mm_player_utils.h | 51 | ||||
-rw-r--r-- | src/mm_player.c | 496 | ||||
-rw-r--r-- | src/mm_player_capture.c | 2 | ||||
-rw-r--r-- | src/mm_player_common_priv.c | 10 | ||||
-rw-r--r-- | src/mm_player_priv.c | 1674 | ||||
-rw-r--r-- | src/mm_player_sound_focus.c | 41 | ||||
-rw-r--r-- | src/mm_player_utils.c | 156 |
12 files changed, 721 insertions, 2387 deletions
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index d7894d4..365f94f 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.64 +Version: 0.6.68 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/Makefile.am b/src/Makefile.am index ee184fe..698793c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,7 +49,8 @@ noinst_HEADERS = include/mm_player_utils.h \ include/mm_player_pd.h \ include/mm_player_tracks.h \ include/mm_player_streaming.h \ - include/mm_player_es.h + include/mm_player_es.h \ + include/mm_player_360.h libmmfplayer_la_LIBADD = $(GST_LIBS) \ $(MMCOMMON_LIBS) \ diff --git a/src/include/mm_player.h b/src/include/mm_player.h index 9a91623..00902cb 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -246,7 +246,7 @@ <td>range</td> </tr> <tr> - <td>"streaming_user_agent"</td> + <td>"streaming_user_agent"</td> <td>string</td> <td>N/A</td> </tr> @@ -676,17 +676,17 @@ #define BUFFER_MAX_PLANE_NUM (4) typedef struct { - MMPixelFormatType format; /**< image format */ - int width; /**< width of video buffer */ - int height; /**< height of video buffer */ - unsigned int timestamp; /**< timestamp of stream buffer (msec)*/ - unsigned int length_total; /**< total length of stream buffer (in byte)*/ + MMPixelFormatType format; /**< image format */ + int width; /**< width of video buffer */ + int height; /**< height of video buffer */ + unsigned int timestamp; /**< timestamp of stream buffer (msec)*/ + unsigned int length_total; /**< total length of stream buffer (in byte)*/ void *data[BUFFER_MAX_PLANE_NUM]; - void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */ - void *internal_buffer; /**< Internal buffer pointer */ - int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */ - int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */ -}MMPlayerVideoStreamDataType; + void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */ + void *internal_buffer; /**< Internal buffer pointer */ + int stride[BUFFER_MAX_PLANE_NUM]; /**< stride of plane */ + int elevation[BUFFER_MAX_PLANE_NUM]; /**< elevation of plane */ +} MMPlayerVideoStreamDataType; /** * Enumerations of player state. @@ -714,48 +714,48 @@ typedef enum { * Enumeration for attribute values types. */ typedef enum { - MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */ - MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */ - MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */ - MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */ - MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */ - MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */ - MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */ - MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */ + MM_PLAYER_ATTRS_TYPE_INVALID = -1, /**< Type is invalid */ + MM_PLAYER_ATTRS_TYPE_INT, /**< Integer type */ + MM_PLAYER_ATTRS_TYPE_DOUBLE, /**< Double type */ + MM_PLAYER_ATTRS_TYPE_STRING, /**< UTF-8 String type */ + MM_PLAYER_ATTRS_TYPE_DATA, /**< Pointer type */ + MM_PLAYER_ATTRS_TYPE_ARRAY, /**< Array type */ + MM_PLAYER_ATTRS_TYPE_RANGE, /**< Range type */ + MM_PLAYER_ATTRS_TYPE_NUM, /**< Number of attribute type */ } MMPlayerAttrsType; /** * Enumeration for attribute validation type. */ typedef enum { - MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */ - MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */ - MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */ - MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */ - MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */ - MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */ + MM_PLAYER_ATTRS_VALID_TYPE_INVALID = -1, /**< Invalid validation type */ + MM_PLAYER_ATTRS_VALID_TYPE_NONE, /**< Do not check validity */ + MM_PLAYER_ATTRS_VALID_TYPE_INT_ARRAY, /**< validity checking type of integer array */ + MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE, /**< validity checking type of integer range */ + MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_ARRAY, /**< validity checking type of double array */ + MM_PLAYER_ATTRS_VALID_TYPE_DOUBLE_RANGE, /**< validity checking type of double range */ } MMPlayerAttrsValidType; /** * Enumeration for attribute access flag. */ typedef enum { - MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */ - MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */ - MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */ - MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */ + MM_PLAYER_ATTRS_FLAG_NONE = 0, /**< None flag is set */ + MM_PLAYER_ATTRS_FLAG_READABLE = 1 << 0, /**< Readable */ + MM_PLAYER_ATTRS_FLAG_WRITABLE = 1 << 1, /**< Writable */ + MM_PLAYER_ATTRS_FLAG_MODIFIED = 1 << 2, /**< Modified */ - MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */ + MM_PLAYER_ATTRS_FLAG_RW = MM_PLAYER_ATTRS_FLAG_READABLE | MM_PLAYER_ATTRS_FLAG_WRITABLE, /**< Readable and Writable */ } MMPlayerAttrsFlag; /** * Enumeration for progressive download */ typedef enum { - MM_PLAYER_PD_MODE_NONE, - MM_PLAYER_PD_MODE_URI, - MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario -}MMPlayerPDMode; + MM_PLAYER_PD_MODE_NONE, + MM_PLAYER_PD_MODE_URI, + MM_PLAYER_PD_MODE_FILE // not tested yet, because of no fixed scenario +} MMPlayerPDMode; /** * Enumeration of track types @@ -765,7 +765,7 @@ typedef enum { MM_PLAYER_TRACK_TYPE_VIDEO, MM_PLAYER_TRACK_TYPE_TEXT, MM_PLAYER_TRACK_TYPE_MAX -}MMPlayerTrackType; +} MMPlayerTrackType; /** * Enumeration of runtime buffering mode @@ -774,10 +774,9 @@ typedef enum { MM_PLAYER_BUFFERING_MODE_ADAPTIVE = 0, /**< default, If buffering is occurred, player will consider the bandwidth to adjust buffer setting. */ MM_PLAYER_BUFFERING_MODE_FIXED, /**< player will set buffer size with this fixed size value. */ MM_PLAYER_BUFFERING_MODE_MAX, -}MMPlayerBufferingMode; +} MMPlayerBufferingMode; -typedef enum -{ +typedef enum { MM_PLAYER_FOCUS_CHANGED_COMPLETED = 0, MM_PLAYER_FOCUS_CHANGED_BY_MEDIA, MM_PLAYER_FOCUS_CHANGED_BY_CALL, @@ -804,8 +803,7 @@ typedef enum { /** * Enumeration of media stream buffer status */ -typedef enum -{ +typedef enum { MM_PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, MM_PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW, } MMPlayerMediaStreamBufferStatus; @@ -813,8 +811,7 @@ typedef enum /** * Enumeration for stream type. */ -typedef enum -{ +typedef enum { MM_PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */ MM_PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */ MM_PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */ @@ -883,8 +880,7 @@ typedef struct { * Video stream info in external demux case * **/ -typedef struct _VideoStreamInfo -{ +typedef struct _VideoStreamInfo { const char *mime; unsigned int framerate_num; unsigned int framerate_den; @@ -893,14 +889,13 @@ typedef struct _VideoStreamInfo unsigned char *codec_extradata; unsigned int extradata_size; unsigned int version; -}MMPlayerVideoStreamInfo; +} MMPlayerVideoStreamInfo; /** * Audio stream info in external demux case * **/ -typedef struct _AudioStreamInfo -{ +typedef struct _AudioStreamInfo { const char *mime; unsigned int channels; unsigned int sample_rate; @@ -914,18 +909,17 @@ typedef struct _AudioStreamInfo // unsigned int depth; // unsigned int endianness; // bool signedness; -}MMPlayerAudioStreamInfo; +} MMPlayerAudioStreamInfo; /** * Subtitle stream info in external demux case * **/ -typedef struct _SubtitleStreamInfo -{ +typedef struct _SubtitleStreamInfo { const char *mime; unsigned int codec_tag; void *context; //for smpte text -}MMPlayerSubtitleStreamInfo; +} MMPlayerSubtitleStreamInfo; /** * Audio stream callback function type. @@ -956,7 +950,7 @@ typedef bool (*mm_player_track_selected_subtitle_language_callback)(int track_n * * @param status [in] buffer status * @param user_param [in] User defined parameter which is passed when set - * to enough data callback or need data callback + * to enough data callback or need data callback * * @return This callback function have to return MM_ERROR_NONE. */ @@ -967,7 +961,7 @@ typedef bool (*mm_player_media_stream_buffer_status_callback) (MMPlayerStreamTyp * * @param offset [in] offset for the buffer playback * @param user_param [in] User defined parameter which is passed when set - * to seek data callback + * to seek data callback * * @return This callback function have to return MM_ERROR_NONE. */ @@ -995,23 +989,22 @@ typedef bool (*mm_player_stream_changed_callback) (void *user_param); * And, mutex, gstreamer and other resources are initialized at this time. \n * If player is created, the state will become MM_PLAYER_STATE_NULL. * - * @param player [out] Handle of player + * @param player [out] Handle of player * - * @return This function returns zero on success, or negative value with error code. \n - * Please refer 'mm_error.h' to know it in detail. - * @pre None - * @post MM_PLAYER_STATE_NULL - * @see mm_player_destroy - * @remark You can create multiple handles on a context at the same time. \n - * However, player cannot guarantee proper operation because of limitation of resources, \n - * such as audio device or display device. + * @return This function returns zero on success, or negative value with error code. \n + * Please refer 'mm_error.h' to know it in detail. + * @pre None + * @post MM_PLAYER_STATE_NULL + * @see mm_player_destroy + * @remark You can create multiple handles on a context at the same time. \n + * However, player cannot guarantee proper operation because of limitation of resources, \n + * such as audio device or display device. * * @par Example * @code char *g_err_attr_name = NULL; -if (mm_player_create(&g_player) != MM_ERROR_NONE) -{ +if (mm_player_create(&g_player) != MM_ERROR_NONE) { LOGE("failed to create player\n"); } @@ -1019,8 +1012,7 @@ if (mm_player_set_attribute(g_player, &g_err_attr_name, "profile_uri", filename, strlen(filename), "display_overlay", (void*)&g_win.xid, sizeof(g_win.xid), - NULL) != MM_ERROR_NONE) -{ + NULL) != MM_ERROR_NONE) { LOGE("failed to set %s attribute\n", g_err_attr_name); free(g_err_attr_name); } @@ -1034,20 +1026,19 @@ int mm_player_create(MMHandleType *player); * This function releases player object and all resources which were created by mm_player_create(). \n * And, player handle will also be destroyed. * - * @param player [in] Handle of player + * @param player [in] Handle of player * - * @return This function returns zero on success, or negative value with error code. - * @pre Player state may be MM_PLAYER_STATE_NULL. \n - * But, it can be called in any state. - * @post Because handle is released, there is no any state. - * @see mm_player_create - * @remark This method can be called with a valid player handle from any state to \n - * completely shutdown the player operation. + * @return This function returns zero on success, or negative value with error code. + * @pre Player state may be MM_PLAYER_STATE_NULL. \n + * But, it can be called in any state. + * @post Because handle is released, there is no any state. + * @see mm_player_create + * @remark This method can be called with a valid player handle from any state to \n + * completely shutdown the player operation. * * @par Example * @code -if (mm_player_destroy(g_player) != MM_ERROR_NONE) -{ +if (mm_player_destroy(g_player) != MM_ERROR_NONE) { LOGE("failed to destroy player\n"); } * @endcode @@ -1080,48 +1071,46 @@ int mm_player_sound_register(MMHandleType player, int pid); * @pre Player state should be MM_PLAYER_STATE_NULL. * @remark None */ -int mm_player_get_client_pid (MMHandleType player, int* pid); +int mm_player_get_client_pid(MMHandleType player, int* pid); /** * This function parses uri and makes gstreamer pipeline by uri scheme. \n * So, uri should be set before realizing with mm_player_set_attribute(). \n * - * @param player [in] Handle of player + * @param player [in] Handle of player * - * @return This function returns zero on success, or negative value with error code. + * @return This function returns zero on success, or negative value with error code. * - * @pre Player state should be MM_PLAYER_STATE_NULL. - * @post Player state will be MM_PLAYER_STATE_READY. - * @see mm_player_unrealize - * @remark None + * @pre Player state should be MM_PLAYER_STATE_NULL. + * @post player state will be MM_PLAYER_STATE_READY. + * @see mm_player_unrealize + * @remark None * @par Example * @code -if (mm_player_realize(g_player) != MM_ERROR_NONE) -{ +if (mm_player_realize(g_player) != MM_ERROR_NONE) { LOGE("failed to realize player\n"); } * @endcode */ -int mm_player_realize(MMHandleType player) ; +int mm_player_realize(MMHandleType player); /** * This function uninitializes player object. So, resources and allocated memory \n * will be freed. And, gstreamer pipeline is also destroyed. So, if you want to play \n * other contents, player should be created again after destruction or realized with new uri. * - * @param player [in] Handle of player + * @param player [in] Handle of player * - * @return This function returns zero on success, or negative value with error code. - * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n - * But, it can be called in any state. - * @post Player state will be MM_PLAYER_STATE_NULL. - * @see mm_player_realize - * @remark This method can be called with a valid player handle from any state. + * @return This function returns zero on success, or negative value with error code. + * @pre Player state may be MM_PLAYER_STATE_READY to unrealize. \n + * But, it can be called in any state. + * @post Player state will be MM_PLAYER_STATE_NULL. + * @see mm_player_realize + * @remark This method can be called with a valid player handle from any state. * * @par Example * @code -if (mm_player_unrealize(g_player) != MM_ERROR_NONE) -{ +if (mm_player_unrealize(g_player) != MM_ERROR_NONE) { LOGE("failed to unrealize player\n"); } * @endcode @@ -1132,17 +1121,16 @@ int mm_player_unrealize(MMHandleType player); * This function is to get current state of player. \n * Application have to check current state before doing some action. * - * @param player [in] Handle of player - * @param state [out] current state of player on success + * @param player [in] Handle of player + * @param state [out] current state of player on success * - * @return This function returns zero on success, or negative value with error code. + * @return This function returns zero on success, or negative value with error code. * - * @see MMPlayerStateType - * @remark None + * @see MMPlayerStateType + * @remark None * @par Example * @code -if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE) -{ +if (mm_player_get_state(g_player, &state) != MM_ERROR_NONE) { LOGE("failed to get state\n"); } * @endcode @@ -1185,7 +1173,7 @@ int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume); * @return This function returns zero on success, or negative value with error code. * * @see MMPlayerVolumeType, mm_player_set_volume - * @remark None + * @remark None * @par Example * @code MMPlayerVolumeType volume; @@ -1193,7 +1181,7 @@ int i; if (mm_player_get_volume(g_player, &volume) != MM_ERROR_NONE) { - LOGW("failed to get volume\n"); + LOGW("failed to get volume\n"); } for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++) @@ -1215,7 +1203,7 @@ int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume); * @pre Player state may be MM_PLAYER_STATE_READY. * @post Player state will be MM_PLAYER_STATE_PLAYING. * @see mm_player_stop - * @remark None + * @remark None * @par Example * @code if (mm_player_start(g_player) != MM_ERROR_NONE) @@ -1238,7 +1226,7 @@ int mm_player_start(MMHandleType player); * @pre Player state may be MM_PLAYER_STATE_PLAYING. * @post Player state will be MM_PLAYER_STATE_READY. * @see mm_player_start - * @remark None + * @remark None * @par Example * @code if (mm_player_stop(g_player) != MM_ERROR_NONE) @@ -1259,7 +1247,7 @@ int mm_player_stop(MMHandleType player); * @pre Player state may be MM_PLAYER_STATE_PLAYING. * @post Player state will be MM_PLAYER_STATE_PAUSED. * @see mm_player_resume - * @remark None + * @remark None * @par Example * @code if (mm_player_pause(g_player) != MM_ERROR_NONE) @@ -1280,7 +1268,7 @@ int mm_player_pause(MMHandleType player); * @pre Player state may be MM_PLAYER_STATE_PAUSED. * @post Player state will be MM_PLAYER_STATE_PLAYING. * @see mm_player_pause - * @remark None + * @remark None * @par Example * @code if (mm_player_resume(g_player) != MM_ERROR_NONE) @@ -1323,7 +1311,7 @@ int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, in * * @return This function returns zero on success, or negative value with errors * @see MMPlayerPosFormatType, mm_player_set_position - * @remark the unit of time-based format is millisecond and other case is percent. + * @remark the unit of time-based format is millisecond and other case is percent. * @par Example * @code int position = 0; @@ -1341,14 +1329,14 @@ int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, un /** * This function is to get current buffer position of playback content. * - * @param player [in] Handle of player. - * @param format [in] Format of position. - * @param start_pos [out] contains buffer start position on success or zero in case of failure. - * @param stop_pos [out] contains buffer current position on success or zero in case of failure. + * @param player [in] Handle of player. + * @param format [in] Format of position. + * @param start_pos [out] contains buffer start position on success or zero in case of failure. + * @param stop_pos [out] contains buffer current position on success or zero in case of failure. * * @return This function returns zero on success, or negative value with errors * @see MMPlayerPosFormatType, mm_player_set_position - * @remark the unit of time-based format is millisecond and other case is percent. + * @remark the unit of time-based format is millisecond and other case is percent. * @par Example * @code int start_pos = 0, stop_pos = 0; @@ -1371,7 +1359,7 @@ int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType for * * @return This function returns zero on success, or negative value with error code. * @see mm_player_deactivate_section_repeat - * @remark None + * @remark None * @par Example * @code int position; @@ -1391,7 +1379,7 @@ int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int en * * @return This function returns zero on success, or negative value with error code. * @see mm_player_activate_section_repeat - * @remark None + * @remark None * @par Example * @code if ( mm_player_deactivate_section_repeat(g_player) != MM_ERROR_NONE) @@ -1412,7 +1400,7 @@ int mm_player_deactivate_section_repeat(MMHandleType player); * * @return This function returns zero on success, or negative value with error code. * @see MMMessageCallback - * @remark None + * @remark None * @par Example * @code int msg_callback(int message, MMMessageParamType *param, void *user_param) @@ -1423,17 +1411,17 @@ int msg_callback(int message, MMMessageParamType *param, void *user_param) //do something break; - case MM_MESSAGE_END_OF_STREAM: - //do something - break; + case MM_MESSAGE_END_OF_STREAM: + //do something + break; case MM_MESSAGE_STATE_CHANGED: //do something - break; + break; case MM_MESSAGE_BEGIN_OF_STREAM: //do something - break; + break; default: break; @@ -1453,14 +1441,14 @@ int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callba * It's only supported when audio stream is included in file. \n * So, if there is video stream or DRM content, it can't be used. * - * @param player [in] Handle of player. - * @param callback [in] Audio stream callback function. - * @param user_param [in] User parameter. + * @param player [in] Handle of player. + * @param callback [in] Audio stream callback function. + * @param user_param [in] User parameter. * - * @return This function returns zero on success, or negative value with error - * code. - * @see mm_player_audio_stream_callback - * @remark It can be used for audio playback only. + * @return This function returns zero on success, or negative value with error + * code. + * @see mm_player_audio_stream_callback + * @remark It can be used for audio playback only. * @par Example * @code bool audio_callback(void *stream, int stream_size, void *user_param) @@ -1471,7 +1459,7 @@ bool audio_callback(void *stream, int stream_size, void *user_param) mm_player_set_audio_stream_callback(g_player, audio_callback, NULL); * @endcode */ - int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param); +int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_stream_callback callback, void *user_param); /** * This function is to mute volume of player @@ -1481,7 +1469,7 @@ mm_player_set_audio_stream_callback(g_player, audio_callback, NULL); * * @return This function returns zero on success, or negative value with error code * @see mm_player_get_mute - * @remark None + * @remark None * @par Example * @code if (mm_player_set_mute(g_player, TRUE) != MM_ERROR_NONE) @@ -1500,7 +1488,7 @@ int mm_player_set_mute(MMHandleType player, int mute); * * @return This function returns zero on success, or negative value with error code * @see mm_player_set_mute - * @remark None + * @remark None * @par Example * @code int mute; @@ -1525,7 +1513,7 @@ int mm_player_get_mute(MMHandleType player, int *mute); * @return This function returns zero on success, or negative value with error * code * @see mm_player_adjust_subtitle_position - * @remark None + * @remark None * @par Example * @code int pos; @@ -1547,7 +1535,7 @@ int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatTyp * postive offset to make video lag * negative offset to make video lead */ -int mm_player_adjust_video_position(MMHandleType player,int offset); +int mm_player_adjust_video_position(MMHandleType player, int offset); /** * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n @@ -1562,7 +1550,7 @@ int mm_player_adjust_video_position(MMHandleType player,int offset); * @return This function returns zero on success, or negative value with error * code * @see mm_player_get_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE - * @remark None + * @remark None * @par Example * @code mm_player_set_attribute(g_player, @@ -1588,7 +1576,7 @@ int mm_player_set_subtitle_silent(MMHandleType player, int silent); * @return This function returns zero on success, or negative value with error * code * @see mm_player_set_subtitle_silent, MM_MESSAGE_UPDATE_SUBTITLE - * @remark None + * @remark None * @par Example * @code int silent = FALSE; @@ -1605,17 +1593,17 @@ int mm_player_get_subtitle_silent(MMHandleType player, int *silent); * This function is to set attributes into player. Multiple attributes can be set simultaneously. \n * If one of attribute fails, this function will stop at the point and let you know the name which is failed. \n * - * @param player [in] Handle of player. - * @param err_attr_name [out] Name of attribute which is failed to set - * @param first_attribute_name [in] Name of the first attribute to set - * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL. - * But, in the case of data or string type, it should be name/value/size. + * @param player [in] Handle of player. + * @param err_attr_name [out] Name of attribute which is failed to set + * @param first_attribute_name [in] Name of the first attribute to set + * @param ... [in] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL. + * But, in the case of data or string type, it should be name/value/size. * - * @return This function returns zero on success, or negative value with error code. + * @return This function returns zero on success, or negative value with error code. * - * @see mm_player_get_attribute - * @remark This function must be terminated by NULL argument. - * And, if this function is failed, err_attr_name param must be free. + * @see mm_player_get_attribute + * @remark This function must be terminated by NULL argument. + * And, if this function is failed, err_attr_name param must be free. * @par Example * @code char *g_err_attr_name = NULL; @@ -1624,8 +1612,7 @@ if (mm_player_set_attribute(g_player, &g_err_attr_name, "profile_uri", filename, strlen(filename), "profile_play_count", count, - NULL) != MM_ERROR_NONE) -{ + NULL) != MM_ERROR_NONE) { LOGW("failed to set %s attribute\n", g_err_attr_name); free(g_err_attr_name); } @@ -1637,23 +1624,22 @@ int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const ch /** * This function is to get attributes from player. Multiple attributes can be got simultaneously. * - * @param player [in] Handle of player. - * @param err_attr_name [out] Name of attribute which is failed to get - * @param first_attribute_name [in] Name of the first attribute to get - * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL. - * But, in the case of data or string type, it should be name/value/size. - * - * @return This function returns zero on success, or negative value with error - * code. - * @see mm_player_set_attribute - * @remark This function must be terminated by NULL argument. - * And, if this function is failed, err_attr_name param must be free. + * @param player [in] Handle of player. + * @param err_attr_name [out] Name of attribute which is failed to get + * @param first_attribute_name [in] Name of the first attribute to get + * @param ... [out] Value for the first attribute, followed optionally by more name/value pairs, terminated by NULL. + * But, in the case of data or string type, it should be name/value/size. + * + * @return This function returns zero on success, or negative value with error + * code. + * @see mm_player_set_attribute + * @remark This function must be terminated by NULL argument. + * And, if this function is failed, err_attr_name param must be free. * @par Example * @code char *g_err_attr_name = NULL; -if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE) -{ +if (mm_player_get_attribute(g_player, &g_err_attr_name, "content_duration", &duration, NULL) != MM_ERROR_NONE) { LOGW("failed to set %s attribute\n", g_err_attr_name); free(g_err_attr_name); } @@ -1664,19 +1650,18 @@ int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const ch /** * This function is to get detail information of attribute. * - * @param player [in] Handle of player. - * @param attribute_name [in] Name of the attribute to get - * @param info [out] Attribute infomation + * @param player [in] Handle of player. + * @param attribute_name [in] Name of the attribute to get + * @param info [out] Attribute infomation * - * @return This function returns zero on success, or negative value with error - * code. + * @return This function returns zero on success, or negative value with error + * code. * - * @see mm_player_set_attribute, mm_player_get_attribute - * @remark None + * @see mm_player_set_attribute, mm_player_get_attribute + * @remark None * @par Example * @code -if (mm_player_get_attribute_info (g_player, "display_method", &method_info) != MM_ERROR_NONE) -{ +if (mm_player_get_attribute_info(g_player, "display_method", &method_info) != MM_ERROR_NONE) { LOGW("failed to get info\n"); } @@ -1684,8 +1669,7 @@ LOGD("type:%d \n", method_info.type); //int, double.. LOGD("flag:%d \n", method_info.flag); //readable, writable.. LOGD("validity type:%d \n", method_info.validity_type); //range, array.. -if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE) -{ +if (method_info. validity_type == MM_PLAYER_ATTRS_VALID_TYPE_INT_RANGE) { LOGD("range min:%d\n", method_info.int_range.min); LOGD("range max:%d\n", method_info.int_range.max); } @@ -1696,14 +1680,11 @@ int mm_player_get_attribute_info(MMHandleType player, const char *attribute_nam /** * This function is to get download position and total size of progressive download * - * @param player [in] Handle of player. - * @param current_pos [in] Download position currently (bytes) - * @param total_size [in] Total size of file (bytes) - * - * @return This function returns zero on success, or negative value with error code. + * @param player [in] Handle of player. + * @param current_pos [in] Download position currently (bytes) + * @param total_size [in] Total size of file (bytes) * - * @see - * @remark + * @return This function returns zero on success, or negative value with error code. * @par Example * @code guint64 current_pos = 0LLU; @@ -1720,13 +1701,13 @@ int mm_player_get_pd_status(MMHandleType player, guint64 *current_pos, guint64 * /** * This function sets callback function for receiving messages of PD downloader. * - * @param player [in] Handle of player. - * @param callback [in] Message callback function. - * @param user_param [in] User parameter which is passed to callback function. + * @param player [in] Handle of player. + * @param callback [in] Message callback function. + * @param user_param [in] User parameter which is passed to callback function. * - * @return This function returns zero on success, or negative value with error code. + * @return This function returns zero on success, or negative value with error code. * @see - * @remark None + * @remark None * @par Example * @code int msg_callback(int message, MMMessageParamType *param, void *user_param) @@ -1736,9 +1717,9 @@ int msg_callback(int message, MMMessageParamType *param, void *user_param) case MM_MESSAGE_PD_DOWNLOADER_START: LOGD("Progressive download is started...\n"); break; - case MM_MESSAGE_PD_DOWNLOADER_END: - LOGD("Progressive download is ended...\n"); - break; + case MM_MESSAGE_PD_DOWNLOADER_END: + LOGD("Progressive download is ended...\n"); + break; default: break; } @@ -1753,21 +1734,18 @@ int mm_player_set_pd_message_callback(MMHandleType player, MMMessageCallback cal /** * This function is to get the track count * - * @param player [in] handle of player. - * @param track [in] type of the track type - * @param info [out] the count of the track + * @param player [in] handle of player. + * @param track [in] type of the track type + * @param info [out] the count of the track * - * @return This function returns zero on success, or negative value with error - * code. + * @return This function returns zero on success, or negative value with error + * code. * - * @see - * @remark None * @par Example * @code gint audio_count = 0; -if (mm_player_get_track_count (g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE) -{ +if (mm_player_get_track_count(g_player, MM_PLAYER_TRACK_TYPE_AUDIO, &audio_count) != MM_ERROR_NONE) { LOGW("failed to get audio track count\n"); } @@ -1779,74 +1757,59 @@ int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int /** * This function is to select the track * - * @param player [in] handle of player. - * @param type [in] type of the track type - * @param index [in] the index of the track + * @param player [in] handle of player. + * @param type [in] type of the track type + * @param index [in] the index of the track * - * @return This function returns zero on success, or negative value with error - * code. - * - * @see - * @remark None + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int index); #ifdef _MULTI_TRACK /** * This function is to add the track when user want multi subtitle * - * @param player [in] handle of player. - * @param index [in] the index of the track - * - * @return This function returns zero on success, or negative value with error - * code. + * @param player [in] handle of player. + * @param index [in] the index of the track * - * @see - * @remark None + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_track_add_subtitle_language(MMHandleType player, int index); /** * This function is to remove the track when user want multi subtitle * - * @param player [in] handle of player. - * @param index [in] the index of the track - * - * @return This function returns zero on success, or negative value with error - * code. + * @param player [in] handle of player. + * @param index [in] the index of the track * - * @see - * @remark None + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_track_remove_subtitle_language(MMHandleType player, int index); /** * This function is to notify which sutitle track is in use * - * @param player [in] handle of player. - * @param callback [in] callback function to register - * @param user_data [in] user data to be passed to the callback function - * - * @return This function returns zero on success, or negative value with error - * code. + * @param player [in] handle of player. + * @param callback [in] callback function to register + * @param user_data [in] user data to be passed to the callback function * - * @see - * @remark None + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_player_track_selected_subtitle_language_callback callback, void *user_param); #endif /** * This function is to get the track language * - * @param player [in] handle of player. - * @param type [in] type of the track type - * @param index [in] the index of the track - * @param code [out] language code in ISO 639-1(string) + * @param player [in] handle of player. + * @param type [in] type of the track type + * @param index [in] the index of the track + * @param code [out] language code in ISO 639-1(string) * - * @return This function returns zero on success, or negative value with error - * code. - * - * @see - * @remark None + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType type, int index, char **code); @@ -1859,55 +1822,17 @@ int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType ty * * @return This function returns zero on success, or negative value with error * code. - * - * @see - * @remark None */ int mm_player_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, int *index); /** - * This function is to set the start position of zoom - * - * @param player [in] handle of player - * @param level [in] level of zoom - * @param x [in] start x position - * @param y [in] start y position - * - * @return This function returns zero on success, or negative value with error - * code. - * - * @see - * @remark None - */ -int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y); - -/** - * This function is to get the start position of zoom - * - * @param player [in] handle of player - * @param type [out] current level of zoom - * @param x [out] start x position - * @param y [out] start y position - * - * @return This function returns zero on success, or negative value with error - * code. - * - * @see - * @remark None - */ -int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y); - -/** * This function is to set the subtitle path * * @param player [in] handle of player * @param path [in] subtitle path * * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_set_external_subtitle_path(MMHandleType player, const char* path); @@ -1921,9 +1846,6 @@ int mm_player_set_external_subtitle_path(MMHandleType player, const char* path); * @param media_clock [in] media clock information * @param audio_time [in] audio timestamp information * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_set_video_share_master_clock(MMHandleType player, long long clock, long long clock_delta, long long video_time, long long media_clock, long long audio_time); /** @@ -1934,9 +1856,6 @@ int mm_player_set_video_share_master_clock(MMHandleType player, long long clock, * @param media_clock [out] media clock information * @param audio_time [out] audio timestamp information * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_get_video_share_master_clock(MMHandleType player, long long *video_time, long long *media_clock, long long *audio_time); @@ -1946,9 +1865,6 @@ int mm_player_get_video_share_master_clock(MMHandleType player, long long *video * @param player [in] handle of player * @param angle [out] orignal angle from content * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_get_video_rotate_angle(MMHandleType player, int *angle); @@ -1958,9 +1874,6 @@ int mm_player_get_video_rotate_angle(MMHandleType player, int *angle); * @param player [in] handle of player * @param mode [in] download mode * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode); @@ -1970,130 +1883,97 @@ int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode); * @param player [in] handle of player * @param enable [in] enable/disable * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_enable_sync_handler(MMHandleType player, bool enable); /** * This function is to set uri. * - * @param player [in] handle of player - * @param uri [in] uri - * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None + * @param player [in] handle of player + * @param uri [in] uri + * @return This function returns zero on success, or negative value with error code. */ int mm_player_set_uri(MMHandleType player, const char *uri); /** * This function is to set next uri. * - * @param player [in] handle of player - * @param uri [in] uri - * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None + * @param player [in] handle of player + * @param uri [in] uri + * @return This function returns zero on success, or negative value with error code. */ int mm_player_set_next_uri(MMHandleType player, const char *uri); /** * This function is to get next uri. * - * @param player [in] handle of player - * @param uri [out] uri - * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None + * @param player [in] handle of player + * @param uri [out] uri + * @return This function returns zero on success, or negative value with error code. */ int mm_player_get_next_uri(MMHandleType player, char **uri); /** * This function is to increase reference count of internal buffer. * - * @param buffer [in] video callback internal buffer - * @return This function returns buffer point; - * - * @see - * @remark None + * @param buffer [in] video callback internal buffer + * @return This function returns buffer point; */ void * mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer); /** * This function is to decrease reference count of internal buffer. * - * @param buffer [in] video callback internal buffer - * @return None; - * - * @see - * @remark None + * @param buffer [in] video callback internal buffer + * @return None; */ void mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer); /**mm_player_submit_packet * This function is to submit buffer to appsrc. \n - * @param player [in] Handle of player. - * @param buf [in] buffer to be submit in appsrc in external feeder case. - * @param len [in] length of buffer. - * @param pts [in] timestamp of buffer. - * @param streamtype [in] stream type of buffer. - * @return This function returns zero on success, or negative value with error code. - * @par Example - * - * @endcode + * @param player [in] Handle of player. + * @param buf [in] buffer to be submit in appsrc in external feeder case. + * @param len [in] length of buffer. + * @param pts [in] timestamp of buffer. + * @param streamtype [in] stream type of buffer. + * @return This function returns zero on success, or negative value with error code. */ int mm_player_submit_packet(MMHandleType player, media_packet_h packet); /**mm_player_set_video_info * This function is to set caps of src pad of video appsrc in external feeder case. \n - * @param player [in] Handle of player. - * @param media_format_h [in] Video stream info. - * @return This function returns zero on success, or negative value with error code. - * @par Example - * - * @endcode + * @param player [in] Handle of player. + * @param media_format_h [in] Video stream info. + * @return This function returns zero on success, or negative value with error code. */ -int mm_player_set_video_info (MMHandleType player, media_format_h format); +int mm_player_set_video_info(MMHandleType player, media_format_h format); /**mm_player_set_audio_info * This function is to set caps of src pad of Audio appsrc in external feeder case. \n * @param player [in] Handle of player. * @param media_format_h [in] Audio stream info. * @return This function returns zero on success, or negative value with error code. - * @par Example - * - * @endcode */ -int mm_player_set_audio_info (MMHandleType player, media_format_h format); +int mm_player_set_audio_info(MMHandleType player, media_format_h format); /**mm_player_set_subtitle_info * This function is to set caps of src pad of subtitle appsrc in external feeder case. \n * @param player [in] Handle of player. * @param subtitle_stream_info [in] Subtitle stream info. * @return This function returns zero on success, or negative value with error code. - * @par Example - * - * @endcode */ -int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *info); +int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *info); /** * This function set callback function for receiving need or enough data message from player. * - * @param player [in] Handle of player. - * @param type [in] stream type - * @param callback [in] data callback function for stream type. - * @param user_param [in] User parameter. + * @param player [in] Handle of player. + * @param type [in] stream type + * @param callback [in] data callback function for stream type. + * @param user_param [in] User parameter. * - * @return This function returns zero on success, or negative value with error - * code. - * @remark - * @see - * @since + * @return This function returns zero on success, or negative value with error + * code. */ int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_buffer_status_callback callback, void * user_param); @@ -2107,9 +1987,6 @@ int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPla * * @return This function returns zero on success, or negative value with error * code. - * @remark - * @see - * @since */ int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerStreamType type, mm_player_media_stream_seek_data_callback callback, void * user_param); @@ -2122,9 +1999,6 @@ int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerS * * @return This function returns zero on success, or negative value with error * code. - * @remark - * @see - * @since */ int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long max_size); @@ -2137,9 +2011,6 @@ int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStre * * @return This function returns zero on success, or negative value with error * code. - * @remark - * @see - * @since */ int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStreamType type, unsigned long long *max_size); @@ -2152,9 +2023,6 @@ int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStre * * @return This function returns zero on success, or negative value with error * code. - * @remark - * @see - * @since */ int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned min_percent); @@ -2167,9 +2035,6 @@ int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerS * * @return This function returns zero on success, or negative value with error * code. - * @remark - * @see - * @since */ int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerStreamType type, unsigned int *min_percent); @@ -2199,7 +2064,6 @@ int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_s * @return This function returns zero on success, or negative value with error * code. * @see mm_player_stream_changed_callback - * @since */ int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param); @@ -2262,9 +2126,6 @@ int mm_player_release_video_stream_bo(MMHandleType player, void* bo); * @param player [in] handle of player * @param file_path [in] file path * @return This function returns zero on success, or negative value with error code. - * - * @see - * @remark None */ int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path); @@ -2298,6 +2159,21 @@ int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, i int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, int *rebuffer_ms); /** + * These functions are to display the 360 video content + */ +int mm_player_360_set_enable(MMHandleType player, bool enable); +int mm_player_360_is_enabled(MMHandleType player, bool *enabled); + +int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch); +int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch); + +int mm_player_360_set_zoom(MMHandleType player, float level); +int mm_player_360_get_zoom(MMHandleType player, float *level); + +int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees); +int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees); + +/** @} */ diff --git a/src/include/mm_player_360.h b/src/include/mm_player_360.h new file mode 100644 index 0000000..fb1bae2 --- /dev/null +++ b/src/include/mm_player_360.h @@ -0,0 +1,50 @@ +/* + * libmm-player + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MM_PLAYER_360_H__ +#define __MM_PLAYER_360_H__ + +/*======================================================================================= +| INCLUDE FILES | +========================================================================================*/ +#include <mm_types.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*======================================================================================= +| GLOBAL FUNCTION PROTOTYPES | +========================================================================================*/ + +int _mmplayer_360_set_enable(MMHandleType player, bool enable); +int _mmplayer_360_is_enabled(MMHandleType player, bool *enabled); +int _mmplayer_360_set_direction_of_view(MMHandleType player, float yaw, float pitch); +int _mmplayer_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch); +int _mmplayer_360_set_zoom(MMHandleType player, float level); +int _mmplayer_360_get_zoom(MMHandleType player, float *level); +int _mmplayer_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees); +int _mmplayer_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees); + +#ifdef __cplusplus +} +#endif + +#endif /* __MM_PLAYER_360_H__ */ diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index a22c7e4..51aafe8 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -121,7 +121,6 @@ enum alassink_sync { enum MMPlayerUriType { MM_PLAYER_URI_TYPE_NONE, /**< Player URI type None */ MM_PLAYER_URI_TYPE_URL_RTSP, /**< Player URI type RTSP */ - MM_PLAYER_URI_TYPE_URL_WFD, /**< Player URI type WFD */ MM_PLAYER_URI_TYPE_URL_HTTP, /**< Player URI type HTTP */ MM_PLAYER_URI_TYPE_URL_MMS, /**< Player URI type MMS */ MM_PLAYER_URI_TYPE_MEM, /**< Player URI type Mem */ @@ -702,8 +701,6 @@ typedef struct { guint resume_event_id; guint resumable_cancel_id; - gboolean keep_detecting_vcodec; - gboolean play_subtitle; gboolean is_subtitle_force_drop; // set TRUE after bus_cb get EOS @@ -731,16 +728,9 @@ typedef struct { MMPlayerSetMode set_mode; - /* decodbin usage */ - gboolean use_decodebin; - /* initialize values */ mm_player_ini_t ini; - /* check to use h/w codec */ - GstCaps* state_tune_caps; - gboolean ignore_asyncdone; - /* video share sync */ gint64 video_share_api_delta; gint64 video_share_clock_delta; @@ -850,8 +840,6 @@ gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index); int _mmplayer_sync_subtitle_pipeline(mm_player_t* player); -int _mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y); -int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y); int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode); int _mmplayer_use_system_clock(MMHandleType hplayer); int _mmplayer_set_video_share_master_clock(MMHandleType hplayer, long long clock, long long clock_delta, long long video_time, long long media_clock, long long audio_time); @@ -879,7 +867,6 @@ const gchar * __get_state_name(int state); gboolean __mmplayer_can_do_interrupt(mm_player_t *player); gboolean __is_streaming(mm_player_t* player); gboolean __is_rtsp_streaming(mm_player_t* player); -gboolean __is_wfd_streaming(mm_player_t* player); gboolean __is_live_streaming(mm_player_t* player); gboolean __is_http_streaming(mm_player_t* player); gboolean __is_http_live_streaming(mm_player_t* player); diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h index cf4d2ac..6890e58 100644 --- a/src/include/mm_player_utils.h +++ b/src/include/mm_player_utils.h @@ -112,24 +112,6 @@ do { \ #define MMPLAYER_FLEAVE(); #endif -#define MAX_SOUND_DEVICE_LEN 18 - -/* element linking */ -#ifdef GST_EXT_PAD_LINK_UNCHECKED -#define GST_ELEMENT_LINK_FILTERED gst_element_link_filtered_unchecked -#define GST_ELEMENT_LINK_MANY gst_element_link_many_unchecked -#define GST_ELEMENT_LINK gst_element_link_unchecked -#define GST_ELEMENT_LINK_PADS gst_element_link_pads_unchecked -#define GST_PAD_LINK gst_pad_link_unchecked -#else -#define GST_ELEMENT_LINK_FILTERED gst_element_link_filtered -#define GST_ELEMENT_LINK_MANY gst_element_link_many -#define GST_ELEMENT_LINK gst_element_link -#define GST_ELEMENT_UNLINK gst_element_unlink -#define GST_ELEMENT_LINK_PADS gst_element_link_pads -#define GST_PAD_LINK gst_pad_link -#endif - #define MMPLAYER_RETURN_IF_FAIL(expr) \ if (!(expr)) { \ LOGW("faild [%s]", #expr); \ @@ -199,12 +181,6 @@ if (!x_var) { \ goto ERROR; \ } -#define MMPLAYER_CHECK_CMD_IF_EXIT(x_player) \ -if (x_player->cmd == MMPLAYER_COMMAND_UNREALIZE || x_player->cmd == MMPLAYER_COMMAND_DESTROY) { \ - LOGD("it's exit state...\n");\ - goto ERROR; \ -} - /* generating dot */ #define MMPLAYER_GENERATE_DOT_IF_ENABLED(x_player, x_name) \ if (x_player->ini.generate_dot) { \ @@ -260,7 +236,6 @@ LOGD("-- prev %s, current %s, pending %s, target %s --\n", \ /* streaming */ #define MMPLAYER_IS_STREAMING(x_player) __is_streaming(x_player) #define MMPLAYER_IS_RTSP_STREAMING(x_player) __is_rtsp_streaming(x_player) -#define MMPLAYER_IS_WFD_STREAMING(x_player) __is_wfd_streaming(x_player) #define MMPLAYER_IS_HTTP_STREAMING(x_player) __is_http_streaming(x_player) #define MMPLAYER_IS_HTTP_PD(x_player) __is_http_progressive_down(x_player) #define MMPLAYER_IS_HTTP_LIVE_STREAMING(x_player) __is_http_live_streaming(x_player) @@ -272,34 +247,8 @@ LOGD("-- prev %s, current %s, pending %s, target %s --\n", \ #define MMPLAYER_URL_HAS_DASH_SUFFIX(x_player) __has_suffix(x_player, "mpd") #define MMPLAYER_URL_HAS_HLS_SUFFIX(x_player) __has_suffix(x_player, "m3u8") -/* etc */ -#define MMF_PLAYER_FILE_BACKUP_PATH "/tmp/media_temp." -#define MMPLAYER_PT_IS_AUDIO(x_pt) (strstr(x_pt, "_97") || strstr(x_pt, "audio")) -#define MMPLAYER_PT_IS_VIDEO(x_pt) (strstr(x_pt, "_96") || strstr(x_pt, "video")) - -#define MMPLAYER_VIDEO_SINK_CHECK(x_player) \ -do { \ - MMPLAYER_RETURN_VAL_IF_FAIL(x_player && \ - x_player->pipeline && \ - x_player->pipeline->videobin && \ - x_player->pipeline->videobin[MMPLAYER_V_SINK].gst, \ - MM_ERROR_PLAYER_NOT_INITIALIZED); \ -} while (0) - -enum { - MMPLAYER_DISPLAY_NULL = 0, - MMPLAYER_DISPLAY_HDMI_ACTIVE, - MMPLAYER_DISPLAY_MIRRORING_ACTIVE, -}; - bool util_is_sdp_file(const char *path); -int util_get_rank_increase(const char *factory_class); -int util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2); // @ int util_exist_file_path(const char *file_path); -bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size); -bool util_remove_file_backup(const char *backup_path); /* For Midi Player */ -int util_is_midi_type_by_mem(void *mem, int size); -int util_is_midi_type_by_file(const char *file_path); char** util_get_cookie_list(const char *cookies); bool util_check_valid_url(const char *proxy); const char* util_get_charset(const char *file_path); diff --git a/src/mm_player.c b/src/mm_player.c index c0e53dd..3fe4b30 100644 --- a/src/mm_player.c +++ b/src/mm_player.c @@ -36,6 +36,7 @@ #include "mm_player_tracks.h" #include "mm_player_es.h" #include "mm_player_sound_focus.h" +#include "mm_player_360.h" int mm_player_create(MMHandleType *player) { @@ -46,8 +47,7 @@ int mm_player_create(MMHandleType *player) /* alloc player structure */ new_player = g_malloc(sizeof(mm_player_t)); - if (!new_player) - { + if (!new_player) { LOGE("Cannot allocate memory for player\n"); result = MM_ERROR_PLAYER_RESOURCE_LIMIT; goto ERROR; @@ -61,22 +61,19 @@ int mm_player_create(MMHandleType *player) g_mutex_init(&new_player->playback_lock); /* load ini files */ - if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) - { + if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) { LOGE("can't load ini"); goto ERROR; } - if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) - { + if (MM_ERROR_NONE != mm_player_audio_effect_ini_load(&new_player->ini)) { LOGE("can't load audio ini"); goto ERROR; } /* create player */ result = _mmplayer_create_player((MMHandleType)new_player); - if(result != MM_ERROR_NONE) - { + if (result != MM_ERROR_NONE) { LOGE("failed to create player"); if (result != MM_ERROR_PLAYER_RESOURCE_LIMIT) result = MM_ERROR_PLAYER_INTERNAL; @@ -89,13 +86,12 @@ int mm_player_create(MMHandleType *player) ERROR: - if ( new_player ) - { - _mmplayer_destroy( (MMHandleType)new_player ); + if (new_player) { + _mmplayer_destroy((MMHandleType)new_player); g_mutex_clear(&new_player->cmd_lock); g_mutex_clear(&new_player->playback_lock); - MMPLAYER_FREEIF( new_player ); + MMPLAYER_FREEIF(new_player); } *player = (MMHandleType)0; @@ -108,19 +104,19 @@ int mm_player_destroy(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_destroy(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); g_mutex_clear(&((mm_player_t*)player)->cmd_lock); g_mutex_clear(&((mm_player_t*)player)->playback_lock); - memset( (mm_player_t*)player, 0x00, sizeof(mm_player_t) ); + memset((mm_player_t*)player, 0x00, sizeof(mm_player_t)); /* free player */ - g_free( (void*)player ); + g_free((void*)player); return result; } @@ -131,27 +127,27 @@ int mm_player_sound_register(MMHandleType player, int pid) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_sound_register_with_pid(player, pid); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } -int mm_player_get_client_pid (MMHandleType player, int* pid) +int mm_player_get_client_pid(MMHandleType player, int* pid) { int result = MM_ERROR_NONE; MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(pid, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_client_pid(player, pid); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -162,11 +158,11 @@ int mm_player_realize(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_realize(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -177,11 +173,11 @@ int mm_player_unrealize(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_unrealize(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -192,11 +188,11 @@ int mm_player_set_message_callback(MMHandleType player, MMMessageCallback callba MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_message_callback(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -218,11 +214,11 @@ int mm_player_set_audio_stream_callback(MMHandleType player, mm_player_audio_str MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_audiostream_cb(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -233,11 +229,11 @@ int mm_player_set_audio_stream_callback_ex(MMHandleType player, bool sync, mm_pl MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_audiostream_cb_ex(player, sync, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -248,11 +244,11 @@ int mm_player_set_video_stream_callback(MMHandleType player, mm_player_video_str MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_videostream_cb(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -263,11 +259,11 @@ int mm_player_do_video_capture(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_do_video_capture(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -279,11 +275,11 @@ int mm_player_set_volume(MMHandleType player, MMPlayerVolumeType *volume) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_volume(player, *volume); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -295,11 +291,11 @@ int mm_player_get_volume(MMHandleType player, MMPlayerVolumeType *volume) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_volume(player, volume); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -310,11 +306,11 @@ int mm_player_set_mute(MMHandleType player, int mute) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_mute(player, mute); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -326,11 +322,11 @@ int mm_player_get_mute(MMHandleType player, int *mute) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_mute(player, mute); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -356,11 +352,11 @@ int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_change_videosink(player, display_surface_type, display_overlay); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -371,11 +367,11 @@ int mm_player_start(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_start(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -386,11 +382,11 @@ int mm_player_stop(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_stop(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -401,11 +397,11 @@ int mm_player_pause(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_pause(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -416,11 +412,11 @@ int mm_player_resume(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_resume(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -431,11 +427,11 @@ int mm_player_activate_section_repeat(MMHandleType player, int start_pos, int en MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_activate_section_repeat(player, start_pos, end_pos); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -446,11 +442,11 @@ int mm_player_deactivate_section_repeat(MMHandleType player) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_deactivate_section_repeat(player); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -461,11 +457,11 @@ int mm_player_set_play_speed(MMHandleType player, float rate, bool streaming) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_playspeed(player, rate, streaming); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -476,17 +472,16 @@ int mm_player_set_position(MMHandleType player, MMPlayerPosFormatType format, in MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if (format >= MM_PLAYER_POS_FORMAT_NUM) - { + if (format >= MM_PLAYER_POS_FORMAT_NUM) { LOGE("wrong format\n"); return MM_ERROR_COMMON_INVALID_ARGUMENT; } - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_position(player, format, pos); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -498,17 +493,16 @@ int mm_player_get_position(MMHandleType player, MMPlayerPosFormatType format, un MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(pos, MM_ERROR_COMMON_INVALID_ARGUMENT); - if (format >= MM_PLAYER_POS_FORMAT_NUM) - { + if (format >= MM_PLAYER_POS_FORMAT_NUM) { LOGE("wrong format\n"); return MM_ERROR_COMMON_INVALID_ARGUMENT; } - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_position(player, (int)format, pos); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -520,11 +514,11 @@ int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType for MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(start_pos && stop_pos, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); - result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos ); + result = _mmplayer_get_buffer_position(player, (int)format, start_pos, stop_pos); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -535,11 +529,11 @@ int mm_player_set_external_subtitle_path(MMHandleType player, const char* path) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_external_subtitle_path(player, path); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -549,17 +543,16 @@ int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatTyp MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - if (format >= MM_PLAYER_POS_FORMAT_NUM) - { + if (format >= MM_PLAYER_POS_FORMAT_NUM) { LOGE("wrong format(%d) \n", format); return MM_ERROR_INVALID_ARGUMENT; } - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_adjust_subtitle_postion(player, format, pos); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -568,11 +561,11 @@ int mm_player_adjust_video_position(MMHandleType player, int offset) { int result = MM_ERROR_NONE; MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_adjust_video_postion(player, offset); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -583,11 +576,11 @@ int mm_player_set_subtitle_silent(MMHandleType player, int silent) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_subtitle_silent(player, silent); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -598,11 +591,11 @@ int mm_player_get_subtitle_silent(MMHandleType player, int* silent) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_subtitle_silent(player, silent); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -615,9 +608,9 @@ int mm_player_set_attribute(MMHandleType player, char **err_attr_name, const ch MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT); - va_start (var_args, first_attribute_name); + va_start(var_args, first_attribute_name); result = _mmplayer_set_attribute(player, err_attr_name, first_attribute_name, var_args); - va_end (var_args); + va_end(var_args); return result; } @@ -630,9 +623,9 @@ int mm_player_get_attribute(MMHandleType player, char **err_attr_name, const ch MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(first_attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT); - va_start (var_args, first_attribute_name); + va_start(var_args, first_attribute_name); result = _mmplayer_get_attribute(player, err_attr_name, first_attribute_name, var_args); - va_end (var_args); + va_end(var_args); return result; } @@ -671,11 +664,11 @@ int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType type, int * MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_track_count(player, type, count); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -686,11 +679,11 @@ int mm_player_select_track(MMHandleType player, MMPlayerTrackType type, int inde MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_select_track(player, type, index); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -701,11 +694,11 @@ int mm_player_track_add_subtitle_language(MMHandleType player, int index) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_track_add_subtitle_language(player, index); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -716,11 +709,11 @@ int mm_player_track_remove_subtitle_language(MMHandleType player, int index) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_track_remove_subtitle_language(player, index); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; @@ -733,11 +726,11 @@ int mm_player_get_current_track(MMHandleType player, MMPlayerTrackType type, int MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(index, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_current_track(player, type, index); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -748,42 +741,11 @@ int mm_player_get_track_language_code(MMHandleType player, MMPlayerTrackType ty MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_track_language_code(player, type, index, code); - MMPLAYER_CMD_UNLOCK( player ); - - return result; -} - -int mm_player_set_display_zoom(MMHandleType player, float level, int x, int y) -{ - int result = MM_ERROR_NONE; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - MMPLAYER_CMD_LOCK( player ); - - result = _mmplayer_set_display_zoom(player, level, x, y); - - MMPLAYER_CMD_UNLOCK( player ); - - return result; -} - -int mm_player_get_display_zoom(MMHandleType player, float *level, int *x, int *y) -{ - int result = MM_ERROR_NONE; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_COMMON_INVALID_ARGUMENT); - - MMPLAYER_CMD_LOCK( player ); - - result = _mmplayer_get_display_zoom(player, level, x, y); - - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -799,11 +761,11 @@ int mm_player_set_video_share_master_clock(MMHandleType player, MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_video_share_master_clock(player, clock, clock_delta, video_time, media_clock, audio_time); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -820,11 +782,11 @@ int mm_player_get_video_share_master_clock(MMHandleType player, MMPLAYER_RETURN_VAL_IF_FAIL(media_clock, MM_ERROR_COMMON_INVALID_ARGUMENT); MMPLAYER_RETURN_VAL_IF_FAIL(audio_time, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_video_share_master_clock(player, video_time, media_clock, audio_time); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -836,11 +798,11 @@ int mm_player_get_video_rotate_angle(MMHandleType player, int *angle) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(angle, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_video_rotate_angle(player, angle); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -851,11 +813,11 @@ int mm_player_set_video_hub_download_mode(MMHandleType player, bool mode) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_video_hub_download_mode(player, mode); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -866,11 +828,11 @@ int mm_player_enable_sync_handler(MMHandleType player, bool enable) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_enable_sync_handler(player, enable); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -881,11 +843,11 @@ int mm_player_set_uri(MMHandleType player, const char *uri) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_uri(player, uri); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; @@ -897,11 +859,11 @@ int mm_player_set_next_uri(MMHandleType player, const char *uri) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_next_uri(player, uri, FALSE); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; @@ -913,11 +875,11 @@ int mm_player_get_next_uri(MMHandleType player, char **uri) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_next_uri(player, uri); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; @@ -929,11 +891,11 @@ int mm_player_track_foreach_selected_subtitle_language(MMHandleType player, mm_p MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_track_foreach_selected_subtitle_language(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -946,11 +908,11 @@ int mm_player_has_closed_caption(MMHandleType player, bool *exist) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(exist, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_has_closed_caption(player, exist); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -976,16 +938,16 @@ int mm_player_submit_packet(MMHandleType player, media_packet_h packet) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); /* no lock here, otherwise callback for the "need-data" signal of appsrc will be blocking */ - //MMPLAYER_CMD_LOCK( player ); + //MMPLAYER_CMD_LOCK(player); result = _mmplayer_submit_packet(player, packet); - //MMPLAYER_CMD_UNLOCK( player ); + //MMPLAYER_CMD_UNLOCK(player); return result; } -int mm_player_set_video_info (MMHandleType player, media_format_h format) +int mm_player_set_video_info(MMHandleType player, media_format_h format) { int result = MM_ERROR_NONE; @@ -993,17 +955,17 @@ int mm_player_set_video_info (MMHandleType player, media_format_h format) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_video_info(player, format); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } -int mm_player_set_audio_info (MMHandleType player, media_format_h format) +int mm_player_set_audio_info(MMHandleType player, media_format_h format) { int result = MM_ERROR_NONE; @@ -1011,16 +973,16 @@ int mm_player_set_audio_info (MMHandleType player, media_format_h format) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_audio_info(player, format); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } -int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info) +int mm_player_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo *subtitle_stream_info) { int result = MM_ERROR_NONE; @@ -1028,11 +990,11 @@ int mm_player_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_subtitle_info(player, subtitle_stream_info); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1045,11 +1007,11 @@ int mm_player_set_media_stream_buffer_max_size(MMHandleType player, MMPlayerStre MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_media_stream_max_size(player, type, max_size); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1064,12 +1026,12 @@ int mm_player_get_media_stream_buffer_max_size(MMHandleType player, MMPlayerStre MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(max_size, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_media_stream_max_size(player, type, &_max_size); *max_size = _max_size; - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1082,11 +1044,11 @@ int mm_player_set_media_stream_buffer_min_percent(MMHandleType player, MMPlayerS MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_media_stream_min_percent(player, type, min_percent); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1100,11 +1062,11 @@ int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, MMPlayerS MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(min_percent, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_media_stream_min_percent(player, type, min_percent); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1117,11 +1079,11 @@ int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, MMPla MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1134,11 +1096,11 @@ int mm_player_set_media_stream_seek_data_callback(MMHandleType player, MMPlayerS MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1149,11 +1111,11 @@ int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_s MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_audiostream_changed_cb(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1164,11 +1126,11 @@ int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_s MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_videostream_changed_cb(player, callback, user_param); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1179,11 +1141,11 @@ int mm_player_set_pcm_spec(MMHandleType player, int samplerate, int channel) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_pcm_spec(player, samplerate, channel); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1195,11 +1157,11 @@ int mm_player_get_timeout(MMHandleType player, int *timeout) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(timeout, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_timeout(player, timeout); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1211,11 +1173,11 @@ int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *e MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1226,11 +1188,11 @@ int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_media_stream_dynamic_resolution(player, drc); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1241,11 +1203,13 @@ int mm_player_release_video_stream_bo(MMHandleType player, void* bo) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(bo, MM_ERROR_COMMON_INVALID_ARGUMENT); -// MMPLAYER_CMD_LOCK( player ); + + //MMPLAYER_CMD_LOCK(player); result = _mmplayer_video_stream_release_bo(player, bo); -// MMPLAYER_CMD_UNLOCK( player ); + //MMPLAYER_CMD_UNLOCK(player); + return result; } @@ -1255,11 +1219,11 @@ int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_file_buffering_path(player, file_path); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1271,12 +1235,12 @@ int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL((stream_type && (stream_index >= 0)), MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); _mmplayer_sound_unregister(&((mm_player_t*)player)->sound_focus); result = mm_player_set_attribute(player, NULL, "sound_stream_type", stream_type, strlen(stream_type), "sound_stream_index", stream_index, NULL); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1287,11 +1251,11 @@ int mm_player_manage_external_storage_state(MMHandleType player, int state) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_manage_external_storage_state(player, state); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1303,11 +1267,11 @@ int mm_player_get_adaptive_variant_info(MMHandleType player, int *num, char **va MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(num && var_info, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_adaptive_variant_info(player, num, var_info); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1318,11 +1282,11 @@ int mm_player_set_max_adaptive_variant_limit(MMHandleType player, int bandwidth, MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_max_adaptive_variant_limit(player, bandwidth, width, height); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1334,11 +1298,11 @@ int mm_player_get_max_adaptive_variant_limit(MMHandleType player, int *bandwidth MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(bandwidth && width && height, MM_ERROR_COMMON_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_max_adaptive_variant_limit(player, bandwidth, width, height); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1348,11 +1312,11 @@ int mm_player_set_streaming_buffering_time(MMHandleType player, int buffer_ms, i int result = MM_ERROR_NONE; MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_streaming_buffering_time(player, buffer_ms, rebuffer_ms); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1364,11 +1328,11 @@ int mm_player_get_streaming_buffering_time(MMHandleType player, int *buffer_ms, MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(buffer_ms && rebuffer_ms, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_streaming_buffering_time(player, buffer_ms, rebuffer_ms); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1378,11 +1342,11 @@ int mm_player_set_audio_only(MMHandleType player, bool audio_only) int result = MM_ERROR_NONE; MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_set_audio_only(player, audio_only); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); return result; } @@ -1394,11 +1358,131 @@ int mm_player_get_audio_only(MMHandleType player, bool *audio_only) MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT); - MMPLAYER_CMD_LOCK( player ); + MMPLAYER_CMD_LOCK(player); result = _mmplayer_get_audio_only(player, audio_only); - MMPLAYER_CMD_UNLOCK( player ); + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_set_enable(MMHandleType player, bool enable) +{ + int result = MM_ERROR_NONE; + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_set_enable(player, enable); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_is_enabled(MMHandleType player, bool *enabled) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(enabled, MM_ERROR_INVALID_ARGUMENT); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_is_enabled(player, enabled); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_set_direction_of_view(MMHandleType player, float yaw, float pitch) +{ + int result = MM_ERROR_NONE; + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_set_direction_of_view(player, yaw, pitch); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_get_direction_of_view(MMHandleType player, float *yaw, float *pitch) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(yaw && pitch, MM_ERROR_INVALID_ARGUMENT); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_get_direction_of_view(player, yaw, pitch); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_set_zoom(MMHandleType player, float level) +{ + int result = MM_ERROR_NONE; + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_set_zoom(player, level); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_get_zoom(MMHandleType player, float *level) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_INVALID_ARGUMENT); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_get_zoom(player, level); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_set_field_of_view(MMHandleType player, int horizontal_degrees, int vertical_degrees) +{ + int result = MM_ERROR_NONE; + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_set_field_of_view(player, horizontal_degrees, vertical_degrees); + + MMPLAYER_CMD_UNLOCK(player); + + return result; +} + +int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees, int *vertical_degrees) +{ + int result = MM_ERROR_NONE; + + MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + MMPLAYER_RETURN_VAL_IF_FAIL(horizontal_degrees && vertical_degrees, MM_ERROR_INVALID_ARGUMENT); + + MMPLAYER_CMD_LOCK(player); + + result = _mmplayer_360_get_field_of_view(player, horizontal_degrees, vertical_degrees); + + MMPLAYER_CMD_UNLOCK(player); return result; } diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c index 514ab7a..7f8c134 100644 --- a/src/mm_player_capture.c +++ b/src/mm_player_capture.c @@ -166,6 +166,8 @@ _mmplayer_do_video_capture(MMHandleType hplayer) return ret; } else { LOGW("invalid state(%d) to capture", player->state); + gst_object_unref(GST_OBJECT(pad)); + pad = NULL; return MM_ERROR_PLAYER_INVALID_STATE; } } diff --git a/src/mm_player_common_priv.c b/src/mm_player_common_priv.c index 675a955..acf3aec 100644 --- a/src/mm_player_common_priv.c +++ b/src/mm_player_common_priv.c @@ -425,14 +425,6 @@ __is_rtsp_streaming(mm_player_t* player) } gboolean -__is_wfd_streaming(mm_player_t* player) -{ - MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); - - return (player->profile.uri_type == MM_PLAYER_URI_TYPE_URL_WFD) ? TRUE : FALSE; -} - -gboolean __is_http_streaming(mm_player_t* player) { MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); @@ -445,7 +437,7 @@ __is_streaming(mm_player_t* player) { MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); - return (__is_http_progressive_down(player) || __is_rtsp_streaming(player) || __is_wfd_streaming(player) || __is_http_streaming(player) + return (__is_http_progressive_down(player) || __is_rtsp_streaming(player) || __is_http_streaming(player) || __is_http_live_streaming(player) || __is_dash_streaming(player) || __is_smooth_streaming(player)) ? TRUE : FALSE; } diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index b02a294..5579042 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -85,27 +85,14 @@ */ #define MM_PLAYER_FADEOUT_TIME_DEFAULT 0 -#define MM_PLAYER_MPEG_VNAME "mpegversion" -#define MM_PLAYER_DIVX_VNAME "divxversion" -#define MM_PLAYER_WMV_VNAME "wmvversion" -#define MM_PLAYER_WMA_VNAME "wmaversion" - #define DEFAULT_PLAYBACK_RATE 1.0 -#define PLAYBACK_RATE_EX_AUDIO_MIN 0.5 -#define PLAYBACK_RATE_EX_AUDIO_MAX 2.0 -#define PLAYBACK_RATE_EX_VIDEO_MIN 0.5 -#define PLAYBACK_RATE_EX_VIDEO_MAX 1.5 #define DEFAULT_NUM_OF_V_OUT_BUFFER 3 -#define GST_QUEUE_DEFAULT_TIME 4 -#define GST_QUEUE_HLS_TIME 8 - #define MMPLAYER_USE_FILE_FOR_BUFFERING(player) \ (((player)->profile.uri_type != MM_PLAYER_URI_TYPE_HLS) && \ (player->ini.http_use_file_buffer) && \ (player->http_file_buffering_path) && \ (strlen(player->http_file_buffering_path) > 0)) -#define MM_PLAYER_NAME "mmplayer" #define PLAYER_DISPLAY_MODE_DST_ROI 5 @@ -145,44 +132,28 @@ static void __mmplayer_gst_decode_callback(GstElement *decodebin, GstPad *pad, static void __mmplayer_gst_decode_unknown_type(GstElement *elem, GstPad* pad, GstCaps *caps, gpointer data); static gboolean __mmplayer_gst_decode_autoplug_continue(GstElement *bin, GstPad* pad, GstCaps * caps, gpointer data); static gint __mmplayer_gst_decode_autoplug_select(GstElement *bin, GstPad* pad, GstCaps * caps, GstElementFactory* factory, gpointer data); -//static GValueArray* __mmplayer_gst_decode_autoplug_factories(GstElement *bin, GstPad* pad, GstCaps * caps, gpointer data); static void __mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad* new_pad, gpointer data); static void __mmplayer_gst_decode_drained(GstElement *bin, gpointer data); static void __mmplayer_gst_element_added(GstElement* bin, GstElement* element, gpointer data); static GstElement * __mmplayer_create_decodebin(mm_player_t* player); static gboolean __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstCaps *caps); - static void __mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data); -static gboolean __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps); static void __mmplayer_pipeline_complete(GstElement *decodebin, gpointer data); static gboolean __mmplayer_is_midi_type(gchar* str_caps); static gboolean __mmplayer_is_only_mp3_type(gchar *str_caps); static void __mmplayer_set_audio_attrs(mm_player_t* player, GstCaps* caps); -//static void __mmplayer_check_video_zero_cpoy(mm_player_t* player, GstElementFactory* factory); - -static gboolean __mmplayer_close_link(mm_player_t* player, GstPad *srcpad, GstElement *sinkelement, const char *padname, const GList *templlist); -static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer data); -static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer data); static void __mmplayer_gst_rtp_no_more_pads(GstElement *element, gpointer data); -//static void __mmplayer_gst_wfd_dynamic_pad(GstElement *element, GstPad *pad, gpointer data); static void __mmplayer_gst_rtp_dynamic_pad(GstElement *element, GstPad *pad, gpointer data); static gboolean __mmplayer_get_stream_service_type(mm_player_t* player); static gboolean __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data); - - -static void __mmplayer_init_factories(mm_player_t* player); -static void __mmplayer_release_factories(mm_player_t* player); static void __mmplayer_release_misc(mm_player_t* player); static void __mmplayer_release_misc_post(mm_player_t* player); static gboolean __mmplayer_init_gstreamer(mm_player_t* player); static GstBusSyncReply __mmplayer_bus_sync_callback(GstBus * bus, GstMessage * message, gpointer data); static gboolean __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data); - static gboolean __mmplayer_gst_extract_tag_from_msg(mm_player_t* player, GstMessage *msg); static gboolean __mmplayer_gst_handle_duration(mm_player_t* player, GstMessage* msg); - -int __mmplayer_switch_audio_sink(mm_player_t* player); static gboolean __mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstElement* fakesink); static GstPadProbeReturn __mmplayer_audio_stream_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data); static void __mmplayer_video_stream_decoded_preroll_cb(GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data); @@ -195,8 +166,6 @@ static gboolean __mmplayer_handle_streaming_error(mm_player_t* player, GstMessag static void __mmplayer_handle_eos_delay(mm_player_t* player, int delay_in_ms); static void __mmplayer_cancel_eos_timer(mm_player_t* player); static gboolean __mmplayer_eos_timer_cb(gpointer u_data); -static gboolean __mmplayer_link_decoder(mm_player_t* player, GstPad *srcpad); -static gboolean __mmplayer_link_sink(mm_player_t* player, GstPad *srcpad); static int __mmplayer_handle_missed_plugin(mm_player_t* player); static int __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_class, const gchar* mime); static gboolean __mmplayer_configure_audio_callback(mm_player_t* player); @@ -207,7 +176,6 @@ static gpointer __mmplayer_next_play_thread(gpointer data); static gpointer __mmplayer_repeat_thread(gpointer data); static gboolean _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag); - static gboolean __mmplayer_add_dump_buffer_probe(mm_player_t *player, GstElement *element); static GstPadProbeReturn __mmplayer_dump_buffer_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer u_data); static void __mmplayer_release_dump_list(GList *dump_list); @@ -238,9 +206,6 @@ static gboolean __mmplayer_can_extract_pcm(mm_player_t* player); static void __mmplayer_do_sound_fadedown(mm_player_t* player, unsigned int time); static void __mmplayer_undo_sound_fadedown(mm_player_t* player); -static void __mmplayer_add_new_caps(GstPad* pad, GParamSpec* unused, gpointer data); -static void __mmplayer_set_unlinked_mime_type(mm_player_t* player, GstCaps *caps); - /* util */ static gboolean __is_ms_buff_src(mm_player_t* player); static gboolean __has_suffix(mm_player_t * player, const gchar * suffix); @@ -256,9 +221,6 @@ static void __mmplayer_activate_next_source(mm_player_t *player, GstState target static void __mmplayer_check_pipeline(mm_player_t* player); static gboolean __mmplayer_deactivate_selector(mm_player_t *player, MMPlayerTrackType type); static void __mmplayer_deactivate_old_path(mm_player_t *player); -#if 0 // We'll need this in future. -static int __mmplayer_gst_switching_element(mm_player_t *player, GstElement *search_from, const gchar *removal_name, const gchar *new_element_name); -#endif static void __mmplayer_update_buffer_setting(mm_player_t *player, GstMessage *buffering_msg); static GstElement *__mmplayer_element_create_and_link(mm_player_t *player, GstPad* pad, const char* name); @@ -381,7 +343,7 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) } if (player->duration < 0) { - LOGW("duration : %lld is Non-Initialized !!! \n",player->duration); + LOGW("duration : %lld is Non-Initialized !!! \n", player->duration); player->duration = 0; } @@ -643,7 +605,7 @@ __mmplayer_set_state(mm_player_t* player, int state) /* rtsp case, get content attrs by GstMessage */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { /* it's first time to update all content attrs. */ - _mmplayer_update_content_attrs( player, ATTR_ALL ); + _mmplayer_update_content_attrs(player, ATTR_ALL); } /* set max sound priority to keep own sound and not to mute other's one */ @@ -1035,7 +997,7 @@ __mmplayer_handle_buffering_message(mm_player_t* player) /* rtsp streaming pause makes rtsp server stop sending data. */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { LOGD("set pause state during buffering\n"); - __gst_pause( player, TRUE ); + __gst_pause(player, TRUE); } } } @@ -1044,7 +1006,7 @@ __mmplayer_handle_buffering_message(mm_player_t* player) case MM_PLAYER_STATE_PLAYING: /* rtsp streaming pause makes rtsp server stop sending data. */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { - __gst_pause ( player, TRUE ); + __gst_pause(player, TRUE); } break; @@ -1102,7 +1064,7 @@ static VariantData * __mmplayer_adaptive_var_info(const VariantData *self, gpointer user_data) { VariantData *var_info = NULL; - g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail(self != NULL, NULL); var_info = g_new0(VariantData, 1); if (!var_info) return NULL; @@ -1367,13 +1329,13 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) if ((GST_TIME_AS_SECONDS(player->last_position) <= 0) && (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED)) { msg_param.connection.buffering = player->streamer->buffering_percent; - MMPLAYER_POST_MSG( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } else { LOGD("Not updating Buffering Message for Live RTSP case !!!\n"); } } else { msg_param.connection.buffering = player->streamer->buffering_percent; - MMPLAYER_POST_MSG( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } } MMPLAYER_CMD_UNLOCK(player); @@ -1426,7 +1388,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) int retVal = MM_ERROR_NONE; LOGD("trying to play from (%lu) pending position\n", player->pending_seek.pos); - retVal = __gst_set_position( player, player->pending_seek.format, player->pending_seek.pos, TRUE ); + retVal = __gst_set_position(player, player->pending_seek.format, player->pending_seek.pos, TRUE); if (MM_ERROR_NONE != retVal) LOGE("failed to seek pending postion. just keep staying current position.\n"); @@ -1484,14 +1446,14 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) if (MMPLAYER_IS_RTSP_STREAMING(player) && (MMPLAYER_IS_LIVE_STREAMING(player))) { - LOGD("Current Buffering Percent = %d",player->streamer->buffering_percent); + LOGD("Current Buffering Percent = %d", player->streamer->buffering_percent); if (player->streamer->buffering_percent < 100) { MMMessageParamType msg_param = {0, }; LOGW("Posting Buffering Completed Message to Application !!!"); msg_param.connection.buffering = 100; - MMPLAYER_POST_MSG ( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } } } @@ -1656,9 +1618,9 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) extract duration ,codec info , resolution from sdp and get it by GstMessage */ if (!strcmp(structure_name, "rtspsrc_properties")) { - gchar *audio_codec = NULL; - gchar *video_codec = NULL; - gchar *video_frame_size = NULL; + gchar *audio_codec = NULL; + gchar *video_codec = NULL; + gchar *video_frame_size = NULL; gst_structure_get(gst_message_get_structure(msg), "rtsp_duration", G_TYPE_UINT64, &player->duration, NULL); LOGD("rtsp duration : %lld msec", GST_TIME_AS_MSECONDS(player->duration)); @@ -1682,11 +1644,11 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) char *seperator = strchr(video_frame_size, '-'); if (seperator) { - char video_width[10]={0,}; + char video_width[10] = {0,}; int frame_size_len = strlen(video_frame_size); int separtor_len = strlen(seperator); - strncpy(video_width,video_frame_size,(frame_size_len-separtor_len)); + strncpy(video_width, video_frame_size, (frame_size_len - separtor_len)); mm_attrs_set_int_by_name(attrs, "content_video_width", atoi(video_width)); seperator++; @@ -2213,7 +2175,7 @@ NEW_ELEMENT: } /* link it */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { + if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) { LOGE("failed to link autoplug element\n"); goto ERROR; } @@ -2225,138 +2187,8 @@ NEW_ELEMENT: MMPLAYER_ELEMENT_SET_STATE(new_element, GST_STATE_PLAYING); } - MMPLAYER_FLEAVE(); - - return; - -STATE_CHANGE_FAILED: -ERROR: - /* FIXIT : take care if new_element has already added to pipeline */ - if (new_element) - gst_object_unref(GST_OBJECT(new_element)); - - if (sinkpad) - gst_object_unref(GST_OBJECT(sinkpad)); - if (caps) - gst_object_unref(GST_OBJECT(caps)); - - /* FIXIT : how to inform this error to MSL ????? */ - /* FIXIT : I think we'd better to use g_idle_add() to destroy pipeline and - * then post an error to application - */ -} - - - -/* FIXIT : check indent */ -#if 0 -static void -__mmplayer_gst_wfd_dynamic_pad(GstElement *element, GstPad *pad, gpointer data) -{ - GstPad *sinkpad = NULL; - GstCaps* caps = NULL; - GstElement* new_element = NULL; - enum MainElementID element_id = MMPLAYER_M_NUM; - - mm_player_t* player = (mm_player_t*) data; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_IF_FAIL(element && pad); - MMPLAYER_RETURN_IF_FAIL(player && - player->pipeline && - player->pipeline->mainbin); - - LOGD("stream count inc : %d\n", player->num_dynamic_pad); - - { - LOGD("using pad caps to autopluging instead of doing typefind\n"); - caps = gst_pad_query_caps(pad); - MMPLAYER_CHECK_NULL(caps); - /* clear previous result*/ - player->have_dynamic_pad = FALSE; - new_element = gst_element_factory_make("rtpmp2tdepay", "wfd_rtp_depay"); - if (!new_element) { - LOGE("failed to create wfd rtp depay element\n"); - goto ERROR; - } - MMPLAYER_ELEMENT_SET_STATE(new_element, GST_STATE_READY); - /* add new element to the pipeline */ - if (FALSE == gst_bin_add(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), new_element)) { - LOGD("failed to add autoplug element to bin\n"); - goto ERROR; - } - /* get pad from element */ - sinkpad = gst_element_get_static_pad(GST_ELEMENT(new_element), "sink"); - if (!sinkpad) { - LOGD("failed to get sinkpad from autoplug element\n"); - goto ERROR; - } - /* link it */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { - LOGD("failed to link autoplug element\n"); - goto ERROR; - } - gst_object_unref(sinkpad); - sinkpad = NULL; - pad = gst_element_get_static_pad(GST_ELEMENT(new_element), "src"); - caps = gst_pad_query_caps(pad); - MMPLAYER_CHECK_NULL(caps); - MMPLAYER_ELEMENT_SET_STATE(new_element, GST_STATE_PLAYING); - /* create typefind */ - new_element = gst_element_factory_make("typefind", NULL); - if (!new_element) { - LOGD("failed to create typefind\n"); - goto ERROR; - } - - MMPLAYER_SIGNAL_CONNECT(player, - G_OBJECT(new_element), - MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, - "have-type", - G_CALLBACK(__mmplayer_typefind_have_type), - (gpointer)player); - - player->have_dynamic_pad = FALSE; - } - - /* excute new_element if created*/ - if (new_element) { - LOGD("adding new element to pipeline\n"); - - /* set state to READY before add to bin */ - MMPLAYER_ELEMENT_SET_STATE(new_element, GST_STATE_READY); - - /* add new element to the pipeline */ - if (FALSE == gst_bin_add(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), new_element)) { - LOGD("failed to add autoplug element to bin\n"); - goto ERROR; - } - - /* get pad from element */ - sinkpad = gst_element_get_static_pad(GST_ELEMENT(new_element), "sink"); - if (!sinkpad) { - LOGD("failed to get sinkpad from autoplug element\n"); - goto ERROR; - } - - /* link it */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { - LOGD("failed to link autoplug element\n"); - goto ERROR; - } - - gst_object_unref(sinkpad); - sinkpad = NULL; - - /* run. setting PLAYING here since streamming source is live source */ - MMPLAYER_ELEMENT_SET_STATE(new_element, GST_STATE_PLAYING); - } - - /* store handle to futher manipulation */ - player->pipeline->mainbin[element_id].id = element_id; - player->pipeline->mainbin[element_id].gst = new_element; + gst_caps_unref(caps); MMPLAYER_FLEAVE(); @@ -2372,14 +2204,13 @@ ERROR: gst_object_unref(GST_OBJECT(sinkpad)); if (caps) - gst_object_unref(GST_OBJECT(caps)); + gst_caps_unref(caps); /* FIXIT : how to inform this error to MSL ????? */ /* FIXIT : I think we'd better to use g_idle_add() to destroy pipeline and * then post an error to application */ } -#endif static GstPadProbeReturn __mmplayer_gst_selector_blocked(GstPad* pad, GstPadProbeInfo *info, gpointer data) @@ -2414,7 +2245,7 @@ __mmplayer_gst_selector_event_probe(GstPad * pad, GstPadProbeInfo * info, gpoint caps = gst_pad_query_caps(pad, NULL); if (!caps) { LOGE("failed to get caps from pad[%s:%s]", GST_DEBUG_PAD_NAME(pad)); - goto ERROR; + return ret; } str = gst_caps_get_structure(caps, 0); @@ -2728,7 +2559,7 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) if (MMPLAYER_IS_MS_BUFF_SRC(player)) { __mmplayer_gst_decode_callback(elem, pad, player); - return; + goto DONE; } LOGD("video selector \n"); @@ -2741,7 +2572,7 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data) if (MMPLAYER_IS_MS_BUFF_SRC(player)) { __mmplayer_gst_decode_callback(elem, pad, player); - return; + goto DONE; } LOGD("audio selector \n"); @@ -2913,14 +2744,17 @@ __mmplayer_gst_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpointer da GstPad* srcpad = NULL; GstPad* sinkpad = NULL; + GstCaps* caps = NULL; gchar* caps_str = NULL; MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player && player->pipeline && player->pipeline->mainbin); - caps_str = gst_caps_to_string(gst_pad_get_current_caps(pad)); + caps = gst_pad_get_current_caps(pad); + caps_str = gst_caps_to_string(caps); LOGD("deinterleave new caps : %s\n", caps_str); MMPLAYER_FREEIF(caps_str); + gst_caps_unref(caps); if ((queue = __mmplayer_element_create_and_link(player, pad, "queue")) == NULL) { LOGE("ERROR : queue create error\n"); @@ -3009,6 +2843,7 @@ __mmplayer_gst_deinterleave_no_more_pads(GstElement *elem, gpointer data) MMPLAYER_LOG_GST_CAPS_TYPE(caps); __mmplayer_set_audio_attrs(player, caps); + gst_caps_unref(caps); } MMPLAYER_FREEIF(change_pad_name); } @@ -3632,7 +3467,7 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) } /* link */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { + if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) { LOGE("failed to get pad from sinkbin\n"); goto ERROR; } @@ -3671,10 +3506,6 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) if ((player->no_more_pad) && (player->num_dynamic_pad == 0)) __mmplayer_pipeline_complete(NULL, player); - /* FIXIT : please leave a note why this code is needed */ - if (MMPLAYER_IS_WFD_STREAMING(player)) - player->no_more_pad = TRUE; - ERROR: MMPLAYER_FREEIF(caps_str); @@ -4164,7 +3995,7 @@ __mmplayer_gst_element_link_bucket(GList* element_bucket) } if (prv_element && prv_element->gst) { - if (GST_ELEMENT_LINK(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) { + if (gst_element_link(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) { LOGD("linking [%s] to [%s] success\n", GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst)), GST_ELEMENT_NAME(GST_ELEMENT(element->gst))); @@ -4509,7 +4340,7 @@ __mmplayer_gst_audio_deinterleave_pad_added(GstElement *elem, GstPad *pad, gpoin (gpointer)player); MMPLAYER_FLEAVE(); - return ; + return; ERROR: LOGE("__mmplayer_gst_audio_deinterleave_pad_added ERROR\n"); @@ -5867,8 +5698,7 @@ __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, g MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); MMPLAYER_RETURN_VAL_IF_FAIL(buffer, FALSE); - if (player->is_subtitle_force_drop) - { + if (player->is_subtitle_force_drop) { LOGW("subtitle is dropped forcedly."); return ret; } @@ -6311,8 +6141,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) G_CALLBACK(__mmplayer_gst_rtp_dynamic_pad), player); MMPLAYER_SIGNAL_CONNECT(player, G_OBJECT(element), MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "no-more-pads", G_CALLBACK(__mmplayer_gst_rtp_no_more_pads), player); - - player->use_decodebin = FALSE; } break; @@ -6363,13 +6191,13 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) g_object_set(G_OBJECT(element), "timeout", http_timeout, NULL); g_object_set(G_OBJECT(element), "blocksize", (unsigned long)(64*1024), NULL); - /* check if prosy is vailid or not */ + /* check if proxy is valid or not */ if (util_check_valid_url(proxy)) g_object_set(G_OBJECT(element), "proxy", proxy, NULL); /* parsing cookies */ if ((cookie_list = util_get_cookie_list((const char*)cookies))) { g_object_set(G_OBJECT(element), "cookies", cookie_list, NULL); - g_strfreev (cookie_list); + g_strfreev(cookie_list); } if (user_agent) g_object_set(G_OBJECT(element), "user-agent", user_agent, NULL); @@ -6413,7 +6241,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) g_object_set(G_OBJECT(element), "location", player->profile.uri, NULL); g_object_get(element, "location", &location, NULL); LOGD("PD_LOCATION [%s].\n", location); - if(location) + if (location) g_free(location); } } @@ -6724,13 +6552,11 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) /* create autoplugging element if src element is not a rtsp src */ if ((player->profile.uri_type != MM_PLAYER_URI_TYPE_URL_RTSP) && - (player->profile.uri_type != MM_PLAYER_URI_TYPE_URL_WFD) && (player->profile.uri_type != MM_PLAYER_URI_TYPE_MS_BUFF)) { element = NULL; enum MainElementID elemId = MMPLAYER_M_NUM; - if ((player->use_decodebin) && - ((MMPLAYER_IS_HTTP_PD(player)) || + if (((MMPLAYER_IS_HTTP_PD(player)) || (!MMPLAYER_IS_HTTP_STREAMING(player)))) { elemId = MMPLAYER_M_AUTOPLUG; element = __mmplayer_create_decodebin(player); @@ -7343,13 +7169,9 @@ int __gst_pause(mm_player_t* player, gboolean async) MMPLAYER_PRINT_STATE(player); /* set pipeline status to PAUSED */ - player->ignore_asyncdone = TRUE; - ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED, async, MMPLAYER_STATE_CHANGE_TIMEOUT(player)); - player->ignore_asyncdone = FALSE; - if (FALSE == async) { if (ret != MM_ERROR_NONE) { GstMessage *msg = NULL; @@ -7394,6 +7216,8 @@ int __gst_pause(mm_player_t* player, gboolean async) ret = __gst_handle_library_error(player, error->code); else if (error->domain == GST_CORE_ERROR) ret = __gst_handle_core_error(player, error->code); + + g_error_free(error); } player->msg_posted = TRUE; } @@ -7494,16 +7318,15 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo * Since some element could have some timing problemn with quering duration, try again. */ if (!player->duration) { - if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec)) - { + if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec)) { /* For RTSP Streaming , duration is not returned in READY state. So seek to the previous position does not work properly. * Added a patch to postpone the actual seek when state changes to PLAY. Sending a fake SEEK_COMPLETED event to finish the current request. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { player->pending_seek.is_pending = TRUE; player->pending_seek.format = format; player->pending_seek.pos = position; player->doing_seek = FALSE; - MMPLAYER_POST_MSG ( player, MM_MESSAGE_SEEK_COMPLETED, NULL ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL); return MM_ERROR_NONE; } else { goto SEEK_ERROR; @@ -7539,10 +7362,10 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo if (position > dur_msec) goto INVALID_ARGS; - query = gst_query_new_seeking (GST_FORMAT_TIME); - if (gst_element_query (player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) { - gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL); - gst_query_unref (query); + query = gst_query_new_seeking(GST_FORMAT_TIME); + if (gst_element_query(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) { + gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL); + gst_query_unref(query); if (!seekable) { LOGW("non-seekable content"); @@ -7551,7 +7374,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo } } else { LOGW("failed to get seeking query"); - gst_query_unref (query); /* keep seeking operation */ + gst_query_unref(query); /* keep seeking operation */ } LOGD("seeking to(%lu) msec, duration is %d msec\n", position, dur_msec); @@ -7560,13 +7383,13 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing. This causes problem is position calculation during normal pause resume scenarios also. Currently during seek , we are sending the current position to rtspsrc module for position saving for later use. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec)) LOGW("getting current position failed in seek\n"); player->last_position = pos_nsec; - g_object_set( player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL ); + g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL); } if (player->doing_seek) { @@ -7932,16 +7755,9 @@ static int __mmfplayer_parse_profile(const char *uri, void *param, MMPlayerParse } } else if ((path = strstr(uri, "rtsp://"))) { if (strlen(path)) { - if ((path = strstr(uri, "/wfd1.0/"))) { - strncpy(data->uri, uri, MM_MAX_URL_LEN-1); - data->uri_type = MM_PLAYER_URI_TYPE_URL_WFD; - ret = MM_ERROR_NONE; - LOGD("uri is actually a wfd client path. giving it to wfdrtspsrc\n"); - } else { - strncpy(data->uri, uri, MM_MAX_URL_LEN-1); - data->uri_type = MM_PLAYER_URI_TYPE_URL_RTSP; - ret = MM_ERROR_NONE; - } + strncpy(data->uri, uri, MM_MAX_URL_LEN-1); + data->uri_type = MM_PLAYER_URI_TYPE_URL_RTSP; + ret = MM_ERROR_NONE; } } else if ((path = strstr(uri, "http://")) || (path = strstr(uri, "https://"))) { if (strlen(path)) { @@ -8289,10 +8105,9 @@ void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_t if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg)) player->sound_focus.focus_changed_msg = (int)msg; - if (strstr(reason_for_change, "call") || - strstr(reason_for_change, "voip") || /* FIXME: to check */ - strstr(reason_for_change, "alarm") || - strstr(reason_for_change, "media")) { + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { // hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -8304,6 +8119,7 @@ void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_t LOGW("fail to set Pause state by asm"); goto EXIT; } + __mmplayer_undo_sound_fadedown(player); } else /* rtsp should connect again in specific network becasue tcp session can't be kept any more */ @@ -8379,10 +8195,9 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou if (MM_ERROR_NONE == __mmplayer_convert_sound_focus_state(FALSE, reason_for_change, &msg)) player->sound_focus.focus_changed_msg = (int)msg; - if (strstr(reason_for_change, "call") || - strstr(reason_for_change, "voip") || /* FIXME: to check */ - strstr(reason_for_change, "alarm") || - strstr(reason_for_change, "media")) { + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { //hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -8395,9 +8210,10 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou goto EXIT; } __mmplayer_undo_sound_fadedown(player); - } else + } else { /* rtsp should connect again in specific network becasue tcp session can't be kept any more */ _mmplayer_unrealize((MMHandleType)player); + } } else { LOGW("pause immediately"); result = _mmplayer_pause((MMHandleType)player); @@ -8406,6 +8222,14 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou goto EXIT; } } + + if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA && + player->sound_focus.session_type == MM_SESSION_TYPE_MEDIA && + !(player->sound_focus.session_flags & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) { + result = mm_sound_set_focus_reacquisition_for_session(player->sound_focus.focus_id, false); + if (result != MM_ERROR_NONE) + LOGW("fail to set focus reacquisition to FALSE, skip going on.."); + } } else if (focus_state == FOCUS_IS_ACQUIRED) { LOGW("FOCUS_IS_ACQUIRED: Got msg from asm to resume"); player->sound_focus.antishock = TRUE; @@ -8471,10 +8295,6 @@ _mmplayer_create_player(MMHandleType handle) return ret; } - /* initialize factories if not using decodebin */ - if (player->factories == NULL) - __mmplayer_init_factories(player); - /* create lock. note that g_tread_init() has already called in gst_init() */ g_mutex_init(&player->fsink_lock); @@ -8552,8 +8372,6 @@ _mmplayer_create_player(MMHandleType handle) player->play_subtitle = FALSE; player->play_count = 0; - player->use_decodebin = TRUE; - player->ignore_asyncdone = FALSE; player->use_deinterleave = FALSE; player->max_audio_channels = 0; player->video_share_api_delta = 0; @@ -8883,9 +8701,6 @@ _mmplayer_destroy(MMHandleType handle) /* release attributes */ _mmplayer_deconstruct_attribute(handle); - /* release factories */ - __mmplayer_release_factories(player); - /* release lock */ g_mutex_clear(&player->fsink_lock); @@ -9054,10 +8869,6 @@ _mmplayer_realize(MMHandleType hplayer) if (update_registry) { LOGD("updating registry...\n"); gst_update_registry(); - - /* then we have to rebuild factories */ - __mmplayer_release_factories(player); - __mmplayer_init_factories(player); } /* realize pipeline */ @@ -9256,8 +9067,6 @@ _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType* volume) return MM_ERROR_NONE; } - - int _mmplayer_set_mute(MMHandleType hplayer, int mute) { @@ -9688,9 +9497,9 @@ _mmplayer_pause(MMHandleType hplayer) But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing. This causes problem is position calculation during normal pause resume scenarios also. Currently during pause , we are sending the current position to rtspsrc module for position saving. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { - g_object_set( player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL ); + g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL); } } break; @@ -10151,10 +9960,9 @@ GstCaps *caps, gpointer data) MMPLAYER_FREEIF(player->type); player->type = gst_caps_to_string(caps); if (player->type) - LOGD("meida type %s found, probability %d%% / %d\n", player->type, probability, gst_caps_get_size(caps)); + LOGD("media type %s found, probability %d%% / %d\n", player->type, probability, gst_caps_get_size(caps)); - if ((!MMPLAYER_IS_WFD_STREAMING(player)) && - (!MMPLAYER_IS_RTSP_STREAMING(player)) && + if ((!MMPLAYER_IS_RTSP_STREAMING(player)) && (g_strrstr(player->type, "audio/x-raw-int"))) { LOGE("not support media format\n"); @@ -10179,37 +9987,16 @@ GstCaps *caps, gpointer data) return; } - if (player->use_decodebin) { - if (!__mmplayer_try_to_plug_decodebin(player, pad, caps)) { - gboolean async = FALSE; - LOGE("failed to autoplug %s\n", player->type); - - mm_attrs_get_int_by_name(player->attrs, "profile_prepare_async", &async); - - if (async && player->msg_posted == FALSE) - __mmplayer_handle_missed_plugin(player); - - goto DONE; - } - } else { - /* try to plug */ - if (!__mmplayer_try_to_plug(player, pad, caps)) { - gboolean async = FALSE; - LOGE("failed to autoplug %s\n", player->type); - - mm_attrs_get_int_by_name(player->attrs, "profile_prepare_async", &async); + if (!__mmplayer_try_to_plug_decodebin(player, pad, caps)) { + gboolean async = FALSE; + LOGE("failed to autoplug %s\n", player->type); - if (async && player->msg_posted == FALSE) - __mmplayer_handle_missed_plugin(player); + mm_attrs_get_int_by_name(player->attrs, "profile_prepare_async", &async); - goto DONE; - } + if (async && player->msg_posted == FALSE) + __mmplayer_handle_missed_plugin(player); - /* finish autopluging if no dynamic pad waiting */ - if ((!player->have_dynamic_pad) && (!player->has_many_types)) { - if (!MMPLAYER_IS_RTSP_STREAMING(player)) - __mmplayer_pipeline_complete(NULL, (gpointer)player); - } + goto DONE; } DONE: @@ -10341,6 +10128,7 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC max_buffer_size_bytes = (type == MUXED_BUFFER_TYPE_FILE) ? (player->ini.http_max_size_bytes) : (5*1024*1024); LOGD("max_buffer_size_bytes = %d\n", max_buffer_size_bytes); + // FIXME : pass ini setting directly. is this ok? __mm_player_streaming_set_queue2(player->streamer, queue2, FALSE, @@ -10398,15 +10186,15 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC mainbin[MMPLAYER_M_AUTOPLUG].gst = decodebin; /* set decodebin property about buffer in streaming playback. * - * in case of hls, it does not need to have big buffer * + * in case of HLS/DASH, it does not need to have big buffer * * because it is kind of adaptive streaming. */ - if (((!MMPLAYER_IS_HTTP_PD(player)) && - (MMPLAYER_IS_HTTP_STREAMING(player))) || MMPLAYER_IS_DASH_STREAMING(player)) { + if (!MMPLAYER_IS_HTTP_PD(player) && MMPLAYER_IS_HTTP_STREAMING(player)) { guint max_size_bytes = MAX_DECODEBIN_BUFFER_BYTES; guint64 max_size_time = MAX_DECODEBIN_BUFFER_TIME; init_buffering_time = (init_buffering_time != 0) ? (init_buffering_time) : (player->ini.http_buffering_time); - if (MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) { + if (MMPLAYER_IS_HTTP_LIVE_STREAMING(player) + || MMPLAYER_IS_DASH_STREAMING(player)) { max_size_bytes = MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES; max_size_time = MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME; } @@ -10467,381 +10255,6 @@ ERROR: return FALSE; } -/* it will return first created element */ -static gboolean -__mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) -{ - MMPlayerGstElement* mainbin = NULL; - const char* mime = NULL; - const GList* item = NULL; - const gchar* klass = NULL; - GstCaps* res = NULL; - gboolean skip = FALSE; - GstPad* queue_pad = NULL; - GstElement* queue = NULL; - GstElement *element = NULL; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline && player->pipeline->mainbin, FALSE); - - mainbin = player->pipeline->mainbin; - - mime = gst_structure_get_name(gst_caps_get_structure(caps, 0)); - - /* return if we got raw output */ - if (g_str_has_prefix(mime, "video/x-raw") || g_str_has_prefix(mime, "audio/x-raw") - || g_str_has_prefix(mime, "text/plain") || g_str_has_prefix(mime, "text/x-pango-markup")) { - - element = (GstElement*)gst_pad_get_parent(pad); -/* NOTE : When no decoder has added during autoplugging. like a simple wave playback. - * No queue will be added. I think it can caused breaking sound when playing raw audio - * frames but there's no different. Decodebin also doesn't add with those wav fils. - * Anyway, currentely raw-queue seems not necessary. - */ -#if 1 - /* NOTE : check if previously linked element is demuxer/depayloader/parse means no decoder - * has linked. if so, we need to add queue for quality of output. note that - * decodebin also has same problem. - */ - klass = gst_element_factory_get_metadata(gst_element_get_factory(element), GST_ELEMENT_METADATA_KLASS); - - /* add queue if needed */ - if ((g_strrstr(klass, "Demux") || g_strrstr(klass, "Depayloader") - || g_strrstr(klass, "Parse")) && !g_str_has_prefix(mime, "text")) { - LOGD("adding raw queue\n"); - - queue = gst_element_factory_make("queue", NULL); - if (!queue) { - LOGW("failed to create queue\n"); - goto ERROR; - } - - /* warmup */ - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(queue, GST_STATE_READY)) { - LOGW("failed to set state READY to queue\n"); - goto ERROR; - } - - /* add to pipeline */ - if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue)) { - LOGW("failed to add queue\n"); - goto ERROR; - } - - /* link queue */ - queue_pad = gst_element_get_static_pad(queue, "sink"); - - if (GST_PAD_LINK_OK != gst_pad_link(pad, queue_pad)) { - LOGW("failed to link queue\n"); - goto ERROR; - } - gst_object_unref(GST_OBJECT(queue_pad)); - queue_pad = NULL; - - /* running */ - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(queue, GST_STATE_PAUSED)) { - LOGW("failed to set state PAUSED to queue\n"); - goto ERROR; - } - - /* replace given pad to queue:src */ - pad = gst_element_get_static_pad(queue, "src"); - if (!pad) { - LOGW("failed to get pad from queue\n"); - goto ERROR; - } - } -#endif - /* check if player can do start continually */ - MMPLAYER_CHECK_CMD_IF_EXIT(player); - - if (__mmplayer_link_sink(player, pad)) - __mmplayer_gst_decode_callback(element, pad, player); - - gst_object_unref(GST_OBJECT(element)); - element = NULL; - - return TRUE; - } - - item = player->factories; - for (; item != NULL; item = item->next) { - GstElementFactory *factory = GST_ELEMENT_FACTORY(item->data); - const GList *pads; - gint idx = 0; - - skip = FALSE; - - /* filtering exclude keyword */ - for (idx = 0; player->ini.exclude_element_keyword[idx][0] != '\0'; idx++) { - if (g_strrstr(GST_OBJECT_NAME(factory), - player->ini.exclude_element_keyword[idx])) { - LOGW("skipping [%s] by exculde keyword [%s]\n", - GST_OBJECT_NAME(factory), - player->ini.exclude_element_keyword[idx]); - - skip = TRUE; - break; - } - } - - if (MMPLAYER_IS_RTSP_STREAMING(player) && g_strrstr(GST_OBJECT_NAME(factory), "omx_mpeg4dec")) { - // omx decoder can not support mpeg4video data partitioned - // rtsp streaming didn't know mpeg4video data partitioned format - // so, if rtsp playback, player will skip omx_mpeg4dec. - LOGW("skipping [%s] when rtsp streaming \n", - GST_OBJECT_NAME(factory)); - - skip = TRUE; - } - - if (skip) continue; - - /* check factory class for filtering */ - klass = gst_element_factory_get_metadata(GST_ELEMENT_FACTORY(factory), GST_ELEMENT_METADATA_KLASS); - - /*parsers are not required in case of external feeder*/ - if (g_strrstr(klass, "Codec/Parser") && MMPLAYER_IS_MS_BUFF_SRC(player)) - continue; - - /* NOTE : msl don't need to use image plugins. - * So, those plugins should be skipped for error handling. - */ - if (g_strrstr(klass, "Codec/Decoder/Image")) { - LOGD("skipping [%s] by not required\n", GST_OBJECT_NAME(factory)); - continue; - } - - /* check pad compatability */ - for (pads = gst_element_factory_get_static_pad_templates(factory); - pads != NULL; pads = pads->next) { - GstStaticPadTemplate *temp1 = pads->data; - GstCaps* static_caps = NULL; - - if (temp1->direction != GST_PAD_SINK - || temp1->presence != GST_PAD_ALWAYS) - continue; - - /* using existing caps */ - if (GST_IS_CAPS(&temp1->static_caps.caps)) - static_caps = gst_caps_ref(temp1->static_caps.caps); - /* create one */ - else - static_caps = gst_caps_from_string(temp1->static_caps.string); - - res = gst_caps_intersect((GstCaps*)caps, static_caps); - gst_caps_unref(static_caps); - static_caps = NULL; - - if (res && !gst_caps_is_empty(res)) { - GstElement *new_element; - GList *elements = player->parsers; - char *name_template = g_strdup(temp1->name_template); - gchar *name_to_plug = GST_OBJECT_NAME(factory); - gst_caps_unref(res); - - /* check ALP Codec can be used or not */ - if ((g_strrstr(klass, "Codec/Decoder/Audio"))) { - /* consider mp3 audio only */ - if (!MMPLAYER_IS_STREAMING(player) && __mmplayer_is_only_mp3_type(player->type)) { - /* try to use ALP decoder first instead of selected decoder */ - GstElement *element = NULL; - GstElementFactory * element_facory; - gchar *path = NULL; - guint64 data_size = 0; - #define MIN_THRESHOLD_SIZE 320 * 1024 // 320K - struct stat sb; - - mm_attrs_get_string_by_name(player->attrs, "profile_uri", &path); - - if (stat(path, &sb) == 0) - data_size = (guint64)sb.st_size; - LOGD("file size : %u", data_size); - - if (data_size > MIN_THRESHOLD_SIZE) { - LOGD("checking if ALP can be used or not"); - element = gst_element_factory_make("omx_mp3dec", "omx mp3 decoder"); - if (element) { - /* check availability because multi-instance is not supported */ - GstStateChangeReturn ret = gst_element_set_state(element, GST_STATE_READY); - - if (ret != GST_STATE_CHANGE_SUCCESS) { - // use just selected decoder - gst_object_unref(element); - } else if (ret == GST_STATE_CHANGE_SUCCESS) { - // replace facotry to use omx - /* clean */ - gst_element_set_state(element, GST_STATE_NULL); - gst_object_unref(element); - - element_facory = gst_element_factory_find("omx_mp3dec"); - /* replace, otherwise use selected thing instead */ - if (element_facory) { - factory = element_facory; - name_to_plug = GST_OBJECT_NAME(factory); - } - } - } - } - } - } else if ((g_strrstr(klass, "Codec/Decoder/Video"))) { - if (g_strrstr(GST_OBJECT_NAME(factory), "omx_")) { - char *env = getenv("MM_PLAYER_HW_CODEC_DISABLE"); - if (env != NULL) { - if (strncasecmp(env, "yes", 3) == 0) { - LOGD("skipping [%s] by disabled\n", name_to_plug); - MMPLAYER_FREEIF(name_template); - continue; - } - } - } - } - - LOGD("found %s to plug\n", name_to_plug); - - new_element = gst_element_factory_create(GST_ELEMENT_FACTORY(factory), NULL); - if (!new_element) { - LOGE("failed to create element [%s]. continue with next.\n", - GST_OBJECT_NAME(factory)); - - MMPLAYER_FREEIF(name_template); - - continue; - } - - /* check and skip it if it was already used. Otherwise, it can be an infinite loop - * because parser can accept its own output as input. - */ - if (g_strrstr(klass, "Parser")) { - gchar *selected = NULL; - - for (; elements; elements = g_list_next(elements)) { - gchar *element_name = elements->data; - - if (g_strrstr(element_name, name_to_plug)) { - LOGD("but, %s already linked, so skipping it\n", name_to_plug); - skip = TRUE; - } - } - - if (skip) { - MMPLAYER_FREEIF(name_template); - continue; - } - - selected = g_strdup(name_to_plug); - player->parsers = g_list_append(player->parsers, selected); - } - - /* store specific handles for futher control */ - if (g_strrstr(klass, "Demux") || g_strrstr(klass, "Parse")) { - /* FIXIT : first value will be overwritten if there's more - * than 1 demuxer/parser - */ - LOGD("plugged element is demuxer. take it\n"); - mainbin[MMPLAYER_M_DEMUX].id = MMPLAYER_M_DEMUX; - mainbin[MMPLAYER_M_DEMUX].gst = new_element; - - /*Added for multi audio support */ - if (g_strrstr(klass, "Demux")) { - mainbin[MMPLAYER_M_DEMUX_EX].id = MMPLAYER_M_DEMUX_EX; - mainbin[MMPLAYER_M_DEMUX_EX].gst = new_element; - - /* NOTE : workaround for bug in mpegtsdemux since doesn't emit - no-more-pad signal. this may cause wrong content attributes at PAUSED state - this code should be removed after mpegtsdemux is fixed */ - if (g_strrstr(GST_OBJECT_NAME(factory), "mpegtsdemux")) { - LOGW("force no-more-pad to TRUE since mpegtsdemux os not giving no-more-pad signal. content attributes may wrong"); - player->no_more_pad = TRUE; - } - } - if (g_strrstr(name_to_plug, "asfdemux")) // to support trust-zone only - g_object_set(mainbin[MMPLAYER_M_DEMUX_EX].gst, "file-location", player->profile.uri, NULL); - } else if (g_strrstr(klass, "Decoder") && __mmplayer_link_decoder(player, pad)) { - if (mainbin[MMPLAYER_M_DEC1].gst == NULL) { - LOGD("plugged element is decoder. take it[MMPLAYER_M_DEC1]\n"); - mainbin[MMPLAYER_M_DEC1].id = MMPLAYER_M_DEC1; - mainbin[MMPLAYER_M_DEC1].gst = new_element; - } else if (mainbin[MMPLAYER_M_DEC2].gst == NULL) { - LOGD("plugged element is decoder. take it[MMPLAYER_M_DEC2]\n"); - mainbin[MMPLAYER_M_DEC2].id = MMPLAYER_M_DEC2; - mainbin[MMPLAYER_M_DEC2].gst = new_element; - } - /* NOTE : IF one codec is found, add it to supported_codec and remove from - * missing plugin. Both of them are used to check what's supported codec - * before returning result of play start. And, missing plugin should be - * updated here for multi track files. - */ - if (g_str_has_prefix(mime, "video")) { - GstPad *src_pad = NULL; - GstPadTemplate *pad_templ = NULL; - GstCaps *caps = NULL; - gchar *caps_str = NULL; - - LOGD("found VIDEO decoder\n"); - player->not_supported_codec &= MISSING_PLUGIN_AUDIO; - player->can_support_codec |= FOUND_PLUGIN_VIDEO; - - src_pad = gst_element_get_static_pad(new_element, "src"); - pad_templ = gst_pad_get_pad_template(src_pad); - caps = GST_PAD_TEMPLATE_CAPS(pad_templ); - - caps_str = gst_caps_to_string(caps); - - /* clean */ - MMPLAYER_FREEIF(caps_str); - gst_object_unref(src_pad); - } else if (g_str_has_prefix(mime, "audio")) { - LOGD("found AUDIO decoder\n"); - player->not_supported_codec &= MISSING_PLUGIN_VIDEO; - player->can_support_codec |= FOUND_PLUGIN_AUDIO; - } - } - - if (!__mmplayer_close_link(player, pad, new_element, - name_template, gst_element_factory_get_static_pad_templates(factory))) { - MMPLAYER_FREEIF(name_template); - if (player->keep_detecting_vcodec) - continue; - - /* Link is failed even though a supportable codec is found. */ - __mmplayer_check_not_supported_codec(player, klass, mime); - - LOGE("failed to call _close_link\n"); - return FALSE; - } - - MMPLAYER_FREEIF(name_template); - return TRUE; - } - - gst_caps_unref(res); - break; - } - } - - /* There is no available codec. */ - __mmplayer_check_not_supported_codec(player, klass, mime); - - MMPLAYER_FLEAVE(); - return FALSE; - -ERROR: - /* release */ - if (queue) - gst_object_unref(queue); - - if (queue_pad) - gst_object_unref(queue_pad); - - if (element) - gst_object_unref(element); - - return FALSE; -} - - static int __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_class, const gchar* mime) { @@ -10878,6 +10291,7 @@ __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_c } else { LOGW("add VIDEO to missing plugin\n"); player->not_supported_codec |= MISSING_PLUGIN_VIDEO; + player->unlinked_video_mime = g_strdup_printf("%s", mime); } } else if (g_str_has_prefix(mime, "audio")) { if ((player->can_support_codec & FOUND_PLUGIN_AUDIO) && (player->audiodec_linked)) { @@ -10885,6 +10299,7 @@ __mmplayer_check_not_supported_codec(mm_player_t* player, const gchar* factory_c } else { LOGW("add AUDIO to missing plugin\n"); player->not_supported_codec |= MISSING_PLUGIN_AUDIO; + player->unlinked_audio_mime = g_strdup_printf("%s", mime); } } } @@ -10961,12 +10376,12 @@ __mmplayer_verify_next_play_path(mm_player_t *player) char *profileName; system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); switch (*profileName) { - case 't': - case 'T': - profile_tv = 1; - break; - default: - profile_tv = 0; + case 't': + case 'T': + profile_tv = 1; + break; + default: + profile_tv = 0; } free(profileName); } @@ -11877,8 +11292,6 @@ GstCaps* caps, GstElementFactory* factory, gpointer data) mime = gst_structure_get_name(gst_caps_get_structure(caps, 0)); if (g_str_has_prefix(mime, "video")) { - // __mmplayer_check_video_zero_cpoy(player, factory); - player->not_supported_codec &= MISSING_PLUGIN_AUDIO; player->can_support_codec |= FOUND_PLUGIN_VIDEO; @@ -11897,22 +11310,6 @@ DONE: return result; } - -#if 0 -static GValueArray* -__mmplayer_gst_decode_autoplug_factories(GstElement *bin, GstPad* pad, -GstCaps * caps, gpointer data) -{ - //mm_player_t* player = (mm_player_t*)data; - - LOGD("decodebin is requesting factories for caps [%s] from element[%s]", - gst_caps_to_string(caps), - GST_ELEMENT_NAME(GST_PAD_PARENT(pad))); - - return NULL; -} -#endif - static void __mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad* new_pad, gpointer data) @@ -11930,6 +11327,7 @@ gpointer data) LOGD("pad removed caps : %s from %s", caps_str, GST_ELEMENT_NAME(elem)); MMPLAYER_FREEIF(caps_str); + gst_caps_unref(caps); } } @@ -12160,30 +11558,6 @@ static gboolean __mmplayer_configure_audio_callback(mm_player_t* player) } static void -__mmplayer_init_factories(mm_player_t* player) -{ - MMPLAYER_RETURN_IF_FAIL(player); - - player->factories = gst_registry_feature_filter(gst_registry_get(), - (GstPluginFeatureFilter)__mmplayer_feature_filter, FALSE, NULL); - player->factories = g_list_sort(player->factories, (GCompareFunc)util_factory_rank_compare); -} - -static void -__mmplayer_release_factories(mm_player_t* player) -{ - MMPLAYER_FENTER(); - MMPLAYER_RETURN_IF_FAIL(player); - - if (player->factories) { - gst_plugin_feature_list_free(player->factories); - player->factories = NULL; - } - - MMPLAYER_FLEAVE(); -} - -static void __mmplayer_release_misc(mm_player_t* player) { int i; @@ -12263,11 +11637,6 @@ __mmplayer_release_misc(mm_player_t* player) /* free memory related to audio effect */ MMPLAYER_FREEIF(player->audio_effect_info.custom_ext_level_for_plugin); - if (player->state_tune_caps) { - gst_caps_unref(player->state_tune_caps); - player->state_tune_caps = NULL; - } - if (player->adaptive_info.var_list) { g_list_free_full(player->adaptive_info.var_list, g_free); player->adaptive_info.var_list = NULL; @@ -12393,673 +11762,6 @@ static GstElement *__mmplayer_element_create_and_link(mm_player_t *player, GstPa return element; } -static gboolean -__mmplayer_close_link(mm_player_t* player, GstPad *srcpad, GstElement *sinkelement, -const char *padname, const GList *templlist) -{ - GstPad *pad = NULL; - gboolean has_dynamic_pads = FALSE; - gboolean has_many_types = FALSE; - const char *klass = NULL; - GstStaticPadTemplate *padtemplate = NULL; - GstElementFactory *factory = NULL; - GstElement* queue = NULL; - GstElement* parser = NULL; - GstPad *pssrcpad = NULL; - GstPad *qsrcpad = NULL, *qsinkpad = NULL; - MMPlayerGstElement *mainbin = NULL; - GstStructure* str = NULL; - GstCaps* srccaps = NULL; - GstState target_state = GST_STATE_READY; - gboolean isvideo_decoder = FALSE; - guint q_max_size_time = 0; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_VAL_IF_FAIL(player && - player->pipeline && - player->pipeline->mainbin, - FALSE); - - mainbin = player->pipeline->mainbin; - - LOGD("plugging pad %s:%s to newly create %s:%s\n", - GST_ELEMENT_NAME(GST_PAD_PARENT(srcpad)), - GST_PAD_NAME(srcpad), - GST_ELEMENT_NAME(sinkelement), - padname); - - factory = gst_element_get_factory(sinkelement); - klass = gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_KLASS); - - /* check if player can do start continually */ - MMPLAYER_CHECK_CMD_IF_EXIT(player); - - /* need it to warm up omx before linking to pipeline */ - if (g_strrstr(GST_ELEMENT_NAME(GST_PAD_PARENT(srcpad)), "demux")) { - LOGD("get demux caps.\n"); - if (player->state_tune_caps) { - gst_caps_unref(player->state_tune_caps); - player->state_tune_caps = NULL; - } - player->state_tune_caps = gst_caps_copy(gst_pad_get_current_caps(srcpad)); - } - - /* NOTE : OMX Codec can check if resource is available or not at this state. */ - if (g_strrstr(GST_ELEMENT_NAME(sinkelement), "omx")) { - if (player->state_tune_caps != NULL) { - LOGD("set demux's caps to omx codec if resource is available"); - if (gst_pad_set_caps(gst_element_get_static_pad(sinkelement, "sink"), player->state_tune_caps)) { - target_state = GST_STATE_PAUSED; - isvideo_decoder = TRUE; - g_object_set(G_OBJECT(sinkelement), "state-tuning", TRUE, NULL); - } else - LOGW("failed to set caps for state tuning"); - } - gst_caps_unref(player->state_tune_caps); - player->state_tune_caps = NULL; - } - - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(sinkelement, target_state)) { - LOGE("failed to set %d state to %s\n", target_state, GST_ELEMENT_NAME(sinkelement)); - if (isvideo_decoder) { - gst_element_set_state(sinkelement, GST_STATE_NULL); - gst_object_unref(G_OBJECT(sinkelement)); - player->keep_detecting_vcodec = TRUE; - } - goto ERROR; - } - - /* add to pipeline */ - if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), sinkelement)) { - LOGE("failed to add %s to mainbin\n", GST_ELEMENT_NAME(sinkelement)); - goto ERROR; - } - - LOGD("element klass : %s\n", klass); - - /* added to support multi track files */ - /* only decoder case and any of the video/audio still need to link*/ - if (g_strrstr(klass, "Decoder") && __mmplayer_link_decoder(player, srcpad)) { - gchar *name = g_strdup(GST_ELEMENT_NAME(GST_PAD_PARENT(srcpad))); - - if (g_strrstr(name, "mpegtsdemux") || g_strrstr(name, "mssdemux")) { - gchar *src_demux_caps_str = NULL; - gchar *needed_parser = NULL; - GstCaps *src_demux_caps = NULL; - gboolean smooth_streaming = FALSE; - - src_demux_caps = gst_pad_query_caps(srcpad, NULL); - src_demux_caps_str = gst_caps_to_string(src_demux_caps); - - gst_caps_unref(src_demux_caps); - - if (g_strrstr(src_demux_caps_str, "video/x-h264")) { - if (g_strrstr(name, "mssdemux")) { - needed_parser = g_strdup("legacyh264parse"); - smooth_streaming = TRUE; - } else - needed_parser = g_strdup("h264parse"); - } else if (g_strrstr(src_demux_caps_str, "video/mpeg")) - needed_parser = g_strdup("mpeg4videoparse"); - - MMPLAYER_FREEIF(src_demux_caps_str); - - if (needed_parser) { - parser = __mmplayer_element_create_and_link(player, srcpad, needed_parser); - MMPLAYER_FREEIF(needed_parser); - - if (!parser) { - LOGE("failed to create parser\n"); - } else { - if (smooth_streaming) - g_object_set(parser, "output-format", 1, NULL); /* NALU/Byte Stream format */ - - /* update srcpad if parser is created */ - pssrcpad = gst_element_get_static_pad(parser, "src"); - srcpad = pssrcpad; - } - } - } - MMPLAYER_FREEIF(name); - - queue = __mmplayer_element_create_and_link(player, srcpad, "queue"); // parser - queue or demuxer - queue - if (!queue) { - LOGE("failed to create queue\n"); - goto ERROR; - } - - /* update srcpad to link with decoder */ - qsrcpad = gst_element_get_static_pad(queue, "src"); - srcpad = qsrcpad; - - q_max_size_time = GST_QUEUE_DEFAULT_TIME; - - /* assigning queue handle for futher manipulation purpose */ - /* FIXIT : make it some kind of list so that msl can support more then two stream(text, data, etc...) */ - if (mainbin[MMPLAYER_M_Q1].gst == NULL) { - mainbin[MMPLAYER_M_Q1].id = MMPLAYER_M_Q1; - mainbin[MMPLAYER_M_Q1].gst = queue; - - if (player->profile.uri_type == MM_PLAYER_URI_TYPE_SS) { - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q1].gst), "max-size-time", 0 , NULL); - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q1].gst), "max-size-buffers", 2, NULL); - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q1].gst), "max-size-bytes", 0, NULL); - } else { - if (!MMPLAYER_IS_RTSP_STREAMING(player)) - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q1].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); - } - } else if (mainbin[MMPLAYER_M_Q2].gst == NULL) { - mainbin[MMPLAYER_M_Q2].id = MMPLAYER_M_Q2; - mainbin[MMPLAYER_M_Q2].gst = queue; - - if (player->profile.uri_type == MM_PLAYER_URI_TYPE_SS) { - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q2].gst), "max-size-time", 0 , NULL); - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q2].gst), "max-size-buffers", 2, NULL); - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q2].gst), "max-size-bytes", 0, NULL); - } else { - if (!MMPLAYER_IS_RTSP_STREAMING(player)) - g_object_set(G_OBJECT(mainbin[MMPLAYER_M_Q2].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); - } - } else { - LOGE("Not supporting more then two elementary stream\n"); - g_assert(1); - } - - pad = gst_element_get_static_pad(sinkelement, padname); - - if (!pad) { - LOGW("failed to get pad(%s) from %s. retrying with [sink]\n", - padname, GST_ELEMENT_NAME(sinkelement)); - - pad = gst_element_get_static_pad(sinkelement, "sink"); - if (!pad) { - LOGE("failed to get pad(sink) from %s. \n", - GST_ELEMENT_NAME(sinkelement)); - goto ERROR; - } - } - - /* to check the video/audio type set the proper flag*/ - const gchar *mime_type = NULL; - srccaps = gst_pad_query_caps(srcpad, NULL); - if (!srccaps) - goto ERROR; - str = gst_caps_get_structure(srccaps, 0); - if (!str) - goto ERROR; - mime_type = gst_structure_get_name(str); - if (!mime_type) - goto ERROR; - - /* link queue and decoder. so, it will be queue - decoder. */ - if (GST_PAD_LINK_OK != gst_pad_link(srcpad, pad)) { - gst_object_unref(GST_OBJECT(pad)); - LOGE("failed to link(%s) to pad(%s)\n", GST_ELEMENT_NAME(sinkelement), padname); - - /* reconstitute supportable codec */ - if (strstr(mime_type, "video")) - player->can_support_codec ^= FOUND_PLUGIN_VIDEO; - else if (strstr(mime_type, "audio")) - player->can_support_codec ^= FOUND_PLUGIN_AUDIO; - goto ERROR; - } - - if (strstr(mime_type, "video")) { - player->videodec_linked = 1; - LOGI("player->videodec_linked set to 1\n"); - - } else if (strstr(mime_type, "audio")) { - player->audiodec_linked = 1; - LOGI("player->auddiodec_linked set to 1\n"); - } - - gst_object_unref(GST_OBJECT(pad)); - gst_caps_unref(GST_CAPS(srccaps)); - srccaps = NULL; - } - - if (!MMPLAYER_IS_HTTP_PD(player)) { - if ((g_strrstr(klass, "Demux") && !g_strrstr(klass, "Metadata")) || (g_strrstr(klass, "Parser"))) { - if (MMPLAYER_IS_HTTP_STREAMING(player)) { - gint64 dur_bytes = 0L; - muxed_buffer_type_e type = MUXED_BUFFER_TYPE_MEM_QUEUE; - - if (!mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst) { - LOGD("creating http streaming buffering queue\n"); - - queue = gst_element_factory_make("queue2", "queue2"); - if (!queue) { - LOGE("failed to create buffering queue element\n"); - goto ERROR; - } - - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(queue, GST_STATE_READY)) { - LOGE("failed to set state READY to buffering queue\n"); - goto ERROR; - } - - if (!gst_bin_add(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue)) { - LOGE("failed to add buffering queue\n"); - goto ERROR; - } - - qsinkpad = gst_element_get_static_pad(queue, "sink"); - qsrcpad = gst_element_get_static_pad(queue, "src"); - - if (GST_PAD_LINK_OK != gst_pad_link(srcpad, qsinkpad)) { - LOGE("failed to link buffering queue\n"); - goto ERROR; - } - srcpad = qsrcpad; - - - mainbin[MMPLAYER_M_MUXED_S_BUFFER].id = MMPLAYER_M_MUXED_S_BUFFER; - mainbin[MMPLAYER_M_MUXED_S_BUFFER].gst = queue; - - if (!MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) { - if (!gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes)) - LOGE("fail to get duration.\n"); - - if (dur_bytes > 0) { - if (MMPLAYER_USE_FILE_FOR_BUFFERING(player)) { - type = MUXED_BUFFER_TYPE_FILE; - } else { - type = MUXED_BUFFER_TYPE_MEM_RING_BUFFER; - if (player->streamer) - player->streamer->ring_buffer_size = player->ini.http_ring_buffer_size; - } - } else { - dur_bytes = 0; - } - } - - /* NOTE : we cannot get any duration info from ts container in case of streaming */ - if (!g_strrstr(GST_ELEMENT_NAME(sinkelement), "mpegtsdemux")) { - __mm_player_streaming_set_queue2(player->streamer, - queue, - TRUE, - player->ini.http_max_size_bytes, - player->ini.http_buffering_time, - 1.0, - player->ini.http_buffering_limit, - type, - player->http_file_buffering_path, - (guint64)dur_bytes); - } - } - } - } - } - /* if it is not decoder or */ - /* in decoder case any of the video/audio still need to link*/ - if (!g_strrstr(klass, "Decoder")) { - pad = gst_element_get_static_pad(sinkelement, padname); - if (!pad) { - LOGW("failed to get pad(%s) from %s. retrying with [sink]\n", - padname, GST_ELEMENT_NAME(sinkelement)); - - pad = gst_element_get_static_pad(sinkelement, "sink"); - - if (!pad) { - LOGE("failed to get pad(sink) from %s. \n", - GST_ELEMENT_NAME(sinkelement)); - goto ERROR; - } - } - - if (GST_PAD_LINK_OK != gst_pad_link(srcpad, pad)) { - gst_object_unref(GST_OBJECT(pad)); - LOGE("failed to link(%s) to pad(%s)\n", GST_ELEMENT_NAME(sinkelement), padname); - goto ERROR; - } - - gst_object_unref(GST_OBJECT(pad)); - } - - for (; templlist != NULL; templlist = templlist->next) { - padtemplate = templlist->data; - - LOGD("director = [%d], presence = [%d]\n", padtemplate->direction, padtemplate->presence); - - if (padtemplate->direction != GST_PAD_SRC || - padtemplate->presence == GST_PAD_REQUEST) - continue; - - switch (padtemplate->presence) { - case GST_PAD_ALWAYS: - { - GstPad *srcpad = gst_element_get_static_pad(sinkelement, "src"); - GstCaps *caps = gst_pad_query_caps(srcpad, NULL); - - /* Check whether caps has many types */ - if (!gst_caps_is_fixed(caps)) { - LOGD("always pad but, caps has many types"); - MMPLAYER_LOG_GST_CAPS_TYPE(caps); - has_many_types = TRUE; - break; - } - - if (!__mmplayer_try_to_plug(player, srcpad, caps)) { - gst_object_unref(GST_OBJECT(srcpad)); - gst_caps_unref(GST_CAPS(caps)); - - LOGE("failed to plug something after %s\n", GST_ELEMENT_NAME(sinkelement)); - goto ERROR; - } - - gst_caps_unref(GST_CAPS(caps)); - gst_object_unref(GST_OBJECT(srcpad)); - - } - break; - - - case GST_PAD_SOMETIMES: - has_dynamic_pads = TRUE; - break; - - default: - break; - } - } - - /* check if player can do start continually */ - MMPLAYER_CHECK_CMD_IF_EXIT(player); - - if (has_dynamic_pads) { - player->have_dynamic_pad = TRUE; - MMPLAYER_SIGNAL_CONNECT(player, sinkelement, MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "pad-added", - G_CALLBACK(__mmplayer_add_new_pad), player); - - /* for streaming, more then one typefind will used for each elementary stream - * so this doesn't mean the whole pipeline completion - */ - if (!MMPLAYER_IS_RTSP_STREAMING(player)) { - MMPLAYER_SIGNAL_CONNECT(player, sinkelement, MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "no-more-pads", - G_CALLBACK(__mmplayer_pipeline_complete), player); - } - } - - if (has_many_types) { - GstPad *pad = NULL; - - player->has_many_types = has_many_types; - - pad = gst_element_get_static_pad(sinkelement, "src"); - MMPLAYER_SIGNAL_CONNECT(player, pad, MM_PLAYER_SIGNAL_TYPE_AUTOPLUG, "notify::caps", G_CALLBACK(__mmplayer_add_new_caps), player); - gst_object_unref(GST_OBJECT(pad)); - } - - - /* check if player can do start continually */ - MMPLAYER_CHECK_CMD_IF_EXIT(player); - - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(sinkelement, GST_STATE_PAUSED)) { - LOGE("failed to set state PAUSED to %s\n", GST_ELEMENT_NAME(sinkelement)); - goto ERROR; - } - - if (queue) { - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(queue, GST_STATE_PAUSED)) { - LOGE("failed to set state PAUSED to queue\n"); - goto ERROR; - } - - queue = NULL; - - gst_object_unref(GST_OBJECT(qsrcpad)); - qsrcpad = NULL; - } - - if (parser) { - if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(parser, GST_STATE_PAUSED)) { - LOGE("failed to set state PAUSED to queue\n"); - goto ERROR; - } - - parser = NULL; - - gst_object_unref(GST_OBJECT(pssrcpad)); - pssrcpad = NULL; - } - - MMPLAYER_FLEAVE(); - - return TRUE; - -ERROR: - - if (queue) { - gst_object_unref(GST_OBJECT(qsrcpad)); - - /* NOTE : Trying to dispose element queue0, but it is in READY instead of the NULL state. - * You need to explicitly set elements to the NULL state before - * dropping the final reference, to allow them to clean up. - */ - gst_element_set_state(queue, GST_STATE_NULL); - /* And, it still has a parent "player". - * You need to let the parent manage the object instead of unreffing the object directly. - */ - - gst_bin_remove(GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), queue); - //gst_object_unref(queue); - } - - if (srccaps) - gst_caps_unref(GST_CAPS(srccaps)); - - return FALSE; -} - -static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer data) -{ - const gchar *klass; - - /* we only care about element factories */ - if (!GST_IS_ELEMENT_FACTORY(feature)) - return FALSE; - - /* only parsers, demuxers and decoders */ - klass = gst_element_factory_get_metadata(GST_ELEMENT_FACTORY(feature), GST_ELEMENT_METADATA_KLASS); - - if (g_strrstr(klass, "Demux") == NULL && - g_strrstr(klass, "Codec/Decoder") == NULL && - g_strrstr(klass, "Depayloader") == NULL && - g_strrstr(klass, "Parse") == NULL) - return FALSE; - return TRUE; -} - - -static void __mmplayer_add_new_caps(GstPad* pad, GParamSpec* unused, gpointer data) -{ - mm_player_t* player = (mm_player_t*) data; - GstCaps *caps = NULL; - GstStructure *str = NULL; - const char *name; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_IF_FAIL(pad) - MMPLAYER_RETURN_IF_FAIL(unused) - MMPLAYER_RETURN_IF_FAIL(data) - - caps = gst_pad_query_caps(pad, NULL); - if (!caps) - return; - - str = gst_caps_get_structure(caps, 0); - if (!str) - return; - - name = gst_structure_get_name(str); - if (!name) - return; - LOGD("name=%s\n", name); - - if (!__mmplayer_try_to_plug(player, pad, caps)) { - LOGE("failed to autoplug for type(%s)\n", name); - gst_caps_unref(caps); - return; - } - - gst_caps_unref(caps); - - __mmplayer_pipeline_complete(NULL, (gpointer)player); - - MMPLAYER_FLEAVE(); - - return; -} - -static void __mmplayer_set_unlinked_mime_type(mm_player_t* player, GstCaps *caps) -{ - GstStructure *str; - gint version = 0; - const char *stream_type; - gchar *version_field = NULL; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_IF_FAIL(player); - MMPLAYER_RETURN_IF_FAIL(caps); - - str = gst_caps_get_structure(caps, 0); - if (!str) - return; - - stream_type = gst_structure_get_name(str); - if (!stream_type) - return; - - - /* set unlinked mime type for downloadable codec */ - if (g_str_has_prefix(stream_type, "video/")) { - if (g_str_has_prefix(stream_type, "video/mpeg")) { - gst_structure_get_int(str, MM_PLAYER_MPEG_VNAME, &version); - version_field = MM_PLAYER_MPEG_VNAME; - } else if (g_str_has_prefix(stream_type, "video/x-wmv")) { - gst_structure_get_int(str, MM_PLAYER_WMV_VNAME, &version); - version_field = MM_PLAYER_WMV_VNAME; - - } else if (g_str_has_prefix(stream_type, "video/x-divx")) { - gst_structure_get_int(str, MM_PLAYER_DIVX_VNAME, &version); - version_field = MM_PLAYER_DIVX_VNAME; - } - - if (version) - player->unlinked_video_mime = g_strdup_printf("%s, %s=%d", stream_type, version_field, version); - else - player->unlinked_video_mime = g_strdup_printf("%s", stream_type); - } else if (g_str_has_prefix(stream_type, "audio/")) { - if (g_str_has_prefix(stream_type, "audio/mpeg")) { - // mp3 or aac - gst_structure_get_int(str, MM_PLAYER_MPEG_VNAME, &version); - version_field = MM_PLAYER_MPEG_VNAME; - } else if (g_str_has_prefix(stream_type, "audio/x-wma")) { - gst_structure_get_int(str, MM_PLAYER_WMA_VNAME, &version); - version_field = MM_PLAYER_WMA_VNAME; - } - - if (version) - player->unlinked_audio_mime = g_strdup_printf("%s, %s=%d", stream_type, version_field, version); - else - player->unlinked_audio_mime = g_strdup_printf("%s", stream_type); - } - - MMPLAYER_FLEAVE(); -} - -static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer data) -{ - mm_player_t* player = (mm_player_t*) data; - GstCaps *caps = NULL; - GstStructure *str = NULL; - const char *name; - - MMPLAYER_FENTER(); - MMPLAYER_RETURN_IF_FAIL(player); - MMPLAYER_RETURN_IF_FAIL(pad); - - GST_OBJECT_LOCK(pad); - if ((caps = gst_pad_get_current_caps(pad))) - gst_caps_ref(caps); - GST_OBJECT_UNLOCK(pad); - - if (NULL == caps) { - caps = gst_pad_query_caps(pad, NULL); - if (!caps) return; - } - - MMPLAYER_LOG_GST_CAPS_TYPE(caps); - - str = gst_caps_get_structure(caps, 0); - if (!str) - return; - - name = gst_structure_get_name(str); - if (!name) - return; - - player->num_dynamic_pad++; - LOGD("stream count inc : %d\n", player->num_dynamic_pad); - - /* Note : If the stream is the subtitle, we try not to play it. Just close the demuxer subtitle pad. - * If want to play it, remove this code. - */ - if (g_strrstr(name, "application")) { - if (g_strrstr(name, "x-id3") || g_strrstr(name, "x-apetag")) { - /* If id3/ape tag comes, keep going */ - LOGD("application mime exception : id3/ape tag"); - } else { - /* Otherwise, we assume that this stream is subtile. */ - LOGD(" application mime type pad is closed."); - return; - } - } else if (g_strrstr(name, "audio")) { - gint samplerate = 0, channels = 0; - - if (player->audiodec_linked) { - gst_caps_unref(caps); - LOGD("multi tracks. skip to plug"); - return; - } - - /* set stream information */ - /* if possible, set it here because the caps is not distrubed by resampler. */ - gst_structure_get_int(str, "rate", &samplerate); - mm_attrs_set_int_by_name(player->attrs, "content_audio_samplerate", samplerate); - - gst_structure_get_int(str, "channels", &channels); - mm_attrs_set_int_by_name(player->attrs, "content_audio_channels", channels); - - LOGD("audio samplerate : %d channels : %d", samplerate, channels); - } else if (g_strrstr(name, "video")) { - gint stype; - mm_attrs_get_int_by_name(player->attrs, "display_surface_type", &stype); - - /* don't make video because of not required */ - if (stype == MM_DISPLAY_SURFACE_NULL || stype == MM_DISPLAY_SURFACE_REMOTE) { - LOGD("no video because it's not required"); - return; - } - - player->v_stream_caps = gst_caps_copy(caps); //if needed, video caps is required when videobin is created - } - - if (!__mmplayer_try_to_plug(player, pad, caps)) { - LOGE("failed to autoplug for type(%s)", name); - - __mmplayer_set_unlinked_mime_type(player, caps); - } - - gst_caps_unref(caps); - - MMPLAYER_FLEAVE(); - return; -} - gboolean __mmplayer_check_subtitle(mm_player_t* player) { @@ -13127,13 +11829,8 @@ __mmplayer_handle_streaming_error(mm_player_t* player, GstMessage * message) MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); MMPLAYER_RETURN_VAL_IF_FAIL(message, FALSE); - s = malloc(sizeof(GstStructure)); - if (s == NULL) { - LOGE("failed to alloc data."); - return FALSE; - } + s = gst_structure_copy(gst_message_get_structure(message)); - memcpy(s, gst_message_get_structure(message), sizeof(GstStructure)); if (!gst_structure_get_uint(s, "error_id", &error_id)) error_id = MMPLAYER_STREAMING_ERROR_NONE; @@ -13276,7 +11973,7 @@ __mmplayer_handle_streaming_error(mm_player_t* player, GstMessage * message) break; default: { - MMPLAYER_FREEIF(s); + gst_structure_free(s); return MM_ERROR_PLAYER_STREAMING_FAIL; } } @@ -13301,7 +11998,7 @@ __mmplayer_handle_streaming_error(mm_player_t* player, GstMessage * message) } else LOGD("skip error post because it's sent already.\n"); - MMPLAYER_FREEIF(s); + gst_structure_free(s); MMPLAYER_FLEAVE(); g_free(error_string); @@ -13314,7 +12011,6 @@ __mmplayer_handle_eos_delay(mm_player_t* player, int delay_in_ms) { MMPLAYER_RETURN_IF_FAIL(player); - /* post now if delay is zero */ if (delay_in_ms == 0 || player->set_mode.pcm_extraction) { LOGD("eos delay is zero. posting EOS now\n"); @@ -13392,116 +12088,6 @@ __mmplayer_eos_timer_cb(gpointer u_data) return FALSE; } -static gboolean -__mmplayer_link_decoder(mm_player_t* player, GstPad *srcpad) -{ - const gchar* name = NULL; - GstStructure* str = NULL; - GstCaps* srccaps = NULL; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); - MMPLAYER_RETURN_VAL_IF_FAIL(srcpad, FALSE); - - /* to check any of the decoder(video/audio) need to be linked to parser*/ - srccaps = gst_pad_query_caps(srcpad, NULL); - if (!srccaps) - goto ERROR; - - str = gst_caps_get_structure(srccaps, 0); - if (!str) - goto ERROR; - - name = gst_structure_get_name(str); - if (!name) - goto ERROR; - - if (strstr(name, "video")) { - if (player->videodec_linked) { - LOGI("Video decoder already linked\n"); - return FALSE; - } - } - if (strstr(name, "audio")) { - if (player->audiodec_linked) { - LOGI("Audio decoder already linked\n"); - return FALSE; - } - } - - gst_caps_unref(srccaps); - - MMPLAYER_FLEAVE(); - - return TRUE; - -ERROR: - if (srccaps) - gst_caps_unref(srccaps); - - return FALSE; -} - -static gboolean -__mmplayer_link_sink(mm_player_t* player , GstPad *srcpad) -{ - const gchar* name = NULL; - GstStructure* str = NULL; - GstCaps* srccaps = NULL; - - MMPLAYER_FENTER(); - - MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); - MMPLAYER_RETURN_VAL_IF_FAIL(srcpad, FALSE); - - /* to check any of the decoder(video/audio) need to be linked to parser*/ - srccaps = gst_pad_query_caps(srcpad, NULL); - if (!srccaps) - goto ERROR; - - str = gst_caps_get_structure(srccaps, 0); - if (!str) - goto ERROR; - - name = gst_structure_get_name(str); - if (!name) - goto ERROR; - - if (strstr(name, "video")) { - if (player->videosink_linked) { - LOGI("Video Sink already linked\n"); - return FALSE; - } - } - if (strstr(name, "audio")) { - if (player->audiosink_linked) { - LOGI("Audio Sink already linked\n"); - return FALSE; - } - } - if (strstr(name, "text")) { - if (player->textsink_linked) { - LOGI("Text Sink already linked\n"); - return FALSE; - } - } - - gst_caps_unref(srccaps); - - MMPLAYER_FLEAVE(); - - //return (!player->videosink_linked || !player->audiosink_linked); - return TRUE; - -ERROR: - if (srccaps) - gst_caps_unref(srccaps); - - return FALSE; -} - - /* sending event to one of sinkelements */ static gboolean __gst_send_event_to_sink(mm_player_t* player, GstEvent* event) @@ -13517,8 +12103,8 @@ __gst_send_event_to_sink(mm_player_t* player, GstEvent* event) /* While adding subtitles in live feeds seek is getting called. Adding defensive check in framework layer.*/ if (GST_EVENT_TYPE(event) == GST_EVENT_SEEK) { - if (MMPLAYER_IS_LIVE_STREAMING (player)) { - LOGE ("Should not send seek event during live playback"); + if (MMPLAYER_IS_LIVE_STREAMING(player)) { + LOGE("Should not send seek event during live playback"); return TRUE; } } @@ -13565,13 +12151,6 @@ __gst_send_event_to_sink(mm_player_t* player, GstEvent* event) sinks = g_list_next(sinks); } -#if 0 - if (internal_sub) - request pad name = sink0; - else - request pad name = sink1; // external -#endif - /* Note : Textbin is not linked to the video or audio bin. * It needs to send the event to the text sink seperatelly. */ @@ -13900,7 +12479,7 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c } /* unlink between decoder and videobin and remove previous videosink from videobin */ - GST_ELEMENT_UNLINK(GST_ELEMENT(player->pipeline->mainbin[dec_index].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_BIN].gst)); + gst_element_unlink(GST_ELEMENT(player->pipeline->mainbin[dec_index].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_BIN].gst)); if (!gst_bin_remove(GST_BIN(player->pipeline->videobin[MMPLAYER_V_BIN].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_SINK].gst))) { LOGE("failed to remove former videosink from videobin"); return MM_ERROR_PLAYER_INTERNAL; @@ -13982,7 +12561,7 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c LOGE("failed to get sink pad from videobin"); return MM_ERROR_PLAYER_INTERNAL; } - if (GST_PAD_LINK_OK != GST_PAD_LINK(src_pad_dec, sink_pad_videobin)) { + if (GST_PAD_LINK_OK != gst_pad_link(src_pad_dec, sink_pad_videobin)) { LOGE("failed to link"); return MM_ERROR_PLAYER_INTERNAL; } @@ -14581,45 +13160,6 @@ __has_suffix(mm_player_t* player, const gchar* suffix) } int -_mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y) -{ - mm_player_t* player = (mm_player_t*) hplayer; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - MMPLAYER_VIDEO_SINK_CHECK(player); - - LOGD("setting display zoom level = %f, offset = %d, %d", level, x, y); - - g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom", level, "zoom-pos-x", x, "zoom-pos-y", y, NULL); - - return MM_ERROR_NONE; -} -int -_mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y) -{ - - mm_player_t* player = (mm_player_t*) hplayer; - float _level = 0.0; - int _x = 0; - int _y = 0; - - MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED); - - MMPLAYER_VIDEO_SINK_CHECK(player); - - g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom", &_level, "zoom-pos-x", &_x, "zoom-pos-y", &_y, NULL); - - LOGD("display zoom level = %f, start off x = %d, y = %d", _level, _x, _y); - - *level = _level; - *x = _x; - *y = _y; - - return MM_ERROR_NONE; -} - -int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode) { mm_player_t* player = (mm_player_t*) hplayer; @@ -15195,7 +13735,7 @@ __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_ty MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); - for (i=0; i<MMPLAYER_PATH_MAX; i++) { + for (i = 0; i < MMPLAYER_PATH_MAX; i++) { if (path_type == MMPLAYER_PATH_MAX || path_type == i) { player->storage_info[i].type = STORAGE_TYPE_INTERNAL; @@ -15213,7 +13753,7 @@ __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_ty int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state) { int ret = MM_ERROR_NONE; - mm_player_t* player = (mm_player_t*) hplayer; + mm_player_t* player = (mm_player_t*)hplayer; MMMessageParamType msg_param = {0, }; MMPLAYER_FENTER(); @@ -15262,17 +13802,17 @@ int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **v return ret; } - result = g_strdup (""); + result = g_strdup(""); for (idx = 0 ; idx < total ; idx++) { VariantData *v_data = NULL; v_data = g_list_nth_data(player->adaptive_info.var_list, idx); if (v_data) { - gchar data[64]={0}; + gchar data[64] = {0}; snprintf(data, sizeof(data), "%d,%d,%d,", v_data->bandwidth, v_data->width, v_data->height); - tmp = g_strconcat (result, data, NULL); - g_free (result); + tmp = g_strconcat(result, data, NULL); + g_free(result); result = tmp; } else { LOGW("There is no variant data in %d", idx); @@ -15297,9 +13837,9 @@ int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth LOGD("set limit to [b]%d, [w]%d, [h]%d", bandwidth, width, height); - player->adaptive_info.limit.bandwidth = (bandwidth >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(bandwidth):(ADAPTIVE_VARIANT_DEFAULT_VALUE); - player->adaptive_info.limit.width = (width >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(width):(ADAPTIVE_VARIANT_DEFAULT_VALUE); - player->adaptive_info.limit.height = (height >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(height):(ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.bandwidth = (bandwidth >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (bandwidth) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.width = (width >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (width) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.height = (height >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (height) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); if (player->pipeline && player->pipeline->mainbin && player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst) { LOGD("update max limit of %s", GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst)); diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c index 4e27284..9bc37cf 100644 --- a/src/mm_player_sound_focus.c +++ b/src/mm_player_sound_focus.c @@ -117,20 +117,20 @@ __mmplayer_sound_get_stream_type(gint type) static bool __mmplayer_check_need_block(const char *focus_acquired_by) { - if (!focus_acquired_by) - return false; - - if (!strcmp(focus_acquired_by, "alarm") || - !strcmp(focus_acquired_by, "ringtone-voip") || - !strcmp(focus_acquired_by, "ringtone-call") || - !strcmp(focus_acquired_by, "voip") || - !strcmp(focus_acquired_by, "call-voice") || - !strcmp(focus_acquired_by, "call-video")) { - LOGW("Blocked by session policy, focus_acquired_by[%s]", focus_acquired_by); - return true; - } - - return false; + if (!focus_acquired_by) + return false; + + if (!strcmp(focus_acquired_by, "alarm") || + !strcmp(focus_acquired_by, "ringtone-voip") || + !strcmp(focus_acquired_by, "ringtone-call") || + !strcmp(focus_acquired_by, "voip") || + !strcmp(focus_acquired_by, "call-voice") || + !strcmp(focus_acquired_by, "call-video")) { + LOGW("Blocked by session policy, focus_acquired_by[%s]", focus_acquired_by); + return true; + } + + return false; } int @@ -147,8 +147,12 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus) } if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { + if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA) + /* option: 1 for no-resume */ + ret = mm_sound_acquire_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player acquire focus"); + else + ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus"); - ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus"); if (ret != MM_ERROR_NONE) { LOGE("failed to acquire sound focus [0x%X]", ret); return ret; @@ -201,7 +205,12 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus) } if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { - ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus"); + if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA) + /* option: 1 for no-resume */ + ret = mm_sound_release_focus_with_option(sound_focus->focus_id, FOCUS_FOR_BOTH, 1, "mm-player release focus"); + else + ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus"); + if (ret != MM_ERROR_NONE) { LOGE("failed to release sound focus\n"); return ret; diff --git a/src/mm_player_utils.c b/src/mm_player_utils.c index 8bc83b4..98c999e 100644 --- a/src/mm_player_utils.c +++ b/src/mm_player_utils.c @@ -71,122 +71,6 @@ int util_exist_file_path(const char *file_path) return MM_ERROR_NONE; } -bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size) -{ - FILE *fp = NULL; - int wsize = 0; - - fp = fopen(backup_path, "wb"); - if (!fp) - return FALSE; - - wsize = fwrite(data_ptr, sizeof(char), data_size, fp); - - fclose(fp); - - if (wsize != data_size) { - if (!access(backup_path, R_OK)) - remove(backup_path); - - LOGE("No space to write!\n"); - - return FALSE; - } - - return TRUE; -} - -bool util_remove_file_backup(const char *backup_path) -{ - if (!backup_path || !strlen(backup_path)) - return FALSE; - - int res = access(backup_path, R_OK); - if (!res) { - if (remove(backup_path) == -1) - return FALSE; - } - - return TRUE; -} - -#define DETECTION_PREFIX_SIZE 20 -int util_is_midi_type_by_mem(void *mem, int size) -{ - const char *p = (const char *)mem; - - if (size < DETECTION_PREFIX_SIZE) - return MM_AUDIO_CODEC_INVALID; - - /* mmf file detection */ - if (p[0] == 'M' && p[1] == 'M' && p[2] == 'M' && p[3] == 'D') { - LOGD("MM_AUDIO_CODEC_MMF\n"); - return MM_AUDIO_CODEC_MMF; - } - - /* midi file detection */ - if (p[0] == 'M' && p[1] == 'T' && p[2] == 'h' && p[3] == 'd') { - LOGD("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI); - return MM_AUDIO_CODEC_MIDI; - } - /* mxmf file detection */ - if (p[0] == 'X' && p[1] == 'M' && p[2] == 'F' && p[3] == '_') { - LOGD("MM_AUDIO_CODEC_MXMF\n"); - return MM_AUDIO_CODEC_MXMF; - } - - /* wave file detection */ - if (p[0] == 'R' && p[1] == 'I' && p[2] == 'F' && p[3] == 'F' && - p[8] == 'W' && p[9] == 'A' && p[10] == 'V' && p[11] == 'E' && - p[12] == 'f' && p[13] == 'm' && p[14] == 't') { - LOGD("MM_AUDIO_CODEC_WAVE\n"); - return MM_AUDIO_CODEC_WAVE; - } - /* i-melody file detection */ - if (memcmp(p, "BEGIN:IMELODY", 13) == 0) { - LOGD("MM_AUDIO_CODEC_IMELODY\n"); - return MM_AUDIO_CODEC_IMELODY; - } - - return MM_AUDIO_CODEC_INVALID; -} - -int util_is_midi_type_by_file(const char *file_path) -{ - struct stat file_attrib; - FILE *fp = NULL; - char prefix[DETECTION_PREFIX_SIZE] = {0,}; - int size; - - if (!file_path) - return FALSE; - - fp = fopen(file_path, "r"); - - if (!fp) - return FALSE; - - memset(&file_attrib, 0, sizeof(file_attrib)); - - if (stat(file_path, &file_attrib) != 0) { - fclose(fp); - return FALSE; - } - - size = (int) file_attrib.st_size; - - if (size < DETECTION_PREFIX_SIZE) { - fclose(fp); - return FALSE; - } - - size = fread(prefix, sizeof(char), DETECTION_PREFIX_SIZE, fp); - - fclose(fp); - - return util_is_midi_type_by_mem(prefix, size); -} - char** util_get_cookie_list(const char *cookies) { @@ -280,46 +164,6 @@ util_is_sdp_file(const char *path) return ret; } -int64_t -util_get_time(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; -} - -int -util_get_rank_increase(const char *factory_class) -{ - gint rank_pri_inc = 20; - gint rank_sec_inc = 10; - gint ret = 0; - - if (g_strrstr(factory_class, "Dsp")) - ret = rank_pri_inc; - else if (g_strrstr(factory_class, "HW")) - ret = rank_pri_inc; - else if (g_strrstr(factory_class, "Arm")) - ret = rank_sec_inc; - - return ret; -} - -int -util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2) -{ - const gchar *klass; - int f1_rank_inc = 0, f2_rank_inc = 0; - - klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f1)); - f1_rank_inc = util_get_rank_increase(klass); - - klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f2)); - f2_rank_inc = util_get_rank_increase(klass); - - return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc); -} - const char* util_get_charset(const char *file_path) { |