From: Sejun Park Date: Thu, 3 May 2018 01:51:41 +0000 (+0900) Subject: [ACR-1217] Added enum for resource conflict X-Git-Tag: submit/tizen/20180510.014849^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F83%2F177683%2F5;p=platform%2Fcore%2Fapi%2Fmediacodec.git [ACR-1217] Added enum for resource conflict Change-Id: I5029960a6024f9b4710928808a555012f38476eb --- diff --git a/doc/media_codec_doc.h b/doc/media_codec_doc.h index 36a1586..1c41347 100755 --- a/doc/media_codec_doc.h +++ b/doc/media_codec_doc.h @@ -35,7 +35,7 @@ * * @section CAPI_MEDIA_CODEC_FEATURE Related Features * This API is related with the following features:\n - * - %http://tizen.org/feature/multimedia.media_codec:\n + * - %http://tizen.org/feature/multimedia.media_codec\n * * It is recommended to design feature related codes in your application for reliability.\n * diff --git a/include/media_codec.h b/include/media_codec.h index 835cbec..5626215 100755 --- a/include/media_codec.h +++ b/include/media_codec.h @@ -43,7 +43,7 @@ extern "C" { typedef struct mediacodec_s *mediacodec_h; /** - * @brief Enumeration of media codec support type + * @brief Enumeration of media codec support type. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks If this codec is to be used as an encoder or decoder, the codec flag must be set to #MEDIACODEC_ENCODER or * #MEDIACODEC_DECODER. If user doesn't set optional flag, default flags will be set to #MEDIACODEC_SUPPORT_TYPE_SW. @@ -56,7 +56,7 @@ typedef enum { } mediacodec_support_type_e; /** - * @brief Enumerations of media codec type + * @brief Enumerations of media codec type. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -94,7 +94,7 @@ typedef enum { } mediacodec_codec_type_e; /** - * @brief Enumeration of media codec error + * @brief Enumeration of media codec error. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -118,46 +118,54 @@ typedef enum { MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE = TIZEN_ERROR_MEDIACODEC | 0x0c, /**< Not available buffer */ MEDIACODEC_ERROR_OVERFLOW_INBUFFER = TIZEN_ERROR_MEDIACODEC | 0x0d, /**< Overflow input buffer (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif)*/ MEDIACODEC_ERROR_RESOURCE_OVERLOADED = TIZEN_ERROR_MEDIACODEC | 0x0e, /**< Exceed the instance limits (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif)*/ + MEDIACODEC_ERROR_RESOURCE_CONFLICT = TIZEN_ERROR_MEDIACODEC | 0x0f, /**< Interrupted by a resource conflict (Since 5.0)*/ } mediacodec_error_e; /** - * @brief Enumeration of buffer status + * @brief Enumeration of buffer status. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - MEDIACODEC_NEED_DATA, - MEDIACODEC_ENOUGH_DATA + MEDIACODEC_NEED_DATA, /**< The internal queue is running out of data */ + MEDIACODEC_ENOUGH_DATA /**< The internal queue is full */ } mediacodec_status_e; /** - * @brief Called when the input buffer(pkt) used up. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @brief Called when the input buffer(packet) used up. * @details It will be invoked when mediacodec has used input buffer. - * @param[in] pkt The media packet handle + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks The @a packet should be released using media_packet_destroy(). + * @param[in] packet The media packet handle * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when input buffer process completed if you register this callback using mediacodec_set_input_buffer_used_cb(). * @see mediacodec_set_input_buffer_used_cb() * @see mediacodec_unset_input_buffer_used_cb() */ -typedef void (*mediacodec_input_buffer_used_cb)(media_packet_h pkt, void *user_data); +typedef void (*mediacodec_input_buffer_used_cb)(media_packet_h packet, void *user_data); /** * @brief Called when the output buffer is available. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @details It will be invoked when mediacodec has output buffer. - * @param[in] pkt The media packet handle + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks The @a packet should be released using media_packet_destroy(). + * @param[in] packet The media packet handle * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when mediacodec process completed(had output buffer) if you register this callback using mediacodec_set_fill_buffer_cb(). * @see mediacodec_set_output_buffer_available_cb() * @see mediacodec_unset_output_buffer_available_cb() */ -typedef void (*mediacodec_output_buffer_available_cb)(media_packet_h pkt, void *user_data); +typedef void (*mediacodec_output_buffer_available_cb)(media_packet_h packet, void *user_data); /** - * @brief Called when the error has occured - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @brief Called when the error has occured. * @details It will be invoked when the error has occured. - * @param[in] error_code The error code + * Following error codes can be delivered. + * #MEDIACODEC_ERROR_INTERNAL, + * #MEDIACODEC_ERROR_INVALID_STREAM, + * #MEDIACODEC_ERROR_NOT_SUPPORTED_FORMAT, + * #MEDIACODEC_ERROR_RESOURCE_CONFLICT + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] error The error code * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when the error has occured if you register this callback using mediacodec_set_error_cb(). * @see mediacodec_set_error_cb() @@ -166,9 +174,9 @@ typedef void (*mediacodec_output_buffer_available_cb)(media_packet_h pkt, void * typedef void (*mediacodec_error_cb)(mediacodec_error_e error, void *user_data); /** - * @brief Called when there is no data to decode/encode - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @brief Called when there is no data to decode/encode. * @details It will be invoked when the end-of-stream is reached. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] user_data The user data passed from the callback registration function * @pre It will be invoked when the eos event generate if you register this callback using mediacodec_set_eos_cb(). * @see mediacodec_set_eos_cb() @@ -178,9 +186,10 @@ typedef void (*mediacodec_eos_cb)(void *user_data); /** * @brief Called when the mediacodec needs more data or has enough data. + * @details It is recommended that the application stops calling mediacodec_process_input() when #MEDIACODEC_ENOUGH_DATA * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * @details It is recommended that the application stops calling mediacodec_process_input() when MEDIACODEC_ENOUGH_DATA * is invoked. + * @param[in] status The state of the buffer * @param[in] user_data The user data passed from the callback registration function * @see mediacodec_set_buffer_status_cb() * @see mediacodec_unset_buffer_status_cb() @@ -199,7 +208,7 @@ typedef void (*mediacodec_buffer_status_cb)(mediacodec_status_e status, void *us typedef bool (*mediacodec_supported_codec_cb)(mediacodec_codec_type_e codec_type, void *user_data); /** - * @brief Creates a mediacodec handle for decoding/encoding + * @brief Creates a mediacodec handle for decoding/encoding. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks you must release @a mediacodec using mediacodec_destroy().\n * Although you can create multiple mediacodec handles at the same time, @@ -253,7 +262,7 @@ int mediacodec_destroy(mediacodec_h mediacodec); int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_type, int flags); /** - * @brief Sets the default info for the video decoder + * @brief Sets the default info for the video decoder. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] width The width for video decoding. @@ -268,7 +277,7 @@ int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_ int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height); /** - * @brief Sets the default info for the video encoder + * @brief Sets the default info for the video encoder. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks The frame rate is the speed of recording and the speed of playback. * If user wants the default setting for ratecontrol, set @a target_bits to @c 0. @@ -287,7 +296,7 @@ int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height); int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int fps, int target_bits); /** - * @brief Sets the default info for the audio decoder + * @brief Sets the default info for the audio decoder. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] samplerate The samplerate for audio decoding. @@ -303,7 +312,7 @@ int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit); /** - * @brief Sets the default info for the audio encoder + * @brief Sets the default info for the audio encoder. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] samplerate The samplerate for audio encoding. @@ -368,6 +377,8 @@ int mediacodec_configure_from_media_format(mediacodec_h mediacodec, media_format * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) + * @retval #MEDIACODEC_ERROR_RESOURCE_OVERLOADED Exceed the instance limits (Since 5.0) + * @retval #MEDIACODEC_ERROR_INTERNAL Internal error (Since 5.0) * @pre The mediacodec should call mediacodec_set_codec()and mediacodec_set_vdec_info()/mediacodec_set_venc_info() before calling mediacodec_prepare() * If the decoder is set by mediacodec_set_codec(), mediacodec_set_vdec_info() should be called. If the encoder is set by * mediacodec_set_codec(), mediacodec_set_venc_info() should be called. @@ -408,8 +419,9 @@ int mediacodec_process_input(mediacodec_h mediacodec, media_packet_h inbuf, uint /** * @brief Gets the decoded or encoded packet from the output queue. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks The @a packet should be released using media_packet_destroy(). * @param[in] mediacodec The handle to mediacodec - * @param[out] outbuf The current output of the decoder/encoder. + * @param[out] packet The current output of the decoder/encoder. * this function passed decoded/encoded frame to output queue. * @param[in] timeOutUs The timeout in microseconds. \n * The input buffer wait up to "timeOutUs" microseconds. @@ -420,7 +432,7 @@ int mediacodec_process_input(mediacodec_h mediacodec, media_packet_h inbuf, uint * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) */ -int mediacodec_get_output(mediacodec_h mediacodec, media_packet_h *outbuf, uint64_t timeOutUs); +int mediacodec_get_output(mediacodec_h mediacodec, media_packet_h *packet, uint64_t timeOutUs); /** * @brief Flushes both input and output buffers. @@ -434,7 +446,7 @@ int mediacodec_get_output(mediacodec_h mediacodec, media_packet_h *outbuf, uint6 int mediacodec_flush_buffers(mediacodec_h mediacodec); /** - * @brief set empty buffer callback the media codec for process, asynchronously. + * @brief Sets empty buffer callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] callback The callback function to register @@ -443,15 +455,15 @@ int mediacodec_flush_buffers(mediacodec_h mediacodec); * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) - * @pre mediacodec_set_input_buffer_used_cb should be called before mediacodec_preare(). - * @post mediacodec_input_buffer_used_cb will be invoked. + * @pre mediacodec_set_input_buffer_used_cb() should be called before mediacodec_preare(). + * @post mediacodec_input_buffer_used_cb() will be invoked. * @see mediacodec_set_input_buffer_used_cb() * @see mediacodec_unset_input_buffer_used_cb() */ int mediacodec_set_input_buffer_used_cb(mediacodec_h mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data); /** - * @brief unset input buffer used callback the media codec for process, asynchronously. + * @brief Unsets input buffer used callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @return @c 0 on success, otherwise a negative error value @@ -463,7 +475,7 @@ int mediacodec_set_input_buffer_used_cb(mediacodec_h mediacodec, mediacodec_inpu int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec); /** - * @brief set output buffer available callback the media codec for process, asynchronously. + * @brief Sets output buffer available callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] callback The callback function to register @@ -472,15 +484,15 @@ int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec); * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) - * @pre mediacodec_set_output_buffer_available_cb should be called before mediacodec_preare(). - * @post mediacodec_output_buffer_available_cb will be invoked. + * @pre mediacodec_set_output_buffer_available_cb() should be called before mediacodec_preare(). + * @post mediacodec_output_buffer_available_cb() will be invoked. * @see mediacodec_set_output_buffer_available_cb() * @see mediacodec_unset_output_buffer_available_cb() */ int mediacodec_set_output_buffer_available_cb(mediacodec_h mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data); /** - * @brief unset output buffer available callback the media codec for process, asynchronously. + * @brief unsets output buffer available callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @return @c 0 on success, otherwise a negative error value @@ -492,7 +504,7 @@ int mediacodec_set_output_buffer_available_cb(mediacodec_h mediacodec, mediacode int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec); /** - * @brief set error callback the media codec for process, asynchronously. + * @brief Sets error callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] callback The callback function to register @@ -501,15 +513,15 @@ int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec); * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) - * @pre mediacodec_set_error_cb should be called before mediacodec_preare(). - * @post mediacodec_error_cb will be invoked. + * @pre mediacodec_set_error_cb() should be called before mediacodec_preare(). + * @post mediacodec_error_cb() will be invoked. * @see mediacodec_set_error_cb() * @see mediacodec_unset_error_cb() */ int mediacodec_set_error_cb(mediacodec_h mediacodec, mediacodec_error_cb callback, void* user_data); /** - * @brief unset error callback the media codec for process, asynchronously. + * @brief Unsets error callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @return @c 0 on success, otherwise a negative error value @@ -521,7 +533,7 @@ int mediacodec_set_error_cb(mediacodec_h mediacodec, mediacodec_error_cb callbac int mediacodec_unset_error_cb(mediacodec_h mediacodec); /** - * @brief set eos callback the media codec for process, asynchronously. + * @brief Sets eos callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] callback The callback function to register @@ -530,15 +542,15 @@ int mediacodec_unset_error_cb(mediacodec_h mediacodec); * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) - * @pre mediacodec_set_eos_cb should be called before mediacodec_preare(). - * @post mediacodec_eos_cb will be invoked. + * @pre mediacodec_set_eos_cb() should be called before mediacodec_preare(). + * @post mediacodec_eos_cb() will be invoked. * @see mediacodec_set_eos_cb() * @see mediacodec_unset_eos_cb() */ int mediacodec_set_eos_cb(mediacodec_h mediacodec, mediacodec_eos_cb callback, void* user_data); /** - * @brief unset eos callback the media codec for process, asynchronously. + * @brief unsets eos callback the media codec for process, asynchronously. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] mediacodec The handle to mediacodec * @return @c 0 on success, otherwise a negative error value @@ -550,7 +562,7 @@ int mediacodec_set_eos_cb(mediacodec_h mediacodec, mediacodec_eos_cb callback, v int mediacodec_unset_eos_cb(mediacodec_h mediacodec); /** - * @brief Registers a callback function to be invoked when the mediacodec needs more data or has enough data. + * @brief Sets a callback function to be invoked when the mediacodec needs more data or has enough data. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @param[in] mediacodec The handle to mediacodec * @param[in] callback The callback function to register @@ -559,15 +571,15 @@ int mediacodec_unset_eos_cb(mediacodec_h mediacodec); * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0) - * @pre mediacodec_set_buffer_status_cb should be called before mediacodec_preare(). - * @post mediacodec_buffer_status_cb will be invoked. + * @pre mediacodec_set_buffer_status_cb() should be called before mediacodec_preare(). + * @post mediacodec_buffer_status_cb() will be invoked. * @see mediacodec_set_buffer_status_cb() * @see mediacodec_unset_buffer_status_cb() */ int mediacodec_set_buffer_status_cb(mediacodec_h mediacodec, mediacodec_buffer_status_cb callback, void* user_data); /** - * @brief Unregisters the callback function. + * @brief Unsets the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @param[in] mediacodec The handle to mediacodec * @return @c 0 on success, otherwise a negative error value @@ -597,7 +609,7 @@ int mediacodec_foreach_supported_codec(mediacodec_h mediacodec, mediacodec_suppo * @param[in] mediacodec The handle to mediacodec * @param[in] codec_type The identifier of the codec type of the encoder. * @param[in] encoder Whether the encoder or decoder : (@c true = encoder, @c false = decoder). - * @param[out] support_type (@c MEDIACODEC_SUPPORT_TYPE_HW = mediacodec can be performed with hardware codec, @c MEDIACODEC_SUPPORT_TYPE_SW = mediacodec can be performed with software codec) + * @param[out] support_type (@c #MEDIACODEC_SUPPORT_TYPE_HW = mediacodec can be performed with hardware codec, @c #MEDIACODEC_SUPPORT_TYPE_SW = mediacodec can be performed with software codec) * @return @c 0 on success, otherwise a negative error value * @retval #MEDIACODEC_ERROR_NONE Successful * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter diff --git a/packaging/capi-media-codec.spec b/packaging/capi-media-codec.spec index 5c09524..daabadd 100755 --- a/packaging/capi-media-codec.spec +++ b/packaging/capi-media-codec.spec @@ -4,7 +4,7 @@ Name: capi-media-codec Summary: A Media Codec library in Tizen Native API -Version: 0.5.12 +Version: 0.5.13 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_codec.c b/src/media_codec.c index 526c1b3..b76269a 100644 --- a/src/media_codec.c +++ b/src/media_codec.c @@ -327,6 +327,7 @@ int mediacodec_prepare(mediacodec_h mediacodec) 1, &resource); if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) switch (rm_ret) { + LOGE("Failed to acquire resource manager %x", rm_ret); case MM_RESOURCE_MANAGER_ERROR_NOT_SUPPORTED: return MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE; case MM_RESOURCE_MANAGER_ERROR_NOT_ENOUGH: @@ -338,12 +339,8 @@ int mediacodec_prepare(mediacodec_h mediacodec) rm_ret = mm_resource_manager_commit(resource_manager); if (rm_ret != MM_RESOURCE_MANAGER_ERROR_NONE) { mm_resource_manager_mark_for_release(resource_manager, resource); - switch (rm_ret) { - case MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY: - return MEDIACODEC_ERROR_RESOURCE_OVERLOADED; - default: - return MEDIACODEC_ERROR_INTERNAL; - } + LOGE("Failed to commit resource manager : %x", rm_ret); + return MEDIACODEC_ERROR_INTERNAL; } handle->codec_resource = resource; @@ -711,7 +708,7 @@ static int __mediacodec_resource_release_cb(mm_resource_manager_h rm, */ handle->codec_resource = NULL; mediacodec_unprepare((mediacodec_h)handle); - __mediacodec_error_cb(MEDIACODEC_ERROR_RESOURCE_OVERLOADED, handle); + __mediacodec_error_cb(MEDIACODEC_ERROR_RESOURCE_CONFLICT, handle); break; } }