#include <mediamuxer_private.h>
#include <media_packet_internal.h>
#include <media_format.h>
+#ifdef USE_MEDIA_CODEC
#include <media_codec.h>
+#endif
+#ifdef USE_MEDIA_DEMUX
#include <mediademuxer.h>
+#endif
#define DUMP_OUTBUF 1
/*-----------------------------------------------------------------------
int bit = DEFAULT_BIT;
unsigned char buf_adts[ADTS_HEADER_SIZE];
uint64_t pts = 0;
+#ifdef USE_MEDIA_CODEC
static int bitrate = DEFAULT_BITRATE;
+#endif
int iseos_codec = 0;
bool validate_with_codec = false;
bool validate_multitrack = false;
g_print("Add video track is invalid for wav/amr\n");
return 1;
}
-
+#ifdef USE_MEDIA_CODEC
if (validate_with_codec) {
media_format_set_video_width(media_format, width);
media_format_set_video_height(media_format, height);
} else {
+#endif
media_format_set_video_width(media_format, 640);
media_format_set_video_height(media_format, 480);
+#ifdef USE_MEDIA_CODEC
}
+#endif
media_format_set_video_avg_bps(media_format, 256000);
media_format_set_video_max_bps(media_format, 256000);
/* To add video track */
mediamuxer_add_track(myMuxer, media_format, &track_index_vid);
g_print("Video Track index is returned : %d\n", track_index_vid);
- } else {
+ }
+#ifdef USE_MEDIA_DEMUX
+ else {
mediamuxer_add_track(myMuxer, media_format, &track_index_vid);
g_print("Video Track index returned is: %d\n", track_index_vid);
test_mediademuxer_select_track(demuxer_index_vid);
}
+#endif
return 0;
}
g_print("Problem during media_format_set_audio_mime operation for aac-adts audio\n");
}
+#ifdef USE_MEDIA_CODEC
if (validate_with_codec) {
if (media_format_set_audio_channel(media_format_a, channel) != MEDIA_FORMAT_ERROR_NONE)
g_print("Problem during media_format_set_audio_channel operation\n");
media_format_set_audio_bit(media_format_a, bit);
media_format_set_audio_avg_bps(media_format_a, bitrate);
} else {
+#endif
if (media_format_set_audio_channel(media_format_a, 2) != MEDIA_FORMAT_ERROR_NONE)
g_print("Problem during media_format_set_audio_channel operation\n");
media_format_set_audio_samplerate(media_format_a, 44100);
media_format_set_audio_bit(media_format_a, 16);
media_format_set_audio_avg_bps(media_format_a, 128000);
+#ifdef USE_MEDIA_CODEC
}
-
+#endif
media_format_set_audio_aac_type(media_format_a, true);
media_format_get_audio_info(media_format_a, &mimetype, &channel, &samplerate, &bit, &avg_bps);
mediamuxer_add_track(myMuxer, media_format_a, &track_index_aud2);
g_print("Audio Multi-Track index returned is: %d\n", track_index_aud2);
}
- } else {
+ }
+#ifdef USE_MEDIA_DEMUX
+ else {
mediamuxer_add_track(myMuxer, media_format_a, &track_index_aud);
g_print("Audio Track index returned is: %d\n", track_index_aud);
test_mediademuxer_select_track(demuxer_index_aud);
}
+#endif
return 0;
}
int test_mediamuxer_write_sample()
{
+#ifdef USE_MEDIA_CODEC
if (validate_with_codec) {
/* Test muxer with codec */
mediacodec_process_all();
- } else if (validate_with_demux) {
+ } else
+#endif
+#ifdef USE_MEDIA_DEMUX
+ if (validate_with_demux) {
+
bool sel_vid = false;
bool sel_aud = false;
test_mediademuxer_start();
sel_aud = true;
g_print("is_video: %d, is_audio: %d\n", sel_vid, sel_aud);
test_mediademuxer_process_all(sel_vid, sel_aud);
- } else if (strncmp(data_sink, "31", 2) == 0 || strncmp(data_sink, "wav", 3) == 0
+ } else
+#endif
+ if (strncmp(data_sink, "31", 2) == 0 || strncmp(data_sink, "wav", 3) == 0
|| strncmp(data_sink, "41", 2) == 0
|| strncmp(data_sink, "42", 2) == 0 || strncmp(data_sink, "amr", 3) == 0) {
demux_audio();
int test_mediamuxer_stop()
{
g_print("test_mediamuxer_stop\n");
+#ifdef USE_MEDIA_DEMUX
if (validate_with_demux)
test_mediademuxer_stop();
+#endif
mediamuxer_stop(myMuxer);
return 0;
}
return ret;
}
+#ifdef USE_MEDIA_DEMUX
int test_mediamuxer_with_demuxer_prepare()
{
int tracks_num = 0;
return 0;
}
-
+#endif
/*-----------------------------------------------------------------------
| TEST FUNCTION |
-----------------------------------------------------------------------*/
test_mediamuxer_set_error_cb();
} else if (strncmp(cmd, "eo", 2) == 0) {
test_mediamuxer_set_eos_cb();
- } else if (validate_with_codec) {
+ }
+#ifdef USE_MEDIA_CODEC
+ else if (validate_with_codec) {
if (strncmp(cmd, "cv", 2) == 0)
g_menu_state = CURRENT_STATUS_RAW_VIDEO_FILENAME;
else if (strncmp(cmd, "ve", 2) == 0)
g_menu_state = CURRENT_STATUS_RAW_AUDIO_FILENAME;
else if (strncmp(cmd, "ae", 2) == 0)
g_menu_state = CURRENT_STATUS_SET_AENC_INFO;
- } else if (validate_with_demux) {
+ }
+#endif
+#ifdef USE_MEDIA_DEMUX
+ else if (validate_with_demux) {
if (strncmp(cmd, "mp", 2) == 0)
g_menu_state = CURRENT_STATUS_FILENAME;
else if (strncmp(cmd, "pr", 2) == 0)
test_mediamuxer_with_demuxer_prepare();
- } else {
+ }
+#endif
+ else {
g_print("unknown menu command. Please try again\n");
}
} else {
g_menu_state = CURRENT_STATUS_MAINMENU;
break;
}
+#ifdef USE_MEDIA_CODEC
case CURRENT_STATUS_RAW_VIDEO_FILENAME: { /* "cv" */
use_video = 1;
static int codecid = 0;
}
}
break;
+#endif
case CURRENT_STATUS_FILENAME: { /* mp */
input_filepath(cmd);
strncpy(media_file, cmd, MAX_INPUT_SIZE - 1);
#include <mediamuxer.h>
#include <mediamuxer_private.h>
#include <media_packet_internal.h>
-#include <media_codec.h>
/* ---------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS: |
bool aud_eos = 0;
bool vid_eos = 0;
bool text_eos = 0;
+bool aud_codec_data = false;
+bool vid_codec_data = false;
extern int track_index_vid, track_index_aud, track_index_aud2;
extern int track_index_text;
extern mediamuxer_h myMuxer;
}
SET_CAPS:
- if (media_packet_set_extra(aud_pkt, aud_caps)) {
- g_print("unable to set the audio codec data \n");
- goto ERROR2;
+ if (!aud_codec_data) {
+ aud_codec_data = true;
+ /* Create the codec data and pass to _gst_copy_buf_to_media_packet() to add into the media packet */
+ GstStructure *structure = NULL;
+ const GValue *value = NULL;
+ GstPad *sink_pad;
+ GstCaps *aud_caps;
+ GstBuffer *codec_data_buffer = NULL;
+ sink_pad = gst_element_get_static_pad(sink, "sink");
+ if (!sink_pad) {
+ g_print("fail to get audio appsink pad\n");
+ goto ERROR2;
+ }
+
+ aud_caps = gst_pad_get_current_caps(sink_pad);
+ structure = gst_caps_get_structure(aud_caps, 0);
+ /* get codec data from caps*/
+ value = gst_structure_get_value(structure, "codec_data");
+ if (value)
+ codec_data_buffer = gst_value_get_buffer(value);
+
+ if (codec_data_buffer) {
+ GstMapInfo codec_data_map;
+ if (!gst_buffer_map(codec_data_buffer, &codec_data_map, GST_MAP_READ)) {
+ g_print("codec data buffer map failed\n");
+ goto ERROR2;
+ }
+ if (media_packet_set_codec_data(aud_pkt, (void *)codec_data_map.data,
+ (unsigned int)codec_data_map.size)) {
+ g_print("unable to set the codec data\n");
+ gst_buffer_unmap(codec_data_buffer, &codec_data_map);
+ goto ERROR2;
+ }
+ gst_buffer_unmap(codec_data_buffer, &codec_data_map);
+
+ media_buffer_flags_e flags;
+ media_packet_get_flags(aud_pkt, &flags);
+ media_packet_set_flags(aud_pkt, flags | MEDIA_PACKET_CODEC_CONFIG);
+ }
+ gst_caps_unref(aud_caps);
}
/* Print count and size to indicate a received buffer */
goto ERROR3;
}
+ if (!vid_codec_data) {
+ vid_codec_data = true;
+ /* Create the codec data and pass to _gst_copy_buf_to_media_packet() to add into the media packet */
+ GstStructure *structure = NULL;
+ const GValue *value = NULL;
+ GstPad *sink_pad;
+ GstCaps *vid_caps;
+ GstBuffer *codec_data_buffer = NULL;
+ sink_pad = gst_element_get_static_pad(sink, "sink");
+ if (!sink_pad) {
+ g_print("fail to get audio appsink pad\n");
+ goto ERROR2;
+ }
+
+ vid_caps = gst_pad_get_current_caps(sink_pad);
+ structure = gst_caps_get_structure(vid_caps, 0);
+ /* get codec data from caps*/
+ value = gst_structure_get_value(structure, "codec_data");
+ if (value)
+ codec_data_buffer = gst_value_get_buffer(value);
+
+ if (codec_data_buffer) {
+ GstMapInfo codec_data_map;
+ if (!gst_buffer_map(codec_data_buffer, &codec_data_map, GST_MAP_READ)) {
+ g_print("codec data buffer map failed\n");
+ goto ERROR2;
+ }
+ if (media_packet_set_codec_data(vid_pkt, (void *)codec_data_map.data,
+ (unsigned int)codec_data_map.size)) {
+ g_print("unable to set the codec data\n");
+ gst_buffer_unmap(codec_data_buffer, &codec_data_map);
+ goto ERROR2;
+ }
+ gst_buffer_unmap(codec_data_buffer, &codec_data_map);
+
+ media_buffer_flags_e flags;
+ media_packet_get_flags(vid_pkt, &flags);
+ media_packet_set_flags(vid_pkt, flags | MEDIA_PACKET_CODEC_CONFIG);
+ }
+ gst_caps_unref(vid_caps);
+ }
+
/* Print count and size to indicate a received buffer */
g_print("Received video buffer count : %4d (size : %5"PRIu64", pts : %12"PRIu64")\n",
++count, ns, buffer->pts);