10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// libjingle 20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Copyright 2010 Google Inc. 30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Redistribution and use in source and binary forms, with or without 50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// modification, are permitted provided that the following conditions are met: 60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 1. Redistributions of source code must retain the above copyright notice, 80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// this list of conditions and the following disclaimer. 90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 2. Redistributions in binary form must reproduce the above copyright notice, 100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// this list of conditions and the following disclaimer in the documentation 110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// and/or other materials provided with the distribution. 120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 3. The name of the author may not be used to endorse or promote products 130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// derived from this software without specific prior written permission. 140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// 150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_MEDIA_BASE_VIDEOADAPTER_H_ // NOLINT 270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_MEDIA_BASE_VIDEOADAPTER_H_ 280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 29cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/videocommon.h" 302a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/common.h" // For ASSERT 312a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/criticalsection.h" 322a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/scoped_ptr.h" 332a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/sigslot.h" 340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket { 360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoFrame; 380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// VideoAdapter adapts an input video frame to an output frame based on the 400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// specified input and output formats. The adaptation includes dropping frames 410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// to reduce frame rate and scaling frames. VideoAdapter is thread safe. 420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoAdapter { 430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org VideoAdapter(); 450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~VideoAdapter(); 460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 472007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org virtual void SetInputFormat(const VideoFormat& format); 480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void SetOutputFormat(const VideoFormat& format); 490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Constrain output resolution to this many pixels overall 500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void SetOutputNumPixels(int num_pixels); 510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int GetOutputNumPixels() const; 520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const VideoFormat& input_format(); 547587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org // Returns true if the adapter is dropping frames in calls to AdaptFrame. 557587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org bool drops_all_frames() const; 560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const VideoFormat& output_format(); 570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // If the parameter black is true, the adapted frames will be black. 580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void SetBlackOutput(bool black); 590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Adapt the input frame from the input format to the output format. Return 610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // true and set the output frame to NULL if the input frame is dropped. Return 620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // true and set the out frame to output_frame_ if the input frame is adapted 630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // successfully. Return false otherwise. 643904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // Note that, if no adaptation is required, |out_frame| will refer directly 653904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // in_frame. If a copy is always required, the caller must do an explicit 663904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // copy. 673904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // If a copy has taken place, |output_frame_| is owned by the VideoAdapter 683904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // and will remain usable until the adapter is destroyed or AdaptFrame is 693904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org // called again. 703904bc80800755e6b2232f974e93be28054892b6buildbot@webrtc.org bool AdaptFrame(VideoFrame* in_frame, VideoFrame** out_frame); 710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 7278afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_scale_third(bool enable); 73952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org bool scale_third() const { return scale_third_; } 74952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org 75d24be9140f01dbf49e0ae4154880887f7c52129cbuildbot@webrtc.org int adaptation_changes() const { return adaption_changes_; } 76d24be9140f01dbf49e0ae4154880887f7c52129cbuildbot@webrtc.org 770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org protected: 780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float FindClosestScale(int width, int height, int target_num_pixels); 79952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org float FindClosestViewScale(int width, int height, int target_num_pixels); 800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float FindLowerScale(int width, int height, int target_num_pixels); 810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 83952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org const float* GetViewScaleFactors() const; 84952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org float FindScale(const float* scale_factors, 85952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org const float upbias, int width, int height, 86952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org int target_num_pixels); 870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool StretchToOutputFrame(const VideoFrame* in_frame); 880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org VideoFormat input_format_; 900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org VideoFormat output_format_; 910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int output_num_pixels_; 92952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org bool scale_third_; // True if adapter allows scaling to 1/3 and 2/3. 9370022fa5eb218ec690774cc4a74558699a79600asergeyu@chromium.org int frames_in_; // Number of input frames. 9470022fa5eb218ec690774cc4a74558699a79600asergeyu@chromium.org int frames_out_; // Number of output frames. 9570022fa5eb218ec690774cc4a74558699a79600asergeyu@chromium.org int frames_scaled_; // Number of frames scaled. 96952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org int adaption_changes_; // Number of changes in scale factor. 97b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org size_t previous_width_; // Previous adapter output width. 98b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org size_t previous_height_; // Previous adapter output height. 990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool black_output_; // Flag to tell if we need to black output_frame_. 1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool is_black_; // Flag to tell if output_frame_ is currently black. 1010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int64 interval_next_frame_; 1022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_ptr<VideoFrame> output_frame_; 1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // The critical section to protect the above variables. 1042a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::CriticalSection critical_section_; 1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org DISALLOW_COPY_AND_ASSIGN(VideoAdapter); 1070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 1080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// CoordinatedVideoAdapter adapts the video input to the encoder by coordinating 1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// the format request from the server, the resolution request from the encoder, 1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// and the CPU load. 1120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass CoordinatedVideoAdapter 1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org : public VideoAdapter, public sigslot::has_slots<> { 1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org enum AdaptRequest { UPGRADE, KEEP, DOWNGRADE }; 1163db045861afcaf20aed671c0de15a6ff4ca32d08wu@webrtc.org enum AdaptReasonEnum { 117e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org ADAPTREASON_NONE = 0, 1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ADAPTREASON_CPU = 1, 1190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ADAPTREASON_BANDWIDTH = 2, 1200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org ADAPTREASON_VIEW = 4 1210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org }; 1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org typedef int AdaptReason; 1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org CoordinatedVideoAdapter(); 1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual ~CoordinatedVideoAdapter() {} 1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1272007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org virtual void SetInputFormat(const VideoFormat& format); 1282007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org 1290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Enable or disable video adaptation due to the change of the CPU load. 1300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_cpu_adaptation(bool enable) { cpu_adaptation_ = enable; } 1310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool cpu_adaptation() const { return cpu_adaptation_; } 1321a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // Enable or disable smoothing when doing CPU adaptation. When smoothing is 1331a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // enabled, system CPU load is tracked using an exponential weighted 1341a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // average. 13578afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_cpu_smoothing(bool enable); 1361a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org bool cpu_smoothing() const { return cpu_smoothing_; } 1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Enable or disable video adaptation due to the change of the GD 1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_gd_adaptation(bool enable) { gd_adaptation_ = enable; } 1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool gd_adaptation() const { return gd_adaptation_; } 1400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Enable or disable video adaptation due to the change of the View 1410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_view_adaptation(bool enable) { view_adaptation_ = enable; } 1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool view_adaptation() const { return view_adaptation_; } 1430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Enable or disable video adaptation to fast switch View 1440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void set_view_switch(bool enable) { view_switch_ = enable; } 1450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool view_switch() const { return view_switch_; } 1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org CoordinatedVideoAdapter::AdaptReason adapt_reason() const { 1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org return adapt_reason_; 1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org } 1500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // When the video is decreased, set the waiting time for CPU adaptation to 1520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // decrease video again. 15378afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_cpu_load_min_samples(int cpu_load_min_samples); 154b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org int cpu_load_min_samples() const { return cpu_load_min_samples_; } 1550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // CPU system load high threshold for reducing resolution. e.g. 0.85f 15678afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_high_system_threshold(float high_system_threshold); 1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float high_system_threshold() const { return high_system_threshold_; } 1580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // CPU system load low threshold for increasing resolution. e.g. 0.70f 15978afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_low_system_threshold(float low_system_threshold); 1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float low_system_threshold() const { return low_system_threshold_; } 1610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // CPU process load threshold for reducing resolution. e.g. 0.10f 16278afd903598b85bd36e67ca5a4cf8e631cef6eaehenrike@webrtc.org void set_process_threshold(float process_threshold); 1630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float process_threshold() const { return process_threshold_; } 1640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Handle the format request from the server via Jingle update message. 1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnOutputFormatRequest(const VideoFormat& format); 1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Handle the resolution request from the encoder due to bandwidth changes. 1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnEncoderResolutionRequest(int width, int height, AdaptRequest request); 169952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org // Handle the resolution request for CPU overuse. 170952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org void OnCpuResolutionRequest(AdaptRequest request); 1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Handle the CPU load provided by a CPU monitor. 1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void OnCpuLoadUpdated(int current_cpus, int max_cpus, 1730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float process_load, float system_load); 1740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal0<> SignalCpuAdaptationUnable; 1760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 1780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Adapt to the minimum of the formats the server requests, the CPU wants, and 1791a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // the encoder wants. Returns true if resolution changed. 1800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool AdaptToMinimumFormat(int* new_width, int* new_height); 1810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool IsMinimumFormat(int pixels); 1820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org void StepPixelCount(CoordinatedVideoAdapter::AdaptRequest request, 1830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int* num_pixels); 1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org CoordinatedVideoAdapter::AdaptRequest FindCpuRequest( 1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int current_cpus, int max_cpus, 1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float process_load, float system_load); 1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool cpu_adaptation_; // True if cpu adaptation is enabled. 1891a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org bool cpu_smoothing_; // True if cpu smoothing is enabled (with adaptation). 1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool gd_adaptation_; // True if gd adaptation is enabled. 1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool view_adaptation_; // True if view adaptation is enabled. 1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org bool view_switch_; // True if view switch is enabled. 1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int cpu_downgrade_count_; 194b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org int cpu_load_min_samples_; 195b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org int cpu_load_num_samples_; 1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // cpu system load thresholds relative to max cpus. 1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float high_system_threshold_; 1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float low_system_threshold_; 1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // cpu process load thresholds relative to current cpus. 2000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org float process_threshold_; 2010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Video formats that the server view requests, the CPU wants, and the encoder 2020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // wants respectively. The adapted output format is the minimum of these. 2030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int view_desired_num_pixels_; 2040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int64 view_desired_interval_; 2050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int encoder_desired_num_pixels_; 2060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org int cpu_desired_num_pixels_; 2070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org CoordinatedVideoAdapter::AdaptReason adapt_reason_; 2080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // The critical section to protect handling requests. 2092a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::CriticalSection request_critical_section_; 2100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2111a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // The weighted average of cpu load over time. It's always updated (if cpu 2121a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org // adaptation is on), but only used if cpu_smoothing_ is set. 2131a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org float system_load_average_; 2141a04b881e0ef480802fb01b4fbe9bcd5388d2c69henrike@webrtc.org 2150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org DISALLOW_COPY_AND_ASSIGN(CoordinatedVideoAdapter); 2160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 2170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace cricket 2190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 2200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif // TALK_MEDIA_BASE_VIDEOADAPTER_H_ // NOLINT 221