OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 // Implement a simple base class for a DirectShow input pin. It may only be | |
6 // used in a single threaded apartment. | |
7 | |
8 #ifndef MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_ | |
9 #define MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_ | |
10 #pragma once | |
11 | |
12 // Avoid including strsafe.h via dshow as it will cause build warnings. | |
13 #define NO_DSHOW_STRSAFE | |
14 #include <dshow.h> | |
15 | |
16 #include "base/memory/ref_counted.h" | |
17 #include "base/win/scoped_comptr.h" | |
18 | |
19 namespace media { | |
20 | |
21 class PinBase : public IPin, | |
scherkus (not reviewing)
2011/06/27 19:24:01
it: style should be same as initializer list (drop
Per K
2011/06/28 10:14:07
Done.
| |
22 public IMemInputPin, | |
23 public base::RefCounted<PinBase> { | |
24 public: | |
25 explicit PinBase(IBaseFilter* owner); | |
26 virtual ~PinBase(); | |
27 | |
28 // Function used for changing the owner. | |
29 // If the owner is deleted the owner should first call this function | |
30 // with owner = NULL. | |
31 void SetOwner(IBaseFilter* owner); | |
32 | |
33 // Checks if a media type is acceptable. This is called when this pin is | |
34 // connected to an output pin. Must return true if the media type is | |
35 // acceptable, false otherwise. | |
36 virtual bool IsMediaTypeValid(const AM_MEDIA_TYPE* media_type) = 0; | |
37 | |
38 // Enumerates valid media types. | |
39 virtual bool GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) = 0; | |
40 | |
41 // Called when new media is received. Note that this is not on the same | |
42 // thread as where the pin is created. | |
43 STDMETHOD(Receive)(IMediaSample* pSample) = 0; | |
44 | |
45 STDMETHOD(Connect)(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt); | |
46 | |
47 STDMETHOD(ReceiveConnection)(IPin* pConnector, const AM_MEDIA_TYPE* pmt); | |
48 | |
49 STDMETHOD(Disconnect)(); | |
50 | |
51 STDMETHOD(ConnectedTo)(IPin** pin); | |
52 | |
53 STDMETHOD(ConnectionMediaType)(AM_MEDIA_TYPE* pmt); | |
54 | |
55 STDMETHOD(QueryPinInfo)(PIN_INFO* info); | |
56 | |
57 STDMETHOD(QueryDirection)(PIN_DIRECTION* pin_dir); | |
58 | |
59 STDMETHOD(QueryId)(LPWSTR* id); | |
60 | |
61 STDMETHOD(QueryAccept)(const AM_MEDIA_TYPE* mt); | |
62 | |
63 STDMETHOD(EnumMediaTypes)(IEnumMediaTypes** types); | |
64 | |
65 STDMETHOD(QueryInternalConnections)(IPin** pin, ULONG* no_pins); | |
66 | |
67 STDMETHOD(EndOfStream)(); | |
68 | |
69 STDMETHOD(BeginFlush)(); | |
70 | |
71 STDMETHOD(EndFlush)(); | |
72 | |
73 STDMETHOD(NewSegment)(REFERENCE_TIME start, | |
74 REFERENCE_TIME stop, | |
75 double dRate); | |
76 | |
77 // Inherited from IMemInputPin. | |
78 STDMETHOD(GetAllocator)(IMemAllocator** allocator); | |
79 | |
80 STDMETHOD(NotifyAllocator)(IMemAllocator* allocator, BOOL read_only); | |
81 | |
82 STDMETHOD(GetAllocatorRequirements)(ALLOCATOR_PROPERTIES* properties); | |
83 | |
84 STDMETHOD(ReceiveMultiple)(IMediaSample** samples, | |
85 long sample_count, | |
86 long* processed); | |
87 STDMETHOD(ReceiveCanBlock)(); | |
88 | |
89 // Inherited from IUnknown. | |
90 STDMETHOD(QueryInterface)(REFIID id, void** object_ptr); | |
91 | |
92 STDMETHOD_(ULONG, AddRef)(); | |
93 | |
94 STDMETHOD_(ULONG, Release)(); | |
95 | |
96 private: | |
97 AM_MEDIA_TYPE current_media_type_; | |
98 base::win::ScopedComPtr<IPin> connected_pin_; | |
99 // owner_ is the filter owning this pin. We don't reference count it since | |
100 // that would create a circular reference count. | |
101 IBaseFilter* owner_; | |
102 }; | |
103 | |
104 } // namespace media | |
105 | |
106 #endif // MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_ | |
OLD | NEW |