summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac8
-rw-r--r--packaging/libmm-player.spec1
-rw-r--r--src/Makefile.am4
-rwxr-xr-xsrc/include/mm_player_capture.h1
-rwxr-xr-xsrc/mm_player_capture.c124
-rw-r--r--src/mm_player_priv.c60
6 files changed, 67 insertions, 131 deletions
diff --git a/configure.ac b/configure.ac
index 85170e8..003ac5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,14 @@ PKG_CHECK_MODULES(MEDIASOUNDMGR,capi-media-sound-manager)
AC_SUBST(MEDIASOUNDMGR_CFLAGS)
AC_SUBST(MEDIASOUNDMGR_LIBS)
+PKG_CHECK_MODULES([GST_ALLOCATORS], [gstreamer-allocators-1.0])
+AC_SUBST(GST_ALLOCATORS_CFLAGS)
+AC_SUBST(GST_ALLOCATORS_LIBS)
+
+PKG_CHECK_MODULES(TBM, libtbm)
+AC_SUBST(TBM_CFLAGS)
+AC_SUBST(TBM_LIBS)
+
AC_ARG_ENABLE(sdk, AC_HELP_STRING([--enable-sdk], [sdk build]),
[
case "${enableval}" in
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec
index b8f430c..22817f5 100644
--- a/packaging/libmm-player.spec
+++ b/packaging/libmm-player.spec
@@ -25,6 +25,7 @@ BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(storage)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-media-sound-manager)
+BuildRequires: pkgconfig(libtbm)
%description
Multimedia Framework Player Library files.
diff --git a/src/Makefile.am b/src/Makefile.am
index 8550881..e5a29ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,6 +36,8 @@ libmmfplayer_la_CFLAGS = -I$(srcdir)/include \
$(STORAGE_CFLAGS) \
$(TZPLATFORM_CONFIG_CFLAGS) \
$(MEDIASOUNDMGR_CFLAGS) \
+ $(TBM_CFLAGS) \
+ $(GST_ALLOCATORS_CFLAGS) \
-Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
noinst_HEADERS = include/mm_player_utils.h \
@@ -66,6 +68,8 @@ libmmfplayer_la_LIBADD = $(GST_LIBS) \
$(SYSTEMINFO_LIBS) \
$(STORAGE_LIBS) \
$(TZPLATFORM_CONFIG_LIBS) \
+ $(TBM_LIBS) \
+ $(GST_ALLOCATORS_LIBS) \
$(MEDIASOUNDMGR_LIBS)
if IS_SDK
diff --git a/src/include/mm_player_capture.h b/src/include/mm_player_capture.h
index 1dd5b92..bf0de1f 100755
--- a/src/include/mm_player_capture.h
+++ b/src/include/mm_player_capture.h
@@ -34,6 +34,7 @@
#endif
#define MAX_BUFFER_PLANE 3
+#define MM_ALIGN(x, a) (((x) +(a) - 1) & ~((a) - 1))
/*=======================================================================================
| GLOBAL FUNCTION PROTOTYPES |
diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c
index 154de2a..8a05907 100755
--- a/src/mm_player_capture.c
+++ b/src/mm_player_capture.c
@@ -351,7 +351,6 @@ __mmplayer_capture_thread(gpointer data)
MMPLAYER_FREEIF(linear_y_plane);
MMPLAYER_FREEIF(linear_uv_plane);
} else if (MM_PLAYER_COLORSPACE_NV12 == player->video_cs) {
- #define MM_ALIGN(x, a) (((x) +(a) - 1) & ~((a) - 1))
int ret = 0;
/* using original width otherwises, app can't know aligned to resize */
planes[0] = player->captured.stride_width[0] * player->captured.stride_height[0];
@@ -518,14 +517,13 @@ static int
__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuffer *buffer)
{
int ret = MM_ERROR_NONE;
- gint planes[MAX_BUFFER_PLANE] = {0, };
+ gint size = 0;
gint i = 0;
gint src_width = 0;
gint src_height = 0;
GstCaps *caps = NULL;
GstStructure *structure = NULL;
GstMapInfo mapinfo = GST_MAP_INFO_INIT;
- GstMemory *memory = NULL;
mm_util_color_format_e src_fmt = MM_UTIL_COLOR_YUV420;
mm_util_color_format_e dst_fmt = MM_UTIL_COLOR_RGB24; // fixed
@@ -553,6 +551,9 @@ __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuff
gst_structure_get_int(structure, "width", &src_width);
gst_structure_get_int(structure, "height", &src_height);
+ GstVideoInfo video_info;
+ gst_video_info_from_caps(&video_info, caps);
+
/* check rgb or yuv */
if (gst_structure_has_name(structure, "video/x-raw")) {
/* NV12T */
@@ -573,107 +574,48 @@ __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuff
if (!g_strcmp0(gst_format, "ST12") || !g_strcmp0(gst_format, "SN12")
|| !g_strcmp0(gst_format, "S420")) {
- guint n;
- MMVideoBuffer *proved = NULL;
+ GstVideoFrame vframe;
+ GstVideoFormat format;
+ const GstVideoFormatInfo *finfo;
/* get video frame info from proved buffer */
- n = gst_buffer_n_memory(buffer);
- memory = gst_buffer_peek_memory(buffer, n-1);
- gst_memory_map(memory, &mapinfo, GST_MAP_READ);
- proved = (MMVideoBuffer *)mapinfo.data;
-
- if (!proved || !proved->data[0] || !proved->data[1]) {
- LOGE("fail to gst_memory_map");
- ret = MM_ERROR_PLAYER_INTERNAL;
- goto ERROR;
- }
-
- memcpy(&player->captured, proved, sizeof(MMVideoBuffer));
-
- planes[0] = proved->size[0];
- planes[1] = proved->size[1];
- planes[2] = proved->size[2];
-
- /* Y */
- player->captured.data[0] = g_try_malloc(planes[0]);
- if (!player->captured.data[0]) {
- gst_memory_unmap(memory, &mapinfo);
- LOGE("no free space\n");
- ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
- goto ERROR;
- }
-
- /* U */
- if (proved->size[1]) {
- player->captured.data[1] = g_try_malloc(planes[1]);
-
- if (!player->captured.data[1]) {
- LOGE("no free space\n");
- gst_memory_unmap(memory, &mapinfo);
- ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
- goto ERROR;
- }
- }
-
- /* V */
- if (proved->size[2]) {
- player->captured.data[2] = g_try_malloc(planes[2]);
-
- if (!player->captured.data[2]) {
- LOGE("no free space\n");
- gst_memory_unmap(memory, &mapinfo);
- ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
- goto ERROR;
+ format = gst_video_format_from_string(gst_format);
+ finfo = gst_video_format_get_info(format);
+
+ if (gst_video_frame_map(&vframe, &video_info, buffer, GST_MAP_READ)) {
+ for (i = 0; i < GST_VIDEO_FORMAT_INFO_N_PLANES(finfo); i++) {
+ player->captured.width[i] = GST_VIDEO_FRAME_PLANE_STRIDE(&vframe, i);
+ player->captured.height[i] = GST_VIDEO_FRAME_COMP_HEIGHT(&vframe, i);
+ player->captured.stride_width[i] = GST_VIDEO_FRAME_PLANE_STRIDE(&vframe, i);
+ player->captured.stride_height[i] = GST_VIDEO_FRAME_COMP_HEIGHT(&vframe, i);
+ size = player->captured.stride_width[i] * player->captured.stride_height[i];
+ guint8 *pixels = GST_VIDEO_FRAME_PLANE_DATA(&vframe, i);
+
+ player->captured.data[i] = g_try_malloc(size);
+ if (!player->captured.data[i]) {
+ gst_video_frame_unmap(&vframe);
+ LOGE("no free space\n");
+ ret = MM_ERROR_PLAYER_NO_FREE_SPACE;
+ goto ERROR;
+ }
+ memcpy(player->captured.data[i], pixels, size);
}
+ gst_video_frame_unmap(&vframe);
}
-
- LOGD("Buffer type %d", proved->type);
- if (proved->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
-
- for (i = 0; i < player->captured.handle_num; i++) {
- tbm_bo_ref(proved->handle.bo[i]);
- }
- LOGD("plane[0] : %p, size %d", proved->data[0], planes[0]);
-
- if (proved->data[0])
- memcpy(player->captured.data[0], proved->data[0], planes[0]);
-
- LOGD("plane[1] : %p, size %d", proved->data[1], planes[1]);
-
- if (proved->data[1])
- memcpy(player->captured.data[1], proved->data[1], planes[1]);
-
- if (player->video_cs == MM_PLAYER_COLORSPACE_I420) {
- LOGD("plane[2] : %p, size %d", proved->data[2], planes[2]);
-
- if (proved->data[2])
- memcpy(player->captured.data[2], proved->data[2], planes[2]);
- }
-
- for (i = 0; i < player->captured.handle_num; i++) {
- tbm_bo_unref(proved->handle.bo[i]);
- }
- } else {
- LOGE("Not support video buffer type %d", proved->type);
- gst_memory_unmap(memory, &mapinfo);
- ret = MM_ERROR_PLAYER_INTERNAL;
- goto ERROR;
- }
-
- gst_memory_unmap(memory, &mapinfo);
goto DONE;
} else {
- GstVideoInfo format_info;
- gst_video_info_from_caps(&format_info, caps);
-
player->captured.width[0] = src_width;
player->captured.height[0] = src_height;
+ player->captured.stride_width[0] = MM_ALIGN(src_width, 4);
+ player->captured.stride_height[0] = src_height;
- switch (GST_VIDEO_INFO_FORMAT(&format_info)) {
+ switch (GST_VIDEO_INFO_FORMAT(&video_info)) {
case GST_VIDEO_FORMAT_I420:
src_fmt = MM_UTIL_COLOR_I420;
player->captured.width[1] = player->captured.width[2] = src_width>>1;
player->captured.height[1] = player->captured.width[2] = src_height>>1;
+ player->captured.stride_width[1] = player->captured.stride_width[2] = MM_ALIGN(player->captured.width[1], 4);
+ player->captured.stride_height[1] = player->captured.stride_height[2] = src_height>>1;
break;
case GST_VIDEO_FORMAT_BGRA:
src_fmt = MM_UTIL_COLOR_BGRA;
diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c
index 49a8e87..8ec62a0 100644
--- a/src/mm_player_priv.c
+++ b/src/mm_player_priv.c
@@ -51,6 +51,8 @@
#include <system_info.h>
#include <sound_manager.h>
+#include <gst/allocators/gsttizenmemory.h>
+#include <tbm_surface_internal.h>
/*===========================================================================================
| |
@@ -3751,13 +3753,14 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
mm_player_t* player = (mm_player_t*)data;
GstCaps *caps = NULL;
MMPlayerVideoStreamDataType *stream = NULL;
- MMVideoBuffer *video_buffer = NULL;
- GstMemory *dataBlock = NULL;
- GstMemory *metaBlock = NULL;
+ tbm_surface_h surface;
+ GstMemory *mem = NULL;
GstMapInfo mapinfo = GST_MAP_INFO_INIT;
GstStructure *structure = NULL;
const gchar *string_format = NULL;
unsigned int fourcc = 0;
+ unsigned int pitch = 0;
+ int index = 0;
MMPLAYER_FENTER();
MMPLAYER_RETURN_IF_FAIL(player && player->video_stream_cb);
@@ -3806,39 +3809,21 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
}
/* set size and timestamp */
- dataBlock = gst_buffer_peek_memory(buffer, 0);
- stream->length_total = gst_memory_get_sizes(dataBlock, NULL, NULL);
+ mem = gst_buffer_peek_memory(buffer, 0);
+ stream->length_total = gst_memory_get_sizes(mem, NULL, NULL);
stream->timestamp = (unsigned int)(GST_TIME_AS_MSECONDS(GST_BUFFER_PTS(buffer))); /* nano sec -> mili sec */
+ surface = gst_tizen_memory_get_surface(mem);
/* check zero-copy */
if (player->set_mode.video_zc &&
player->set_mode.media_packet_video_stream &&
- gst_buffer_n_memory(buffer) > 1) {
- metaBlock = gst_buffer_peek_memory(buffer, 1);
- gst_memory_map(metaBlock, &mapinfo, GST_MAP_READ);
- video_buffer = (MMVideoBuffer *)mapinfo.data;
- }
-
- if (video_buffer) { /* hw codec */
- /* set tbm bo */
- if (video_buffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
- int i = 0;
-
- /* copy pointer of tbm bo, stride, elevation */
- while (i < MM_VIDEO_BUFFER_PLANE_MAX && video_buffer->handle.bo[i]) {
- stream->bo[i] = tbm_bo_ref(video_buffer->handle.bo[i]);
- i++;
- }
- } else {
- LOGE("Not support video buffer format");
- goto ERROR;
+ gst_is_tizen_memory(mem)) {
+ for (index = 0; index < gst_tizen_memory_get_num_bos(mem); index++) {
+ tbm_surface_internal_get_plane_data(surface, index, NULL, NULL, &pitch);
+ stream->bo[index] = tbm_bo_ref(gst_tizen_memory_get_bos(mem, index));
+ stream->stride[index] = pitch;
+ stream->elevation[index] = stream->height;
}
- memcpy(stream->stride, video_buffer->stride_width,
- sizeof(int) * MM_VIDEO_BUFFER_PLANE_MAX);
- memcpy(stream->elevation, video_buffer->stride_height,
- sizeof(int) * MM_VIDEO_BUFFER_PLANE_MAX);
-
- /* will be released, by calling _mm_player_video_stream_internal_buffer_unref() */
stream->internal_buffer = gst_buffer_ref(buffer);
} else { /* sw codec */
int i = 0;
@@ -3855,7 +3840,7 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
tbm_surface_info_s info;
gboolean gst_ret;
- gst_ret = gst_memory_map(dataBlock, &mapinfo, GST_MAP_READWRITE);
+ gst_ret = gst_memory_map(mem, &mapinfo, GST_MAP_READWRITE);
if (!gst_ret) {
LOGE("fail to gst_memory_map");
goto ERROR;
@@ -3933,33 +3918,28 @@ __mmplayer_video_stream_decoded_render_cb(GstElement* object, GstBuffer *buffer,
goto ERROR;
}
}
-
- if (metaBlock)
- gst_memory_unmap(metaBlock, &mapinfo);
- else
- gst_memory_unmap(dataBlock, &mapinfo);
+ gst_memory_unmap(mem, &mapinfo);
return;
ERROR:
LOGE("release video stream resource.");
- if (metaBlock) {
+ if (gst_is_tizen_memory(mem)) {
int i = 0;
for (i = 0 ; i < MM_VIDEO_BUFFER_PLANE_MAX ; i++) {
if (stream->bo[i])
tbm_bo_unref(stream->bo[i]);
}
- gst_memory_unmap(metaBlock, &mapinfo);
/* unref gst buffer */
if (stream->internal_buffer)
gst_buffer_unref(stream->internal_buffer);
- } else if (dataBlock) {
+ } else {
if (stream->bo[0])
_mmplayer_video_stream_release_bo(player, stream->bo[0]);
- gst_memory_unmap(dataBlock, &mapinfo);
}
+ gst_memory_unmap(mem, &mapinfo);
g_free(stream);
return;
}