1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Implement a simple base class for a DirectShow input pin. It may only be
6 // used in a single threaded apartment.
8 #ifndef MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_
9 #define MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_
12 // Avoid including strsafe.h via dshow as it will cause build warnings.
13 #define NO_DSHOW_STRSAFE
16 #include "base/memory/ref_counted.h"
17 #include "base/win/scoped_comptr.h"
24 public base::RefCounted
<PinBase
> {
26 explicit PinBase(IBaseFilter
* owner
);
29 // Function used for changing the owner.
30 // If the owner is deleted the owner should first call this function
32 void SetOwner(IBaseFilter
* owner
);
34 // Checks if a media type is acceptable. This is called when this pin is
35 // connected to an output pin. Must return true if the media type is
36 // acceptable, false otherwise.
37 virtual bool IsMediaTypeValid(const AM_MEDIA_TYPE
* media_type
) = 0;
39 // Enumerates valid media types.
40 virtual bool GetValidMediaType(int index
, AM_MEDIA_TYPE
* media_type
) = 0;
42 // Called when new media is received. Note that this is not on the same
43 // thread as where the pin is created.
44 STDMETHOD(Receive
)(IMediaSample
* sample
) = 0;
46 STDMETHOD(Connect
)(IPin
* receive_pin
, const AM_MEDIA_TYPE
* media_type
);
48 STDMETHOD(ReceiveConnection
)(IPin
* connector
,
49 const AM_MEDIA_TYPE
* media_type
);
51 STDMETHOD(Disconnect
)();
53 STDMETHOD(ConnectedTo
)(IPin
** pin
);
55 STDMETHOD(ConnectionMediaType
)(AM_MEDIA_TYPE
* media_type
);
57 STDMETHOD(QueryPinInfo
)(PIN_INFO
* info
);
59 STDMETHOD(QueryDirection
)(PIN_DIRECTION
* pin_dir
);
61 STDMETHOD(QueryId
)(LPWSTR
* id
);
63 STDMETHOD(QueryAccept
)(const AM_MEDIA_TYPE
* media_type
);
65 STDMETHOD(EnumMediaTypes
)(IEnumMediaTypes
** types
);
67 STDMETHOD(QueryInternalConnections
)(IPin
** pins
, ULONG
* no_pins
);
69 STDMETHOD(EndOfStream
)();
71 STDMETHOD(BeginFlush
)();
73 STDMETHOD(EndFlush
)();
75 STDMETHOD(NewSegment
)(REFERENCE_TIME start
,
79 // Inherited from IMemInputPin.
80 STDMETHOD(GetAllocator
)(IMemAllocator
** allocator
);
82 STDMETHOD(NotifyAllocator
)(IMemAllocator
* allocator
, BOOL read_only
);
84 STDMETHOD(GetAllocatorRequirements
)(ALLOCATOR_PROPERTIES
* properties
);
86 STDMETHOD(ReceiveMultiple
)(IMediaSample
** samples
,
89 STDMETHOD(ReceiveCanBlock
)();
91 // Inherited from IUnknown.
92 STDMETHOD(QueryInterface
)(REFIID id
, void** object_ptr
);
94 STDMETHOD_(ULONG
, AddRef
)();
96 STDMETHOD_(ULONG
, Release
)();
99 AM_MEDIA_TYPE current_media_type_
;
100 base::win::ScopedComPtr
<IPin
> connected_pin_
;
101 // owner_ is the filter owning this pin. We don't reference count it since
102 // that would create a circular reference count.
108 #endif // MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_