#include <string.h>
#include <mm_types.h>
#include <mm_error.h>
+#include <media_packet.h>
#include "mm_streamrecorder_internal.h"
#include "mm_streamrecorder_recorder.h"
return ret;
}
+int _mmstreamrecorder_push_video_packet(MMHandleType handle, media_packet_h media_packet, unsigned long timestamp, void *buffer)
+{
+ int ret = MM_ERROR_NONE;
+ unsigned int ind = 0;
+ uint32_t plane_num = 0;
+ mmf_streamrecorder_t *hstreamrecorder = MMF_STREAMRECORDER(handle);
+ GstStreamRecorderBuffer *stream_buffer = NULL;
+ int image_width = 0;
+ int image_height = 0;
+ unsigned char *data_buffer = NULL;
+ int size = 0, total_size = 0;
+
+ if (!hstreamrecorder) {
+ _mmstreamrec_dbg_err("Not initialized");
+ ret = MM_ERROR_STREAMRECORDER_NOT_INITIALIZED;
+ return ret;
+ }
+
+ ret = media_packet_get_number_of_video_planes(media_packet, &plane_num);
+ if (plane_num <= 0 || ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("invalid plane_num [%d] is returned", plane_num);
+ return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT;
+ }
+
+ stream_buffer = (GstStreamRecorderBuffer *) malloc(sizeof(GstStreamRecorderBuffer));
+ if (stream_buffer == NULL) {
+ _mmstreamrec_dbg_err("stream buffer allocation fail");
+ return MM_ERROR_STREAMRECORDER_LOW_MEMORY;
+ }
+
+ stream_buffer->str_handle = handle;
+ stream_buffer->buffer = gst_buffer_new();
+ if (stream_buffer->buffer == NULL) {
+ free(stream_buffer);
+ stream_buffer = NULL;
+ _mmstreamrec_dbg_err("gst buffer allocation fail");
+ return MM_ERROR_STREAMRECORDER_LOW_MEMORY;
+ }
+ stream_buffer->user_buffer = buffer;
+ stream_buffer->buffer->pts = timestamp;
+ GST_BUFFER_DURATION(stream_buffer->buffer) = GST_CLOCK_TIME_NONE;
+
+ for (ind = 0; ind < plane_num; ++ind) {
+ ret = media_packet_get_video_stride_width(media_packet, ind, &image_width);
+ ret |= media_packet_get_video_stride_height(media_packet, ind, &image_height);
+ ret |= media_packet_get_video_plane_data_ptr(media_packet, ind, (void**)&data_buffer);
+
+ if (ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("media_packet_get_video_plane_data_ptr() plane[%d] failed", ind);
+ return MM_ERROR_STREAMRECORDER_INVALID_ARGUMENT;
+ }
+
+ size = image_width * image_height;
+ total_size += size;
+ _mmstreamrec_dbg_err("Plane[%d] info : %d x %d (%p) size = %d\n", ind, image_width, image_height, data_buffer, total_size);
+
+ if (ind == plane_num - 1) //last plane
+ gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY,
+ data_buffer, size, 0, size, stream_buffer, _mmstreamrecorder_buffer_destroy));
+ else
+ gst_buffer_append_memory(stream_buffer->buffer, gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY,
+ data_buffer, size, 0, size, NULL, NULL));
+ }
+
+ ret = _mmstreamrecorder_push_videostream_buffer(handle, timestamp, stream_buffer->buffer, total_size);
+
+ return ret;
+}
+
int _mmstreamrecorder_push_stream_buffer(MMHandleType handle, MMStreamRecorderStreamType streamtype, unsigned long timestamp, void *buffer, int size)
{
int ret = MM_ERROR_NONE;