| LOCAL FUNCTION PROTOTYPES: |\r
---------------------------------------------------------------------------*/\r
static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data);\r
-static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);\r
+//static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer);\r
static gpointer __mmplayer_capture_thread(gpointer data);\r
static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int buttom);\r
static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos);\r
GstBuffer *buf = NULL;\r
g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL);\r
\r
+\r
if (buf)\r
{\r
- ret = __mmplayer_get_video_frame_from_buffer(player, buf);\r
+ //ret = __mmplayer_get_video_frame_from_buffer(player, buf);\r
gst_buffer_unref(buf);\r
}\r
return ret;\r
pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" );\r
\r
/* register probe */\r
+#ifndef GST_API_VERSION_1\r
player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad,\r
G_CALLBACK (__mmplayer_video_capture_probe), player);\r
+#else\r
+ player->video_capture_cb_probe_id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER,\r
+ __mmplayer_video_capture_probe, player, NULL);\r
+#endif\r
\r
gst_object_unref(GST_OBJECT(pad));\r
pad = NULL;\r
-\r
debug_fleave();\r
\r
return ret;\r
unsigned char * linear_y_plane = NULL;\r
unsigned char * linear_uv_plane = NULL;\r
\r
- return_if_fail (player);\r
+ return_val_if_fail(player, NULL);\r
\r
while (!player->capture_thread_exit)\r
{\r
debug_log("e[0]=%d, e[1]=%d", player->captured.e[0], player->captured.e[1]);\r
debug_log("a[0]=%p, a[1]=%p", player->captured.a[0], player->captured.a[1]);\r
\r
+ #if 0\r
if (mm_attrs_get_int_by_name(player->attrs, "content_video_width", &(player->captured.w[0])) != MM_ERROR_NONE)\r
{\r
debug_error("failed to get content width attribute");\r
debug_error("failed to get content height attribute");\r
goto ERROR;\r
}\r
+ #endif\r
\r
linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]);\r
linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2);\r
msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE;\r
goto ERROR;\r
}\r
- memset(src_buffer, 0x00, sizeof(linear_y_plane_size+linear_uv_plane_size));\r
+ memset(src_buffer, 0x00, linear_y_plane_size+linear_uv_plane_size);\r
memcpy(src_buffer, linear_y_plane, linear_y_plane_size);\r
memcpy(src_buffer+linear_y_plane_size, linear_uv_plane, linear_uv_plane_size);\r
\r
/**\r
* The output is fixed as RGB888\r
*/\r
+#ifdef GST_API_VERSION_1\r
static int\r
__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)\r
{\r
if (gst_structure_has_name(structure, "video/x-raw-yuv"))\r
{\r
gst_structure_get_fourcc (structure, "format", &fourcc);\r
-\r
switch(fourcc)\r
{\r
/* NV12T */\r
gboolean isbluefirst = FALSE;\r
\r
/**\r
+\r
+ * The followings will be considered.\r
+ * RGBx, xRGB, BGRx, xBGR\r
+ * RGB888, BGR888\r
+ * RGB565\r
+ *\r
+ */\r
+ gst_structure_get_int (structure, "bpp", &bpp);\r
+ gst_structure_get_int (structure, "depth", &depth);\r
+ gst_structure_get_int (structure, "endianness", &endianess);\r
+ gst_structure_get_int (structure, "blue_mask", &blue_mask);\r
+\r
+ if (endianess == 4321)\r
+ bigendian = TRUE;\r
+\r
+ if (blue_mask == -16777216)\r
+ isbluefirst = TRUE;\r
+\r
+ switch(bpp)\r
+ {\r
+ case 32:\r
+ {\r
+ switch(depth)\r
+ {\r
+ case 32:\r
+ if (bigendian && isbluefirst)\r
+ src_fmt = MM_UTIL_IMG_FMT_BGRA8888;\r
+ case 24:\r
+ if (bigendian && isbluefirst)\r
+ src_fmt = MM_UTIL_IMG_FMT_BGRX8888;\r
+ break;\r
+ default:\r
+ goto UNKNOWN;\r
+ break;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case 24:\r
+ default:\r
+ {\r
+ goto UNKNOWN;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ goto UNKNOWN;\r
+ }\r
+ GstMapInfo info;\r
+ gst_buffer_map (buffer, &info, GST_MAP_WRITE);\r
+ __mm_player_convert_colorspace(player, info.data, src_fmt, src_width, src_height, dst_fmt);\r
+ gst_buffer_unmap (buffer, &info);\r
+\r
+DONE:\r
+ /* do convert colorspace */\r
+ g_cond_signal( player->capture_thread_cond );\r
+\r
+ debug_fleave();\r
+\r
+ return MM_ERROR_NONE;\r
+\r
+UNKNOWN:\r
+ debug_error("unknown format to capture\n");\r
+ return MM_ERROR_PLAYER_INTERNAL;\r
+}\r
+#else\r
+/**\r
+ * The output is fixed as RGB888\r
+ */\r
+static int\r
+__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer)\r
+{\r
+ gint yplane_size = 0;\r
+ gint uvplane_size = 0;\r
+ gint src_width = 0;\r
+ gint src_height = 0;\r
+ const gchar *fmt;\r
+ GstCaps *caps = NULL;\r
+ GstStructure *structure = NULL;\r
+ mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420;\r
+ mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed\r
+\r
+ debug_fenter();\r
+\r
+ return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );\r
+ return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT );\r
+\r
+ /* get fourcc */\r
+ caps = GST_BUFFER_CAPS(buffer);\r
+\r
+ return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT );\r
+ debug_log("caps to capture: %s\n", gst_caps_to_string(caps));\r
+\r
+ structure = gst_caps_get_structure (caps, 0);\r
+\r
+ return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL);\r
+\r
+ /* init capture image buffer */\r
+ memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture));\r
+\r
+ gst_structure_get_int (structure, "width", &src_width);\r
+ gst_structure_get_int (structure, "height", &src_height);\r
+\r
+ /* check rgb or yuv */\r
+ if (gst_structure_has_name(structure, "video/x-raw-yuv"))\r
+ {\r
+ fmt = gst_structure_get_string (structure, "format");\r
+ switch (GST_STR_FOURCC (fmt))\r
+ {\r
+ /* NV12T */\r
+ case GST_MAKE_FOURCC ('S', 'T', '1', '2'):\r
+ {\r
+ debug_msg ("captured format is ST12\n");\r
+\r
+ MMPlayerMPlaneImage *proved = NULL;\r
+ player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED;\r
+\r
+ /* get video frame info from proved buffer */\r
+ proved = (MMPlayerMPlaneImage *)gst_buffer_copy (buffer);\r
+\r
+ if ( !proved || !proved->a[0] || !proved->a[1] )\r
+ return MM_ERROR_PLAYER_INTERNAL;\r
+\r
+ yplane_size = proved->y_size;\r
+ uvplane_size = proved->uv_size;\r
+\r
+ debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size);\r
+ memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage));\r
+ memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage));\r
+\r
+ player->captured.a[0] = g_try_malloc(yplane_size);\r
+ if ( !player->captured.a[0] )\r
+ return MM_ERROR_SOUND_NO_FREE_SPACE;\r
+\r
+ player->captured.a[1] = g_try_malloc(uvplane_size);\r
+ if ( !player->captured.a[1] )\r
+ return MM_ERROR_SOUND_NO_FREE_SPACE;\r
+\r
+ memcpy(player->captured.a[0], proved->a[0], yplane_size);\r
+ memcpy(player->captured.a[1], proved->a[1], uvplane_size);\r
+ goto DONE;\r
+ }\r
+ break;\r
+\r
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):\r
+ {\r
+ src_fmt = MM_UTIL_IMG_FMT_I420;\r
+ }\r
+ break;\r
+\r
+ default:\r
+ {\r
+ goto UNKNOWN;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ else if (gst_structure_has_name(structure, "video/x-raw-rgb"))\r
+ {\r
+ gint bpp;\r
+ gint depth;\r
+ gint endianess;\r
+ gint blue_mask;\r
+ gboolean bigendian = FALSE;\r
+ gboolean isbluefirst = FALSE;\r
+\r
+ /**\r
* The followings will be considered.\r
* RGBx, xRGB, BGRx, xBGR\r
* RGB888, BGR888\r
debug_error("unknown format to capture\n");\r
return MM_ERROR_PLAYER_INTERNAL;\r
}\r
+#endif\r
\r
static gboolean\r
__mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data)\r
return_val_if_fail ( buffer, FALSE);\r
debug_fenter();\r
\r
- ret = __mmplayer_get_video_frame_from_buffer(player, buffer);\r
+ //ret = __mmplayer_get_video_frame_from_buffer(player, buffer);\r
\r
if ( ret != MM_ERROR_NONE)\r
{\r
/* remove probe to be called at one time */\r
if (player->video_capture_cb_probe_id)\r
{\r
+#ifndef GST_API_VERSION_1\r
gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id);\r
+#else\r
+ gst_pad_remove_probe (pad, player->video_capture_cb_probe_id);\r
+#endif\r
player->video_capture_cb_probe_id = 0;\r
}\r
\r