• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2007 Sebastien Moutte <sebastien@moutte.net>
3  *
4  * gstdshow.h:
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef _GSTDSHOW_
23 #define _GSTDSHOW_
24 
25 #include <streams.h>
26 #include <windows.h>
27 #include <tchar.h>
28 #include <objbase.h>
29 #include <dshow.h>
30 #include <Rpc.h>
31 
32 #include <gst/gst.h>
33 #include <gst/video/video.h>
34 
35 typedef struct _DshowDeviceEntry DshowDeviceEntry;
36 
37 struct _DshowDeviceEntry
38 {
39   gchar *device;
40   gchar *device_name;
41   gint device_index;
42   GstCaps *caps;
43   IMoniker *moniker;
44 };
45 
46 typedef struct _GstCapturePinMediaType
47 {
48   AM_MEDIA_TYPE *mediatype;
49   IPin *capture_pin;
50 
51   VIDEO_STREAM_CONFIG_CAPS vscc;
52 
53   //default caps
54   gint defaultWidth;
55   gint defaultHeight;
56   gint defaultFPS;
57 
58   gint granularityWidth;        //will be removed when GST_TYPE_INT_RANGE_STEP exits
59   gint granularityHeight;       //will be removed when GST_TYPE_INT_RANGE_STEP exits
60 } GstCapturePinMediaType;
61 
62 /* free memory of the input pin mediatype */
63 void gst_dshow_free_pin_mediatype (gpointer pt);
64 
65 /* free memory of the input dshow mediatype */
66 void gst_dshow_free_mediatype (AM_MEDIA_TYPE * pmt);
67 
68 /* create a new capture media type that handles dshow video caps of a capture pin */
69 GstCapturePinMediaType *gst_dshow_new_pin_mediatype (IPin * pin);
70 
71 /* create a new capture media type from enum mediatype */
72 GstCapturePinMediaType * gst_dshow_new_pin_mediatype_from_enum_mediatypes (IPin * pin,
73     IEnumMediaTypes *enum_mediatypes);
74 
75 /* create a new capture media type from streamcaps */
76 GstCapturePinMediaType *gst_dshow_new_pin_mediatype_from_streamcaps (IPin * pin,
77     gint id, IAMStreamConfig * streamcaps);
78 
79 /* free the memory of all mediatypes of the input list if pin mediatype */
80 void gst_dshow_free_pins_mediatypes (GList * mediatypes);
81 
82 /* allow to know what kind of media type we have */
83 gboolean gst_dshow_check_mediatype (AM_MEDIA_TYPE * media_type,
84     const GUID sub_type, const GUID format_type);
85 
86 /* get a pin from directshow filter */
87 gboolean gst_dshow_get_pin_from_filter (IBaseFilter * filter,
88     PIN_DIRECTION pindir, IPin ** pin);
89 
90 /* find and return a filter according to the input and output types */
91 gboolean gst_dshow_find_filter (CLSID input_majortype, CLSID input_subtype,
92     CLSID output_majortype, CLSID output_subtype,
93     gchar * prefered_filter_name, IBaseFilter ** filter);
94 
95 /* get the dshow device path from device friendly name.
96 If friendly name is not set, it will return the first available device */
97 gchar *gst_dshow_getdevice_from_devicename (const GUID * device_category,
98     gchar ** device_name, gint * device_index);
99 
100 /* show the capture filter property page (generally used to setup the device). the page is modal*/
101 gboolean gst_dshow_show_propertypage (IBaseFilter * base_filter);
102 
103 /* translate GUID format to gsteamer video format */
104 GstVideoFormat gst_dshow_guid_to_gst_video_format (AM_MEDIA_TYPE *mediatype);
105 
106 /* check if IPin is connected */
107 gboolean gst_dshow_is_pin_connected (IPin *pin);
108 
109 /* transform a dshow video caps to a gstreamer video caps */
110 GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format,
111     const gchar * name, GstCapturePinMediaType * pin_mediatype);
112 
113 /* configure the latency of the capture source */
114 bool gst_dshow_configure_latency (IPin *pCapturePin, guint bufSizeMS);
115 
116 /* enumerate devices of a given category (i.e., audio or video) */
117 void gst_dshow_device_entry_free (DshowDeviceEntry *entry);
118 void gst_dshow_device_list_free (GList * devices);
119 GList * gst_dshow_enumerate_devices (const GUID * device_category, gboolean getcaps);
120 
121 DshowDeviceEntry * gst_dshow_select_device (const GUID * device_category,
122     const gchar *device, const gchar *device_name, const gint device_index);
123 
124 /* create capture filter from moniker */
125 IBaseFilter *gst_dshow_create_capture_filter (IMoniker *moniker);
126 
127 #endif /* _GSTDSHOW_ */
128