Disable force-compositing-mode on background pages
[chromium-blink-merge.git] / media / video / capture / win / pin_base_win.h
blobac84f2e2662dae703d5ab53841bac2cf0b7a45e7
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_
10 #pragma once
12 // Avoid including strsafe.h via dshow as it will cause build warnings.
13 #define NO_DSHOW_STRSAFE
14 #include <dshow.h>
16 #include "base/memory/ref_counted.h"
17 #include "base/win/scoped_comptr.h"
19 namespace media {
21 class PinBase
22 : public IPin,
23 public IMemInputPin,
24 public base::RefCounted<PinBase> {
25 public:
26 explicit PinBase(IBaseFilter* owner);
27 virtual ~PinBase();
29 // Function used for changing the owner.
30 // If the owner is deleted the owner should first call this function
31 // with owner = NULL.
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,
76 REFERENCE_TIME stop,
77 double dRate);
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,
87 long sample_count,
88 long* processed);
89 STDMETHOD(ReceiveCanBlock)();
91 // Inherited from IUnknown.
92 STDMETHOD(QueryInterface)(REFIID id, void** object_ptr);
94 STDMETHOD_(ULONG, AddRef)();
96 STDMETHOD_(ULONG, Release)();
98 private:
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.
103 IBaseFilter* owner_;
106 } // namespace media
108 #endif // MEDIA_VIDEO_CAPTURE_WIN_PIN_BASE_WIN_H_