Addressed prevent issues [Sync with 2.4] 74/53574/2 accepted/tizen/mobile/20151212.071329 accepted/tizen/tv/20151212.072809 accepted/tizen/wearable/20151212.073432 submit/tizen/20151211.091510
authorMahesh Kondiparthi <kd.mahesh@samsung.com>
Tue, 8 Dec 2015 04:13:49 +0000 (09:43 +0530)
committerMahesh Kondiparthi <kd.mahesh@samsung.com>
Tue, 8 Dec 2015 05:15:00 +0000 (10:45 +0530)
update user_cb from _mx_gst_bus_call
Replace printf with g_print
Addressed review comments

Change-Id: I9c808ed82beba37c682b20846b79e8820d3997c3
Signed-off-by: Mahesh Kondiparthi <kd.mahesh@samsung.com>
src/port_gst/mediamuxer_port_gst.c
test/mediamuxer_test.c
test/mediamuxer_test_with_mediacodec.c

index 98c49f238fcef2186774c0a83214a81a61f552ac..93dbec5a88aa054d3132609994da9c6e69eda2d0 100644 (file)
@@ -306,7 +306,8 @@ static gint __gst_handle_library_error(mxgst_handle_t* gst_handle, int code)
 static gboolean _mx_gst_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
 {
        MEDIAMUXER_FENTER();
-       int ret  = MX_ERROR_NONE;
+       gboolean ret = TRUE;
+       int error_val  = MX_ERROR_NONE;
        mxgst_handle_t *gst_handle = (mxgst_handle_t*)data;
        switch (GST_MESSAGE_TYPE(msg)) {
        case GST_MESSAGE_EOS:
@@ -317,20 +318,23 @@ static gboolean _mx_gst_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
                        GError *error;
                        gst_message_parse_error(msg, &error, &debug);
                        if (!error) {
-                               MX_E("GST error message parsing failed");
+                               MX_E("GStreamer callback error message parsing failed\n");
+                               ret = FALSE;
                                break;
                        }
-                       MX_E("Error: %s\n", error->message);
+                       MX_I("GStreamer callback Error: %s\n", error->message);
                        if (error) {
                                if (error->domain == GST_RESOURCE_ERROR)
-                                       ret = __gst_handle_resource_error(gst_handle, error->code);
+                                       error_val = __gst_handle_resource_error(gst_handle, error->code);
                                else if (error->domain == GST_LIBRARY_ERROR)
-                                       ret = __gst_handle_library_error(gst_handle, error->code);
+                                       error_val = __gst_handle_library_error(gst_handle, error->code);
                                else if (error->domain == GST_CORE_ERROR)
-                                       ret = __gst_handle_core_error(gst_handle, error->code);
+                                       error_val = __gst_handle_core_error(gst_handle, error->code);
                                else
-                                       MX_E("Unexpected error has occured");
-                               /* ToDo: Update the user callback with ret... */
+                                       MX_I("Unknown GStreamer callback error\n");
+                               /* Update the user callback with ret value */
+                               ((gst_error_cb)gst_handle->user_cb[_GST_EVENT_TYPE_ERROR])(error_val, (void*)error->message);
+
                                return ret;
                        }
                        g_free(debug);
@@ -339,11 +343,11 @@ static gboolean _mx_gst_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
                }
                break;
        default:
-               MX_E("unhandled message: 0x%x", GST_MESSAGE_TYPE(msg));
+               MX_I("unhandled gst callback message: 0x%x\n", GST_MESSAGE_TYPE(msg));
                break;
        }
        MEDIAMUXER_FLEAVE();
-       return TRUE;
+       return ret;
 }
 
 /*
@@ -498,7 +502,7 @@ mx_ret_e _gst_create_pipeline(mxgst_handle_t *gst_handle)
                                        gst_element_link(current->appsrc, current->parser);
 
                                        /* Link videoparse to muxer_video_pad.   Request for muxer A/V pads. */
