1/*
2 * Copyright 2009 Google Inc.
3 * Author: lexnikitin@google.com (Alexey Nikitin)
4 *
5 * V4LLookup provides basic functionality to work with V2L2 devices in Linux
6 * The functionality is implemented as a class with virtual methods for
7 * the purpose of unit testing.
8 */
9#ifndef TALK_MEDIA_DEVICES_V4LLOOKUP_H_
10#define TALK_MEDIA_DEVICES_V4LLOOKUP_H_
11
12#include <string>
13
14#ifdef LINUX
15namespace cricket {
16class V4LLookup {
17 public:
18  virtual ~V4LLookup() {}
19
20  static bool IsV4L2Device(const std::string& device_path) {
21    return GetV4LLookup()->CheckIsV4L2Device(device_path);
22  }
23
24  static void SetV4LLookup(V4LLookup* v4l_lookup) {
25    v4l_lookup_ = v4l_lookup;
26  }
27
28  static V4LLookup* GetV4LLookup() {
29    if (!v4l_lookup_) {
30      v4l_lookup_ = new V4LLookup();
31    }
32    return v4l_lookup_;
33  }
34
35 protected:
36  static V4LLookup* v4l_lookup_;
37  // Making virtual so it is easier to mock
38  virtual bool CheckIsV4L2Device(const std::string& device_path);
39};
40
41}  // namespace cricket
42
43#endif  // LINUX
44#endif  // TALK_MEDIA_DEVICES_V4LLOOKUP_H_
45