blob: d9932add52c3fd362278902f426dba446d8a7ee9 [file] [log] [blame]
perkj@google.comef04cf42011-09-02 09:47:28 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
perkj@google.comef04cf42011-09-02 09:47:28 +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
11#ifndef MODULES_INTERFACE_MODULE_H_
12#define MODULES_INTERFACE_MODULE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
perkj@google.comea72c342011-09-05 11:11:04 +000014#include <assert.h>
15
niklase@google.com470e71d2011-07-07 08:21:25 +000016#include "typedefs.h"
17
perkj@google.comef04cf42011-09-02 09:47:28 +000018namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000019
perkj@google.comef04cf42011-09-02 09:47:28 +000020class Module {
21 public:
pwestin@webrtc.org5c3a4002012-05-24 09:52:19 +000022 // 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.comef04cf42011-09-02 09:47:28 +000026 // Returns the number of milliseconds until the module want a worker
27 // thread to call Process.
28 virtual int32_t TimeUntilNextProcess() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000029
perkj@google.comef04cf42011-09-02 09:47:28 +000030 // Process any pending tasks such as timeouts.
31 virtual int32_t Process() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000032
perkj@google.comef04cf42011-09-02 09:47:28 +000033 protected:
34 virtual ~Module() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000035};
36
perkj@google.comef04cf42011-09-02 09:47:28 +000037// Reference counted version of the module interface.
38class RefCountedModule : public Module {
39 public:
40 // Increase the reference count by one.
41 // Returns the incremented reference count.
perkj@google.comea72c342011-09-05 11:11:04 +000042 // 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.orgf6bb77a2012-01-24 17:16:59 +000045 assert(false && "Not implemented.");
perkj@google.comea72c342011-09-05 11:11:04 +000046 return 1;
47 }
niklase@google.com470e71d2011-07-07 08:21:25 +000048
perkj@google.comef04cf42011-09-02 09:47:28 +000049 // 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.comea72c342011-09-05 11:11:04 +000053 // 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.orgf6bb77a2012-01-24 17:16:59 +000056 assert(false && "Not implemented.");
perkj@google.comea72c342011-09-05 11:11:04 +000057 return 1;
58 }
perkj@google.comef04cf42011-09-02 09:47:28 +000059
60 protected:
61 virtual ~RefCountedModule() {}
62};
63
64} // namespace webrtc
65
66#endif // MODULES_INTERFACE_MODULE_H_