*
* @section CAPI_MEDIA_CODEC_MODULE_OVERVIEW Overview
*
+ * @section CAPI_MEDIA_CODEC_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - %http://tizen.org/feature/multimedia.media_codec:\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ *
* MEDIA CODEC API allows :
* The API allows you to direct access to the media codec on device. It operates on "raw" data, so any file headers
* must be stripped off. media_packet is used for zero-copy.
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_create(mediacodec_h *mediacodec);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_destroy(mediacodec_h mediacodec);
* @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
* @retval #MEDIACODEC_ERROR_CODEC_NOT_FOUND Codec not found
+ * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
*/
int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_type, int flags);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int fps, int target_bits);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_set_aenc_info(mediacodec_h mediacodec, int samplerate, int channel, int bit, int bitrate);
* @retval #MEDIACODEC_ERROR_NONE Successful
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIACODEC_ERROR_CODEC_NOT_FOUND Unsupported codec
+ * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @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()
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
* @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.
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_unprepare(mediacodec_h mediacodec);
* @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
* @retval #MEDIACODEC_ERROR_OVERFLOW_INBUFFER Overflow inputbuffer
+ * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
*/
int mediacodec_process_input(mediacodec_h mediacodec, media_packet_h inbuf, uint64_t timeOutUs);
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @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)
*/
int mediacodec_get_output(mediacodec_h mediacodec, media_packet_h *outbuf, uint64_t timeOutUs);
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
*/
int mediacodec_flush_buffers(mediacodec_h mediacodec);
* @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_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.
* @see mediacodec_set_input_buffer_used_cb()
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @see mediacodec_set_input_buffer_used_cb()
*/
int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec);
* @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_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.
* @see mediacodec_set_output_buffer_available_cb()
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @see mediacodec_set_output_buffer_available_cb()
*/
int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec);
* @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_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.
* @see mediacodec_set_error_cb()
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @see mediacodec_set_error_cb()
*/
int mediacodec_unset_error_cb(mediacodec_h mediacodec);
* @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_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.
* @see mediacodec_set_eos_cb()
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @see mediacodec_set_event_handler_cb()
*/
int mediacodec_unset_eos_cb(mediacodec_h mediacodec);
* @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_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.
* @see mediacodec_set_buffer_status_cb()
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
*/
int mediacodec_unset_buffer_status_cb(mediacodec_h mediacodec);
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @see mediacodec_foreach_supported_codec()
*/
int mediacodec_foreach_supported_codec(mediacodec_h mediacodec, mediacodec_supported_codec_cb callback, void *user_data);
* @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_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
@code
#include <media_codec.h>
mediacodec_h mediacodec;
* @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MEDIACODEC_ERROR_INVALID_OPERATION The user calls mediacodec_get_packet_pool() before calling mediacodec_prepare().
+ * @retval #MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE Not supported on device (Since 4.0)
* @pre mediacodec_get_packet_pool() should be called after calling mediacodec_prepare().
* @post If the pool is used, media_packet_pool_deallocate() and media_packet_pool_destroy() should be called.
* @see media_packet_pool_acquire_packet()
void _mc_create_decoder_map_from_ini(mc_handle_t *mc_handle);
void _mc_create_encoder_map_from_ini(mc_handle_t *mc_handle);
-const codec_type_e simple_to_codec_type_enumeration(codec_type_e codec_id);
-const codec_type_e codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id);
+mediacodec_codec_type_e simple_to_codec_type_enumeration(codec_type_e codec_id);
+codec_type_e codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id);
#ifdef __cplusplus
}
Name: capi-media-codec
Summary: A Media Codec library in Tizen Native API
-Version: 0.5.8
-Release: 2
+Version: 0.5.10
+Release: 0
Group: Multimedia/API
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
#include <media_codec_spec_emul.h>
#include <media_codec_ini.h>
+static gboolean _check_support_audio_info(mediacodec_codec_type_e codec_id, int samplerate, int channel, int bit_depth);
+static gboolean _check_support_video_info(mediacodec_codec_type_e codec_id, int width, int height);
+
int mc_create(MMHandleType *mediacodec)
{
mc_handle_t *new_mediacodec = NULL;
return MC_INVALID_ARG;
}
- if ((width <= 0) || (height <= 0))
+ if (!_check_support_video_info(mc_handle->codec_id, width, height))
return MC_PARAM_ERROR;
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && !mc_handle->is_encoder,
return MC_INVALID_ARG;
}
- if ((width <= 0) || (height <= 0))
+ if (!_check_support_video_info(mc_handle->codec_id, width, height) || fps < 0 || target_bits < 0)
return MC_PARAM_ERROR;
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && mc_handle->is_encoder,
return MC_INVALID_ARG;
}
- if ((samplerate <= 0) || (channel <= 0) || (bit <= 0))
+ if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
return MC_PARAM_ERROR;
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && !mc_handle->is_encoder,
return MC_INVALID_ARG;
}
- if ((samplerate <= 0) || (channel <= 0) || (bit <= 0))
+ if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
return MC_PARAM_ERROR;
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && mc_handle->is_encoder,
if (type == MEDIA_FORMAT_AUDIO) {
media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &bitrate);
+ codec_id = mimetype & codec_mask;
+
if (GET_IS_ENCODER(flags)) {
- if ((samplerate <= 0) || (channel <= 0) || (bit <= 0) || (bitrate <= 0)) {
+ if (!_check_support_audio_info(codec_id, samplerate, channel, bit)) {
LOGE("invalid pram is set : samplerate : %d, channel : %d, bit : %d, bitrate : %d",
samplerate, channel, bit, bitrate);
return MC_PARAM_ERROR;
mc_handle->info.audio.bit_depth = bit;
mc_handle->info.audio.bitrate = bitrate * 1000;
} else if (GET_IS_DECODER(flags)) {
- if ((samplerate <= 0) || (channel <= 0) || (bit <= 0)) {
+ if (!_check_support_audio_info(codec_id, samplerate, channel, bit)) {
LOGE("invalid pram is set : samplerate : %d, channel : %d, bit : %d",
samplerate, channel, bit);
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);
+ codec_id = mimetype & codec_mask;
if (GET_IS_ENCODER(flags)) {
- if ((width <= 0) || (height <= 0) || (bitrate <= 0) || (fps <= 0)) {
+ if (!_check_support_video_info(codec_id, width, height) || fps <= 0 || bitrate <= 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.video.framerate = fps;
mc_handle->info.video.bitrate = bitrate * 1000;
} else if (GET_IS_DECODER(flags)) {
- if ((width <= 0) || (height <= 0)) {
+ if (!_check_support_video_info(codec_id, width, height)) {
LOGE("invalid pram is set : width : %d, height : %d",
width, height);
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;
return;
}
-const codec_type_e codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id)
+codec_type_e codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id)
{
guint media_codec_id_u = (guint)media_codec_id;
}
}
-const codec_type_e simple_to_codec_type_enumeration(codec_type_e codec_id)
+mediacodec_codec_type_e simple_to_codec_type_enumeration(codec_type_e codec_id)
{
guint codec_id_u = (guint)codec_id;
return NONE;
}
}
+
+gboolean _check_support_audio_info(mediacodec_codec_type_e codec_id, int samplerate, int channel, int bit_depth)
+{
+ gint i = 0;
+ gint maxchannels = 2;
+ gint n_rates = 0;
+ gint s_bit_depth = 32;
+
+ switch (codec_id) {
+ case MEDIACODEC_AMR_NB:
+ {
+ const static gint l_rates[] = { 8000 };
+ maxchannels = 1;
+ n_rates = G_N_ELEMENTS(l_rates);
+ s_bit_depth = 16; /* NOTE: amrnbenc/amrnbdec surpports S16LE as format*/
+
+ while (i < n_rates) {
+ if (l_rates[i] == samplerate)
+ break;
+ i++;
+ }
+
+ if (i == n_rates) {
+ LOGE("Invalid samplerate set");
+ return false;
+ }
+ break;
+ }
+ case MEDIACODEC_AAC_LC:
+ case MEDIACODEC_AAC_HE:
+ {
+ const static gint l_rates[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
+ maxchannels = 6;
+ n_rates = G_N_ELEMENTS(l_rates);
+ s_bit_depth = 32; /* NOTE: avdec_aac/avenc_aac surpports S32LE as format*/
+
+ while (i < n_rates) {
+ if (l_rates[i] == samplerate)
+ break;
+ i++;
+ }
+
+ if (i == n_rates) {
+ LOGE("Invalid samplerate set");
+ return false;
+ }
+ break;
+ }
+ case MEDIACODEC_MP3:
+ {
+ s_bit_depth = 16; /* NOTE: amrenc/amrnbdec surpports S16LE as format*/
+ break;
+ }
+ case MEDIACODEC_VORBIS:
+ {
+ s_bit_depth = 32; /* NOTE: vorbisenc/vorbisdec surpports S32LE as format */
+ break;
+ }
+ case MEDIACODEC_FLAC:
+ {
+ s_bit_depth = 32; /* NOTE: avdec_flac surpports S32LE as format */
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (channel < 0 || channel > maxchannels) {
+ LOGE("Invalid channel set");
+ return false;
+ }
+
+ if (bit_depth != s_bit_depth) {
+ LOGE("Invalid bit set");
+ return false;
+ }
+
+ return true;
+}
+
+gboolean _check_support_video_info(mediacodec_codec_type_e codec_id, int width, int height)
+{
+ gint i = 0;
+ gint n_sizes = 0;
+
+ if (width <= 0 || height <= 0) {
+ LOGE("Invalid resolution set");
+ return false;
+ }
+
+ switch (codec_id) {
+ case MEDIACODEC_H261:
+ {
+ const static gint widths[] = { 352, 176 };
+ const static gint heights[] = { 288, 144 };
+ n_sizes = G_N_ELEMENTS(widths);
+
+ while (i < n_sizes) {
+ if ((widths[i] == width) && (heights[i] == height))
+ break;
+ i++;
+ }
+
+ if (i == n_sizes) {
+ LOGE("Invalid resolution set");
+ return false;
+ }
+ break;
+ }
+ case MEDIACODEC_H263:
+ {
+ const static gint widths[] = { 352, 704, 176, 1408, 128 };
+ const static gint heights[] = { 288, 576, 144, 1152, 96 };
+ n_sizes = G_N_ELEMENTS(widths);
+
+ while (i < n_sizes) {
+ if ((widths[i] == width) && (heights[i] == height))
+ break;
+ i++;
+ }
+
+ if (i == n_sizes) {
+ LOGE("Invalid resolution set");
+ return false;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ return true;
+}
static gint __gst_handle_core_error(mc_gst_core_t *core, int code);
static const gchar * _mc_error_to_string(mc_ret_e err);
static const gchar * _mc_bit_to_string(int bit);
-static int _mc_get_support_bit_from_format(media_format_mimetype_e format);
static int _mc_link_vtable(mc_gst_core_t *core, mediacodec_codec_type_e id, gboolean is_encoder, gboolean is_hw);
static int _mc_gst_flush_buffers(mc_gst_core_t *core);
}
mc_gst_port_def_t *port_def = &core->ports[out_port_index]->port_def;
- if (encoder) {
+ if (video) {
+ media_format_set_video_mime(core->output_fmt, out_mime);
+ media_format_set_video_width(core->output_fmt, port_def->info.video.width);
+ media_format_set_video_height(core->output_fmt, port_def->info.video.height);
- if (video) {
- media_format_set_video_mime(core->output_fmt, out_mime);
- media_format_set_video_width(core->output_fmt, port_def->info.video.width);
- media_format_set_video_height(core->output_fmt, port_def->info.video.height);
+ if (encoder)
media_format_set_video_avg_bps(core->output_fmt, port_def->info.video.bitrate);
- } else {
- int support_bit = 0;
- support_bit = _mc_get_support_bit_from_format(out_mime);
-
- media_format_set_audio_mime(core->output_fmt, out_mime);
- media_format_set_audio_channel(core->output_fmt, port_def->info.audio.channel);
- media_format_set_audio_samplerate(core->output_fmt, port_def->info.audio.samplerate);
- media_format_set_audio_bit(core->output_fmt, support_bit);
- media_format_set_audio_avg_bps(core->output_fmt, port_def->info.audio.bitrate);
- }
} else {
+ media_format_set_audio_mime(core->output_fmt, out_mime);
+ media_format_set_audio_channel(core->output_fmt, port_def->info.audio.channel);
+ media_format_set_audio_samplerate(core->output_fmt, port_def->info.audio.samplerate);
+ media_format_set_audio_bit(core->output_fmt, port_def->info.audio.bit_depth);
- if (video) {
- media_format_set_video_mime(core->output_fmt, out_mime);
- media_format_set_video_width(core->output_fmt, port_def->info.video.width);
- media_format_set_video_height(core->output_fmt, port_def->info.video.height);
- } else {
- media_format_set_audio_mime(core->output_fmt, out_mime);
- media_format_set_audio_channel(core->output_fmt, port_def->info.audio.channel);
- media_format_set_audio_samplerate(core->output_fmt, port_def->info.audio.samplerate);
- media_format_set_audio_bit(core->output_fmt, port_def->info.audio.bit_depth);
- }
+ if (encoder)
+ media_format_set_audio_avg_bps(core->output_fmt, port_def->info.audio.bitrate);
}
+
return MC_ERROR_NONE;
}
is_format_change |= input_port_def->info.video.width != width;
is_format_change |= input_port_def->info.video.height != height;
- is_format_change |= (input_port_def->info.video.framerate != framerate) && (framerate != 0);
+ is_format_change |= ((input_port_def->info.video.framerate != framerate) && (framerate != 0));
if (is_format_change) {
LOGD("Format changed : resolution %dx%d -> %dx%d, framerate %d -> %d",
input_port_def->info.video.width, input_port_def->info.video.height, width, height,
if (core->encoder) {
sformat = __mc_get_gst_input_format(mimetype, core->is_hw);
- is_format_change |= input_port_def->info.video.bitrate != bitrate * 1000;
+ is_format_change |= ((input_port_def->info.video.bitrate != bitrate * 1000) && (bitrate != 0));
is_format_change |= g_strcmp0(input_port_def->info.video.format, sformat);
if (is_format_change) {
LOGD("Bitrate changed : %d -> %d", input_port_def->info.video.bitrate, bitrate);
}
if (core->encoder) {
- is_format_change |= input_port_def->info.audio.bitrate != bitrate * 1000;
+ is_format_change |= ((input_port_def->info.audio.bitrate != bitrate * 1000) && (bitrate != 0));
if (is_format_change) {
LOGD("Bitrate changed : %d -> %d", input_port_def->info.audio.bitrate, bitrate);
input_port_def->info.audio.bitrate = bitrate * 1000;
pad = gst_element_get_static_pad(core->appsrc, "src");
gst_pad_push_event(pad, gst_event_new_stream_start("start"));
gst_object_unref(pad);
+ is_format_change = TRUE;
initiative = FALSE;
}
case MEDIACODEC_AAC:
if (core->encoder) {
gst_caps_set_simple(caps,
+ "format", G_TYPE_STRING, _mc_bit_to_string(port_def->info.audio.bit_depth),
"layout", G_TYPE_STRING, "interleaved", NULL);
g_object_set(GST_OBJECT(core->codec), "compliance", -2, NULL);
} else {
static gint _mc_gst_gstbuffer_to_appsrc(mc_gst_core_t *core, GstMCBuffer *mcbuffer)
{
- gint ret = MC_ERROR_NONE;
-
- MEDIACODEC_FENTER();
-
- ret = gst_app_src_push_buffer(GST_APP_SRC(core->appsrc), mcbuffer->buffer);
- LOGD("pushed buffer to appsrc : %p, buffer of size %" G_GSIZE_FORMAT "",
- mcbuffer->buffer, gst_buffer_get_size(mcbuffer->buffer));
-
- MEDIACODEC_FLEAVE();
-
- return ret;
+ return gst_app_src_push_buffer(GST_APP_SRC(core->appsrc), mcbuffer->buffer);
}
media_packet_h _mc_get_input_buffer(mc_gst_core_t *core)
}
/* create basic core elements */
- ret = _mc_gst_create_pipeline(mc_handle->core, factory_name);
+ ret = _mc_gst_create_pipeline(new_core, factory_name);
if (ret != MC_ERROR_NONE) {
LOGE("failed to create pipeline");
return ret;
}
/* link vtable */
- ret = _mc_link_vtable(mc_handle->core, id, encoder, hardware);
+ ret = _mc_link_vtable(new_core, id, encoder, hardware);
if (ret != MC_ERROR_NONE) {
LOGE("vtable link failed");
return ret;
}
}
-int _mc_get_support_bit_from_format(media_format_mimetype_e format)
-{
- gint bit = 0;
-
- switch (format) {
- case MEDIA_FORMAT_PCM_S16LE:
- case MEDIA_FORMAT_PCM_S16BE:
- case MEDIA_FORMAT_PCM_U16LE:
- case MEDIA_FORMAT_PCM_U16BE:
- bit = 16;
- break;
- case MEDIA_FORMAT_PCM_S32LE:
- case MEDIA_FORMAT_PCM_S32BE:
- case MEDIA_FORMAT_PCM_U32LE:
- case MEDIA_FORMAT_PCM_U32BE:
- case MEDIA_FORMAT_PCM_F32LE:
- case MEDIA_FORMAT_PCM_F32BE:
- bit = 32;
- break;
- default:
- LOGE("NOT SUPPORTED!!!!");
- break;
- }
-
- return bit;
-}
-
int _mc_get_mime(mc_gst_core_t *core)
{
media_format_mimetype_e mime = MEDIA_FORMAT_MAX;