#ifdef TIZEN_FEATURE_INTEGRATION
#include <camera.h>
#include <mediademuxer.h>
+#include <mediamuxer.h>
#endif
#define PACKAGE "media_codec_test"
gboolean is_encoder;
gboolean hardware;
gboolean enable_dump;
+ gboolean enable_muxer;
gint frame;
type_e type;
#ifdef TIZEN_FEATURE_INTEGRATION
camera_h camera_handle;
mediademuxer_h demuxer;
+ mediamuxer_h muxer;
#endif
GThread *thread;
guint fps;
guint target_bits;
media_format_mimetype_e mime;
+ gint track;
gint video_track;
/* Audio */
else
output_dump(app, out_pkt);
}
-
+#ifdef TIZEN_FEATURE_INTEGRATION
+ if (app->enable_muxer) {
+ if (mediamuxer_write_sample(app->muxer, app->track, out_pkt) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_write_sample failed\n");
+ g_print("write sample!!!\n");
+ }
+#endif
app->frame_count++;
app->fbd++;
return;
}
+
+void _mediamuxer_eos_cb(void *user_data)
+{
+ if (user_data == NULL) {
+ g_print("invalid param");
+ return;
+ }
+
+ App *app = (App *)user_data;
+
+ g_print("muxer eos\n");
+
+ if (mediamuxer_stop(app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print(" mediamuxer_stop failed\n");
+
+ if (mediamuxer_unprepare(app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print(" mediamuxer_unprepare failed\n");
+
+ if (mediamuxer_destroy(app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print(" mediamuxer_destory failed\n");
+
+ g_print("mediamuxer destroyed\n");
+}
#endif
gboolean _foreach_cb(mediacodec_codec_type_e codec_type, void *user_data)
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);
+ media_format_set_audio_avg_bps(codec_format, app->bitrate);
ret = mediacodec_configure_from_media_format(app->mc_handle[0], codec_format, app->flag);
if (ret != MEDIACODEC_ERROR_NONE)
return;
}
+#ifdef TIZEN_FEATURE_INTEGRATION
+ if (app->enable_muxer) {
+ if (mediamuxer_create(&app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_create failed\n");
+
+ if (mediamuxer_set_data_sink(app->muxer, "/tmp/muxtest.mp4", MEDIAMUXER_CONTAINER_FORMAT_MP4) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_set_data_sink failed\n");
+
+ media_format_create(&app->format[0]);
+ if (app->type == AUDIO_ENC)
+ media_format_set_audio_mime(app->format[0], codec_mime);
+ else if (app->type == VIDEO_ENC)
+ media_format_set_video_mime(app->format[0], codec_mime);
+ else
+ g_print("invalid format\n");
+
+ if (mediamuxer_set_eos_cb(app->muxer, _mediamuxer_eos_cb, app) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_set_eos_cb failed\n");
+
+ if (mediamuxer_add_track(app->muxer, app->format[0], &app->track) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_add_track failed\n");
+
+ if (mediamuxer_prepare(app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_prepare failed\n");
+
+ if (mediamuxer_start(app->muxer) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_start failed\n");
+ }
+#endif
+
/* get packet pool instance */
ret = mediacodec_get_packet_pool(app->mc_handle[0], &pkt_pool);
void _mediacodec_destroy(App *app)
{
+ if (app == NULL) {
+ g_print("invalid param");
+ return;
+ }
#ifdef USE_POOL
if (media_packet_pool_deallocate(pkt_pool) != MEDIA_PACKET_ERROR_NONE) {
g_print("media packet pool destroyed! \n");
#endif
mediacodec_destroy(app->mc_handle[0]);
+#ifdef TIZEN_FEATURE_INTEGRATION
+ if (app->enable_muxer) {
+ if (mediamuxer_close_track(app->muxer, app->track) != MEDIAMUXER_ERROR_NONE)
+ g_print("mediamuxer_close_track failed\n");
+ }
+#endif
}
void input_filepath(char *filename, App *app)
_mediacodec_camera_stop(app);
else if (strncmp(cmd, "au", 2) == 0)
g_menu_state = CURRENT_STATUS_AUTO_TEST;
+ else if (strncmp(cmd, "mp", 2) == 0) {
+ if (!app->enable_muxer) {
+ app->enable_muxer = TRUE;
+ g_print("muxer enabled\n");
+ } else {
+ app->enable_dump = FALSE;
+ g_print("dump disabled\n");
+ }
+ }
#endif
else if (strncmp(cmd, "dp", 2) == 0) {
if (!app->enable_dump) {
g_print("q. quit test suite \n");
g_print("dp. enable dump \n");
#ifdef TIZEN_FEATURE_INTEGRATION
+ g_print("mp. enable muxer \n");
g_print("-----------------------------------------------------------------------------------------\n");
g_print("cr. camera preview -> encoder -> decoder\n");
g_print("au. integration test with mediademuxer\n");