-                                       sprintf(track_no, "video_%.2d", vid_track_cnt++);  /* sprintf(track_no,"video_00"); */
+                                       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");
@@ -516,8 +520,8 @@ mx_ret_e _gst_create_pipeline(mxgst_handle_t *gst_handle)
                        for (current = gst_handle->track_info.track_head; current; current = current->next) {
                                if (current->track_index%NO_OF_TRACK_TYPES == 1) {
 
-                                       sprintf(str_appsrc, "audio_appsrc%d", current->track_index);
-                                       sprintf(str_parser, "audio_parser%d", current->track_index);
+                                       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);
 
@@ -571,7 +575,7 @@ mx_ret_e _gst_create_pipeline(mxgst_handle_t *gst_handle)
                                        } else {
                                                gst_element_link(current->appsrc, current->parser);
                                                /* Link videoparse to muxer_video_pad.   Request for muxer A/V pads. */
-                                               sprintf(track_no, "audio_%.2d", aud_track_cnt++);  /* sprintf(track_no,"audio_00"); */
+                                               snprintf(track_no, MAX_STRING_LENGTH - 1, "audio_%.2d", aud_track_cnt++);  /* sprintf(track_no,"audio_00"); */
 
                                                audio_pad = gst_element_get_request_pad(gst_handle->muxer, track_no);
                                                aud_src = gst_element_get_static_pad(current->parser, "src");
index 90a220f65b1cd9b6e119a69cb6cbac02a16c4ceb..44d53c0eeb2b47b2b99248c5677134b82ec8e026 100644 (file)
@@ -213,10 +213,7 @@ int test_mediamuxer_add_track_video()
 int test_mediamuxer_add_track_audio()
 {
        media_format_mimetype_e mimetype;
-       int channel = 0;
-       int samplerate = 0;
-       int bit = 0;
-       int avg_bps = 0;
+       int avg_bps = 128000;
 
        g_print("test_mediamuxer_add_track_audio\n");
        media_format_create(&media_format_a);
@@ -224,7 +221,7 @@ int test_mediamuxer_add_track_audio()
        if (strncmp(data_sink, "1", 1) == 0 || strncmp(data_sink, "mp4", 3) == 0) {
                /* MEDIA_FORMAT_AAC_LC  MEDIA_FORMAT_AAC_HE  MEDIA_FORMAT_AAC_HE_PS */
                if (media_format_set_audio_mime(media_format_a, MEDIA_FORMAT_AAC_LC) == MEDIA_FORMAT_ERROR_INVALID_OPERATION)
-                       g_print("Problem during media_format_set_audio_mime operation\n");
+                       g_print("Problem during media_format_set_audio_mime operation, for AAC in MP4\n");
        } else if (strncmp(data_sink, "2", 1) == 0 || strncmp(data_sink, "3gp", 3) == 0
                        || strncmp(data_sink, "3", 1) == 0) {
                if (media_format_set_audio_mime(media_format_a, MEDIA_FORMAT_AAC_LC) == MEDIA_FORMAT_ERROR_INVALID_OPERATION)
@@ -356,7 +353,7 @@ int test_mediamuxer_destroy()
 
 void app_err_cb(mediamuxer_error_e error, void *user_data)
 {
-       printf("Got Error %d from mediamuxer\n", error);
+       g_print("Got Error %d: %s from mediamuxer\n", error, (char *)user_data);
 }
 
 int test_mediamuxer_set_error_cb()
index f14b90db1835699dd1eb2898a92ce266501ed70a..e9927f910a38a0fef393f0bb0fbe0a904ac67f6b 100644 (file)
@@ -505,7 +505,7 @@ int __mediacodec_process_input(void)
                media_packet_get_buffer_data_ptr(in_buf, &data);
                if (data == NULL)
                        return MEDIACODEC_ERROR_INVALID_PARAMETER;
-               printf("use_encoder=%d\n", use_encoder);
+               g_print("use_encoder=%d\n", use_encoder);
 
                if (use_encoder) {
                        if (use_video) {
@@ -514,7 +514,7 @@ int __mediacodec_process_input(void)
                                if (bMultipleFiles) {
                                        buf_size = __extract_input_per_frame(fp_src, data);
                                        fclose(fp_src);
-                                       sprintf(g_uri+g_len, "%05d", frame_count+1);
+                                       snprintf(g_uri+g_len, MAX_STRING_LEN-g_len, "%05d", frame_count+1);
                                        fp_src = fopen(g_uri, "r");
                                        if (fp_src == NULL) {
                                                media_packet_set_flags(in_buf, MEDIA_PACKET_END_OF_STREAM);
@@ -534,7 +534,7 @@ int __mediacodec_process_input(void)
                        } else {
                                /* Audio Encoder - AAC */
                                buf_size = __extract_input_aacenc(fp_src, data);
-                               printf("audio buf_size=%d\n", buf_size);
+                               g_print("audio buf_size=%d\n", buf_size);
                                /* pts is not needed for muxer, if adts header is present */
                                /* media_packet_set_pts (in_buf, pts); */
                                g_print("----pts calculation: input pts = %"PRIu64", buf_size=%d samplerate=%d, samplebyte=%d\n", pts, buf_size, samplerate, samplebyte);
@@ -556,10 +556,6 @@ int __mediacodec_process_input(void)
                        g_print("%s - input_buf size = %4d  (0x%x) at %4d frame, %p\n", __func__, buf_size, buf_size, frame_count, in_buf);
 
                        ret = mediacodec_process_input(g_media_codec[0], in_buf, 0);
-                       if (use_video && buf_size == -1) {
-                               g_print("%s - END : input_buf size = %d  frame_count : %d\n", __func__, buf_size, frame_count);
-                               return MEDIACODEC_ERROR_INVALID_INBUFFER;
-                       }
                } else {
                        g_print("%s - [WARN] Check to input buf_size = %4d  at %4d frame, %p\n", __func__, buf_size, frame_count, in_buf);
                        return MEDIACODEC_ERROR_INVALID_INBUFFER;