{
streamrecorder_s *handle = NULL;
int ret = MM_ERROR_NONE;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
handle = (streamrecorder_s *)recorder;
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("stramrecorder_unrealize fail");
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (state != MM_STREAMRECORDER_STATE_CREATED) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
+
ret = mm_streamrecorder_destroy(handle->mm_handle);
if (ret == MM_ERROR_NONE) {
{
int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (state != MM_STREAMRECORDER_STATE_CREATED) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
ret = mm_streamrecorder_realize(handle->mm_handle);
if (ret != MM_ERROR_NONE) {
{
int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (state != MM_STREAMRECORDER_STATE_PREPARED) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
+
ret = mm_streamrecorder_unrealize(handle->mm_handle);
if (ret != MM_ERROR_NONE) {
LOGE("stramrecorder_unrealize fail");
int _streamrecorder_start(streamrecorder_h recorder)
{
+ int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (!(state == MM_STREAMRECORDER_STATE_PREPARED || state == MM_STREAMRECORDER_STATE_PAUSED)) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
+
return __convert_streamrecorder_error_code(__func__, mm_streamrecorder_record(handle->mm_handle));
}
int _streamrecorder_pause(streamrecorder_h recorder)
{
+ int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (state != MM_STREAMRECORDER_STATE_RECORDING) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
+
+
return __convert_streamrecorder_error_code(__func__, mm_streamrecorder_pause(handle->mm_handle));
}
int _streamrecorder_commit(streamrecorder_h recorder)
{
+ int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ int state = MM_STREAMRECORDER_STATE_NONE;
if (recorder == NULL) {
LOGE("NULL pointer handle");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ ret = streamrecorder_get_state(recorder, &state);
+ if (ret != MM_ERROR_NONE) {
+ return __convert_streamrecorder_error_code(__func__, ret);
+ }
+
+ if (!(state == MM_STREAMRECORDER_STATE_RECORDING || state == MM_STREAMRECORDER_STATE_PAUSED)) {
+ LOGE("STREAMRECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return STREAMRECORDER_ERROR_INVALID_STATE;
+ }
+
return __convert_streamrecorder_error_code(__func__, mm_streamrecorder_commit(handle->mm_handle));
}
int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ if (recorder == NULL) {
+ LOGE("NULL pointer handle");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
MMSTR_VIDEO_FRAMERATE, framerate,
NULL);
int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ if (recorder == NULL) {
+ LOGE("NULL pointer handle");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (framerate == NULL) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
MMSTR_VIDEO_FRAMERATE, framerate,
NULL);
int ret = MM_ERROR_NONE;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
+ if (format == NULL) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
MMSTR_VIDEO_SOURCE_FORMAT, format,
NULL);
return STREAMRECORDER_ERROR_INVALID_STATE;
}
+ if (width == 0 || height == 0) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
MMSTR_VIDEO_RESOLUTION_WIDTH, width,
MM_FILE_FORMAT_AAC, /* STREAMRECORDER_FILE_FORMAT_ADTS */
MM_FILE_FORMAT_WAV, /* STREAMRECORDER_FILE_FORMAT_WAV */
};
+ if (recorder == NULL) {
+ LOGE("handle is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
if (format < STREAMRECORDER_FILE_FORMAT_3GP || format > STREAMRECORDER_FILE_FORMAT_WAV) {
LOGE("invalid format %d", format);
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ if (kbyte < 0) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
MMSTR_TARGET_MAX_SIZE, kbyte,
NULL);
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ if (second < 0) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
MMSTR_TARGET_TIME_LIMIT, second,
NULL);
{
int ret = MM_ERROR_NONE;
int mm_codec = 0;
+ int video_enable = 0;
streamrecorder_s *handle = (streamrecorder_s *)recorder;
if (handle == NULL) {
}
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
+ MMSTR_VIDEO_ENABLE, &video_enable,
MMSTR_VIDEO_ENCODER, &mm_codec,
NULL);
- if (ret == MM_ERROR_NONE) {
+ if (ret == MM_ERROR_NONE && video_enable != 0) {
switch (mm_codec) {
case MM_VIDEO_CODEC_H263:
*codec = STREAMRECORDER_VIDEO_CODEC_H263;
ret = MM_ERROR_STREAMRECORDER_INTERNAL;
break;
}
+ } else {
+ ret = MM_ERROR_STREAMRECORDER_INTERNAL;
}
return __convert_streamrecorder_error_code(__func__, ret);
int _streamrecorder_set_audio_encoder_bitrate(streamrecorder_h recorder, int bitrate)
{
- if (bitrate < 1) {
+ if (bitrate <= 0) {
LOGE("invalid bitrate %d", bitrate);
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
- ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL,
- MMSTR_VIDEO_BITRATE, bitrate,
- NULL);
+ if (bitrate < 0) {
+ LOGE("Invalid bitrate %d", bitrate);
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_streamrecorder_set_attributes(handle->mm_handle, NULL, MMSTR_VIDEO_BITRATE, bitrate, NULL);
return __convert_streamrecorder_error_code(__func__, ret);
}
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
- ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
- MMSTR_TARGET_MAX_SIZE, kbyte,
- NULL);
+ if (kbyte == NULL) {
+ LOGE("Size limit is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL, MMSTR_TARGET_MAX_SIZE, kbyte, NULL);
return __convert_streamrecorder_error_code(__func__, ret);
}
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
- ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
- MMSTR_TARGET_TIME_LIMIT, second,
- NULL);
+ if (second == NULL) {
+ LOGE("Time limit is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL, MMSTR_TARGET_TIME_LIMIT, second, NULL);
return __convert_streamrecorder_error_code(__func__, ret);
}
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ if (samplerate == NULL) {
+ LOGE("samplerate is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
MMSTR_AUDIO_SAMPLERATE, samplerate,
NULL);
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+ if (bitrate == NULL) {
+ LOGE("bitrate is NULL");
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
+
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
MMSTR_AUDIO_BITRATE, bitrate,
NULL);
LOGE("handle is NULL");
return STREAMRECORDER_ERROR_INVALID_PARAMETER;
}
+
+ if (bitrate == NULL) {
+ return STREAMRECORDER_ERROR_INVALID_PARAMETER;
+ }
ret = mm_streamrecorder_get_attributes(handle->mm_handle, NULL,
MMSTR_VIDEO_BITRATE, bitrate,
NULL);