diff options
-rwxr-xr-x[-rw-r--r--] | sys/dshowsrcwrapper/gstdshow.cpp | 56 | ||||
-rwxr-xr-x[-rw-r--r--] | sys/dshowsrcwrapper/gstdshow.h | 20 | ||||
-rwxr-xr-x[-rw-r--r--] | sys/dshowsrcwrapper/gstdshowvideosrc.cpp | 73 | ||||
-rwxr-xr-x[-rw-r--r--] | sys/dshowsrcwrapper/gstdshowvideosrc.h | 11 |
4 files changed, 90 insertions, 70 deletions
diff --git a/sys/dshowsrcwrapper/gstdshow.cpp b/sys/dshowsrcwrapper/gstdshow.cpp index 8b77b5857..e3a4f4a61 100644..100755 --- a/sys/dshowsrcwrapper/gstdshow.cpp +++ b/sys/dshowsrcwrapper/gstdshow.cpp @@ -321,3 +321,59 @@ gst_dshow_show_propertypage (IBaseFilter *base_filter) } return ret; } + +GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name, + const VIDEO_STREAM_CONFIG_CAPS * vscc, const VIDEOINFOHEADER *video_info, + GstCaptureVideoDefault *video_default) +{ + GstCaps *video_caps = NULL; + GstStructure *video_structure = NULL; + + video_default->defaultWidth = video_info->bmiHeader.biWidth; + video_default->defaultHeight = video_info->bmiHeader.biHeight; + video_default->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame); + video_default->granularityWidth = vscc->OutputGranularityX; + video_default->granularityHeight = vscc->OutputGranularityY; + + /* raw video format */ + switch (video_format) { + case GST_VIDEO_FORMAT_BGR: + video_caps = gst_caps_from_string (GST_VIDEO_CAPS_BGR); + break; + case GST_VIDEO_FORMAT_I420: + video_caps = gst_caps_from_string (GST_VIDEO_CAPS_YUV ("I420")); + default: + break; + } + + /* other video format */ + if (!video_caps){ + if (g_strcasecmp (name, "video/x-dv, systemstream=FALSE") == 0) { + video_caps = gst_caps_new_simple ("video/x-dv", + "systemstream", G_TYPE_BOOLEAN, FALSE, + "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('d', 'v', 's', 'd'), + NULL); + } else if (g_strcasecmp (name, "video/x-dv, systemstream=TRUE") == 0) { + video_caps = gst_caps_new_simple ("video/x-dv", + "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); + return video_caps; + } + } + + if (!video_caps) + return NULL; + + video_structure = gst_caps_get_structure (video_caps, 0); + + gst_structure_set (video_structure,
+ "width", GST_TYPE_INT_RANGE, vscc->MinOutputSize.cx, vscc->MaxOutputSize.cx,
+ "height", GST_TYPE_INT_RANGE, vscc->MinOutputSize.cy, vscc->MaxOutputSize.cy, + "framerate", GST_TYPE_FRACTION_RANGE, + (gint) (10000000 / vscc->MaxFrameInterval), 1, + (gint) (10000000 / vscc->MinFrameInterval), 1, + NULL); + + g_print ("caps are %s\n", gst_caps_to_string (video_caps)); + + return video_caps; +} diff --git a/sys/dshowsrcwrapper/gstdshow.h b/sys/dshowsrcwrapper/gstdshow.h index 4491e50d6..f13d9a8d2 100644..100755 --- a/sys/dshowsrcwrapper/gstdshow.h +++ b/sys/dshowsrcwrapper/gstdshow.h @@ -31,6 +31,8 @@ #include <Rpc.h> #include <glib.h> +#include <gst/gst.h> +#include <gst/video/video.h> typedef struct _GstCapturePinMediaType { @@ -38,6 +40,18 @@ typedef struct _GstCapturePinMediaType IPin *capture_pin; } GstCapturePinMediaType; +/* video default properties associated to a video format (YUY2, I420, RGB24 ...) */ +typedef struct _GstCaptureVideoDefault +{ + gint defaultWidth; + gint defaultHeight; + gint defaultFPS; + + gint granularityWidth; //will be removed when GST_TYPE_INT_RANGE_STEP exits + gint granularityHeight; //will be removed when GST_TYPE_INT_RANGE_STEP exits + +} GstCaptureVideoDefault; + #ifdef __cplusplus
extern "C" {
#endif @@ -71,6 +85,12 @@ gchar *gst_dshow_getdevice_from_devicename (const GUID *device_category, gchar * /* show the capture filter property page (generally used to setup the device). the page is modal*/ gboolean gst_dshow_show_propertypage (IBaseFilter *base_filter); + +/* transform a dshow video caps to a gstreamer video caps */ +GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name, + const VIDEO_STREAM_CONFIG_CAPS * vscc, const VIDEOINFOHEADER *video_info, + GstCaptureVideoDefault *video_default); + #ifdef __cplusplus
}
diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp index 1f4ff4abc..32c19f86f 100644..100755 --- a/sys/dshowsrcwrapper/gstdshowvideosrc.cpp +++ b/sys/dshowsrcwrapper/gstdshowvideosrc.cpp @@ -924,21 +924,9 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin, /* I420 */ if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) { - video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat; - - video_default->defaultWidth = video_info->bmiHeader.biWidth; - video_default->defaultHeight = video_info->bmiHeader.biHeight; - video_default->defaultFPS = (int) (10000000 / video_info->AvgTimePerFrame); - video_default->granularityWidth = vscc.OutputGranularityX; - video_default->granularityHeight = vscc.OutputGranularityY; - mediacaps = gst_caps_new_simple ("video/x-raw-yuv", - "width", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cx, vscc.MaxOutputSize.cx, - "height", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cy, vscc.MaxOutputSize.cy, - "framerate", GST_TYPE_FRACTION_RANGE, - (int) (10000000 / vscc.MaxFrameInterval), 1, - (int) (10000000 / vscc.MinFrameInterval), 1, - "format", GST_TYPE_FOURCC, MAKEFOURCC ('I', '4', '2', '0'), NULL); + mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, &vscc, + (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat, video_default); if (mediacaps) { src->pins_mediatypes = @@ -955,27 +943,9 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin, /* BGR */ if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_RGB24, FORMAT_VideoInfo)) { - video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat; - video_default->defaultWidth = video_info->bmiHeader.biWidth; - video_default->defaultHeight = video_info->bmiHeader.biHeight; - video_default->defaultFPS = (int) (10000000 / video_info->AvgTimePerFrame); - video_default->granularityWidth = vscc.OutputGranularityX; - video_default->granularityHeight = vscc.OutputGranularityY; - - /* ffmpegcolorspace handles RGB24 in BIG_ENDIAN */ - mediacaps = gst_caps_new_simple ("video/x-raw-rgb", - "bpp", G_TYPE_INT, 24, - "depth", G_TYPE_INT, 24, - "width", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cx, vscc.MaxOutputSize.cx, - "height", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cy, vscc.MaxOutputSize.cy, - "framerate", GST_TYPE_FRACTION_RANGE, - (int) (10000000 / vscc.MaxFrameInterval), 1, - (int) (10000000 / vscc.MinFrameInterval), 1, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "red_mask", G_TYPE_INT, 255, - "green_mask", G_TYPE_INT, 65280, - "blue_mask", G_TYPE_INT, 16711680, NULL); + mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL, &vscc, + (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat, video_default); if (mediacaps) { src->pins_mediatypes = @@ -992,22 +962,10 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin, /* DVSD */ if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) { - video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat; - - video_default->defaultWidth = video_info->bmiHeader.biWidth; - video_default->defaultHeight = video_info->bmiHeader.biHeight; - video_default->defaultFPS = (int) (10000000 / video_info->AvgTimePerFrame); - video_default->granularityWidth = vscc.OutputGranularityX; - video_default->granularityHeight = vscc.OutputGranularityY; - - mediacaps = gst_caps_new_simple ("video/x-dv", - "systemstream", G_TYPE_BOOLEAN, FALSE, - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('d', 'v', 's', 'd'), - "framerate", GST_TYPE_FRACTION_RANGE, - (int) (10000000 / vscc.MaxFrameInterval), 1, - (int) (10000000 / vscc.MinFrameInterval), 1, - "width", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cx, vscc.MaxOutputSize.cx, - "height", GST_TYPE_INT_RANGE, vscc.MinOutputSize.cy, vscc.MaxOutputSize.cy, NULL); + + mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, + "video/x-dv, systemstream=FALSE", &vscc, (VIDEOINFOHEADER *) + pin_mediatype->mediatype->pbFormat, video_default); if (mediacaps) { src->pins_mediatypes = @@ -1026,15 +984,12 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin, if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) { video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat; - //No video size in caps when stream ? I do know if the following fields exist - video_default->defaultWidth = video_info->bmiHeader.biWidth; - video_default->defaultHeight = video_info->bmiHeader.biHeight; - video_default->defaultFPS = (int) (10000000 / video_info->AvgTimePerFrame); - video_default->granularityWidth = vscc.OutputGranularityX; - video_default->granularityHeight = vscc.OutputGranularityY; - - mediacaps = gst_caps_new_simple ("video/x-dv", - "systemstream", G_TYPE_BOOLEAN, TRUE, NULL); + video_default->granularityWidth = 0; + video_default->granularityHeight = 0; + + mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, + "video/x-dv, systemstream=TRUE", &vscc, (VIDEOINFOHEADER *) + pin_mediatype->mediatype->pbFormat, video_default); if (mediacaps) { src->pins_mediatypes = diff --git a/sys/dshowsrcwrapper/gstdshowvideosrc.h b/sys/dshowsrcwrapper/gstdshowvideosrc.h index 415830719..bced6bef6 100644..100755 --- a/sys/dshowsrcwrapper/gstdshowvideosrc.h +++ b/sys/dshowsrcwrapper/gstdshowvideosrc.h @@ -42,17 +42,6 @@ G_BEGIN_DECLS typedef struct _GstDshowVideoSrc GstDshowVideoSrc; typedef struct _GstDshowVideoSrcClass GstDshowVideoSrcClass; -/* video default properties associated to a video format (YUY2, I420, RGB24 ...) */ -typedef struct _GstCaptureVideoDefault -{ - gint defaultWidth; - gint defaultHeight; - gint defaultFPS; - - gint granularityWidth; //will be removed when GST_TYPE_INT_RANGE_STEP exits - gint granularityHeight; //will be removed when GST_TYPE_INT_RANGE_STEP exits - -} GstCaptureVideoDefault; struct _GstDshowVideoSrc { |