#define DEFAULT_FRAMERATE_NUM 30
#define DEFAULT_FRAMERATE_DEN 1
#define DEFAULT_VIDEO_FRAME_DURATION 33 /* ms */
+#define PLAYER_DATA_PUSH_WAIT_COUNT 10
+#define PLAYER_STATE_CHECK_INTERVAL (100*1000)
/*---------------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
GstMapInfo buff_info = GST_MAP_INFO_INIT;
uint64_t pts = 0;
uint64_t duration = 0;
+ int wait_cnt = 0;
/* get size */
_buffer = gst_buffer_new_and_alloc(size);
goto ERROR;
}
GST_BUFFER_PTS(_buffer) = (GstClockTime)pts;
+
+ while ((GST_STATE(element) < GST_STATE_PAUSED) && (wait_cnt < PLAYER_DATA_PUSH_WAIT_COUNT)) {
+ LOGW("wait to update source state : %d, %d", player->state, GST_STATE(element));
+ usleep(PLAYER_STATE_CHECK_INTERVAL);
+ wait_cnt++;
+ }
+
+ if (wait_cnt == PLAYER_DATA_PUSH_WAIT_COUNT) {
+ LOGE("source is not ready %d", GST_STATE(element));
+ ret = MM_ERROR_PLAYER_INTERNAL;
+ goto ERROR;
+ }
+
gst_app_src_push_buffer(GST_APP_SRC(element), _buffer);
}
/* check eos */
if (media_packet_is_end_of_stream(packet, &is_eos) != MEDIA_PACKET_ERROR_NONE) {
LOGE("failed to get eos info");
- ret = MM_ERROR_PLAYER_INTERNAL;
- goto ERROR;
+ return MM_ERROR_PLAYER_INTERNAL;
}
if (is_eos) {
g_signal_emit_by_name(element, "end-of-stream", &ret);
}
+ return ret;
+
ERROR:
+ gst_buffer_unref(_buffer);
return ret;
}