* @brief Called when the input buffer(pkt) used up.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @details It will be invoked when mediacodec has used input buffer.
- * @param[in] pkt The media packet handle
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] pkt 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()
* @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
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] pkt 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()
* @brief Called when the error has occured
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @details It will be invoked when the error has occured.
- * @param[in] error_code The error code
+ * @param[in] error_code 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()
* @brief Called when there is no data to decode/encode
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @details It will be invoked when the end-of-stream is reached.
- * @param[in] user_data The user data passed from the callback registration function
+ * @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()
* @see mediacodec_unset_eos_cb()
* @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] user_data The user data passed from the callback registration function
+ * @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()
*/
* the mediacodec cannot guarantee proper operation because of limited resources, like
* audio or display device.
*
- * @param[out] mediacodec A new handle to mediacodec
+ * @param[out] mediacodec A new handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @remarks To completely shutdown the mediacodec operation, call this function with a valid player handle from any
* mediacodec
*
- * @param[in] mediacodec The handle to mediacodec to be destroyed.
+ * @param[in] mediacodec The handle to mediacodec to be destroyed.
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @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.
- * @param[in] height The height for video decoding.
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] width The width for video decoding.
+ * @param[in] height The height for video decoding.
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @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.
- * @param[in] channel The channels for audio decoding.
- * @param[in] bit The bits resolution for audio decoding.
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] samplerate The samplerate for audio decoding.
+ * @param[in] channel The channels for audio decoding.
+ * @param[in] bit The bits resolution for audio decoding.
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit);
/**
- * @brief Sets the default info for the audio encdoer
+ * @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.
- * @param[in] channel The channels for audio encoding.
- * @param[in] bit The bits resolution for audio encoding.
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] samplerate The samplerate for audio encoding.
+ * @param[in] channel The channels for audio encoding.
+ * @param[in] bit The bits resolution for audio encoding.
* @param[in] bitrate The bitrate for audio encoding.
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
int mediacodec_set_aenc_info(mediacodec_h mediacodec, int samplerate, int channel, int bit, int bitrate);
/**
+ * @brief Sets the codec type and codec default info via media format.
+ * @details Sets the value via media format instead of mediacodec_set_codec(), mediacodec_set_venc_info(),
+ * mediacodec_set_vdec_info(), mediacodec_set_aenc_info(), and mediacodec_set_adec_info().
+ * @since_tizen 4.0
+ * @remarks When using the @a format parameter from the output of the media demuxer, you can use media format via media_packet_get_format().
+ * Otherwise, you must set the following values after creating media format.
+ * Set the audio or video codec type via media_format_set_video_mime() or media_format_set_audio_mime().
+ * For video decoding, width, height must be set via media_format_set_video_width() and media_format_set_video_height().
+ * For video encoding, width, height, target bitrate, and frame rate must be set via media_format_set_video_avg_bps() and media_format_set_video_frame_rate().
+ * For audio decoding, samplerate, channel, and bit must be set via media_format_set_audio_samplerate(), media_format_set_audio_channel() and media_format_set_audio_bit().
+ * For audio encoding, samplerate, channel, bit, and bitrate must be set via media_format_set_audio_avg_bps().\n
+ * If this codec is to be used as a decoder, pass the #MEDIACODEC_DECODER flag.
+ * If this codec is to be used as an encoder, pass the #MEDIACODEC_ENCODER flag.\n
+ * The software codec is used as default setting (#MEDIACODEC_SUPPORT_TYPE_SW) if user doesn't set hardware flag.
+ * If you wants to use h/w decoder, you needs to pass the #MEDIACODEC_DECODER | #MEDIACODEC_SUPPORT_TYPE_HW.
+ * @param[in] mediacodec The mediacodec handle
+ * @param[in] format The #media_format_h of input data
+ * @param[in] flags The encoding/decoding scheme,
+ * values of #mediacodec_support_type_e combined with bitwise 'or'
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_CODEC_NOT_FOUND Unsupported codec
+ * @pre The media format has been created and the required values for configuration have been set.
+ * @see media_format_set_video_mime()
+ * @see media_format_set_audio_mime()
+ * @see media_format_set_video_width()
+ * @see media_format_set_video_height()
+ * @see media_format_set_video_avg_bps()
+ * @see media_format_set_video_frame_rate()
+ * @see media_format_set_audio_channel()
+ * @see media_format_set_audio_samplerate()
+ * @see media_format_set_audio_bit()
+ * @see media_format_set_audio_avg_bps()
+ */
+int mediacodec_configure_from_media_format(mediacodec_h mediacodec, media_format_h format, int flags);
+
+/**
* @brief Prepares @a mediacodec for encoding/decoding.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] mediacodec The handle to mediacodec
+ * @param[in] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Unprepares @a mediacodec for encoding/decoding.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] mediacodec The handle to mediacodec
+ * @param[in] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Decodes/Encodes a packet. The function passed undecoded/unencoded packet to the input queue and decode/encode a
- * frame sequentially.
+ * frame sequentially.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] mediacodec The handle to mediacodec
- * @param[in] inbuf The current input format for the decoder/encoder
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] inbuf The current input format for the decoder/encoder
* @param[in] timeOutUs The timeout in microseconds. \n
* The input buffer wait up to "timeOutUs" microseconds.
* @return @c 0 on success, otherwise a negative error value
/**
* @brief Gets the decoded or encoded packet from the output queue.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @param[in] mediacodec The handle to mediacodec
- * @param[out] outbuf The current output of the decoder/encoder. this function passed decoded/encoded frame to output
- * queue.
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[out] outbuf 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.
* @return @c 0 on success, otherwise a negative error value
/**
* @brief Flushes both input and output buffers.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @param[in] mediacodec The handle to mediacodec
+ * @param[in] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief set 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
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
/**
* @brief unset 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
+ * @param[in] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief set 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
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
/**
* @brief unset 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] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief set 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
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
/**
* @brief unset 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] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief set 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
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
/**
* @brief unset 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] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Registers 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
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
/**
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @param[in] mediacodec The handle to mediacodec
+ * @param[in] mediacodec The handle to mediacodec
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Retrieves all supported codecs by invoking callback function once for each supported codecs.
* @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 invoke
- * @param[in] user_data The user data to be passed to the callback function
+ * @param[in] mediacodec The handle to mediacodec
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Verifies whether encoding can be performed with codec_type or not.
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @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[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)
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
/**
* @brief Gets the media packet pool allocated for recycling media packets.
* @details The user can get the pool allocated with the number of packets are required to be used in codecs.\n
- * It is recomended to use media packet pool for better stability and performance.
+ * It is recomended to use media packet pool for better stability and performance.
* @since_tizen 3.0
* @remarks The @a pool should be released using media_packet_pool_deallocate() and destroyed using media_packet_pool_destroy().
- * @param[in] mediacodec The mediacodec handle
- * @param[out] pool The allocated pool handle
+ * @param[in] mediacodec The mediacodec handle
+ * @param[out] pool The allocated pool handle
* @return @c 0 on success, otherwise a negative error value
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
return ret;
}
+int mc_configure(MMHandleType mediacodec, media_format_h format, int flags)
+{
+ int ret = MC_ERROR_NONE;
+ mc_handle_t *mc_handle = (mc_handle_t *) mediacodec;
+ int i;
+ const int codec_mask = 0xFFF0;
+ int codec_id = 0;
+ int channel = 0;
+ int samplerate = 0;
+ int bit = 0;
+ int bitrate = 0;
+ int width = 0;
+ int height = 0;
+ int fps = 0;
+ media_format_type_e type;
+ media_format_mimetype_e mimetype;
+
+ if (!mc_handle) {
+ LOGE("fail invaild param");
+ return MC_INVALID_ARG;
+ }
+
+ if (media_format_get_type(format, &type) != MEDIA_FORMAT_ERROR_NONE) {
+ LOGE("failed to retrieve type");
+ return MC_INVALID_ARG;
+ }
+
+ if (type == MEDIA_FORMAT_AUDIO) {
+ media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &bitrate);
+
+ if (GET_IS_ENCODER(flags)) {
+ if ((samplerate <= 0) || (channel <= 0) || (bit <= 0) || (bitrate <= 0)) {
+ LOGE("invalid pram is set : samplerate : %d, channel : %d, bit : %d, bitrate : %d",
+ samplerate, channel, bit, bitrate);
+ return MC_PARAM_ERROR;
+ }
+
+ mc_handle->info.encoder.samplerate = samplerate;
+ mc_handle->info.encoder.channel = channel;
+ mc_handle->info.encoder.bit = bit;
+ mc_handle->info.encoder.bitrate = bitrate * 1000;
+ } else if (GET_IS_DECODER(flags)) {
+ if ((samplerate <= 0) || (channel <= 0) || (bit <= 0)) {
+ LOGE("invalid pram is set : samplerate : %d, channel : %d, bit : %d",
+ samplerate, channel, bit);
+ return MC_PARAM_ERROR;
+ }
+ mc_handle->info.decoder.samplerate = samplerate;
+ mc_handle->info.decoder.channel = channel;
+ mc_handle->info.decoder.bit = bit;
+ } else {
+ LOGE("either an encoder or a decoder must be set");
+ return MC_PARAM_ERROR;
+ }
+ } else if (type == MEDIA_FORMAT_VIDEO) {
+ media_format_get_video_info(format, &mimetype, &width, &height, &bitrate, NULL);
+ media_format_get_video_frame_rate(format, &fps);
+
+ if (GET_IS_ENCODER(flags)) {
+ if ((width <= 0) || (height <= 0) || (bitrate <= 0) || (fps <= 0)) {
+ LOGE("invalid pram is set : width : %d, height : %d, bitrate : %d, fps : %d",
+ width, height, bitrate, fps);
+ return MC_PARAM_ERROR;
+ }
+
+ mc_handle->info.encoder.width = width;
+ mc_handle->info.encoder.height = height;
+ mc_handle->info.encoder.fps = fps;
+ mc_handle->info.encoder.bitrate = bitrate * 1000;
+ } else if (GET_IS_DECODER(flags)) {
+ if ((width <= 0) || (height <= 0)) {
+ LOGE("invalid pram is set : width : %d, height : %d",
+ width, height);
+ return MC_PARAM_ERROR;
+ }
+
+ mc_handle->info.decoder.width = width;
+ mc_handle->info.decoder.height = height;
+ } else {
+ LOGE("either an encoder or a decoder must be set");
+ return MC_PARAM_ERROR;
+ }
+ } else {
+ LOGE("invalid format type is set");
+ return MC_PARAM_ERROR;
+ }
+
+ if (!GET_IS_HW(flags) && !GET_IS_SW(flags))
+ flags |= MEDIACODEC_SUPPORT_TYPE_SW;
+
+ codec_id = mimetype & codec_mask;
+
+ for (i = 0; i < mc_handle->ini->num_supported_codecs; i++) {
+ if ((codec_id == spec_emul[i].codec_id) && (flags == spec_emul[i].codec_type))
+ break;
+ }
+ LOGD("support_list : %d, i : %d", mc_handle->ini->num_supported_codecs, i);
+
+ if (i == mc_handle->ini->num_supported_codecs)
+ return MC_CODEC_NOT_FOUND;
+
+ mc_handle->port_type = spec_emul[i].port_type;
+
+ mc_handle->is_encoder = GET_IS_ENCODER(flags) ? 1 : 0;
+ mc_handle->is_hw = GET_IS_HW(flags) ? 1 : 0;
+ mc_handle->codec_id = codec_id;
+ mc_handle->is_video = CHECK_BIT(codec_id, 13);
+
+ mc_handle->is_prepared = true;
+
+ LOGD("encoder : %d, hardware : %d, codec_id : %x, video : %d",
+ mc_handle->is_encoder, mc_handle->is_hw, mc_handle->codec_id, mc_handle->is_video);
+
+ return ret;
+}
+
int mc_prepare(MMHandleType mediacodec)
{
int ret = MC_ERROR_NONE;
app->offset += *size;
}
*/
-int _configure(App *app, int codecid, int flag, gboolean *hardware)
+int _configure(App *app, int codecid, int flag, gboolean *hardware, media_format_mimetype_e *codec_mime)
{
gboolean encoder;
media_format_mimetype_e mime = 0;
if (encoder) {
extractor = yuv_extractor;
mime = *hardware ? MEDIA_FORMAT_NV12 : MEDIA_FORMAT_I420;
+ *codec_mime = MEDIA_FORMAT_H264_SP;
} else {
extractor = h264_extractor;
mime = MEDIA_FORMAT_H264_SP;
if (encoder) {
extractor = yuv_extractor;
mime = *hardware ? MEDIA_FORMAT_NV12 : MEDIA_FORMAT_I420;
+ *codec_mime = MEDIA_FORMAT_MPEG4_SP;
} else {
extractor = mpeg4_extractor;
mime = MEDIA_FORMAT_MPEG4_SP;
if (encoder) {
extractor = yuv_extractor;
mime = *hardware ? MEDIA_FORMAT_NV12 : MEDIA_FORMAT_I420;
+ *codec_mime = MEDIA_FORMAT_H263;
} else {
extractor = h263_extractor;
- mime = MEDIA_FORMAT_H263P;
+ mime = MEDIA_FORMAT_H263;
}
break;
case MEDIACODEC_AAC:
if (encoder) {
extractor = aacenc_extractor;
mime = MEDIA_FORMAT_PCM_F32LE; /* FIXME need to check according to verdor */
+ *codec_mime = MEDIA_FORMAT_AAC;
} else {
extractor = aacdec_extractor;
mime = MEDIA_FORMAT_AAC;
if (encoder) {
extractor = aacenc_extractor;
mime = MEDIA_FORMAT_PCM_F32LE; /* FIXME need to check according to verdor */
+ *codec_mime = MEDIA_FORMAT_AAC_HE;
}
break;
case MEDIACODEC_AAC_HE_PS:
void _mediacodec_prepare(App *app, gboolean frame_all)
{
int ret;
+ media_format_mimetype_e codec_mime;
+ media_format_h codec_format;
g_print("supported codec lists -internal-\n");
mediacodec_foreach_supported_codec_static((mediacodec_supported_codec_cb)_foreach_cb, app);
g_print("mediacodec_create failed\n");
return;
}
-
+#if 0
/* set codec */
ret = mediacodec_set_codec(app->mc_handle[0], app->codecid, app->flag);
if (ret != MEDIACODEC_ERROR_NONE) {
g_print("mediacodec_set_codec failed\n");
return;
}
-
+#endif
/* get mime and link to each codec parser */
- app->mime = _configure(app, app->codecid, app->flag, &app->hardware);
+ app->mime = _configure(app, app->codecid, app->flag, &app->hardware, &codec_mime);
/* set codec info */
ret = media_format_create(&fmt);
switch (app->type) {
case VIDEO_DEC:
- ret = mediacodec_set_vdec_info(app->mc_handle[0], app->width, app->height);
media_format_set_video_mime(fmt, app->mime);
media_format_set_video_width(fmt, app->width);
media_format_set_video_height(fmt, app->height);
+
+ ret = mediacodec_configure_from_media_format(app->mc_handle[0], fmt, app->flag);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ g_print("mediacodec_configure failed\n");
break;
case VIDEO_ENC:
- ret = mediacodec_set_venc_info(app->mc_handle[0], app->width, app->height, app->fps, app->target_bits);
media_format_set_video_mime(fmt, app->mime);
media_format_set_video_width(fmt, app->width);
media_format_set_video_height(fmt, app->height);
media_format_set_video_avg_bps(fmt, app->target_bits);
+
+ media_format_create(&codec_format);
+ media_format_set_video_mime(codec_format, codec_mime);
+ media_format_set_video_width(codec_format, app->width);
+ media_format_set_video_height(codec_format, app->height);
+ media_format_set_video_avg_bps(codec_format, app->target_bits);
+ media_format_set_video_frame_rate(codec_format, app->fps);
+
+ ret = mediacodec_configure_from_media_format(app->mc_handle[0], codec_format, app->flag);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ g_print("mediacodec_configure failed\n");
+ media_format_unref(codec_format);
break;
case AUDIO_DEC:
- ret = mediacodec_set_adec_info(app->mc_handle[0], app->samplerate, app->channel, app->bit);
media_format_set_audio_mime(fmt, app->mime);
media_format_set_audio_channel(fmt, app->channel);
media_format_set_audio_samplerate(fmt, app->samplerate);
media_format_set_audio_bit(fmt, app->bit);
+
+ ret = mediacodec_configure_from_media_format(app->mc_handle[0], fmt, app->flag);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ g_print("mediacodec_configure failed\n");
break;
case AUDIO_ENC:
- ret = mediacodec_set_aenc_info(app->mc_handle[0], app->samplerate, app->channel, app->bit, app->bitrate);
media_format_set_audio_mime(fmt, app->mime);
media_format_set_audio_channel(fmt, app->channel);
media_format_set_audio_samplerate(fmt, app->samplerate);
media_format_set_audio_bit(fmt, app->bit);
+
+ media_format_create(&codec_format);
+ media_format_set_audio_mime(codec_format, codec_mime);
+ media_format_set_audio_channel(codec_format, app->channel);
+ media_format_set_audio_samplerate(codec_format, app->samplerate);
+ media_format_set_audio_bit(codec_format, app->bit);
+
+ ret = mediacodec_configure_from_media_format(app->mc_handle[0], codec_format, app->flag);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ g_print("mediacodec_set_configure failed\n");
+ media_format_unref(codec_format);
break;
default:
g_print("invaild type\n");