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 | |
18 namespace media { | |
19 | |
20 class PinBase : public IPin, | |
21 public IMemInputPin, | |
22 public base::RefCounted<PinBase> { | |
23 public: | |
24 explicit PinBase(IBaseFilter* owner); | |
25 virtual ~PinBase(); | |
26 | |
27 // Checks if a media type is acceptable. This is called when this pin is | |
28 // connected to an output pin. Must return true if the media type is | |
29 // acceptable, false otherwise. | |
30 virtual bool IsMediaTypeValid(const AM_MEDIA_TYPE* media_type) = 0; | |
31 | |
32 // Enumerates valid media types. | |
33 virtual bool GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) = 0; | |
34 | |
35 // Called when new media is received. Note that this is not on the same | |
36 // thread as where the pin is created. | |
37 virtual HRESULT STDMETHODCALLTYPE Receive(IMediaSample *pSample) = 0; | |
tommi (sloooow) - chröme
2011/06/23 14:05:56
follow chromium style (variable naming and positio
Per K
2011/06/27 11:47:50
Done.
| |
38 | |
39 virtual HRESULT STDMETHODCALLTYPE Connect(IPin *pReceivePin, | |
40 const AM_MEDIA_TYPE *pmt); | |
41 | |
42 virtual HRESULT STDMETHODCALLTYPE ReceiveConnection( | |
43 IPin *pConnector, | |
44 const AM_MEDIA_TYPE *pmt); | |
45 | |
46 virtual HRESULT STDMETHODCALLTYPE Disconnect(); | |
47 | |
48 virtual HRESULT STDMETHODCALLTYPE ConnectedTo(IPin **pPin); | |
49 | |
50 virtual HRESULT STDMETHODCALLTYPE ConnectionMediaType(AM_MEDIA_TYPE *pmt); | |
51 | |
52 virtual HRESULT STDMETHODCALLTYPE QueryPinInfo(PIN_INFO *pInfo); | |
53 | |
54 virtual HRESULT STDMETHODCALLTYPE QueryDirection(PIN_DIRECTION *pPinDir); | |
55 | |
56 virtual HRESULT STDMETHODCALLTYPE QueryId(LPWSTR *Id); | |
57 | |
58 virtual HRESULT STDMETHODCALLTYPE QueryAccept(const AM_MEDIA_TYPE *pmt); | |
59 | |
60 virtual HRESULT STDMETHODCALLTYPE EnumMediaTypes(IEnumMediaTypes **ppEnum); | |
61 | |
62 virtual HRESULT STDMETHODCALLTYPE QueryInternalConnections(IPin **apPin, | |
63 ULONG *nPin); | |
64 | |
65 virtual HRESULT STDMETHODCALLTYPE EndOfStream(); | |
66 | |
67 virtual HRESULT STDMETHODCALLTYPE BeginFlush(); | |
68 | |
69 virtual HRESULT STDMETHODCALLTYPE EndFlush(); | |
70 | |
71 virtual HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, | |
72 REFERENCE_TIME tStop, | |
73 double dRate); | |
74 | |
75 // Inherited from IMemInputPin. | |
76 virtual HRESULT STDMETHODCALLTYPE GetAllocator(IMemAllocator **ppAllocator); | |
77 | |
78 virtual HRESULT STDMETHODCALLTYPE NotifyAllocator(IMemAllocator *pAllocator, | |
79 BOOL bReadOnly); | |
80 | |
81 virtual HRESULT STDMETHODCALLTYPE GetAllocatorRequirements( | |
82 ALLOCATOR_PROPERTIES *pProps); | |
83 | |
84 virtual HRESULT STDMETHODCALLTYPE ReceiveMultiple(IMediaSample **pSamples, | |
85 long nSamples, | |
86 long *nSamplesProcessed); | |
87 virtual HRESULT STDMETHODCALLTYPE ReceiveCanBlock(); | |
88 | |
89 // Inherited from IUnknown. | |
90 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, | |
91 void** object_ptr); | |
92 | |
93 virtual ULONG STDMETHODCALLTYPE AddRef(); | |
94 | |
95 virtual ULONG STDMETHODCALLTYPE Release(); | |
96 | |
97 private: | |
98 AM_MEDIA_TYPE current_media_type_; | |
99 IPin* connected_pin_; | |
tommi (sloooow) - chröme
2011/06/23 14:05:56
ScopedComPtr?
Per K
2011/06/27 11:47:50
Done.
| |
100 IBaseFilter* owner_; | |
tommi (sloooow) - chröme
2011/06/23 14:05:56
ScopedComPtr? if not, document why.
Per K
2011/06/27 11:47:50
Done.
| |
101 }; | |
102 | |
103 } // namespace media | |
104 | |
105 #endif // MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_ | |
OLD | NEW |