1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Implement a simple base class for a DirectShow input pin. It may only be
// used in a single threaded apartment.
#ifndef MEDIA_CAPTURE_VIDEO_WIN_PIN_BASE_WIN_H_
#define MEDIA_CAPTURE_VIDEO_WIN_PIN_BASE_WIN_H_
#include "base/memory/raw_ptr.h"
// Avoid including strsafe.h via dshow as it will cause build warnings.
#define NO_DSHOW_STRSAFE
#include <dshow.h>
#include <wrl/client.h>
#include "base/memory/ref_counted.h"
namespace media {
class PinBase : public IPin,
public IMemInputPin,
public base::RefCounted<PinBase> {
public:
explicit PinBase(IBaseFilter* owner);
// Function used for changing the owner.
// If the owner is deleted the owner should first call this function
// with owner = NULL.
void SetOwner(IBaseFilter* owner);
// Checks if a media type is acceptable. This is called when this pin is
// connected to an output pin. Must return true if the media type is
// acceptable, false otherwise.
virtual bool IsMediaTypeValid(const AM_MEDIA_TYPE* media_type) = 0;
// Enumerates valid media types.
virtual bool GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) = 0;
// Called when new media is received. Note that this is not on the same
// thread as where the pin is created.
IFACEMETHODIMP Receive(IMediaSample* sample) override = 0;
IFACEMETHODIMP Connect(IPin* receive_pin,
const AM_MEDIA_TYPE* media_type) override;
IFACEMETHODIMP ReceiveConnection(IPin* connector,
const AM_MEDIA_TYPE* media_type) override;
IFACEMETHODIMP Disconnect() override;
IFACEMETHODIMP ConnectedTo(IPin** pin) override;
IFACEMETHODIMP ConnectionMediaType(AM_MEDIA_TYPE* media_type) override;
IFACEMETHODIMP QueryPinInfo(PIN_INFO* info) override;
IFACEMETHODIMP QueryDirection(PIN_DIRECTION* pin_dir) override;
IFACEMETHODIMP QueryId(LPWSTR* id) override;
IFACEMETHODIMP QueryAccept(const AM_MEDIA_TYPE* media_type) override;
IFACEMETHODIMP EnumMediaTypes(IEnumMediaTypes** types) override;
IFACEMETHODIMP QueryInternalConnections(IPin** pins, ULONG* no_pins) override;
IFACEMETHODIMP EndOfStream() override;
IFACEMETHODIMP BeginFlush() override;
IFACEMETHODIMP EndFlush() override;
IFACEMETHODIMP NewSegment(REFERENCE_TIME start,
REFERENCE_TIME stop,
double dRate) override;
// Inherited from IMemInputPin.
IFACEMETHODIMP GetAllocator(IMemAllocator** allocator) override;
IFACEMETHODIMP NotifyAllocator(IMemAllocator* allocator,
BOOL read_only) override;
IFACEMETHODIMP GetAllocatorRequirements(
ALLOCATOR_PROPERTIES* properties) override;
IFACEMETHODIMP ReceiveMultiple(IMediaSample** samples,
long sample_count,
long* processed) override;
IFACEMETHODIMP ReceiveCanBlock() override;
// Inherited from IUnknown.
IFACEMETHODIMP QueryInterface(REFIID id, void** object_ptr) override;
IFACEMETHODIMP_(ULONG) AddRef() override;
IFACEMETHODIMP_(ULONG) Release() override;
protected:
friend class base::RefCounted<PinBase>;
virtual ~PinBase();
private:
AM_MEDIA_TYPE current_media_type_;
Microsoft::WRL::ComPtr<IPin> connected_pin_;
// owner_ is the filter owning this pin. We don't reference count it since
// that would create a circular reference count.
raw_ptr<IBaseFilter> owner_;
};
} // namespace media
#endif // MEDIA_CAPTURE_VIDEO_WIN_PIN_BASE_WIN_H_
|