mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
dshowvideosrc: factorize dshow video format parsing
This commit is contained in:
parent
77fa16cf44
commit
0f10b769bf
4 changed files with 90 additions and 70 deletions
56
sys/dshowsrcwrapper/gstdshow.cpp
Normal file → Executable file
56
sys/dshowsrcwrapper/gstdshow.cpp
Normal file → Executable file
|
@ -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;
|
||||
}
|
||||
|
|
20
sys/dshowsrcwrapper/gstdshow.h
Normal file → Executable file
20
sys/dshowsrcwrapper/gstdshow.h
Normal file → Executable file
|
@ -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
|
||||
|
@ -72,6 +86,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
|
||||
}
|
||||
#endif
|
||||
|
|
69
sys/dshowsrcwrapper/gstdshowvideosrc.cpp
Normal file → Executable file
69
sys/dshowsrcwrapper/gstdshowvideosrc.cpp
Normal file → Executable file
|
@ -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;
|
||||
video_default->granularityWidth = 0;
|
||||
video_default->granularityHeight = 0;
|
||||
|
||||
mediacaps = gst_caps_new_simple ("video/x-dv",
|
||||
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
|
||||
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 =
|
||||
|
|
11
sys/dshowsrcwrapper/gstdshowvideosrc.h
Normal file → Executable file
11
sys/dshowsrcwrapper/gstdshowvideosrc.h
Normal file → Executable file
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue