• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 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 MODULES_INTERFACE_MODULE_H_
12 #define MODULES_INTERFACE_MODULE_H_
13 
14 #include <assert.h>
15 
16 #include "typedefs.h"
17 
18 namespace webrtc {
19 
20 class Module {
21  public:
22   // Change the unique identifier of this object.
23   virtual int32_t ChangeUniqueId(const int32_t id) = 0;
24 
25   // Returns the number of milliseconds until the module want a worker
26   // thread to call Process.
27   virtual int32_t TimeUntilNextProcess() = 0;
28 
29   // Process any pending tasks such as timeouts.
30   virtual int32_t Process() = 0;
31 
32  protected:
~Module()33   virtual ~Module() {}
34 };
35 
36 // Reference counted version of the module interface.
37 class RefCountedModule : public Module {
38  public:
39   // Increase the reference count by one.
40   // Returns the incremented reference count.
41   // TODO(perkj): Make this pure virtual when Chromium have implemented
42   // reference counting ADM and Video capture module.
AddRef()43   virtual int32_t AddRef() {
44     assert(!"Not implemented.");
45     return 1;
46   }
47 
48   // Decrease the reference count by one.
49   // Returns the decreased reference count.
50   // Returns 0 if the last reference was just released.
51   // When the reference count reach 0 the object will self-destruct.
52   // TODO(perkj): Make this pure virtual when Chromium have implemented
53   // reference counting ADM and Video capture module.
Release()54   virtual int32_t Release() {
55     assert(!"Not implemented.");
56     return 1;
57   }
58 
59  protected:
~RefCountedModule()60   virtual ~RefCountedModule() {}
61 };
62 
63 }  // namespace webrtc
64 
65 #endif  // MODULES_INTERFACE_MODULE_H_
66