1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
13
14#include <vector>
15
16#include "webrtc/common.h"
17
18namespace webrtc {
19
20// Functor to use when supplying a verifier function for the queue item
21// verifcation.
22template <typename T>
23class RenderQueueItemVerifier {
24 public:
25  explicit RenderQueueItemVerifier(size_t minimum_capacity)
26      : minimum_capacity_(minimum_capacity) {}
27
28  bool operator()(const std::vector<T>& v) const {
29    return v.capacity() >= minimum_capacity_;
30  }
31
32 private:
33  size_t minimum_capacity_;
34};
35
36class ProcessingComponent {
37 public:
38  ProcessingComponent();
39  virtual ~ProcessingComponent();
40
41  virtual int Initialize();
42  virtual void SetExtraOptions(const Config& config) {}
43  virtual int Destroy();
44
45  bool is_component_enabled() const;
46
47 protected:
48  virtual int Configure();
49  int EnableComponent(bool enable);
50  void* handle(size_t index) const;
51  size_t num_handles() const;
52
53 private:
54  virtual void* CreateHandle() const = 0;
55  virtual int InitializeHandle(void* handle) const = 0;
56  virtual int ConfigureHandle(void* handle) const = 0;
57  virtual void DestroyHandle(void* handle) const = 0;
58  virtual size_t num_handles_required() const = 0;
59  virtual int GetHandleError(void* handle) const = 0;
60
61  std::vector<void*> handles_;
62  bool initialized_;
63  bool enabled_;
64  size_t num_handles_;
65};
66
67}  // namespace webrtc
68
69#endif  // WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H__
70