content/media/webrtc/LoadManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webrtc/LoadManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _LOADMANAGER_H_
    1.10 +#define _LOADMANAGER_H_
    1.11 +
    1.12 +#include "LoadMonitor.h"
    1.13 +#include "webrtc/common_types.h"
    1.14 +#include "webrtc/video_engine/include/vie_base.h"
    1.15 +#include "mozilla/TimeStamp.h"
    1.16 +#include "nsTArray.h"
    1.17 +
    1.18 +extern PRLogModuleInfo *gLoadManagerLog;
    1.19 +
    1.20 +namespace mozilla {
    1.21 +
    1.22 +class LoadManager : public LoadNotificationCallback,
    1.23 +                    public webrtc::CPULoadStateCallbackInvoker,
    1.24 +                    public webrtc::CpuOveruseObserver
    1.25 +{
    1.26 +public:
    1.27 +    LoadManager(int aLoadMeasurementInterval,
    1.28 +                int aAveragingMeasurements,
    1.29 +                float aHighLoadThreshold,
    1.30 +                float aLowLoadThreshold);
    1.31 +    ~LoadManager();
    1.32 +
    1.33 +    // LoadNotificationCallback interface
    1.34 +    virtual void LoadChanged(float aSystemLoad, float aProcessLoad) MOZ_OVERRIDE;
    1.35 +    // CpuOveruseObserver interface
    1.36 +    // Called as soon as an overuse is detected.
    1.37 +    virtual void OveruseDetected() MOZ_OVERRIDE;
    1.38 +    // Called periodically when the system is not overused any longer.
    1.39 +    virtual void NormalUsage() MOZ_OVERRIDE;
    1.40 +    // CPULoadStateCallbackInvoker interface
    1.41 +    virtual void AddObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE;
    1.42 +    virtual void RemoveObserver(webrtc::CPULoadStateObserver * aObserver) MOZ_OVERRIDE;
    1.43 +
    1.44 +private:
    1.45 +    void LoadHasChanged();
    1.46 +
    1.47 +    nsRefPtr<LoadMonitor> mLoadMonitor;
    1.48 +    float mLoadSum;
    1.49 +    int   mLoadSumMeasurements;
    1.50 +    // Set when overuse was signaled to us, and hasn't been un-signaled yet.
    1.51 +    bool  mOveruseActive;
    1.52 +    // Load measurement settings
    1.53 +    int mLoadMeasurementInterval;
    1.54 +    int mAveragingMeasurements;
    1.55 +    float mHighLoadThreshold;
    1.56 +    float mLowLoadThreshold;
    1.57 +
    1.58 +    webrtc::CPULoadState mCurrentState;
    1.59 +
    1.60 +    nsTArray<webrtc::CPULoadStateObserver*> mObservers;
    1.61 +};
    1.62 +
    1.63 +} //namespace
    1.64 +
    1.65 +#endif /* _LOADMANAGER_H_ */

mercurial