static void feed_vdec_data2(int frame_count);
static unsigned int extract_nal(FILE *fd, unsigned char* nal);
+#ifdef USE_FEED_VENC_DATA
static unsigned int extract_yuv420(FILE *fd, unsigned char* yuv);
-static unsigned int extract_pcm ( FILE *fd, unsigned char* pcm );
+#endif
+static unsigned int extract_pcm(FILE *fd, unsigned char* pcm);
static unsigned int extract_aacdec(FILE *fd, unsigned char* aacdata);
+#ifdef USE_FEED_VENC_DATA
unsigned int extract_yuv420(FILE *fd, unsigned char* yuv)
{
size_t result;
int read_size;
unsigned char buffer[1000000];
+ if (fd == NULL)
+ return -1;
+
if (feof(fd))
return 0;
return read_size;
}
+#endif
-unsigned int extract_pcm ( FILE *fd, unsigned char* pcm )
+unsigned int extract_pcm(FILE *fd, unsigned char* pcm)
{
size_t result;
int read_size;
unsigned char buffer[1000000];
+ if (fd == NULL)
+ return -1;
+
if (feof(fd))
return 0;
unsigned int hader_size = ADTS_HEADER_SIZE;
unsigned char buffer[1000000];
+ if (fd == NULL)
+ return -1;
+
if (feof(fd))
return 0;
int nal_unit_type = 0;
int init;
+ if (fd == NULL)
+ return -1;
+
zero_count = 0;
if (feof(fd))
return -1;
static guint64 pts = 0L;
void *buf_data_ptr = NULL;
- if (media_packet_create_alloc(vdec_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- fprintf(stderr, "media_packet_create_alloc failed\n");
+ if (media_packet_new_alloc(vdec_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_new_alloc failed\n");
return;
}
*/
read = extract_nal(fp_vdec, buf_data_ptr);
fprintf(stderr, "real length = %d\n", read);
- if (read == 0) {
+ if (read <= 0) {
fprintf(stderr, "input file read failed\n");
- media_packet_destroy(video_pkt);
+ media_packet_unref(video_pkt);
return;
}
*/
read = extract_nal(fp_vdec, buf_data_ptr);
fprintf(stderr, "real length = %d\n", read);
- if (read == 0) {
+ if (read <= 0) {
fprintf(stderr, "input file read failed\n");
- media_packet_destroy(video_pkt);
+ media_packet_unref(video_pkt);
return;
}
return;
}
+#ifdef USE_FEED_VENC_DATA
static void feed_venc_data(int frame_count)
{
int read = 0;
- static guint64 pts = 0L;
void *buf_data_ptr = NULL;
int ret;
- if (media_packet_create_alloc(venc_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
- fprintf(stderr, "media_packet_create_alloc failed\n");
+ if (media_packet_new_alloc(venc_fmt, NULL, NULL, &video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_new_alloc failed\n");
return;
}
read = extract_yuv420(fp_venc, buf_data_ptr);
fprintf(stderr, "real length = %d\n", read);
- if (read == 0) {
+ if (read <= 0) {
fprintf(stderr, "input file read failed\n");
return;
}
_feed_called = TRUE;
return;
}
+#endif
static void feed_aenc_data(int frame_count)
{
int read = 0;
- static guint64 pts = 0L;
void *buf_data_ptr = NULL;
int ret;
- if (media_packet_create_alloc(aenc_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
- fprintf(stderr, "media_packet_create_alloc failed\n");
+ if (media_packet_new_alloc(aenc_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_new_alloc failed\n");
return;
}
*/
read = extract_pcm(fp_aenc, buf_data_ptr);
fprintf(stderr, "real length = %d\n", read);
- if (read == 0) {
+ if (read <= 0) {
fprintf(stderr, "input file read failed\n");
return;
}
/* push media packet */
ret = mediacodec_process_input ( g_media_codec, audio_pkt, 0);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ fprintf(stderr, "mediacodec_process_input failed 0x%x\n", ret);
_feed_called = TRUE;
return;
static void feed_adec_data(int frame_count)
{
int read = 0;
- static guint64 pts = 0L;
void *buf_data_ptr = NULL;
int ret;
- if (media_packet_create_alloc(adec_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
- fprintf(stderr, "media_packet_create_alloc failed\n");
+ if (media_packet_new_alloc(adec_fmt, NULL, NULL, &audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_new_alloc failed\n");
return;
}
read = extract_aacdec(fp_adec, buf_data_ptr);
fprintf(stderr, "real length = %d\n", read);
- if (read == 0) {
+ if (read <= 0) {
fprintf(stderr, "input file read failed\n");
return;
}
/* push media packet */
ret = mediacodec_process_input ( g_media_codec, audio_pkt, 0);
+ if (ret != MEDIACODEC_ERROR_NONE)
+ fprintf(stderr, "mediacodec_process_input failed 0x%x\n", ret);
_feed_called = TRUE;
return;
if (_is_positive) {
ret = mediacodec_get_output(g_media_codec, &output_buf, 0);
assert_eq(ret, MEDIACODEC_ERROR_NONE);
- media_packet_destroy(output_buf);
+ media_packet_unref(output_buf);
} else {
ret = mediacodec_get_output(NULL, &output_buf, 0);
assert_eq(ret, MEDIACODEC_ERROR_INVALID_PARAMETER);
return 0;
}
-static bool _mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data)
+static void _mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data)
{
int ret = 0;
_emptybufferCB_called = true;
- if (!_use_pool)
- media_packet_destroy(pkt);
- else {
+ if (!_use_pool) {
+ media_packet_unref(pkt);
+ } else {
ret = media_packet_pool_release_packet(pool, pkt);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
+ if (ret != MEDIA_PACKET_ERROR_NONE)
fprintf(stderr, "media_packet_pool_release_packet failed");
- return false;
- }
}
- return true;
}
-static bool _mediacodec_fill_buffer_cb(media_packet_h * pkt, void *user_data)
+static void _mediacodec_fill_buffer_cb(media_packet_h * pkt, void *user_data)
{
fprintf(stderr, "output available callback invoked\n");
if (pkt != NULL) {
}
_fillbufferCB_called = true;
- return true;
}
-static bool _mediacodec_eos_cb(void *user_data)
+static void _mediacodec_eos_cb(void *user_data)
{
fprintf(stderr, "eos callback invoked!\n");
_eosCB_called = true;
- return true;
}
-static bool fill_cb(media_packet_h * pkt, void *user_data)
+static void fill_cb(media_packet_h pkt, void *user_data)
{
g_print("fill_cb is called\n");
- return true;
}
-static bool error_cb(mediacodec_error_e error, void *user_data)
+static void error_cb(mediacodec_error_e error, void *user_data)
{
g_print("error_cb is called\n");
_errorCB_called = true;
- return true;
}
-static bool eos_cb(void *user_data)
+static void eos_cb(void *user_data)
{
g_print("eos_cb is called\n");
- return true;
}
static bool _mcdiacodec_supported_cb(mediacodec_codec_type_e type, void *user_data)
return true;
}
-static bool _mediacodec_buffer_status_cb(mediacodec_status_e status, void *user_data)
+static void _mediacodec_buffer_status_cb(mediacodec_status_e status, void *user_data)
{
g_print("_mediacodec_buffer_status_cb is called\n");
- return true;
}
/**
void utc_media_mediacodec_startup(void)
{
int ret = 0;
- int i;
char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
system_info_get_platform_bool("http://tizen.org/feature/multimedia.media_codec", &_mediacodec_supported);
}
snprintf(adec_path, size_of_path, "%s/res/%s", pszValue, adec_file);
- }
- else
- {
- PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
- }
- if ( (fp_vdec = fopen(vdec_path, "r")) == -1 ) {
- fprintf(stderr, "File %s not exist\n", vdec_path);
- }
+ fp_vdec = fopen(vdec_path, "r");
+ if (fp_vdec == NULL)
+ fprintf(stderr, "File %s not exist\n", vdec_path);
- if ( (fp_venc = fopen(venc_path, "r")) == -1 ) {
- fprintf(stderr, "File %s not exist\n", venc_path);
- }
+ fp_venc = fopen(venc_path, "r");
+ if (fp_venc == NULL)
+ fprintf(stderr, "File %s not exist\n", venc_path);
- if ( (fp_adec = fopen(adec_path, "r")) == -1 ) {
- fprintf(stderr, "File %s not exist\n", adec_path);
- }
+ fp_adec = fopen(adec_path, "r");
+ if (fp_adec == NULL)
+ fprintf(stderr, "File %s not exist\n", adec_path);
- if ( (fp_aenc = fopen(aenc_path, "r")) == -1 ) {
- fprintf(stderr, "File %s not exist\n", aenc_path);
+ fp_aenc = fopen(aenc_path, "r");
+ if (fp_aenc == NULL)
+ fprintf(stderr, "File %s not exist\n", aenc_path);
+ }
+ else
+ {
+ PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
}
ret = mediacodec_create(&g_media_codec);
*/
void utc_media_mediacodec_cleanup(void)
{
- int i;
int ret;
if (aenc_fmt)
}
if (fp_vdec) {
- if (vdec_path)
- free(vdec_path);
fclose(fp_vdec);
fp_vdec = NULL;
}
if (fp_venc) {
- if (venc_path)
- free(venc_path);
fclose(fp_venc);
fp_venc = NULL;
}
if (fp_aenc) {
- if (aenc_path)
- free(aenc_path);
fclose(fp_aenc);
fp_aenc = NULL;
}
if (fp_adec) {
- if (adec_path)
- free(adec_path);
fclose(fp_adec);
fp_adec = NULL;
}
+
+ if (vdec_path) {
+ free(vdec_path);
+ vdec_path = NULL;
+ }
+
+ if (venc_path) {
+ free(venc_path);
+ venc_path = NULL;
+ }
+
+ if (aenc_path) {
+ free(aenc_path);
+ aenc_path = NULL;
+ }
+
+ if (adec_path) {
+ free(adec_path);
+ adec_path = NULL;
+ }
}
/**
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
- void *data = NULL;
- unsigned int data_size = 0;
- int i = 0;
-
if (!_mediacodec_supported) {
- ret = mediacodec_process_input(g_media_codec, NULL, NULL);
+ ret = mediacodec_process_input(g_media_codec, NULL, 0);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);
return 0;
}
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
- void *data = NULL;
- unsigned int data_size = 0;
- int i = 0;
-
if (!_mediacodec_supported) {
- ret = mediacodec_process_input(NULL, NULL, NULL);
+ ret = mediacodec_process_input(NULL, NULL, 0);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);
return 0;
}
{
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
-
- void *data = NULL;
- void *input_data = NULL;
- unsigned int data_size = 0;
int bit_depth[] = { 16, 32 };
int i = 0;
if (!_mediacodec_supported) {
- ret = mediacodec_get_output(g_media_codec, NULL, NULL);
+ ret = mediacodec_get_output(g_media_codec, NULL, 0);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);
return 0;
}
{
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
-
- void *data = NULL;
- void *input_data = NULL;
- unsigned int data_size = 0;
int bit_depth[] = { 16, 32 };
int i = 0;
if (!_mediacodec_supported) {
- ret = mediacodec_get_output(NULL, NULL, NULL);
+ ret = mediacodec_get_output(NULL, NULL, 0);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);
return 0;
}
{
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
-
- void *data = NULL;
- void *input_data = NULL;
- unsigned int data_size = 0;
int bit_depth[] = { 16, 32 };
int i = 0;
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
- int i;
- void *data = NULL;
- unsigned int data_size = 0;
-
if (!_mediacodec_supported) {
ret = mediacodec_set_input_buffer_used_cb(g_media_codec,
(mediacodec_input_buffer_used_cb)_mediacodec_empty_buffer_cb,
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
- void *data = NULL;
- unsigned int data_size = 0;
- int i = 0;
-
if (!_mediacodec_supported) {
ret = mediacodec_get_packet_pool(g_media_codec, &pool);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);
assert(!_is_broken);
int ret = MEDIACODEC_ERROR_NONE;
- void *data = NULL;
- unsigned int data_size = 0;
-
if (!_mediacodec_supported) {
ret = mediacodec_get_packet_pool(NULL, &pool);
assert_eq(ret, MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE);