summaryrefslogtreecommitdiff
path: root/chromium/media/capture/video/win/filter_base_win.h
blob: 5a3ecb0ce5ec42c06643848aef0c26769dd3a13a (plain)
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
// 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 DirectShow filters. It may only be used in
// a single threaded apartment.

#ifndef MEDIA_CAPTURE_VIDEO_WIN_FILTER_BASE_WIN_H_
#define MEDIA_CAPTURE_VIDEO_WIN_FILTER_BASE_WIN_H_

// Avoid including strsafe.h via dshow as it will cause build warnings.
#define NO_DSHOW_STRSAFE
#include <dshow.h>
#include <stddef.h>
#include <wrl/client.h>

#include "base/macros.h"
#include "base/memory/ref_counted.h"

namespace media {

class FilterBase : public IBaseFilter, public base::RefCounted<FilterBase> {
 public:
  FilterBase();

  // Number of pins connected to this filter.
  virtual size_t NoOfPins() = 0;
  // Returns the IPin interface pin no index.
  virtual IPin* GetPin(int index) = 0;

  // Inherited from IUnknown.
  STDMETHOD(QueryInterface)(REFIID id, void** object_ptr) override;
  STDMETHOD_(ULONG, AddRef)() override;
  STDMETHOD_(ULONG, Release)() override;

  // Inherited from IBaseFilter.
  STDMETHOD(EnumPins)(IEnumPins** enum_pins) override;

  STDMETHOD(FindPin)(LPCWSTR id, IPin** pin) override;

  STDMETHOD(QueryFilterInfo)(FILTER_INFO* info) override;

  STDMETHOD(JoinFilterGraph)(IFilterGraph* graph, LPCWSTR name) override;

  STDMETHOD(QueryVendorInfo)(LPWSTR* vendor_info) override;

  // Inherited from IMediaFilter.
  STDMETHOD(Stop)() override;

  STDMETHOD(Pause)() override;

  STDMETHOD(Run)(REFERENCE_TIME start) override;

  STDMETHOD(GetState)(DWORD msec_timeout, FILTER_STATE* state) override;

  STDMETHOD(SetSyncSource)(IReferenceClock* clock) override;

  STDMETHOD(GetSyncSource)(IReferenceClock** clock) override;

  // Inherited from IPersistent.
  STDMETHOD(GetClassID)(CLSID* class_id) override = 0;

 protected:
  friend class base::RefCounted<FilterBase>;
  virtual ~FilterBase();

 private:
  FILTER_STATE state_;
  Microsoft::WRL::ComPtr<IFilterGraph> owning_graph_;

  DISALLOW_COPY_AND_ASSIGN(FilterBase);
};

}  // namespace media

#endif  // MEDIA_CAPTURE_VIDEO_WIN_FILTER_BASE_WIN_H_