return MC_INVALID_ARG;
}
- if (!_check_support_video_info(mc_handle->codec_id, width, height))
+ if (!_check_support_video_info(mc_handle->codec_id, width, height)) {
+ LOGE("invaild param[res %dx%d]", width, height);
return MC_PARAM_ERROR;
+ }
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && !mc_handle->is_encoder,
MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
return MC_INVALID_ARG;
}
- if (!_check_support_video_info(mc_handle->codec_id, width, height) || fps < 0 || target_bits < 0)
+ if (!_check_support_video_info(mc_handle->codec_id, width, height) || fps < 0 || target_bits < 0) {
+ LOGE("invaild param[res %dx%d, fps %d, target_bits %d]", width, height, fps, target_bits);
return MC_PARAM_ERROR;
+ }
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && mc_handle->is_encoder,
MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
return MC_INVALID_ARG;
}
- if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
+ if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit)) {
+ LOGE("invaild param[samplerate %d, channel %d, bit %d]", samplerate, channel, bit);
return MC_PARAM_ERROR;
+ }
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && !mc_handle->is_encoder,
MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
return MC_INVALID_ARG;
}
- if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
+ if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit) || bitrate < 0) {
+ LOGE("invaild param[samplerate %d, channel %d, bit %d, bitrate %d]", samplerate, channel, bit, bitrate);
return MC_PARAM_ERROR;
+ }
MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && mc_handle->is_encoder,
MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle)
{
- MEDIACODEC_FENTER();
-
int ret = MC_ERROR_NONE;
- media_format_mimetype_e out_mime;
int num_supported_codec = 0;
int i = 0;
- GstCaps *caps = NULL;
-
- if (!mc_handle)
- return MC_PARAM_ERROR;
-
- mediacodec_codec_type_e id;
+ int bitrate = 0;
bool video;
bool encoder;
bool hardware;
gchar *factory_name = NULL;
+ GstCaps *caps = NULL;
+ media_format_mimetype_e out_mime;
+ mediacodec_codec_type_e id;
mc_codec_map_t *codec_map;
+ MEDIACODEC_FENTER();
+
+ if (!mc_handle)
+ return MC_PARAM_ERROR;
+
id = mc_handle->codec_id;
video = mc_handle->is_video;
encoder = mc_handle->is_encoder;
g_object_set(new_core->capsfilter, "caps", caps, NULL);
gst_caps_unref(caps);
+ if (new_core->encoder) {
+ if (new_core->video)
+ bitrate = mc_handle->info.video.bitrate;
+ else
+ bitrate = mc_handle->info.audio.bitrate;
+
+ LOGI("set encoder bitrate[v:%d] %d", new_core->video, bitrate);
+
+ g_object_set(new_core->codec, "bitrate", bitrate, NULL);
+ }
+
mc_handle->core = new_core;
LOGD("initialized... %d", ret);
MEDIACODEC_FLEAVE();