#include <media_packet.h>
/*-----------------------------------------------------------------------
-| GLOBAL VARIABLE DEFINITIONS: |
+| GLOBAL CONSTANT DEFINITIONS: |
-----------------------------------------------------------------------*/
#define MAX_STRING_LEN 100
#define PACKAGE "mediademuxer_test"
-/*-----------------------------------------------------------------------
-| GLOBAL CONSTANT DEFINITIONS: |
------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------
-| IMPORTED VARIABLE DECLARATIONS: |
------------------------------------------------------------------------*/
+enum {
+ CURRENT_STATUS_MAINMENU,
+ CURRENT_STATUS_FILENAME,
+ CURRENT_STATUS_SET_DATA
+};
/*-----------------------------------------------------------------------
-| IMPORTED FUNCTION DECLARATIONS: |
+| GLOBAL VARIABLE DEFINITIONS: |
-----------------------------------------------------------------------*/
+mediademuxer_h demuxer = NULL;
+media_format_h *g_media_format = NULL;
+media_format_mimetype_e v_mime;
+media_format_mimetype_e a_mime;
+int g_menu_state = CURRENT_STATUS_MAINMENU;
+int num_tracks = 0;
+int aud_track =-1;
+int vid_track =-1;
+int w;
+int h;
+int channel = 0;
+int samplerate = 0;
+bool is_adts = 0;
/*-----------------------------------------------------------------------
-| LOCAL #defines: |
+| DEBUG DEFINITIONS |
-----------------------------------------------------------------------*/
/*
* D E B U G M E S S A G E
fprintf(stderr, MMF_WARN"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
} while(0)
-/*-----------------------------------------------------------------------
-| LOCAL CONSTANT DEFINITIONS: |
------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
-| LOCAL DATA TYPE DEFINITIONS: |
+| TEST VARIABLE DEFINITIONS: |
-----------------------------------------------------------------------*/
+#define DEMUXER_OUTPUT_DUMP 1
-/*-----------------------------------------------------------------------
-| LOCAL VARIABLE DEFINITIONS: |
------------------------------------------------------------------------*/
+#if DEMUXER_OUTPUT_DUMP
+FILE *fp_audio_out = NULL;
+FILE *fp_video_out = NULL;
+
+#define ADTS_HEADER_SIZE 7
+unsigned char buf_adts[ADTS_HEADER_SIZE];
+
+#define AMR_NB_MIME_HDR_SIZE 6
+#define AMR_WB_MIME_HDR_SIZE 9
+static const char AMRNB_HDR [] = "#!AMR\n";
+static const char AMRWB_HDR [] = "#!AMR-WB\n";
+int write_amrnb_header = 0; /* write magic number for AMR-NB Header at one time */
+int write_amrwb_header = 0; /* write magic number for AMR-WB Header at one time */
+#endif
/*-----------------------------------------------------------------------
-| LOCAL FUNCTION PROTOTYPES: |
+| HELPER FUNCTION |
-----------------------------------------------------------------------*/
-#if 0
-int test_mediademuxer_create();
-int test_mediademuxer_destroy();
-int test_mediademuxer_prepare();
-int test_mediademuxer_unprepare();
-int test_mediademuxer_set_data_source();
-int test_mediademuxer_get_track_count();
-int test_mediademuxer_get_track_info();
-int test_mediademuxer_select_track();
-int test_mediademuxer_unselect_track();
-int test_mediademuxer_seek_to();
-int test_mediademuxer_read_sample();
-int test_mediademuxer_get_sample_track_index();
-int test_mediademuxer_get_sample_track_time();
-int test_mediademuxer_advance();
-int test_mediademuxer_is_key_frame();
-int test_mediademuxer_is_encrypted();
-int test_mediademuxe_audio_only();
-int test_mediademuxe_video_only();
-int test_mediademuxe_audio_video_only();
+
+#if DEMUXER_OUTPUT_DUMP
+/**
+ * Add ADTS header at the beginning of each and every AAC packet.
+ * This is needed as MediaCodec encoder generates a packet of raw AAC data.
+ * Note the packetLen must count in the ADTS header itself.
+ **/
+void generate_header_aac_adts(unsigned char *buffer, int packetLen)
+{
+ int profile = 2; //AAC LC (0x01)
+ int freqIdx = 4; //44KHz (0x04)
+ int chanCfg = 1; //CPE (0x01)
+
+ if (samplerate == 96000) freqIdx = 0;
+ else if (samplerate == 88200) freqIdx = 1;
+ else if (samplerate == 64000) freqIdx = 2;
+ else if (samplerate == 48000) freqIdx = 3;
+ else if (samplerate == 44100) freqIdx = 4;
+ else if (samplerate == 32000) freqIdx = 5;
+ else if (samplerate == 24000) freqIdx = 6;
+ else if (samplerate == 22050) freqIdx = 7;
+ else if (samplerate == 16000) freqIdx = 8;
+ else if (samplerate == 12000) freqIdx = 9;
+ else if (samplerate == 11025) freqIdx = 10;
+ else if (samplerate == 8000) freqIdx = 11;
+
+ if ((channel == 1) || (channel == 2))
+ chanCfg = channel;
+
+ /* Make ADTS header */
+ buffer[0] = (char)0xFF;
+ buffer[1] = (char)0xF1;
+ buffer[2] = (char)(((profile-1)<<6) + (freqIdx<<2) +(chanCfg>>2));
+ buffer[3] = (char)(((chanCfg&3)<<6) + (packetLen>>11));
+ buffer[4] = (char)((packetLen&0x7FF) >> 3);
+ buffer[5] = (char)(((packetLen&7)<<5) + 0x1F);
+ buffer[6] = (char)0xFC;
+}
#endif
-int aud_track=-1;
-int vid_track=-1;
-mediademuxer_h demuxer = NULL;
-int num_tracks = 0;
-media_format_h *g_media_format = NULL;
-int test_mediademuxer_get_track_info()
-{
- int ret = 0;
- int track = 0;
- int w;
- int h;
- int channel;
- int samplerate;
- media_format_mimetype_e mime;
- g_print("test_mediademuxer_get_track_info\n");
- g_media_format =
- (media_format_h *) g_malloc(sizeof(media_format_h) * num_tracks);
- g_print("allocated %p memory for g_media_format\n", g_media_format);
- if (g_media_format) {
- for (; track < num_tracks; track++) {
- if (ret == 0) {
- g_print
- ("g_media_format[%d] is created successfully! \n",
- track);
- ret =
- mediademuxer_get_track_info(demuxer, track,
- &g_media_format[track]);
- if (ret == 0) {
- if (media_format_get_video_info
- (g_media_format[track], &mime, &w,
- &h, NULL,
- NULL) == MEDIA_FORMAT_ERROR_NONE) {
- g_print
- ("media_format_get_video_info is sucess!\n");
- g_print
- ("\t\t[media_format_get_video]mime:%x, width :%d, height :%d\n",
- mime, w, h);
- vid_track = track;
- } else if (media_format_get_audio_info
- (g_media_format[track], &mime,
- &channel, &samplerate, NULL,
- NULL) ==
- MEDIA_FORMAT_ERROR_NONE) {
- g_print
- ("media_format_get_audio_info is sucess!\n");
- g_print
- ("\t\t[media_format_get_audio]mime:%x, channel :%d, samplerate :%d\n",
- mime, channel, samplerate);
- aud_track = track;
- } else {
- g_print("Not Supported YET");
- }
- } else {
- g_print
- ("Error while getting mediademuxer_get_track_info\n");
- }
- media_format_unref(g_media_format[track]);
- g_media_format[track] = NULL;
- } else {
- g_print
- ("Error while creating media_format_create\n");
- }
- }
- g_free(g_media_format);
- g_media_format = NULL;
- } else {
- g_print("Error while allocating memory\n");
- }
- return ret;
-}
+
+/*-----------------------------------------------------------------------
+| LOCAL FUNCTION |
+-----------------------------------------------------------------------*/
int test_mediademuxer_create()
{
return ret;
}
-int test_mediademuxer_destroy()
+int test_mediademuxer_set_data_source(mediademuxer_h demuxer, const char *path)
{
int ret = 0;
- g_print("test_mediademuxer_destroy\n");
- ret = mediademuxer_destroy(demuxer);
- demuxer = NULL;
+ g_print("test_mediademuxer_set_data_source\n");
+
+#if DEMUXER_OUTPUT_DUMP
+ fp_audio_out = fopen("/opt/usr/media/dump_audio.out", "wb");
+ fp_video_out = fopen("/opt/usr/media/dump_video.out", "wb");
+#endif
+
+ ret = mediademuxer_set_data_source(demuxer, path);
return ret;
}
return ret;
}
-int test_mediademuxer_start()
-{
- int ret = 0;
- g_print("test_mediademuxer_start\n");
- ret = mediademuxer_start(demuxer);
- return ret;
-}
-
-int test_mediademuxer_get_state()
-{
- g_print("test_mediademuxer_get_state\n");
- mediademuxer_state state;
- if(mediademuxer_get_state(demuxer, &state) == MEDIADEMUXER_ERROR_NONE) {
- g_print("\nMediademuxer_state=%d",state);
- }
- else {
- g_print("\nMediademuxer_state call failed\n");
- }
- return 0;
-}
-
-int test_mediademuxer_stop()
-{
- int ret = 0;
- g_print("test_mediademuxer_stop\n");
- ret = mediademuxer_stop(demuxer);
- return ret;
-}
-
-int test_mediademuxer_unprepare()
-{
- int ret = 0;
- g_print("test_mediademuxer_unprepare\n");
- ret = mediademuxer_unprepare(demuxer);
- return ret;
-}
-
-int test_mediademuxer_set_data_source(mediademuxer_h demuxer, const char *path)
-{
- int ret = 0;
- g_print("test_mediademuxer_set_data_source\n");
- ret = mediademuxer_set_data_source(demuxer, path);
- return ret;
-}
-
int test_mediademuxer_get_track_count()
{
g_print("test_mediademuxer_get_track_count\n");
mediademuxer_get_track_count(demuxer, &num_tracks);
- g_print("Number of tracks [%d]", num_tracks);
+ g_print("Number of total tracks [%d]\n", num_tracks);
return 0;
}
int test_mediademuxer_select_track()
{
+ int track = 0;
g_print("test_mediademuxer_select_track\n");
- if (mediademuxer_select_track(demuxer, 0)) {
- g_print("mediademuxer_select track 0 failed\n");
- return -1;
- }
- if (mediademuxer_select_track(demuxer, 1)) {
- g_print("mediademuxer_select track 1 failed\n");
- return -1;
+ for (track = 0; track < num_tracks; track++) {
+ if (mediademuxer_select_track(demuxer, track)) {
+ g_print("mediademuxer_select_track index [%d] failed\n", track);
+ return -1;
+ }
+ g_print("select track index is [%d] of the total track [%d]\n", track, num_tracks);
}
-
return 0;
}
-int test_mediademuxer_unselect_track()
+int test_mediademuxer_start()
{
- g_print("test_mediademuxer_select_track\n");
- if (mediademuxer_unselect_track(demuxer, 0)) {
- g_print("mediademuxer_select track 0 failed\n");
- return -1;
- }
-
- return 0;
+ int ret = 0;
+ g_print("test_mediademuxer_start\n");
+ ret = mediademuxer_start(demuxer);
+ return ret;
}
-int test_mediademuxer_seek_to()
+int test_mediademuxer_get_track_info()
{
- g_print("test_mediademuxer_seek_to\n");
- int64_t pos = 1;
- mediademuxer_seek(demuxer, pos);
- g_print("Number of tracks [%d]", num_tracks);
- return 0;
-}
+ int ret = 0;
+ int track = 0;
-void app_err_cb(mediademuxer_error_e error, void *user_data)
-{
- printf("Got Error %d from Mediademuxer\n",error);
-}
+ g_print("test_mediademuxer_get_track_info\n");
+ g_media_format =
+ (media_format_h *) g_malloc(sizeof(media_format_h) * num_tracks);
+ g_print("allocated %p memory for g_media_format\n", g_media_format);
+ if (g_media_format) {
+ for (; track < num_tracks; track++) {
+ if (ret == 0) {
+ g_print("g_media_format[%d] is created successfully! \n", track);
+ ret = mediademuxer_get_track_info(demuxer, track,
+ &g_media_format[track]);
+ if (ret == 0) {
+ if (media_format_get_video_info(g_media_format[track], &v_mime,
+ &w, &h, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
+ g_print("media_format_get_video_info is sucess!\n");
+ g_print("\t\t[media_format_get_video]mime:%x, width :%d, height :%d\n",
+ v_mime, w, h);
+ vid_track = track;
+ } else if (media_format_get_audio_info(g_media_format[track], &a_mime,
+ &channel, &samplerate, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
+ g_print("media_format_get_audio_info is sucess!\n");
+ g_print("\t\t[media_format_get_audio]mime:%x, channel :%d, samplerate :%d\n",
+ a_mime, channel, samplerate);
+ media_format_get_audio_aac_type(g_media_format[track], &is_adts);
+ aud_track = track;
+ } else {
+ g_print("Not Supported YET");
+ }
+ } else {
+ g_print("Error while getting mediademuxer_get_track_info\n");
+ }
+ media_format_unref(g_media_format[track]);
+ g_media_format[track] = NULL;
+ } else {
+ g_print("Error while creating media_format_create\n");
+ }
+ }
+ g_free(g_media_format);
+ g_media_format = NULL;
+ } else {
+ g_print("Error while allocating memory\n");
+ }
+
+#if DEMUXER_OUTPUT_DUMP
+ if ((a_mime == MEDIA_FORMAT_AAC_LC) && (is_adts == 0)) {
+ g_print("MIME : MEDIA_FORMAT_AAC_LC ------Need to add header for dump test \n");
+ } else if (a_mime == MEDIA_FORMAT_AMR_NB) {
+ g_print("MIME : MEDIA_FORMAT_AMR_NB ------Need to add header for dump test \n");
+ write_amrnb_header = 1;
+ } else if (a_mime == MEDIA_FORMAT_AMR_WB) {
+ g_print("MIME : MEDIA_FORMAT_AMR_WB ------Need to add header for dump test \n");
+ write_amrwb_header = 1;
+ } else
+ g_print("--------------------------- Don't Need to add header for dump test\n");
+#endif
-int test_mediademuxer_set_error_cb()
-{
- int ret = 0;
- g_print("test_mediademuxer_set_error_cb\n");
- ret = mediademuxer_set_error_cb(demuxer,app_err_cb,demuxer);
return ret;
}
void *_fetch_audio_data(void *ptr)
{
+ int ret = MD_ERROR_NONE;
int *status = (int *)g_malloc(sizeof(int) * 1);
- *status = -1;
- g_print("Audio Data function\n");
media_packet_h audbuf;
int count = 0;
+ uint64_t buf_size = 0;
+ void *data = NULL;
+ *status = -1;
+ g_print("Audio Data function\n");
while (1) {
- int EOS = mediademuxer_read_sample(demuxer, aud_track, &audbuf);
- if (EOS == MD_EOS || EOS != MD_ERROR_NONE)
+ ret = mediademuxer_read_sample(demuxer, aud_track, &audbuf);
+ if (ret == MD_EOS) {
+ g_print("EOS return of mediademuxer_read_sample()\n");
pthread_exit(NULL);
+ } else if (ret != MD_ERROR_NONE) {
+ g_print("Error (%d) return of mediademuxer_read_sample()\n", ret);
+ pthread_exit(NULL);
+ }
count++;
- g_print("Read::[%d] audio sample\n", count);
+ media_packet_get_buffer_size(audbuf, &buf_size);
+ media_packet_get_buffer_data_ptr(audbuf, &data);
+ g_print("Audio Read Count::[%4d] frame - get_buffer_size = %lld\n", count, buf_size);
+
+#if DEMUXER_OUTPUT_DUMP
+ if ((a_mime == MEDIA_FORMAT_AAC_LC) && (is_adts == 0)) {
+ /* This is used only AAC raw case for adding each ADTS frame header */
+ generate_header_aac_adts(buf_adts, (buf_size+ADTS_HEADER_SIZE));
+ fwrite(&buf_adts[0], 1, ADTS_HEADER_SIZE, fp_audio_out);
+ } else if ((a_mime == MEDIA_FORMAT_AMR_NB) && (write_amrnb_header == 1)) {
+ /* This is used only AMR-NB case for adding magic header in only first frame */
+ g_print("%s - AMRNB_HDR write in first frame\n",__func__);
+ fwrite(&AMRNB_HDR[0], 1, sizeof(AMRNB_HDR) - 1, fp_audio_out);
+ write_amrnb_header = 0;
+ } else if ((a_mime == MEDIA_FORMAT_AMR_WB) && (write_amrwb_header == 1)) {
+ /* This is used only AMR-WB case for adding magic header in only first frame */
+ g_print("%s - AMRWB_HDR write in first frame\n",__func__);
+ fwrite(&AMRWB_HDR[0], 1, sizeof(AMRWB_HDR) - 1, fp_audio_out);
+ write_amrwb_header = 0;
+ }
+
+ if (data != NULL)
+ fwrite(data, 1, buf_size, fp_audio_out);
+ else
+ g_print("DUMP : write(audio data) fail for NULL\n");
+#endif
media_packet_destroy(audbuf);
}
*status = 0;
-
return (void *)status;
}
void *_fetch_video_data(void *ptr)
{
+ int ret = MD_ERROR_NONE;
int *status = (int *)g_malloc(sizeof(int) * 1);
media_packet_h vidbuf;
+ int count = 0;
+ uint64_t buf_size = 0;
+ void *data = NULL;
+
*status = -1;
g_print("Video Data function\n");
- int count = 0;
while (1) {
- int EOS = mediademuxer_read_sample(demuxer, vid_track, &vidbuf);
- if (EOS == MD_EOS || EOS != MD_ERROR_NONE)
+ ret = mediademuxer_read_sample(demuxer, vid_track, &vidbuf);
+ if (ret == MD_EOS) {
+ g_print("EOS return of mediademuxer_read_sample()\n");
+ pthread_exit(NULL);
+ } else if (ret != MD_ERROR_NONE) {
+ g_print("Error (%d) return of mediademuxer_read_sample()\n", ret);
pthread_exit(NULL);
+ }
count++;
- g_print("Read::[%d] video sample\n", count);
+ media_packet_get_buffer_size(vidbuf, &buf_size);
+ media_packet_get_buffer_data_ptr(vidbuf, &data);
+ g_print("Video Read Count::[%4d] frame - get_buffer_size = %lld\n", count, buf_size);
+
+#if DEMUXER_OUTPUT_DUMP
+ if (data != NULL)
+ fwrite(data, 1, buf_size, fp_video_out);
+ else
+ g_print("DUMP : write(video data) fail for NULL\n");
+#endif
media_packet_destroy(vidbuf);
}
*status = 0;
return 0;
}
+int test_mediademuxer_seek_to()
+{
+ g_print("test_mediademuxer_seek_to\n");
+ int64_t pos = 1;
+ mediademuxer_seek(demuxer, pos);
+ g_print("Number of tracks [%d]\n", num_tracks);
+ return 0;
+}
+
+int test_mediademuxer_unselect_track()
+{
+ g_print("test_mediademuxer_select_track\n");
+ if (mediademuxer_unselect_track(demuxer, 0)) {
+ g_print("mediademuxer_select track 0 failed\n");
+ return -1;
+ }
+ return 0;
+}
+
+int test_mediademuxer_stop()
+{
+ int ret = 0;
+ g_print("test_mediademuxer_stop\n");
+ ret = mediademuxer_stop(demuxer);
+ return ret;
+}
+
+int test_mediademuxer_unprepare()
+{
+ int ret = 0;
+ g_print("test_mediademuxer_unprepare\n");
+ ret = mediademuxer_unprepare(demuxer);
+ return ret;
+}
+
+int test_mediademuxer_destroy()
+{
+ int ret = 0;
+ g_print("test_mediademuxer_destroy\n");
+ ret = mediademuxer_destroy(demuxer);
+ demuxer = NULL;
+
+#if DEMUXER_OUTPUT_DUMP
+ if (fp_audio_out)
+ fclose(fp_audio_out);
+ if (fp_video_out)
+ fclose(fp_video_out);
+#endif
+ return ret;
+}
+
+int test_mediademuxer_get_state()
+{
+ g_print("test_mediademuxer_get_state\n");
+ mediademuxer_state state;
+ if(mediademuxer_get_state(demuxer, &state) == MEDIADEMUXER_ERROR_NONE) {
+ if (state == MEDIADEMUXER_NONE)
+ g_print("Mediademuxer_state = NONE\n");
+ else if (state == MEDIADEMUXER_IDLE)
+ g_print("Mediademuxer_state = IDLE\n");
+ else if (state == MEDIADEMUXER_READY)
+ g_print("Mediademuxer_state = READY\n");
+ else if (state == MEDIADEMUXER_DEMUXING)
+ g_print("Mediademuxer_state = DEMUXING\n");
+ else
+ g_print("Mediademuxer_state = NOT SUPPORT STATE\n");
+ }
+ else {
+ g_print("Mediademuxer_state call failed\n");
+ }
+ return 0;
+}
+
+void app_err_cb(mediademuxer_error_e error, void *user_data)
+{
+ printf("Got Error %d from Mediademuxer\n",error);
+}
+
+int test_mediademuxer_set_error_cb()
+{
+ int ret = 0;
+ g_print("test_mediademuxer_set_error_cb\n");
+ ret = mediademuxer_set_error_cb(demuxer,app_err_cb,demuxer);
+ return ret;
+}
+
+
+/*-----------------------------------------------------------------------
+| EXTRA FUNCTION |
+-----------------------------------------------------------------------*/
int test_mediademuxer_get_sample_track_index()
{
g_print("test_mediademuxer_get_sample_track_index\n");
return 0;
}
-enum {
- CURRENT_STATUS_MAINMENU,
- CURRENT_STATUS_FILENAME,
- CURRENT_STATUS_SET_DATA
-};
-
-int g_menu_state = CURRENT_STATUS_MAINMENU;
-
-static void display_sub_basic();
-
-void reset_menu_state()
+/*-----------------------------------------------------------------------
+| TEST FUNCTION |
+-----------------------------------------------------------------------*/
+static void display_sub_basic()
{
- g_menu_state = CURRENT_STATUS_MAINMENU;
- return;
+ g_print("\n");
+ g_print("===========================================================================\n");
+ g_print(" media demuxer test\n");
+ g_print(" SELECT : c -> (s) -> p -> (goto submenu) -> d -> q \n");
+ g_print("---------------------------------------------------------------------------\n");
+ g_print("c. Create \t");
+ g_print("s. Set callback \t");
+ g_print("p. Path \t");
+ g_print("d. Destroy \t");
+ g_print("q. Quit \n");
+ g_print("---------------------------------------------------------------------------\n");
}
void _interpret_main_menu(char *cmd)
{
int len = strlen(cmd);
if (len == 1) {
- if (strncmp(cmd, "a", 1) == 0) {
+ if (strncmp(cmd, "c", 1) == 0) {
test_mediademuxer_create();
+ } else if (strncmp(cmd, "s", 1) == 0) {
+ test_mediademuxer_set_error_cb();
+ } else if (strncmp(cmd, "p", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_FILENAME;
} else if (strncmp(cmd, "d", 1) == 0) {
test_mediademuxer_unprepare();
test_mediademuxer_destroy();
- } else if (strncmp(cmd, "s", 1) == 0) {
- g_menu_state = CURRENT_STATUS_FILENAME;
} else if (strncmp(cmd, "q", 1) == 0) {
exit(0);
- } else if (strncmp(cmd, "c", 1) == 0) {
- test_mediademuxer_set_error_cb();
} else {
g_print("unknown menu \n");
}
}
-
return;
}
if (g_menu_state == CURRENT_STATUS_MAINMENU) {
display_sub_basic();
} else if (g_menu_state == CURRENT_STATUS_FILENAME) {
- g_print("*** input mediapath.\n");
+ g_print("*** input media path.\n");
} else if (g_menu_state == CURRENT_STATUS_SET_DATA) {
g_print("\n");
- g_print
- ("=========================================================================================\n");
- g_print
- (" media demuxer submenu\n");
- g_print
- ("-----------------------------------------------------------------------------------------\n");
- g_print("1.Get Track\t");
- g_print("2.Get Info\t");
- g_print("3.Select Track\t");
- g_print("4.Uselect Track\n");
- g_print("5.Seek\t");
- g_print("6.Read Sample\t");
- g_print("7.Get Sample Track Index\t");
- g_print("8.Get Sample Track Time\n");
- g_print("9.Advance\t");
- g_print("10.Is Key Frame\t");
- g_print("11.Is Key encrypted\t");
- g_print("a. start\n");
- g_print("b. stop\n");
- g_print("u. unprepare\n");
- g_print("s. get state\n");
- g_print("12.Go Back to main menu\n");
- g_print
- ("-----------------------------------------------------------------------------------------\n");
+ g_print("=============================================================\n");
+ g_print(" media demuxer submenu\n");
+ g_print(" SELECT from 1 to 9, others are option \n");
+ g_print("-------------------------------------------------------------\n");
+ g_print(" 1. Get Track\t");
+ g_print(" 2. Select Track\n");
+ g_print(" 3. Start\t");
+ g_print(" 4. Get Info\n");
+ g_print(" 5. Read Sample\n");
+ g_print(" 6. Stop\t");
+ g_print(" 7. Unprepare\t");
+ g_print(" 8. Get state\n");
+ g_print(" 9. Go Back to main menu\n");
+ g_print(" a. Seek\t");
+ g_print(" b. Uselect Track\n");
+ g_print(" c. Get Sample Track Index\t");
+ g_print(" d. Get Sample Track Time\n");
+ g_print(" e. Advance\t");
+ g_print(" f. Is Key Frame\t");
+ g_print(" g. Is Key encrypted\n");
+ g_print("-------------------------------------------------------------\n");
} else {
g_print("*** unknown status.\n");
/* exit(0); */
g_print(" >>> ");
}
+void reset_menu_state()
+{
+ g_menu_state = CURRENT_STATUS_MAINMENU;
+ return;
+}
+
gboolean timeout_menu_display(void *data)
{
displaymenu();
if (ret != MD_ERROR_INVALID_ARGUMENT) {
g_menu_state = CURRENT_STATUS_SET_DATA;
} else {
- g_print
- ("test_mediademuxer_prepare failed \n");
+ g_print("test_mediademuxer_prepare failed \n");
g_menu_state = CURRENT_STATUS_FILENAME;
}
} else {
if (strncmp(cmd, "1", len) == 0) {
test_mediademuxer_get_track_count();
} else if (strncmp(cmd, "2", len) == 0) {
- test_mediademuxer_get_track_info();
- } else if (strncmp(cmd, "3", len) == 0) {
test_mediademuxer_select_track();
+ } else if (strncmp(cmd, "3", len) == 0) {
+ test_mediademuxer_start();
} else if (strncmp(cmd, "4", len) == 0) {
- test_mediademuxer_unselect_track();
+ test_mediademuxer_get_track_info();
} else if (strncmp(cmd, "5", len) == 0) {
- test_mediademuxer_seek_to();
- } else if (strncmp(cmd, "6", len) == 0) {
test_mediademuxer_read_sample();
+ } else if (strncmp(cmd, "6", len) == 0) {
+ test_mediademuxer_stop();
} else if (strncmp(cmd, "7", len) == 0) {
- test_mediademuxer_get_sample_track_index
- ();
+ test_mediademuxer_unprepare();
} else if (strncmp(cmd, "8", len) == 0) {
- test_mediademuxer_get_sample_track_time
- ();
+ test_mediademuxer_get_state();
} else if (strncmp(cmd, "9", len) == 0) {
- test_mediademuxer_advance();
+ reset_menu_state();
} else if (strncmp(cmd, "a", len) == 0) {
- test_mediademuxer_start();
+ test_mediademuxer_seek_to();
} else if (strncmp(cmd, "b", len) == 0) {
- test_mediademuxer_stop();
- } else if (strncmp(cmd, "u", len) == 0) {
- test_mediademuxer_unprepare();
- } else if (strncmp(cmd, "s", len) == 0) {
- test_mediademuxer_get_state();
+ test_mediademuxer_unselect_track();
+ } else if (strncmp(cmd, "c", len) == 0) {
+ test_mediademuxer_get_sample_track_index();
+ } else if (strncmp(cmd, "d", len) == 0) {
+ test_mediademuxer_get_sample_track_time();
+ } else if (strncmp(cmd, "e", len) == 0) {
+ test_mediademuxer_advance();
+ } else if (strncmp(cmd, "f", len) == 0) {
+ test_mediademuxer_is_key_frame();
+ } else if (strncmp(cmd, "g", len) == 0) {
+ test_mediademuxer_is_encrypted();
+ } else {
+ g_print("UNKNOW COMMAND\n");
}
} else if (len == 2) {
if (strncmp(cmd, "10", len) == 0) {
- test_mediademuxer_is_key_frame();
- } else if (strncmp(cmd, "11", len) == 0) {
- test_mediademuxer_is_encrypted();
- } else if (strncmp(cmd, "12", len) == 0) {
- reset_menu_state();
+ g_print("UNKNOW COMMAND\n");
} else {
g_print("UNKNOW COMMAND\n");
}
g_timeout_add(100, timeout_menu_display, 0);
}
-static void display_sub_basic()
-{
- g_print("\n");
- g_print
- ("=========================================================================================\n");
- g_print(" media demuxer test\n");
- g_print
- ("-----------------------------------------------------------------------------------------\n");
- g_print("a. Create \t");
- g_print("c. Set error_call_back\t");
- g_print("s. Setdata \t\t");
- g_print("d. Destroy \t\t");
- g_print("q. exit \t\t");
- g_print("\n");
- g_print
- ("=========================================================================================\n");
-}
-
/**
* This function is to execute command.
*