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