dshowvideosrc: move VIDEO_STREAM_CONFIG_CAPS to GstCapturePinMediaType

This commit is contained in:
Julien Isorce 2009-09-04 16:29:53 +02:00
parent bdbcbc743c
commit e806e7aaeb
3 changed files with 41 additions and 23 deletions

View file

@ -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 void
gst_dshow_free_pins_mediatypes (GList *pins_mediatypes) 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, 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; GstCaps *video_caps = NULL;
GstStructure *video_structure = 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->defaultWidth = video_info->bmiHeader.biWidth;
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight; pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;
pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame); pin_mediatype->defaultFPS = (gint) (10000000 / video_info->AvgTimePerFrame);
pin_mediatype->granularityWidth = vscc->OutputGranularityX; pin_mediatype->granularityWidth = pin_mediatype->vscc.OutputGranularityX;
pin_mediatype->granularityHeight = vscc->OutputGranularityY; pin_mediatype->granularityHeight = pin_mediatype->vscc.OutputGranularityY;
/* raw video format */ /* raw video format */
switch (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 */ /* value that the filter supports" as it said in the VIDEO_STREAM_CONFIG_CAPS dshwo doc */
gst_structure_set (video_structure, gst_structure_set (video_structure,
"width", GST_TYPE_INT_RANGE, vscc->MinOutputSize.cx, vscc->MaxOutputSize.cx, "width", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cx, pin_mediatype->vscc.MaxOutputSize.cx,
"height", GST_TYPE_INT_RANGE, vscc->MinOutputSize.cy, vscc->MaxOutputSize.cy, "height", GST_TYPE_INT_RANGE, pin_mediatype->vscc.MinOutputSize.cy, pin_mediatype->vscc.MaxOutputSize.cy,
"framerate", GST_TYPE_FRACTION_RANGE, "framerate", GST_TYPE_FRACTION_RANGE,
(gint) (10000000 / vscc->MaxFrameInterval), 1, (gint) (10000000 / pin_mediatype->vscc.MaxFrameInterval), 1,
(gint) (10000000 / vscc->MinFrameInterval), 1, (gint) (10000000 / pin_mediatype->vscc.MinFrameInterval), 1,
NULL); NULL);
return video_caps; return video_caps;

View file

@ -36,6 +36,8 @@ typedef struct _GstCapturePinMediaType
AM_MEDIA_TYPE *mediatype; AM_MEDIA_TYPE *mediatype;
IPin *capture_pin; IPin *capture_pin;
VIDEO_STREAM_CONFIG_CAPS vscc;
//default caps //default caps
gint defaultWidth; gint defaultWidth;
gint defaultHeight; gint defaultHeight;
@ -51,6 +53,9 @@ void gst_dshow_free_pin_mediatype (gpointer pt);
/* free memory of the input dshow mediatype */ /* free memory of the input dshow mediatype */
void gst_dshow_free_mediatype (AM_MEDIA_TYPE *pmt); 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 */ /* free the memory of all mediatypes of the input list if pin mediatype */
void gst_dshow_free_pins_mediatypes (GList *mediatypes); 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 */ /* 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, GstCapturePinMediaType *pin_mediatype); GstCapturePinMediaType *pin_mediatype);
#endif /* _GSTDSHOW_ */ #endif /* _GSTDSHOW_ */

View file

@ -545,7 +545,6 @@ 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);
@ -881,30 +880,27 @@ gst_dshowvideosrc_getcaps_from_streamcaps (GstDshowVideoSrc * src, IPin * pin,
caps = gst_caps_new_empty (); caps = gst_caps_new_empty ();
for (; i < icount; i++) { for (; i < icount; i++) {
GstCapturePinMediaType *pin_mediatype = g_new0 (GstCapturePinMediaType, 1);
GstCapturePinMediaType *pin_mediatype =
gst_dshow_new_pin_mediatype (pin, i, streamcaps);
pin->AddRef(); if (pin_mediatype) {
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 {
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, 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)) { } 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)) { } 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",
"video/x-dv, systemstream=FALSE", &vscc, pin_mediatype); pin_mediatype);
} 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)) {
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",
"video/x-dv, systemstream=TRUE", &vscc, pin_mediatype); pin_mediatype);
pin_mediatype->granularityWidth = 0; pin_mediatype->granularityWidth = 0;
pin_mediatype->granularityHeight = 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); g_list_append (src->pins_mediatypes, pin_mediatype);
gst_caps_append (caps, mediacaps); gst_caps_append (caps, mediacaps);
} else { } else {
/* failed to convert dshow caps */
gst_dshow_free_pin_mediatype (pin_mediatype); gst_dshow_free_pin_mediatype (pin_mediatype);
} }