| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------------------*/
/* STATIC INTERNAL FUNCTION */
-static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
+static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_audio_dataprobe_check(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_video_dataprobe_encoded(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static GstPadProbeReturn __mmcamcorder_audioque_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
/*---------------------------------------------------------------------------------------
| GLOBAL FUNCTION DEFINITIONS: |
---------------------------------------------------------------------------------------*/
-gboolean _mmcamcorder_video_push_buffer(void *handle, GstBuffer *buffer)
+gboolean _mmcamcorder_video_push_buffer(void *handle, GstSample *sample)
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
_MMCamcorderVideoInfo *info_video = NULL;
_MMCamcorderGstElement *element = NULL;
GstClockTime current_ts = 0; /* nsec */
+ GstBuffer *buffer = NULL;
mmf_return_val_if_fail(hcamcorder, FALSE);
mmf_return_val_if_fail(MMF_CAMCORDER_SUBCONTEXT(hcamcorder), FALSE);
+ buffer = gst_sample_get_buffer(sample);
+
mmf_return_val_if_fail(buffer, FALSE);
mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
if (info_video->is_first_frame) {
/* check first I frame for H.264 stream */
- if (info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ if (_mmcamcorder_is_encoded_preview_pixel_format(info_image->preview_format)) {
if (GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
- MMCAM_LOG_WARNING("NOT I frame.. skip this buffer");
+ MMCAM_LOG_WARNING("NOT key frame.. skip this buffer");
return TRUE;
} else {
- MMCAM_LOG_WARNING("[H.264] first I frame");
+ MMCAM_LOG_WARNING("first key frame");
}
}
info_video->base_video_ts = current_ts;
}
} else {
- if (_mmcamcorder_invoke_video_stream_cb(handle, buffer, FALSE) == FALSE) {
+ if (_mmcamcorder_invoke_video_stream_cb(handle, sample, FALSE, -1) == FALSE) {
/* increase base video timestamp by frame duration,
it will remove delay of dropped buffer when play recorded file. */
info_video->base_video_ts += current_ts - info_video->last_video_ts;
}
-static gboolean __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
+static void __mmcamcorder_video_stream_cb(GstElement *element, GstSample *sample, gpointer u_data)
{
- return _mmcamcorder_video_push_buffer(u_data, gst_sample_get_buffer(sample));
+ mmf_return_if_fail(sample);
+
+ /* no need to check return value here */
+ _mmcamcorder_video_push_buffer(u_data, sample);
+
+ gst_sample_unref(sample);
}
bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
- /* register pipeline message callback */
- hcamcorder->encode_pipeline_cb_event_id = gst_bus_add_watch(bus, (GstBusFunc)_mmcamcorder_pipeline_cb_message, hcamcorder);
-
/* set sync handler */
gst_bus_set_sync_handler(bus, _mmcamcorder_encode_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
return ret;
}
- /* Remove pipeline message callback */
- if (hcamcorder->encode_pipeline_cb_event_id != 0) {
- g_source_remove(hcamcorder->encode_pipeline_cb_event_id);
- hcamcorder->encode_pipeline_cb_event_id = 0;
- }
-
/* Remove remained message */
if (bus) {
GstMessage *gst_msg = NULL;
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-width", info->video_width);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-height", info->video_height);
- } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
+ } else if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format) &&
info->preview_width == info->video_width &&
info->preview_height == info->video_height) {
- MMCAM_LOG_INFO("H264 preview mode and same resolution");
-
+ MMCAM_LOG_INFO("Encoded[%d] preview mode and same resolution", sc->info_image->preview_format);
/* No need to restart preview */
info->restart_preview = FALSE;
} else if (info->use_videoscale &&