perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 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 MODULES_INTERFACE_MODULE_H_ |
| 12 | #define MODULES_INTERFACE_MODULE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
perkj@google.com | ea72c34 | 2011-09-05 11:11:04 +0000 | [diff] [blame] | 14 | #include <assert.h> |
| 15 | |
pbos@webrtc.org | 57eb858 | 2013-11-11 10:20:27 +0000 | [diff] [blame] | 16 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 18 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 20 | class Module { |
| 21 | public: |
pwestin@webrtc.org | 5c3a400 | 2012-05-24 09:52:19 +0000 | [diff] [blame] | 22 | // TODO(henrika): Remove this when chrome is updated. |
| 23 | // DEPRICATED Change the unique identifier of this object. |
| 24 | virtual int32_t ChangeUniqueId(const int32_t id) { return 0; } |
| 25 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 26 | // Returns the number of milliseconds until the module want a worker |
| 27 | // thread to call Process. |
| 28 | virtual int32_t TimeUntilNextProcess() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 30 | // Process any pending tasks such as timeouts. |
| 31 | virtual int32_t Process() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 33 | protected: |
| 34 | virtual ~Module() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 37 | // Reference counted version of the module interface. |
| 38 | class RefCountedModule : public Module { |
| 39 | public: |
| 40 | // Increase the reference count by one. |
| 41 | // Returns the incremented reference count. |
perkj@google.com | ea72c34 | 2011-09-05 11:11:04 +0000 | [diff] [blame] | 42 | // TODO(perkj): Make this pure virtual when Chromium have implemented |
| 43 | // reference counting ADM and Video capture module. |
| 44 | virtual int32_t AddRef() { |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 45 | assert(false && "Not implemented."); |
perkj@google.com | ea72c34 | 2011-09-05 11:11:04 +0000 | [diff] [blame] | 46 | return 1; |
| 47 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 49 | // Decrease the reference count by one. |
| 50 | // Returns the decreased reference count. |
| 51 | // Returns 0 if the last reference was just released. |
| 52 | // When the reference count reach 0 the object will self-destruct. |
perkj@google.com | ea72c34 | 2011-09-05 11:11:04 +0000 | [diff] [blame] | 53 | // TODO(perkj): Make this pure virtual when Chromium have implemented |
| 54 | // reference counting ADM and Video capture module. |
| 55 | virtual int32_t Release() { |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 56 | assert(false && "Not implemented."); |
perkj@google.com | ea72c34 | 2011-09-05 11:11:04 +0000 | [diff] [blame] | 57 | return 1; |
| 58 | } |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 59 | |
| 60 | protected: |
| 61 | virtual ~RefCountedModule() {} |
| 62 | }; |
| 63 | |
| 64 | } // namespace webrtc |
| 65 | |
| 66 | #endif // MODULES_INTERFACE_MODULE_H_ |