blob: 577f1570ad63987a7199a78bcae09cfacd5fa2f5 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
14#include <vector>
15
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000016#include "webrtc/common.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017
18namespace webrtc {
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000019
peahfa6228e2015-11-16 16:27:42 -080020// 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
niklase@google.com470e71d2011-07-07 08:21:25 +000036class ProcessingComponent {
37 public:
pbos@webrtc.org91620802013-08-02 11:44:11 +000038 ProcessingComponent();
niklase@google.com470e71d2011-07-07 08:21:25 +000039 virtual ~ProcessingComponent();
40
41 virtual int Initialize();
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000042 virtual void SetExtraOptions(const Config& config) {}
niklase@google.com470e71d2011-07-07 08:21:25 +000043 virtual int Destroy();
niklase@google.com470e71d2011-07-07 08:21:25 +000044
andrew@webrtc.org755b04a2011-11-15 16:57:56 +000045 bool is_component_enabled() const;
46
niklase@google.com470e71d2011-07-07 08:21:25 +000047 protected:
48 virtual int Configure();
49 int EnableComponent(bool enable);
Peter Kasting69558702016-01-12 16:26:35 -080050 void* handle(size_t index) const;
51 size_t num_handles() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53 private:
54 virtual void* CreateHandle() const = 0;
55 virtual int InitializeHandle(void* handle) const = 0;
56 virtual int ConfigureHandle(void* handle) const = 0;
bjornv@webrtc.org5964fe02014-04-22 06:52:28 +000057 virtual void DestroyHandle(void* handle) const = 0;
Peter Kasting69558702016-01-12 16:26:35 -080058 virtual size_t num_handles_required() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059 virtual int GetHandleError(void* handle) const = 0;
60
niklase@google.com470e71d2011-07-07 08:21:25 +000061 std::vector<void*> handles_;
62 bool initialized_;
63 bool enabled_;
Peter Kasting69558702016-01-12 16:26:35 -080064 size_t num_handles_;
niklase@google.com470e71d2011-07-07 08:21:25 +000065};
andrew@webrtc.org61e596f2013-07-25 18:28:29 +000066
niklase@google.com470e71d2011-07-07 08:21:25 +000067} // namespace webrtc
68
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000069#endif // WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H__