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// Declaration of abstract class VideoCapturer
270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_MEDIA_BASE_VIDEOCAPTURER_H_
290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_MEDIA_BASE_VIDEOCAPTURER_H_
300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string>
320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <vector>
330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
34cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/mediachannel.h"
35cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/videoadapter.h"
36cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/videocommon.h"
37cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/videoframefactory.h"
38cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/devices/devicemanager.h"
392a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/basictypes.h"
402a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/criticalsection.h"
412a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/messagehandler.h"
422a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/rollingaccumulator.h"
432a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/scoped_ptr.h"
442a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/sigslot.h"
452a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/thread.h"
462a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/timing.h"
470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket {
500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoProcessor;
520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Current state of the capturer.
540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// TODO(hellner): CS_NO_DEVICE is an error code not a capture state. Separate
550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//                error codes and states.
560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgenum CaptureState {
570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_STOPPED,    // The capturer has been stopped or hasn't started yet.
580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_STARTING,   // The capturer is in the process of starting. Note, it may
590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                 // still fail to start.
600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_RUNNING,    // The capturer has been started successfully and is now
610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                 // capturing.
620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_PAUSED,     // The capturer has been paused.
630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_FAILED,     // The capturer failed to start.
640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CS_NO_DEVICE,  // The capturer has no device and consequently failed to start.
650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org};
660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoFrame;
680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgstruct CapturedFrame {
700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const uint32 kFrameHeaderSize = 40;  // Size from width to data_size.
710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  static const uint32 kUnknownDataSize = 0xFFFFFFFF;
720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CapturedFrame();
740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the number of bytes of the frame data. If data_size is known, return
760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // it directly. Otherwise, calculate the size based on width, height, and
770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // fourcc. Return true if succeeded.
780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool GetDataSize(uint32* size) const;
790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // The width and height of the captured frame could be different from those
810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // of VideoFormat. Once the first frame is captured, the width, height,
820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // fourcc, pixel_width, and pixel_height should keep the same over frames.
830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int    width;         // in number of pixels
840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int    height;        // in number of pixels
850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  uint32 fourcc;        // compression
860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  uint32 pixel_width;   // width of a pixel, default is 1
870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  uint32 pixel_height;  // height of a pixel, default is 1
880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int64  elapsed_time;  // elapsed time since the creation of the frame
890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                        // source (that is, the camera), in nanoseconds.
900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int64  time_stamp;    // timestamp of when the frame was captured, in unix
910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                        // time with nanosecond units.
920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  uint32 data_size;     // number of bytes of the frame data
930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int    rotation;      // rotation in degrees of the frame (0, 90, 180, 270)
940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void*  data;          // pointer to the frame data. This object allocates the
950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                        // memory or points to an existing memory.
960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private:
980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  DISALLOW_COPY_AND_ASSIGN(CapturedFrame);
990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org};
1000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// VideoCapturer is an abstract class that defines the interfaces for video
1020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// capturing. The subclasses implement the video capturer for various types of
1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// capturers and various platforms.
1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
105e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org// The captured frames may need to be adapted (for example, cropping).
106e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org// Video adaptation is built into and enabled by default. After a frame has
107e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org// been captured from the device, it is sent to the video adapter, then video
108e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org// processors, then out to the encoder.
1090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Programming model:
1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   Create an object of a subclass of VideoCapturer
1120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   Initialize
1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   SignalStateChange.connect()
1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   SignalFrameCaptured.connect()
1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   Find the capture format for Start() by either calling GetSupportedFormats()
1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   and selecting one of the supported or calling GetBestCaptureFormat().
117e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org//   video_adapter()->OnOutputFormatRequest(desired_encoding_format)
1180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   Start()
1190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   GetCaptureFormat() optionally
1200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   Stop()
1210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Assumption:
1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   The Start() and Stop() methods are called by a single thread (E.g., the
1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   media engine thread). Hence, the VideoCapture subclasses dont need to be
1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//   thread safe.
1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org//
1270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass VideoCapturer
1280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    : public sigslot::has_slots<>,
1292a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org      public rtc::MessageHandler {
1300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public:
1310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  typedef std::vector<VideoProcessor*> VideoProcessors;
1320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // All signals are marshalled to |thread| or the creating thread if
1340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // none is provided.
1350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  VideoCapturer();
1362a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  explicit VideoCapturer(rtc::Thread* thread);
1370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual ~VideoCapturer() {}
1380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Gets the id of the underlying device, which is available after the capturer
1400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // is initialized. Can be used to determine if two capturers reference the
1410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // same device.
1420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const std::string& GetId() const { return id_; }
1430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the capture formats supported by the video capturer. The supported
1450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // formats are non empty after the device has been opened successfully.
1460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const std::vector<VideoFormat>* GetSupportedFormats() const;
1470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the best capture format for the desired format. The best format is the
1490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // same as one of the supported formats except that the frame interval may be
1500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // different. If the application asks for 16x9 and the camera does not support
1510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // 16x9 HD or the application asks for 16x10, we find the closest 4x3 and then
1520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // crop; Otherwise, we find what the application asks for. Note that we assume
1530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // that for HD, the desired format is always 16x9. The subclasses can override
1540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // the default implementation.
1550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Parameters
1560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   desired: the input desired format. If desired.fourcc is not kAnyFourcc,
1570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //            the best capture format has the exactly same fourcc. Otherwise,
1580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //            the best capture format uses a fourcc in GetPreferredFourccs().
1590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   best_format: the output of the best capture format.
1600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Return false if there is no such a best format, that is, the desired format
1610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // is not supported.
1620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool GetBestCaptureFormat(const VideoFormat& desired,
1630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                                    VideoFormat* best_format);
1640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // TODO(hellner): deprecate (make private) the Start API in favor of this one.
1660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //                Also remove CS_STARTING as it is implied by the return
1670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //                value of StartCapturing().
1680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool StartCapturing(const VideoFormat& capture_format);
1690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Start the video capturer with the specified capture format.
1700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Parameter
1710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   capture_format: The caller got this parameter by either calling
1720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //                   GetSupportedFormats() and selecting one of the supported
1730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //                   or calling GetBestCaptureFormat().
1740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Return
1750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   CS_STARTING:  The capturer is trying to start. Success or failure will
1760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //                 be notified via the |SignalStateChange| callback.
1770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   CS_RUNNING:   if the capturer is started and capturing.
1780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   CS_PAUSED:    Will never be returned.
1790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   CS_FAILED:    if the capturer failes to start..
1800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  //   CS_NO_DEVICE: if the capturer has no device and fails to start.
1810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual CaptureState Start(const VideoFormat& capture_format) = 0;
1820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Sets the desired aspect ratio. If the capturer is capturing at another
1830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // aspect ratio it will crop the width or the height so that asked for
1840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // aspect ratio is acheived. Note that ratio_w and ratio_h do not need to be
1850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // relatively prime.
1860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void UpdateAspectRatio(int ratio_w, int ratio_h);
1870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void ClearAspectRatio();
1880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the current capture format, which is set by the Start() call.
1900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Note that the width and height of the captured frames may differ from the
1910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // capture format. For example, the capture format is HD but the captured
1920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // frames may be smaller than HD.
1930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const VideoFormat* GetCaptureFormat() const {
1940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    return capture_format_.get();
1950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
1960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
1970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Pause the video capturer.
1980e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool Pause(bool paused);
1990e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Stop the video capturer.
2000e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual void Stop() = 0;
2010e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Check if the video capturer is running.
2020e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool IsRunning() = 0;
2030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Restart the video capturer with the new |capture_format|.
2040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Default implementation stops and starts the capturer.
2050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool Restart(const VideoFormat& capture_format);
2060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // TODO(thorcarpenter): This behavior of keeping the camera open just to emit
2070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // black frames is a total hack and should be fixed.
2080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // When muting, produce black frames then pause the camera.
2090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // When unmuting, start the camera. Camera starts unmuted.
2100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool MuteToBlackThenPause(bool muted);
2110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool IsMuted() const {
2120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    return muted_;
2130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
2140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CaptureState capture_state() const {
2150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    return capture_state_;
2160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
2170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Adds a video processor that will be applied on VideoFrames returned by
2190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // |SignalVideoFrame|. Multiple video processors can be added. The video
2200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // processors will be applied in the order they were added.
2210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void AddVideoProcessor(VideoProcessor* video_processor);
2220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Removes the |video_processor| from the list of video processors or
2230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // returns false.
2240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool RemoveVideoProcessor(VideoProcessor* video_processor);
2250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Returns true if the capturer is screencasting. This can be used to
2270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // implement screencast specific behavior.
2280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool IsScreencast() const = 0;
2290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Caps the VideoCapturer's format according to max_format. It can e.g. be
2310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // used to prevent cameras from capturing at a resolution or framerate that
2320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // the capturer is capable of but not performing satisfactorily at.
2330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // The capping is an upper bound for each component of the capturing format.
2340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // The fourcc component is ignored.
2350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void ConstrainSupportedFormats(const VideoFormat& max_format);
2360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void set_enable_camera_list(bool enable_camera_list) {
2380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    enable_camera_list_ = enable_camera_list;
2390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
2400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool enable_camera_list() {
2410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    return enable_camera_list_;
2420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
2432007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org
2442007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  // Enable scaling to ensure square pixels.
2452007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  void set_square_pixel_aspect_ratio(bool square_pixel_aspect_ratio) {
2462007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org    square_pixel_aspect_ratio_ = square_pixel_aspect_ratio;
2472007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  }
2482007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  bool square_pixel_aspect_ratio() {
2492007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org    return square_pixel_aspect_ratio_;
2502007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  }
2512007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org
2520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Signal all capture state changes that are not a direct result of calling
2530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Start().
2540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  sigslot::signal2<VideoCapturer*, CaptureState> SignalStateChange;
2550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Frame callbacks are multithreaded to allow disconnect and connect to be
2560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // called concurrently. It also ensures that it is safe to call disconnect
2570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // at any time which is needed since the signal may be called from an
2580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // unmarshalled thread owned by the VideoCapturer.
2590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Signal the captured frame to downstream.
2600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  sigslot::signal2<VideoCapturer*, const CapturedFrame*,
2610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                   sigslot::multi_threaded_local> SignalFrameCaptured;
262b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org  // Signal the captured and possibly adapted frame to downstream consumers
263b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org  // such as the encoder.
2640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  sigslot::signal2<VideoCapturer*, const VideoFrame*,
2650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                   sigslot::multi_threaded_local> SignalVideoFrame;
2660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
2670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  const VideoProcessors& video_processors() const { return video_processors_; }
2680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
269952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // If 'screencast_max_pixels' is set greater than zero, screencasts will be
270952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // scaled to be no larger than this value.
271952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // If set to zero, the max pixels will be limited to
272952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // Retina MacBookPro 15" resolution of 2880 x 1800.
273952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // For high fps, maximum pixels limit is set based on common 24" monitor
274952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  // resolution of 2048 x 1280.
275952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  int screencast_max_pixels() const { return screencast_max_pixels_; }
276952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  void set_screencast_max_pixels(int p) {
2772a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org    screencast_max_pixels_ = rtc::_max(0, p);
278952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  }
279952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org
280e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  // If true, run video adaptation. By default, video adaptation is enabled
281e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  // and users must call video_adapter()->OnOutputFormatRequest()
282e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  // to receive frames.
283e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  bool enable_video_adapter() const { return enable_video_adapter_; }
284e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  void set_enable_video_adapter(bool enable_video_adapter) {
285e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org    enable_video_adapter_ = enable_video_adapter;
286e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  }
287e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org
288e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  CoordinatedVideoAdapter* video_adapter() { return &video_adapter_; }
289e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  const CoordinatedVideoAdapter* video_adapter() const {
290e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org    return &video_adapter_;
291e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  }
292e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org
2932a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org  // Takes ownership.
2942a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org  void set_frame_factory(VideoFrameFactory* frame_factory) {
2952a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org    frame_factory_.reset(frame_factory);
2962a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org  }
2972a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org
2987587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  // Gets statistics for tracked variables recorded since the last call to
2997587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  // GetStats.  Note that calling GetStats resets any gathered data so it
3007587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  // should be called only periodically to log statistics.
3017587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  void GetStats(VariableInfo<int>* adapt_drop_stats,
3027587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org                VariableInfo<int>* effect_drop_stats,
3033657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org                VariableInfo<double>* frame_time_stats,
3043657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org                VideoFormat* last_captured_frame_format);
3057587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org
3060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org protected:
3070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Callback attached to SignalFrameCaptured where SignalVideoFrames is called.
3080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void OnFrameCaptured(VideoCapturer* video_capturer,
3090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                       const CapturedFrame* captured_frame);
3100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void SetCaptureState(CaptureState state);
3110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Marshals SignalStateChange onto thread_.
3132a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  void OnMessage(rtc::Message* message);
3140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // subclasses override this virtual method to provide a vector of fourccs, in
3160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // order of preference, that are expected by the media engine.
3170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) = 0;
3180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // mutators to set private attributes
3200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void SetId(const std::string& id) {
3210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    id_ = id;
3220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
3230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void SetCaptureFormat(const VideoFormat* format) {
3250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org    capture_format_.reset(format ? new VideoFormat(*format) : NULL);
326e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org    if (capture_format_) {
327e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org      ASSERT(capture_format_->interval > 0 &&
328e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org             "Capture format expected to have positive interval.");
329e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org      // Video adapter really only cares about capture format interval.
330e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org      video_adapter_.SetInputFormat(*capture_format_);
331e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org    }
3320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  }
3330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void SetSupportedFormats(const std::vector<VideoFormat>& formats);
3352a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org  VideoFrameFactory* frame_factory() { return frame_factory_.get(); }
3360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private:
3380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void Construct();
3390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Get the distance between the desired format and the supported format.
3400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Return the max distance if they mismatch. See the implementation for
3410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // details.
3420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int64 GetFormatDistance(const VideoFormat& desired,
3430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org                          const VideoFormat& supported);
3440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Convert captured frame to readable string for LOG messages.
3460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string ToString(const CapturedFrame* frame) const;
3470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Applies all registered processors. If any of the processors signal that
3490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // the frame should be dropped the return value will be false. Note that
3500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // this frame should be dropped as it has not applied all processors.
3510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool ApplyProcessors(VideoFrame* video_frame);
3520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3530e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Updates filtered_supported_formats_ so that it contains the formats in
3540e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // supported_formats_ that fulfill all applied restrictions.
3550e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  void UpdateFilteredSupportedFormats();
3560e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  // Returns true if format doesn't fulfill all applied restrictions.
3570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool ShouldFilterFormat(const VideoFormat& format) const;
3580e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3593657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org  void UpdateStats(const CapturedFrame* captured_frame);
3603657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org
3617587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  // Helper function to save statistics on the current data from a
3627587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  // RollingAccumulator into stats.
3637587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  template<class T>
3647587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  static void GetVariableSnapshot(
3652a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org      const rtc::RollingAccumulator<T>& data,
3667587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org      VariableInfo<T>* stats);
3677587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org
3682a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::Thread* thread_;
3690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::string id_;
3700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  CaptureState capture_state_;
3712a0553609b5b6d1d4dce0366b334dc9ef8aa4d65buildbot@webrtc.org  rtc::scoped_ptr<VideoFrameFactory> frame_factory_;
3722a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::scoped_ptr<VideoFormat> capture_format_;
3730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::vector<VideoFormat> supported_formats_;
3742a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::scoped_ptr<VideoFormat> max_format_;
3750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  std::vector<VideoFormat> filtered_supported_formats_;
3760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
3770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int ratio_w_;  // View resolution. e.g. 1280 x 720.
3780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int ratio_h_;
3790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool enable_camera_list_;
3802007187dab65bb5d6f602355216534d6dd4ceaf2mallinath@webrtc.org  bool square_pixel_aspect_ratio_;  // Enable scaling to square pixels.
3810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int scaled_width_;  // Current output size from ComputeScale.
3820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int scaled_height_;
383952740e2dafeb2599d21778eb2e1b8f1c8f2bb07wu@webrtc.org  int screencast_max_pixels_;  // Downscale screencasts further if requested.
3840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  bool muted_;
3850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  int black_frame_count_down_;
3860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
387e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  bool enable_video_adapter_;
388e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org  CoordinatedVideoAdapter video_adapter_;
389e8b0cc3bf706964d657fdb25f0c5791c5a7aa3d7henrike@webrtc.org
3902a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::Timing frame_length_time_reporter_;
3912a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::CriticalSection frame_stats_crit_;
3927587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org
3937587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  int adapt_frame_drops_;
3942a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::RollingAccumulator<int> adapt_frame_drops_data_;
3957587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  int effect_frame_drops_;
3962a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::RollingAccumulator<int> effect_frame_drops_data_;
3977587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org  double previous_frame_time_;
3982a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::RollingAccumulator<double> frame_time_data_;
3993657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org  // The captured frame format before potential adapation.
4003657d9107db9ffd3dfbe996b9a3af57e4818efb4buildbot@webrtc.org  VideoFormat last_captured_frame_format_;
4017587c5e0b2fb5100b52bf271370ee1369ba18690henrike@webrtc.org
4022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org  rtc::CriticalSection crit_;
4030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  VideoProcessors video_processors_;
4040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
4050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org  DISALLOW_COPY_AND_ASSIGN(VideoCapturer);
4060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org};
4070e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
4080e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}  // namespace cricket
4090e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org
4100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif  // TALK_MEDIA_BASE_VIDEOCAPTURER_H_
411