Home | History | Annotate | Download | only in interface
      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 MODULES_INTERFACE_MODULE_H_
     12 #define MODULES_INTERFACE_MODULE_H_
     13 
     14 #include <assert.h>
     15 
     16 #include "webrtc/typedefs.h"
     17 
     18 namespace webrtc {
     19 
     20 class Module {
     21  public:
     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 
     26   // Returns the number of milliseconds until the module want a worker
     27   // thread to call Process.
     28   virtual int32_t TimeUntilNextProcess() = 0;
     29 
     30   // Process any pending tasks such as timeouts.
     31   virtual int32_t Process() = 0;
     32 
     33  protected:
     34   virtual ~Module() {}
     35 };
     36 
     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.
     42   // TODO(perkj): Make this pure virtual when Chromium have implemented
     43   // reference counting ADM and Video capture module.
     44   virtual int32_t AddRef() {
     45     assert(false && "Not implemented.");
     46     return 1;
     47   }
     48 
     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.
     53   // TODO(perkj): Make this pure virtual when Chromium have implemented
     54   // reference counting ADM and Video capture module.
     55   virtual int32_t Release() {
     56     assert(false && "Not implemented.");
     57     return 1;
     58   }
     59 
     60  protected:
     61   virtual ~RefCountedModule() {}
     62 };
     63 
     64 }  // namespace webrtc
     65 
     66 #endif  // MODULES_INTERFACE_MODULE_H_
     67