Index: gstdirectdrawsink.c =================================================================== --- gstdirectdrawsink.c (original) +++ gstdirectdrawsink.c (working copy) @@ -117,6 +117,11 @@ GST_PAD_ALWAYS, GST_STATIC_CAPS ("video/x-raw-rgb, " "framerate = (fraction) [ 0, MAX ], " + "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]" + ";" + "video/x-raw-yuv, " + "format=(fourcc)I420, " + "framerate = (fraction) [ 0, MAX ], " "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]") ); @@ -864,11 +869,23 @@ /* Write each line respecting the destination surface pitch */ data = surf_desc.lpSurface; - src_pitch = GST_BUFFER_SIZE (buf) / ddrawsink->video_height; - for (line = 0; line < surf_desc.dwHeight; line++) { - memcpy (data, GST_BUFFER_DATA (buf) + (line * src_pitch), src_pitch); - data += surf_desc.lPitch; + if(surf_desc.ddpfPixelFormat.dwFlags==DDPF_RGB){ + src_pitch = GST_BUFFER_SIZE (buf) / ddrawsink->video_height; + for (line = 0; line < surf_desc.dwHeight; line++) { + memcpy (data, GST_BUFFER_DATA (buf) + (line * src_pitch), src_pitch); + data += surf_desc.lPitch; + } + }else{ + //Y plane + src_pitch = GST_ROUND_UP_4(ddrawsink->video_width); + for (line = 0; line < surf_desc.dwHeight; line++) { + memcpy (data, GST_BUFFER_DATA (buf) + (line * src_pitch),ddrawsink->video_width); + data += surf_desc.lPitch; + } + //U/V planes + memcpy (data, GST_BUFFER_DATA (buf) + (line * src_pitch),GST_BUFFER_SIZE (buf) - (line * src_pitch)); } + /* Unlock the surface */ hRes = IDirectDrawSurface7_Unlock (ddrawsink->offscreen_surface, NULL); @@ -982,6 +999,7 @@ pPixelFormat->dwFlags = DDPF_FOURCC; ret &= gst_structure_get_fourcc (structure, "format", &fourcc); pPixelFormat->dwFourCC = fourcc; + pPixelFormat->dwYUVBitCount = 8; } else { GST_CAT_WARNING_OBJECT (directdrawsink_debug, ddrawsink, "unknown caps name received %" GST_PTR_FORMAT, caps); @@ -1609,6 +1627,9 @@ DDCAPS ddcaps_hardware; DDCAPS ddcaps_emulation; GstCaps *format_caps = NULL; + DWORD numCodes = 0; + DWORD *fccCodes = NULL; + gint i; ddrawsink->caps = gst_caps_new_empty (); if (!ddrawsink->caps) @@ -1684,8 +1705,26 @@ return NULL; } - /*GST_CAT_INFO_OBJECT (directdrawsink_debug, ddrawsink, "returning caps %s", - * gst_caps_to_string (ddrawsink->caps)); */ + IDirectDraw7_GetFourCCCodes(ddrawsink->ddraw_object,&numCodes,NULL); + fccCodes=g_newa(DWORD,numCodes); + IDirectDraw7_GetFourCCCodes(ddrawsink->ddraw_object,&numCodes,fccCodes); + for(i=0;icaps,caps); + } + //GST_CAT_INFO_OBJECT (directdrawsink_debug, ddrawsink, "returning caps %s", + // gst_caps_to_string (ddrawsink->caps)); return ddrawsink->caps; }