mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
dshowvideosrc: move VIDEO_STREAM_CONFIG_CAPS to GstCapturePinMediaType
This commit is contained in:
parent
bdbcbc743c
commit
e806e7aaeb
3 changed files with 41 additions and 23 deletions
|
@ -57,6 +57,22 @@ gst_dshow_free_pin_mediatype (gpointer pt)
|
|||
}
|
||||
}
|
||||
|
||||
GstCapturePinMediaType *
|
||||
gst_dshow_new_pin_mediatype (IPin *pin, gint id, IAMStreamConfig * streamcaps)
|
||||
{
|
||||
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
|
||||
|
||||
HRESULT hres = streamcaps->GetStreamCaps(id, &pin_mediatype->mediatype, (BYTE *) & pin_mediatype->vscc);
|
||||
if (FAILED (hres) || !pin_mediatype->mediatype) {
|
||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pin->AddRef();
|
||||
pin_mediatype->capture_pin = pin;
|
||||
|
||||
return pin_mediatype;
|
||||
}
|
||||
|
||||
void
|
||||
gst_dshow_free_pins_mediatypes (GList *pins_mediatypes)
|
||||
|
@ -323,7 +339,7 @@ gst_dshow_show_propertypage (IBaseFilter *base_filter)
|
|||
}
|
||||
|
||||
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* name,
|
||||
const VIDEO_STREAM_CONFIG_CAPS * vscc, GstCapturePinMediaType *pin_mediatype)
|
||||
GstCapturePinMediaType *pin_mediatype)
|
||||
{
|
||||
GstCaps *video_caps = NULL;
|
||||
GstStructure *video_structure = NULL;
|
||||
|
@ -332,8 +348,8 @@ GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* nam
|
|||
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
|
||||
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
|
||||
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
|
||||
pin_mediatype->granularityWidth = vscc->OutputGranularityX;
|
||||
pin_mediatype->granularityHeight = vscc->OutputGranularityY;
|
||||
pin_mediatype->granularityWidth = pin_mediatype->vscc.OutputGranularityX;
|
||||
pin_mediatype->granularityHeight = pin_mediatype->vscc.OutputGranularityY;
|
||||
|
||||
/* raw video format */
|
||||
switch (video_format) {
|
||||
|
@ -376,11 +392,11 @@ GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format, const gchar* nam
|
|||
/* value that the filter supports" as it said in the VIDEO_STREAM_CONFIG_CAPS dshwo doc */
|
||||
|
||||
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,
|
||||
"width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx, pin_mediatype->vscc.MaxOutputSize.cx,
|
||||
"height", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cy, pin_mediatype->vscc.MaxOutputSize.cy,
|
||||
"framerate", GST_TYPE_FRACTION_RANGE,
|
||||
(gint) (10000000 / vscc->MaxFrameInterval), 1,
|
||||
(gint) (10000000 / vscc->MinFrameInterval), 1,
|
||||
(gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval), 1,
|
||||
(gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1,
|
||||
NULL);
|
||||
|
||||
return video_caps;
|
||||
|
|
|
@ -36,6 +36,8 @@ typedef struct _GstCapturePinMediaType
|
|||
AM_MEDIA_TYPE *mediatype;
|
||||
IPin *capture_pin;
|
||||
|
||||
VIDEO_STREAM_CONFIG_CAPS vscc;
|
||||
|
||||
//default caps
|
||||
gint defaultWidth;
|
||||
gint defaultHeight;
|
||||
|
@ -51,6 +53,9 @@ void gst_dshow_free_pin_mediatype (gpointer pt);
|
|||
/* free memory of the input dshow mediatype */
|
||||
void gst_dshow_free_mediatype (AM_MEDIA_TYPE *pmt);
|
||||
|
||||
/* create a new capture media type that handles dshow video caps of a capture pin */
|
||||
GstCapturePinMediaType *gst_dshow_new_pin_mediatype (IPin *pin, gint id, IAMStreamConfig * streamcaps);
|
||||
|
||||
/* free the memory of all mediatypes of the input list if pin mediatype */
|
||||
void gst_dshow_free_pins_mediatypes (GList *mediatypes);
|
||||
|
||||
|
@ -74,6 +79,6 @@ 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, GstCapturePinMediaType *pin_mediatype);
|
||||
GstCapturePinMediaType *pin_mediatype);
|
||||
|
||||
#endif /* _GSTDSHOW_ */
|
|
@ -545,7 +545,6 @@ gst_dshowvideosrc_get_caps (GstBaseSrc * basesrc)
|
|||
GstCaps *caps =
|
||||
gst_dshowvideosrc_getcaps_from_streamcaps (src, capture_pin,
|
||||
streamcaps);
|
||||
g_print ("caps: %s\n", gst_caps_to_string(caps));
|
||||
|
||||
if (caps) {
|
||||
gst_caps_append (src->caps, caps);
|
||||
|
@ -881,30 +880,27 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
|
|||
caps = gst_caps_new_empty ();
|
||||
|
||||
for (; i < icount; i++) {
|
||||
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
|
||||
|
||||
GstCapturePinMediaType *pin_mediatype =
|
||||
gst_dshow_new_pin_mediatype (pin, i, streamcaps);
|
||||
|
||||
pin->AddRef();
|
||||
pin_mediatype->capture_pin = pin;
|
||||
|
||||
hres = streamcaps->GetStreamCaps(i, &pin_mediatype->mediatype, (BYTE *) & vscc);
|
||||
if (FAILED (hres) || !pin_mediatype->mediatype) {
|
||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||
} else {
|
||||
if (pin_mediatype) {
|
||||
|
||||
GstCaps *mediacaps = NULL;
|
||||
|
||||
if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_I420, FORMAT_VideoInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, &vscc, pin_mediatype);
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_I420, NULL, pin_mediatype);
|
||||
|
||||
} 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, pin_mediatype);
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_BGR, NULL, pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_VideoInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||
"video/x-dv, systemstream=FALSE", &vscc, pin_mediatype);
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, "video/x-dv, systemstream=FALSE",
|
||||
pin_mediatype);
|
||||
|
||||
} else if (gst_dshow_check_mediatype (pin_mediatype->mediatype, MEDIASUBTYPE_dvsd, FORMAT_DvInfo)) {
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN,
|
||||
"video/x-dv, systemstream=TRUE", &vscc, pin_mediatype);
|
||||
mediacaps = gst_dshow_new_video_caps (GST_VIDEO_FORMAT_UNKNOWN, "video/x-dv, systemstream=TRUE",
|
||||
pin_mediatype);
|
||||
|
||||
pin_mediatype->granularityWidth = 0;
|
||||
pin_mediatype->granularityHeight = 0;
|
||||
|
@ -915,6 +911,7 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
|
|||
g_list_append (src->pins_mediatypes, pin_mediatype);
|
||||
gst_caps_append (caps, mediacaps);
|
||||
} else {
|
||||
/* failed to convert dshow caps */
|
||||
gst_dshow_free_pin_mediatype (pin_mediatype);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue