static int gst_muxer_destroy(MMHandleType pHandle);
static int gst_muxer_set_error_cb(MMHandleType pHandle,
gst_muxer_error_cb callback, void* user_data);
-static void _generate_header_aac_adts(unsigned char *buffer, int packetLen, int samplerate, int channel);
/* Media Muxer API common */
static media_port_muxer_ops def_mux_ops = {
case MEDIA_FORMAT_H264_SP:
case MEDIA_FORMAT_H264_MP:
case MEDIA_FORMAT_H264_HP:
- new_caps = gst_caps_new_simple("video/x-h264",
- "stream-format", G_TYPE_STRING, "byte-stream", NULL);
+ new_caps = gst_caps_new_empty_simple("video/x-h264");
if (!new_caps) {
MX_E("Fail to make simple caps");
return NULL;
break;
case MEDIA_FORMAT_MPEG4_SP:
new_caps = gst_caps_new_simple("video/mpeg",
- "mpegversion", G_TYPE_INT, 4, NULL);
+ "mpegversion", G_TYPE_INT, 4,
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ NULL);
if (!new_caps) {
MX_E("Fail to make simple caps");
return NULL;
}
if (current->caps == NULL) {
-
new_caps = __gst_codec_specific_caps(current_mime);
-
if (new_caps == NULL) {
MX_E("Setting Audio caps failed\n");
ret = MX_ERROR_UNKNOWN;
}
gchar *caps_string = NULL;
caps_string = gst_caps_to_string(new_caps);
- MX_I("New cap is = %s\n", caps_string);
- if (caps_string)
+ if (caps_string) {
+ MX_I("New caps is = %s", caps_string);
g_free(caps_string);
+ }
current->caps = new_caps;
}
break;
}
gchar *caps_string = NULL;
caps_string = gst_caps_to_string(new_caps);
- MX_I("New cap is = %s\n", caps_string);
- if (caps_string)
+ if (caps_string) {
+ MX_I("New caps is = %s", caps_string);
g_free(caps_string);
+ }
+
current->caps = new_caps;
}
break;
case MEDIA_FORMAT_UNKNOWN:
default:
MX_E("Unknown format type\n");
+ break;
}
MEDIAMUXER_FLEAVE();
return ret;
return MX_ERROR;
}
MX_I("Memory allocated to track = %p\n", current);
+ memset(current, 0, sizeof(mx_gst_track));
+
current->media_format = (void *)media_format;
media_format_ref((media_format_h)current->media_format);
current->start_feed = 1;
MX_E("Unsupported container-format. Currently suports only MP4, 3GP, WAV & AMR\n");
ret = MEDIAMUXER_ERROR_INVALID_PATH;
goto ERROR;
+ }
+
+ if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_MP4) {
+ gst_handle->muxer = gst_element_factory_make("mp4mux", "mp4mux");
+ /* gst_element_factory_make("mp4mux", "mp4mux"); */
+ MX_I("make mp4mux element");
+ } else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_3GP) {
+ gst_handle->muxer = gst_element_factory_make("3gppmux", "3gppmux");
+ /* gst_handle->muxer = gst_element_factory_make("avmux_3gp", "avmux_3gp");*/
+ /* gst_handle->muxer = gst_element_factory_make("qtmux", "qtmux"); */
+ MX_I("make 3gppmux element");
+ } else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_WAV) {
+ gst_handle->muxer = gst_element_factory_make("wavenc", "wavenc");
+ MX_I("make wavenc element");
+ } else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS) {
+ gst_handle->muxer = gst_element_factory_make("aacparse", "aacparse");
+ MX_I("make aacparse element");
+ } else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_NB
+ || gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_WB) {
+ gst_handle->muxer = gst_element_factory_make("avmux_amr", "avmux_amr");
+ MX_I("make avmux_amr element");
} else {
- if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_MP4)
- gst_handle->muxer = gst_element_factory_make("mp4mux", "mp4mux");
- /* gst_element_factory_make("mp4mux", "mp4mux"); */
- else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_3GP)
- gst_handle->muxer = gst_element_factory_make("3gppmux", "3gppmux");
- /* gst_handle->muxer = gst_element_factory_make("avmux_3gp", "avmux_3gp");*/
- /* gst_handle->muxer = gst_element_factory_make("qtmux", "qtmux"); */
- else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_WAV)
- gst_handle->muxer = gst_element_factory_make("wavenc", "wavenc");
- else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS)
- gst_handle->muxer = gst_element_factory_make("avmux_adts", "avmux_adts");
- else if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_NB
- || gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_WB)
- gst_handle->muxer = gst_element_factory_make("avmux_amr", "avmux_amr");
-
- if ((!gst_handle->pipeline) || (!gst_handle->muxer) || (!gst_handle->sink)) {
- MX_E("One element could not be created. Exiting.\n");
- ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
- goto ERROR;
- }
+ MX_I("didn't make muxer element");
+ }
- /* Build the pipeline */
- gst_bin_add_many(GST_BIN(gst_handle->pipeline), gst_handle->muxer, gst_handle->sink, NULL);
+ if ((!gst_handle->pipeline) || (!gst_handle->muxer) || (!gst_handle->sink)) {
+ MX_E("One element could not be created. Exiting.\n");
+ ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
+ goto ERROR;
+ }
+
+ /* Build the pipeline */
+ gst_bin_add_many(GST_BIN(gst_handle->pipeline), gst_handle->muxer, gst_handle->sink, NULL);
+ if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS) {
+ GstCaps *outcaps = gst_caps_new_simple("audio/mpeg", "stream-format", G_TYPE_STRING, "adts", NULL);
+ if (!gst_element_link_filtered(gst_handle->muxer, gst_handle->sink, outcaps))
+ MX_E("muxer-sink link failed\n");
+ gst_caps_unref(outcaps);
+ } else {
if (!gst_element_link(gst_handle->muxer, gst_handle->sink))
MX_E("muxer-sink link failed\n");
+ }
- if (gst_handle->track_info.video_track_cnt) { /* Video track(s) exist */
- for (current = gst_handle->track_info.track_head; current; current = current->next) {
- if (current->track_index%NO_OF_TRACK_TYPES == 0) { /* Video track */
-
- snprintf(str_appsrc, MAX_STRING_LENGTH - 1, "video_appsrc%d", current->track_index);
- snprintf(str_parser, MAX_STRING_LENGTH - 1, "video_parser%d", current->track_index);
-
- current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
-
- if (media_format_get_video_info((media_format_h)(current->media_format), &mimetype, NULL, NULL, NULL, NULL)
- == MEDIA_FORMAT_ERROR_NONE) {
- if (mimetype == MEDIA_FORMAT_H264_SP || mimetype == MEDIA_FORMAT_H264_MP || mimetype == MEDIA_FORMAT_H264_HP)
- current->parser = gst_element_factory_make("h264parse", str_parser);
- else if (mimetype == MEDIA_FORMAT_H263 || mimetype == MEDIA_FORMAT_H263P)
- current->parser = gst_element_factory_make("h263parse", str_parser);
- else if (mimetype == MEDIA_FORMAT_MPEG4_SP)
- current->parser = gst_element_factory_make("mpeg4videoparse", str_parser);
- } else {
- MX_E("Can't retrive mimetype for the current track. Unsupported MIME Type\n");
- ret = MEDIAMUXER_ERROR_INVALID_PARAMETER;
- goto ERROR;
- }
+ if (gst_handle->track_info.video_track_cnt) { /* Video track(s) exist */
+ for (current = gst_handle->track_info.track_head; current; current = current->next) {
+ if (current->track_index%NO_OF_TRACK_TYPES == 0) { /* Video track */
+
+ snprintf(str_appsrc, MAX_STRING_LENGTH - 1, "video_appsrc%d", current->track_index);
+ snprintf(str_parser, MAX_STRING_LENGTH - 1, "video_parser%d", current->track_index);
+
+ current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
+
+ if (media_format_get_video_info((media_format_h)(current->media_format), &mimetype, NULL, NULL, NULL, NULL)
+ == MEDIA_FORMAT_ERROR_NONE) {
+ if (mimetype == MEDIA_FORMAT_H264_SP
+ || mimetype == MEDIA_FORMAT_H264_MP
+ || mimetype == MEDIA_FORMAT_H264_HP) {
+ current->parser = gst_element_factory_make("h264parse", str_parser);
+ MX_I("make h264parse element");
+ } else if (mimetype == MEDIA_FORMAT_H263
+ || mimetype == MEDIA_FORMAT_H263P) {
+ current->parser = gst_element_factory_make("h263parse", str_parser);
+ MX_I("make h263parse element");
+ } else if (mimetype == MEDIA_FORMAT_MPEG4_SP) {
+ current->parser = gst_element_factory_make("mpeg4videoparse", str_parser);
+ MX_I("make mpeg4videoparse element");
+ }
+ } else {
+ MX_E("Can't retrive mimetype for the current track. Unsupported MIME Type\n");
+ ret = MEDIAMUXER_ERROR_INVALID_PARAMETER;
+ goto ERROR;
+ }
- if ((!current->appsrc) || (!current->parser)) {
- MX_E("One element (video_appsrc/vparse) could not be created. Exiting.\n");
- ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
- goto ERROR;
- }
+ if ((!current->appsrc) || (!current->parser)) {
+ MX_E("One element (video_appsrc/vparse) could not be created. Exiting.\n");
+ ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
+ goto ERROR;
+ }
- gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, current->parser, NULL);
+ gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, current->parser, NULL);
#ifdef ASYCHRONOUS_WRITE
- /* ToDo: Use a function pointer, and create independent fucntions to each track */
- MX_I("\nRegistering video callback for cur->tr_ind = %d\n", current->track_index);
- g_signal_connect(current->appsrc, "need-data",
- G_CALLBACK(_video_start_feed), current);
- g_signal_connect(current->appsrc, "enough-data",
- G_CALLBACK(_video_stop_feed), current);
+ /* ToDo: Use a function pointer, and create independent fucntions to each track */
+ MX_I("\nRegistering video callback for cur->tr_ind = %d\n", current->track_index);
+ g_signal_connect(current->appsrc, "need-data",
+ G_CALLBACK(_video_start_feed), current);
+ g_signal_connect(current->appsrc, "enough-data",
+ G_CALLBACK(_video_stop_feed), current);
#else
- g_object_set(current->appsrc, "block", TRUE, NULL);
- gst_app_src_set_stream_type((GstAppSrc *)current->appsrc,
- GST_APP_STREAM_TYPE_STREAM);
+ g_object_set(current->appsrc, "block", TRUE, NULL);
+ gst_app_src_set_stream_type((GstAppSrc *)current->appsrc,
+ GST_APP_STREAM_TYPE_STREAM);
#endif
- if (current->caps)
- g_object_set(current->appsrc, "caps", current->caps, NULL);
+ if (current->caps)
+ g_object_set(current->appsrc, "caps", current->caps, NULL);
- g_object_set(current->appsrc, "max-bytes", (guint64)3 * 1024 * 1024, NULL);
+ g_object_set(current->appsrc, "max-bytes", (guint64)3 * 1024 * 1024, NULL);
- gst_element_link(current->appsrc, current->parser);
+ if (!gst_element_link(current->appsrc, current->parser))
+ MX_E("appsrc-parse failed\n");
- /* Link videoparse to muxer_video_pad. Request for muxer A/V pads. */
- snprintf(track_no, MAX_STRING_LENGTH - 1, "video_%.2d", vid_track_cnt++); /* sprintf(track_no,"video_00"); */
+ /* Link videoparse to muxer_video_pad. Request for muxer A/V pads. */
+ snprintf(track_no, MAX_STRING_LENGTH - 1, "video_%.2d", vid_track_cnt++); /* sprintf(track_no,"video_00"); */
- video_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
- vid_src = gst_element_get_static_pad(current->parser, "src");
+ video_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
+ if (!video_pad)
+ MX_E("muxer get request pad fail (%s)", track_no);
+ vid_src = gst_element_get_static_pad(current->parser, "src");
+ if (!vid_src)
+ MX_E("parser get src pad");
- if (gst_pad_link(vid_src, video_pad) != GST_PAD_LINK_OK)
- MX_E("video parser to muxer link failed\n");
+ if (gst_pad_link(vid_src, video_pad) != GST_PAD_LINK_OK)
+ MX_E("video parser to muxer link failed\n");
- gst_object_unref(GST_OBJECT(vid_src));
- gst_object_unref(GST_OBJECT(video_pad));
- }
+ gst_object_unref(GST_OBJECT(vid_src));
+ gst_object_unref(GST_OBJECT(video_pad));
}
}
+ }
- if (gst_handle->track_info.audio_track_cnt) { /* Audio track(s) exist */
- for (current = gst_handle->track_info.track_head; current; current = current->next) {
- if (current->track_index%NO_OF_TRACK_TYPES == 1) {
-
- snprintf(str_appsrc, MAX_STRING_LENGTH - 1, "audio_appsrc%d", current->track_index);
- snprintf(str_parser, MAX_STRING_LENGTH - 1, "audio_parser%d", current->track_index);
-
- current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
-
- if (media_format_get_audio_info((media_format_h)(current->media_format), &mimetype, NULL, NULL, NULL, NULL) ==
- MEDIA_FORMAT_ERROR_NONE) {
- if (mimetype == MEDIA_FORMAT_AAC_LC || mimetype == MEDIA_FORMAT_AAC_HE || mimetype == MEDIA_FORMAT_AAC_HE_PS)
- current->parser = gst_element_factory_make("aacparse", str_parser);
- else if (mimetype == MEDIA_FORMAT_PCM
- || (mimetype == MEDIA_FORMAT_AAC && gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS)
- || (mimetype == MEDIA_FORMAT_AMR_NB && gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_3GP))
- MX_I("Do Nothing, as there is no need of parser for wav, 3gp(amr-nb) and AAC_ADTS\n");
- else if (mimetype == MEDIA_FORMAT_AMR_NB || mimetype == MEDIA_FORMAT_AMR_WB)
- current->parser = gst_element_factory_make("amrparse", str_parser);
+ if (gst_handle->track_info.audio_track_cnt) { /* Audio track(s) exist */
+ for (current = gst_handle->track_info.track_head; current; current = current->next) {
+ if (current->track_index%NO_OF_TRACK_TYPES == 1) {
+
+ snprintf(str_appsrc, MAX_STRING_LENGTH - 1, "audio_appsrc%d", current->track_index);
+ snprintf(str_parser, MAX_STRING_LENGTH - 1, "audio_parser%d", current->track_index);
+
+ current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
+
+ if (media_format_get_audio_info((media_format_h)(current->media_format), &mimetype, NULL, NULL, NULL, NULL) ==
+ MEDIA_FORMAT_ERROR_NONE) {
+ if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS) {
+ MX_I("not make parse element");
+ } else if (mimetype == MEDIA_FORMAT_AAC || mimetype == MEDIA_FORMAT_AAC_LC
+ || mimetype == MEDIA_FORMAT_AAC_HE || mimetype == MEDIA_FORMAT_AAC_HE_PS) {
+ current->parser = gst_element_factory_make("aacparse", str_parser);
+ MX_I("make aacparse element");
+ } else if (mimetype == MEDIA_FORMAT_AMR || mimetype == MEDIA_FORMAT_AMR_NB || mimetype == MEDIA_FORMAT_AMR_WB) {
+ current->parser = gst_element_factory_make("amrparse", str_parser);
+ MX_I("make amrparse element");
+ } else if (mimetype == MEDIA_FORMAT_PCM) {
+ MX_I("Do Nothing, as there is no need of parser for wav\n");
} else {
- MX_E("Can't retrive mimetype for the current track. Unsupported MIME Type. Proceeding to the next track\n");
+ MX_I("Do Nothing");
}
+ } else {
+ MX_E("Can't retrive mimetype for the current track. Unsupported MIME Type. Proceeding to the next track\n");
+ }
+
+ if (!current->appsrc) {
+ MX_E("One element (audio_appsrc) could not be created. Exiting.\n");
+ ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
+ goto ERROR;
+ }
- if (!current->appsrc) {
- MX_E("One element (audio_appsrc) could not be created. Exiting.\n");
+ gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, NULL);
+ if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS
+ || mimetype == MEDIA_FORMAT_PCM) {
+ MX_I("Do Nothing, as there is no need of parser for wav and AAC_ADTS\n");
+ } else {
+ if (!current->parser) {
+ MX_E("One element (audio-parser) could not be created. Exiting.\n");
ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
goto ERROR;
}
-
- gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, NULL);
- if (mimetype == MEDIA_FORMAT_PCM
- || (mimetype == MEDIA_FORMAT_AAC && gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS)
- || (mimetype == MEDIA_FORMAT_AMR_NB && gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_3GP)) {
- MX_I("Do Nothing, as there is no need of parser for wav and AAC_ADTS\n");
- } else {
- if (!current->parser) {
- MX_E("One element (audio-parser) could not be created. Exiting.\n");
- ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
- goto ERROR;
- }
- gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->parser, NULL);
- }
+ gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->parser, NULL);
+ }
#ifdef ASYCHRONOUS_WRITE
- /* ToDo: Use a function pointer, and create independent fucntions to each track */
- MX_I("\nRegistering audio callback for cur->tr_ind = %d\n", current->track_index);
- g_signal_connect(current->appsrc, "need-data",
- G_CALLBACK(_audio_start_feed), current);
- g_signal_connect(current->appsrc, "enough-data",
- G_CALLBACK(_audio_stop_feed), current);
- g_object_set(current->appsrc, "format", GST_FORMAT_TIME, NULL);
+ /* ToDo: Use a function pointer, and create independent fucntions to each track */
+ MX_I("\nRegistering audio callback for cur->tr_ind = %d\n", current->track_index);
+ g_signal_connect(current->appsrc, "need-data",
+ G_CALLBACK(_audio_start_feed), current);
+ g_signal_connect(current->appsrc, "enough-data",
+ G_CALLBACK(_audio_stop_feed), current);
+ g_object_set(current->appsrc, "format", GST_FORMAT_TIME, NULL);
#else
- g_object_set(current->appsrc, "block", TRUE, NULL);
- gst_app_src_set_stream_type((GstAppSrc *)current->appsrc,
- GST_APP_STREAM_TYPE_STREAM);
+ g_object_set(current->appsrc, "block", TRUE, NULL);
+ gst_app_src_set_stream_type((GstAppSrc *)current->appsrc,
+ GST_APP_STREAM_TYPE_STREAM);
#endif
- if (current->caps)
- g_object_set(current->appsrc, "caps", current->caps, NULL);
-
- g_object_set(current->appsrc, "max-bytes", 3 * 1024 * 1024, NULL);
-
- /* For wav, wavenc is muxer */
- if (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_WAV
- || gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AAC_ADTS
- || gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_NB
- || gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_AMR_WB
- || (gst_handle->muxed_format == MEDIAMUXER_CONTAINER_FORMAT_3GP && mimetype == MEDIA_FORMAT_AMR_NB)) {
- gst_element_link(current->appsrc, gst_handle->muxer);
- } else {
- gst_element_link(current->appsrc, current->parser);
- /* Link videoparse to muxer_video_pad. Request for muxer A/V pads. */
- snprintf(track_no, MAX_STRING_LENGTH - 1, "audio_%.2d", aud_track_cnt++); /* sprintf(track_no,"audio_00"); */
+ if (current->caps)
+ g_object_set(current->appsrc, "caps", current->caps, NULL);
- audio_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
- aud_src = gst_element_get_static_pad(current->parser, "src");
+ g_object_set(current->appsrc, "max-bytes", 3 * 1024 * 1024, NULL);
- if (gst_pad_link(aud_src, audio_pad) != GST_PAD_LINK_OK)
- MX_E("audio parser to muxer link failed\n");
+ /* For wav, wavenc is muxer */
+ if (!current->parser) {
+ gst_element_link(current->appsrc, gst_handle->muxer);
+ } else {
+ gst_element_link(current->appsrc, current->parser);
+ /* Link videoparse to muxer_video_pad. Request for muxer A/V pads. */
+ snprintf(track_no, MAX_STRING_LENGTH - 1, "audio_%.2d", aud_track_cnt++); /* sprintf(track_no,"audio_00"); */
- gst_object_unref(GST_OBJECT(aud_src));
- gst_object_unref(GST_OBJECT(audio_pad));
- }
+ audio_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
+ aud_src = gst_element_get_static_pad(current->parser, "src");
+
+ if (gst_pad_link(aud_src, audio_pad) != GST_PAD_LINK_OK)
+ MX_E("audio parser to muxer link failed\n");
+
+ gst_object_unref(GST_OBJECT(aud_src));
+ gst_object_unref(GST_OBJECT(audio_pad));
}
}
}
+ }
- if (gst_handle->track_info.subtitle_track_cnt) { /* Subtitle track(s) exist */
- for (current = gst_handle->track_info.track_head; current; current = current->next) {
- if (current->track_index%NO_OF_TRACK_TYPES == 2) {
+ if (gst_handle->track_info.subtitle_track_cnt) { /* Subtitle track(s) exist */
+ for (current = gst_handle->track_info.track_head; current; current = current->next) {
+ if (current->track_index%NO_OF_TRACK_TYPES == 2) {
- snprintf(str_appsrc, MAX_STRING_LENGTH, "subtitle_appsrc%d", current->track_index);
+ snprintf(str_appsrc, MAX_STRING_LENGTH, "subtitle_appsrc%d", current->track_index);
- current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
+ current->appsrc = gst_element_factory_make("appsrc", str_appsrc);
- if (!current->appsrc) {
+ if (!current->appsrc) {
- MX_E("One element (text_appsrc) could not be created. Exiting.\n");
- ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
- goto ERROR;
- }
+ MX_E("One element (text_appsrc) could not be created. Exiting.\n");
+ ret = MEDIAMUXER_ERROR_RESOURCE_LIMIT;
+ goto ERROR;
+ }
- gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, NULL);
+ gst_bin_add_many(GST_BIN(gst_handle->pipeline), current->appsrc, NULL);
- /* Set subtitle_caps for corresponding src elements */
- if (current->caps)
- g_object_set(current->appsrc, "caps", current->caps, NULL);
- g_object_set(current->appsrc, "format", GST_FORMAT_TIME, NULL);
+ /* Set subtitle_caps for corresponding src elements */
+ if (current->caps)
+ g_object_set(current->appsrc, "caps", current->caps, NULL);
+ g_object_set(current->appsrc, "format", GST_FORMAT_TIME, NULL);
#ifdef ASYCHRONOUS_WRITE
- /* ToDo: Use a function pointer, and create independent functions to each track */
- MX_I("\nRegistering subtitle callback for cur->tr_ind = %d\n", current->track_index);
- g_signal_connect(current->appsrc, "need-data", G_CALLBACK(_subtitle_start_feed), current);
- g_signal_connect(current->appsrc, "enough-data", G_CALLBACK(_subtitle_stop_feed), current);
+ /* ToDo: Use a function pointer, and create independent functions to each track */
+ MX_I("\nRegistering subtitle callback for cur->tr_ind = %d\n", current->track_index);
+ g_signal_connect(current->appsrc, "need-data", G_CALLBACK(_subtitle_start_feed), current);
+ g_signal_connect(current->appsrc, "enough-data", G_CALLBACK(_subtitle_stop_feed), current);
#else
- g_object_set(current->appsrc, "block", TRUE, NULL);
- gst_app_src_set_stream_type((GstAppSrc *)current->appsrc, GST_APP_STREAM_TYPE_STREAM);
+ g_object_set(current->appsrc, "block", TRUE, NULL);
+ gst_app_src_set_stream_type((GstAppSrc *)current->appsrc, GST_APP_STREAM_TYPE_STREAM);
#endif
- snprintf(track_no, MAX_STRING_LENGTH, "subtitle_%.2d", text_track_cnt++); /* snprintf(track_no,"subtitle_00"); */
- subtitle_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
- subtitle_src = gst_element_get_static_pad(current->appsrc, "src");
- MX_I("Linking subtitle-appsrc to muxersubtitle static-pad\n");
- if (gst_pad_link(subtitle_src, subtitle_pad) != GST_PAD_LINK_OK)
- MX_E("subtitle_src and subtitle_pad link failed");
+ snprintf(track_no, MAX_STRING_LENGTH, "subtitle_%.2d", text_track_cnt++); /* snprintf(track_no,"subtitle_00"); */
+ subtitle_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
+ subtitle_src = gst_element_get_static_pad(current->appsrc, "src");
+ MX_I("Linking subtitle-appsrc to muxersubtitle static-pad\n");
+ if (gst_pad_link(subtitle_src, subtitle_pad) != GST_PAD_LINK_OK)
+ MX_E("subtitle_src and subtitle_pad link failed");
- gst_object_unref(GST_OBJECT(subtitle_src));
- gst_object_unref(GST_OBJECT(subtitle_pad));
- }
+ gst_object_unref(GST_OBJECT(subtitle_src));
+ gst_object_unref(GST_OBJECT(subtitle_pad));
}
}
-
}
MX_I("Output_uri= %s\n", gst_handle->output_uri);
/* GstMapInfo map; */
int ret = MX_ERROR_NONE;
-#if 0
/* get codec data and set caps */
char *pkt_codec_data;
unsigned int codec_data_size;
g_object_get(G_OBJECT(current->appsrc), "caps", &appsrc_caps, NULL);
codec_data_caps_string = gst_caps_to_string(appsrc_caps);
- MX_I("[LGB] Appsrc caps is %s", codec_data_caps_string);
+ MX_I("Appsrc caps is %s", codec_data_caps_string);
g_free(codec_data_caps_string);
if (appsrc_caps)
new_appsrc_caps = gst_caps_copy(appsrc_caps);
gst_caps_set_simple(new_appsrc_caps, "codec_data", GST_TYPE_BUFFER, codec_data_buffer, NULL);
codec_data_caps_string = gst_caps_to_string(new_appsrc_caps);
- MX_I("[LGB] New appsrc caps is %s", codec_data_caps_string);
+ MX_I("New appsrc caps is %s", codec_data_caps_string);
g_free(codec_data_caps_string);
g_object_set(G_OBJECT(current->appsrc), "caps", new_appsrc_caps, NULL);
gst_caps_unref(appsrc_caps);
gst_caps_unref(new_appsrc_caps);
gst_buffer_unref(codec_data_buffer);
- MX_I("codec data is %p, codec_data_size %u", pkt_codec_data, codec_data_size);
+
}
-#endif
+
media_packet_get_buffer_size(out_pkt, &size);
MX_I("Media packet Buffer capacity: %llu\n", size);
- /* Check adts header */
- media_format_h format = NULL;
- unsigned char buf_adts[ADTS_HEADER_SIZE] = {0, };
- bool is_adts = TRUE;
- if (media_packet_get_format(out_pkt, &format) == MEDIA_PACKET_ERROR_NONE) {
- media_format_mimetype_e a_mime;
- int channel = 0;
- int samplerate = 0;
- int bit = 0;
- if (media_format_get_audio_info(format, &a_mime, &channel, &samplerate,
- &bit, NULL) == MEDIA_FORMAT_ERROR_NONE) {
- if (a_mime == MEDIA_FORMAT_AAC_LC) {
- media_format_get_audio_aac_type(format, &is_adts);
- if (is_adts == FALSE) {
- /* generator adts header */
- size = size + ADTS_HEADER_SIZE;
- _generate_header_aac_adts(buf_adts, size, samplerate, channel);
- MX_I("Add adts header");
- }
- }
- }
- media_format_unref(format);
- }
-
/* copy data */
data_ptr = (unsigned char *)g_malloc(size);
if (!data_ptr) {
goto ERROR;
}
- if (is_adts == FALSE) {
- memcpy(data_ptr, (char *)buf_adts, ADTS_HEADER_SIZE);
- memcpy(data_ptr + ADTS_HEADER_SIZE, (char *)pkt_data, size - ADTS_HEADER_SIZE);
- } else {
- memcpy(data_ptr, (char *)pkt_data, size);
- }
+ memcpy(data_ptr, (char *)pkt_data, size);
uint64_t info;
gst_buffer_insert_memory(buffer, -1,
MEDIAMUXER_FLEAVE();
return ret;
}
-
-static void _generate_header_aac_adts(unsigned char *buffer, int packetLen, int samplerate, int channel)
-{
- 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;
-}
-