mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
dshowvideosrc: move default video caps into GstCapturePinMediaType
This commit is contained in:
parent
bf4c1f3541
commit
d321799bfb
4 changed files with 32 additions and 67 deletions
|
@ -323,17 +323,17 @@ gst_dshow_show_propertypage (IBaseFilter *base_filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
||||||
const VIDEO_STREAM_CONFIG_CAPS * vscc, const VIDEOINFOHEADER *video_info,
|
const VIDEO_STREAM_CONFIG_CAPS * vscc, GstCapturePinMediaType *pin_mediatype)
|
||||||
GstCaptureVideoDefault *video_default)
|
|
||||||
{
|
{
|
||||||
GstCaps *video_caps = NULL;
|
GstCaps *video_caps = NULL;
|
||||||
GstStructure *video_structure = NULL;
|
GstStructure *video_structure = NULL;
|
||||||
|
VIDEOINFOHEADER *video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
||||||
|
|
||||||
video_default->defaultWidth = video_info->bmiHeader.biWidth;
|
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
|
||||||
video_default->defaultHeight = video_info->bmiHeader.biHeight;
|
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
|
||||||
video_default->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||||
video_default->granularityWidth = vscc->OutputGranularityX;
|
pin_mediatype->granularityWidth = vscc->OutputGranularityX;
|
||||||
video_default->granularityHeight = vscc->OutputGranularityY;
|
pin_mediatype->granularityHeight = vscc->OutputGranularityY;
|
||||||
|
|
||||||
/* raw video format */
|
/* raw video format */
|
||||||
switch (video_format) {
|
switch (video_format) {
|
||||||
|
|
|
@ -35,19 +35,15 @@ typedef struct _GstCapturePinMediaType
|
||||||
{
|
{
|
||||||
AM_MEDIA_TYPE *mediatype;
|
AM_MEDIA_TYPE *mediatype;
|
||||||
IPin *capture_pin;
|
IPin *capture_pin;
|
||||||
} GstCapturePinMediaType;
|
|
||||||
|
|
||||||
/* video default properties associated to a video format (YUY2, I420, RGB24 ...) */
|
//default caps
|
||||||
typedef struct _GstCaptureVideoDefault
|
|
||||||
{
|
|
||||||
gint defaultWidth;
|
gint defaultWidth;
|
||||||
gint defaultHeight;
|
gint defaultHeight;
|
||||||
gint defaultFPS;
|
gint defaultFPS;
|
||||||
|
|
||||||
gint granularityWidth; //will be removed when GST_TYPE_INT_RANGE_STEP exits
|
gint granularityWidth; //will be removed when GST_TYPE_INT_RANGE_STEP exits
|
||||||
gint granularityHeight; //will be removed when GST_TYPE_INT_RANGE_STEP exits
|
gint granularityHeight; //will be removed when GST_TYPE_INT_RANGE_STEP exits
|
||||||
|
} GstCapturePinMediaType;
|
||||||
} GstCaptureVideoDefault;
|
|
||||||
|
|
||||||
/* free memory of the input pin mediatype */
|
/* free memory of the input pin mediatype */
|
||||||
void gst_dshow_free_pin_mediatype (gpointer pt);
|
void gst_dshow_free_pin_mediatype (gpointer pt);
|
||||||
|
@ -78,7 +74,6 @@ gboolean gst_dshow_show_propertypage (IBaseFilter *base_filter);
|
||||||
|
|
||||||
/* transform a dshow video caps to a gstreamer video caps */
|
/* transform a dshow video caps to a gstreamer video caps */
|
||||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
||||||
const VIDEO_STREAM_CONFIG_CAPS * vscc, const VIDEOINFOHEADER *video_info,
|
const VIDEO_STREAM_CONFIG_CAPS * vscc, GstCapturePinMediaType *pin_mediatype);
|
||||||
GstCaptureVideoDefault *video_default);
|
|
||||||
|
|
||||||
#endif /* _GSTDSHOW_ */
|
#endif /* _GSTDSHOW_ */
|
|
@ -203,7 +203,6 @@ gst_dshowvideosrc_init (GstDshowVideoSrc * src, GstDshowVideoSrcClass * klass)
|
||||||
src->media_filter = NULL;
|
src->media_filter = NULL;
|
||||||
src->filter_graph = NULL;
|
src->filter_graph = NULL;
|
||||||
src->caps = NULL;
|
src->caps = NULL;
|
||||||
src->video_defaults = NULL;
|
|
||||||
src->pins_mediatypes = NULL;
|
src->pins_mediatypes = NULL;
|
||||||
src->is_rgb = FALSE;
|
src->is_rgb = FALSE;
|
||||||
|
|
||||||
|
@ -237,12 +236,12 @@ gst_dshowvideosrc_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != -1) {
|
if (res != -1) {
|
||||||
GList *type_video_default = g_list_nth (src->video_defaults, res);
|
GList *type_pin_mediatype = g_list_nth (src->pins_mediatypes, res);
|
||||||
if (type_video_default) {
|
if (type_pin_mediatype) {
|
||||||
GstCaptureVideoDefault *video_default = (GstCaptureVideoDefault *) type_video_default->data;
|
GstCapturePinMediaType *pin_mediatype = (GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||||
gst_structure_fixate_field_nearest_int (structure, "width", video_default->defaultWidth);
|
gst_structure_fixate_field_nearest_int (structure, "width", pin_mediatype->defaultWidth);
|
||||||
gst_structure_fixate_field_nearest_int (structure, "height", video_default->defaultHeight);
|
gst_structure_fixate_field_nearest_int (structure, "height", pin_mediatype->defaultHeight);
|
||||||
gst_structure_fixate_field_nearest_fraction (structure, "framerate", video_default->defaultFPS, 1);
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate", pin_mediatype->defaultFPS, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,11 +266,6 @@ gst_dshowvideosrc_dispose (GObject * gobject)
|
||||||
src->caps = NULL;
|
src->caps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->video_defaults) {
|
|
||||||
g_list_free (src->video_defaults);
|
|
||||||
src->video_defaults = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src->pins_mediatypes) {
|
if (src->pins_mediatypes) {
|
||||||
gst_dshow_free_pins_mediatypes (src->pins_mediatypes);
|
gst_dshow_free_pins_mediatypes (src->pins_mediatypes);
|
||||||
src->pins_mediatypes = NULL;
|
src->pins_mediatypes = NULL;
|
||||||
|
@ -551,6 +545,7 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
|
||||||
GstCaps *caps =
|
GstCaps *caps =
|
||||||
gst_dshowvideosrc_getcaps_from_streamcaps (src, capture_pin,
|
gst_dshowvideosrc_getcaps_from_streamcaps (src, capture_pin,
|
||||||
streamcaps);
|
streamcaps);
|
||||||
|
g_print ("caps: %s\n", gst_caps_to_string(caps));
|
||||||
|
|
||||||
if (caps) {
|
if (caps) {
|
||||||
gst_caps_append (src->caps, caps);
|
gst_caps_append (src->caps, caps);
|
||||||
|
@ -694,15 +689,10 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
|
|
||||||
if (res != -1 && src->pins_mediatypes) {
|
if (res != -1 && src->pins_mediatypes) {
|
||||||
/* get the corresponding media type and build the dshow graph */
|
/* get the corresponding media type and build the dshow graph */
|
||||||
GList *type = g_list_nth (src->pins_mediatypes, res);
|
GList *type_pin_mediatype = g_list_nth (src->pins_mediatypes, res);
|
||||||
|
|
||||||
//will be removed when GST_TYPE_INT_RANGE_STEP exits
|
if (type_pin_mediatype) {
|
||||||
GList *type_video_default = g_list_nth (src->video_defaults, res);
|
GstCapturePinMediaType *pin_mediatype = (GstCapturePinMediaType *) type_pin_mediatype->data;
|
||||||
|
|
||||||
if (type && type_video_default) {
|
|
||||||
//will be removed when GST_TYPE_INT_RANGE_STEP exits
|
|
||||||
GstCaptureVideoDefault *video_default = (GstCaptureVideoDefault *) type_video_default->data;
|
|
||||||
GstCapturePinMediaType *pin_mediatype = NULL;
|
|
||||||
gchar *caps_string = NULL;
|
gchar *caps_string = NULL;
|
||||||
gchar *src_caps_string = NULL;
|
gchar *src_caps_string = NULL;
|
||||||
|
|
||||||
|
@ -719,17 +709,10 @@ gst_dshowvideosrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
/* check if the desired video size is valid about granularity */
|
/* check if the desired video size is valid about granularity */
|
||||||
/* This check will be removed when GST_TYPE_INT_RANGE_STEP exits */
|
/* This check will be removed when GST_TYPE_INT_RANGE_STEP exits */
|
||||||
/* See remarks in gst_dshowvideosrc_getcaps_from_streamcaps function */
|
/* See remarks in gst_dshowvideosrc_getcaps_from_streamcaps function */
|
||||||
if (video_default->granularityWidth != 0 && width % video_default->granularityWidth != 0)
|
if (pin_mediatype->granularityWidth != 0 && width % pin_mediatype->granularityWidth != 0)
|
||||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n", width, video_default->granularityWidth) ;
|
g_warning ("your desired video size is not valid : %d mod %d !=0\n", width, pin_mediatype->granularityWidth) ;
|
||||||
if (video_default->granularityHeight !=0 && height % video_default->granularityHeight != 0)
|
if (pin_mediatype->granularityHeight !=0 && height % pin_mediatype->granularityHeight != 0)
|
||||||
g_warning ("your desired video size is not valid : %d mod %d !=0\n", height, video_default->granularityHeight) ;
|
g_warning ("your desired video size is not valid : %d mod %d !=0\n", height, pin_mediatype->granularityHeight) ;
|
||||||
|
|
||||||
/* display all capabilities when using --gst-debug-level=3 */
|
|
||||||
src_caps_string = gst_caps_to_string (src->caps);
|
|
||||||
GST_LOG (src_caps_string);
|
|
||||||
g_free (src_caps_string);
|
|
||||||
|
|
||||||
pin_mediatype = (GstCapturePinMediaType *) type->data;
|
|
||||||
|
|
||||||
/* update mediatype */
|
/* update mediatype */
|
||||||
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
|
||||||
|
@ -899,7 +882,6 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
|
||||||
|
|
||||||
for (; i < icount; i++) {
|
for (; i < icount; i++) {
|
||||||
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
|
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
|
||||||
GstCaptureVideoDefault *video_default = g_new0 (GstCaptureVideoDefault, 1);
|
|
||||||
|
|
||||||
pin->AddRef();
|
pin->AddRef();
|
||||||
pin_mediatype->capture_pin = pin;
|
pin_mediatype->capture_pin = pin;
|
||||||
|
@ -907,42 +889,33 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
|
||||||
hres = streamcaps->GetStreamCaps(i, &pin_mediatype->mediatype, (BYTE *) & vscc);
|
hres = streamcaps->GetStreamCaps(i, &pin_mediatype->mediatype, (BYTE *) & vscc);
|
||||||
if (FAILED (hres) || !pin_mediatype->mediatype) {
|
if (FAILED (hres) || !pin_mediatype->mediatype) {
|
||||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||||
g_free (video_default);
|
|
||||||
} else {
|
} else {
|
||||||
GstCaps *mediacaps = NULL;
|
GstCaps *mediacaps = NULL;
|
||||||
|
|
||||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) {
|
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) {
|
||||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, &vscc,
|
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, &vscc, pin_mediatype);
|
||||||
(VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat, video_default);
|
|
||||||
|
|
||||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_RGB24, FORMAT_VideoInfo)) {
|
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_RGB24, FORMAT_VideoInfo)) {
|
||||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL, &vscc,
|
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL, &vscc, pin_mediatype);
|
||||||
(VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat, video_default);
|
|
||||||
|
|
||||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) {
|
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) {
|
||||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||||
"video/x-dv, systemstream=FALSE", &vscc, (VIDEOINFOHEADER *)
|
"video/x-dv, systemstream=FALSE", &vscc, pin_mediatype);
|
||||||
pin_mediatype->mediatype->pbFormat, video_default);
|
|
||||||
|
|
||||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) {
|
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) {
|
||||||
|
|
||||||
video_default->granularityWidth = 0;
|
|
||||||
video_default->granularityHeight = 0;
|
|
||||||
|
|
||||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||||
"video/x-dv, systemstream=TRUE", &vscc, (VIDEOINFOHEADER *)
|
"video/x-dv, systemstream=TRUE", &vscc, pin_mediatype);
|
||||||
pin_mediatype->mediatype->pbFormat, video_default);
|
|
||||||
|
pin_mediatype->granularityWidth = 0;
|
||||||
|
pin_mediatype->granularityHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediacaps) {
|
if (mediacaps) {
|
||||||
src->pins_mediatypes =
|
src->pins_mediatypes =
|
||||||
g_list_append (src->pins_mediatypes, pin_mediatype);
|
g_list_append (src->pins_mediatypes, pin_mediatype);
|
||||||
src->video_defaults =
|
|
||||||
g_list_append (src->video_defaults, video_default);
|
|
||||||
gst_caps_append (caps, mediacaps);
|
gst_caps_append (caps, mediacaps);
|
||||||
} else {
|
} else {
|
||||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||||
g_free (video_default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,6 @@ struct _GstDshowVideoSrc
|
||||||
/* list of caps created from the list of supported media types of the dshow capture filter */
|
/* list of caps created from the list of supported media types of the dshow capture filter */
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
/* list of dshow default video properties from filter's capture pins */
|
|
||||||
GList *video_defaults;
|
|
||||||
|
|
||||||
/* list of dshow media types from the filter's capture pins */
|
/* list of dshow media types from the filter's capture pins */
|
||||||
GList *pins_mediatypes;
|
GList *pins_mediatypes;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue