From a433c71ff93b8725d1dfe5293b18dae3c41d3147 Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Thu, 22 Dec 2016 14:58:27 +0900 Subject: [PATCH] Send eos event into appsrc when eos media packet [Version] 0.1.7 [Profile] Common, Mobile, Wearable, TV [Issue Type] Fix bugs Change-Id: I45485a1257416d4e7ea3277aa45e8b49f823deb7 --- packaging/capi-mediamuxer.spec | 2 +- src/port_gst/mediamuxer_port_gst.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/packaging/capi-mediamuxer.spec b/packaging/capi-mediamuxer.spec index 0f09465..a125ab0 100755 --- a/packaging/capi-mediamuxer.spec +++ b/packaging/capi-mediamuxer.spec @@ -1,6 +1,6 @@ Name: capi-mediamuxer Summary: A Media Muxer library in Tizen Native API -Version: 0.1.6 +Version: 0.1.7 Release: 1 Group: Multimedia/API License: Apache-2.0 diff --git a/src/port_gst/mediamuxer_port_gst.c b/src/port_gst/mediamuxer_port_gst.c index caa4f72..a1ea5c0 100755 --- a/src/port_gst/mediamuxer_port_gst.c +++ b/src/port_gst/mediamuxer_port_gst.c @@ -1146,14 +1146,17 @@ static int _gst_copy_media_packet_to_buf(mx_gst_track *current, media_packet_h o goto ERROR; } buffer->duration = info; - /* TBD: set falgs is not available now in media_packet */ + media_buffer_flags_e flags; if (media_packet_get_flags(out_pkt, &flags)) { MX_E("unable to get the buffer size\n"); ret = MX_ERROR_UNKNOWN; goto ERROR; } - GST_BUFFER_FLAG_SET(buffer, flags); + + if (flags & MEDIA_PACKET_SYNC_FRAME) + GST_BUFFER_FLAG_UNSET(buffer, GST_BUFFER_FLAG_DELTA_UNIT); + ERROR: MEDIAMUXER_FLEAVE(); return ret; @@ -1167,6 +1170,7 @@ static int gst_muxer_write_sample(MMHandleType pHandle, int track_index, MEDIAMUXER_CHECK_NULL(pHandle); mxgst_handle_t *gst_handle = (mxgst_handle_t *) pHandle; mx_gst_track *current = NULL; + bool eos = FALSE; for (current = gst_handle->track_info.track_head; current; current = current->next) if (current->track_index == track_index) break; @@ -1191,7 +1195,16 @@ static int gst_muxer_write_sample(MMHandleType pHandle, int track_index, gst_inbuf2 = gst_buffer_new(); /* ToDo: Add functionality to the following function */ /* MX_I("\nBefore buff=%x\n", gst_inbuf2); */ - _gst_copy_media_packet_to_buf(current, inbuf, gst_inbuf2); + if (media_packet_is_end_of_stream(inbuf, &eos) != MEDIA_PACKET_ERROR_NONE) { + MX_E("media_packet_is_end_of_stream failed"); + goto ERROR; + } + + ret = _gst_copy_media_packet_to_buf(current, inbuf, gst_inbuf2); + if (ret != MX_ERROR_NONE) { + MX_E("media packet copy to gstbuffer error"); + goto ERROR; + } if (track_index%NO_OF_TRACK_TYPES == 0) { /* NO_OF_TRACK_TYPES*n for video */ MX_I("Waiting till start_feed of current video track, index=%d is active\n", current->track_index); @@ -1210,7 +1223,14 @@ static int gst_muxer_write_sample(MMHandleType pHandle, int track_index, if (ret != GST_FLOW_OK) { /* We got some error, stop sending data */ MX_E("--video appsrc push failed--\n"); + ret = MX_ERROR_INVALID_ARGUMENT; + } + + if (eos) { + MX_I("end of stream"); + gst_app_src_end_of_stream((GstAppSrc *)current->appsrc); } + } else if (track_index%NO_OF_TRACK_TYPES == 1) { /* NO_OF_TRACK_TYPES*n+1 for audio */ MX_I(" Waiting till start_feed of current audio track, index=%d is active\n", current->track_index); #ifdef ASYCHRONOUS_WRITE @@ -1226,6 +1246,11 @@ static int gst_muxer_write_sample(MMHandleType pHandle, int track_index, /* We got some error, stop sending data */ MX_E("--audio appsrc push failed--\n"); } + + if (eos) { + MX_I("end of stream"); + gst_app_src_end_of_stream((GstAppSrc *)current->appsrc); + } } else if (track_index%NO_OF_TRACK_TYPES == 2) { /* NO_OF_TRACK_TYPES*n+2 for subtitle */ MX_I(" Waiting till start_feed of current subtitle, index=%d is active\n", current->track_index); #ifdef ASYCHRONOUS_WRITE @@ -1241,6 +1266,10 @@ static int gst_muxer_write_sample(MMHandleType pHandle, int track_index, /* We got some error, stop sending data */ MX_E("--subtitle appsrc push failed--\n"); } + if (eos) { + MX_I("end of stream"); + gst_app_src_end_of_stream((GstAppSrc *)current->appsrc); + } } else { MX_E("Unsupported track index=%d. track_index-mod3= %d. Only 0/1/2 track index is vaild\n", track_index, track_index%NO_OF_TRACK_TYPES); ret = MX_ERROR_INVALID_ARGUMENT; -- 2.7.4