Home | History | Annotate | Download | only in include
      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 WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_DEFINES_H_
     12 #define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_DEFINES_H_
     13 
     14 #include "webrtc/common_video/interface/i420_video_frame.h"
     15 #include "webrtc/modules/interface/module_common_types.h"
     16 #include "webrtc/typedefs.h"
     17 
     18 namespace webrtc
     19 {
     20 // Defines
     21 #ifndef NULL
     22     #define NULL    0
     23 #endif
     24 
     25 enum {kVideoCaptureUniqueNameLength =1024}; //Max unique capture device name lenght
     26 enum {kVideoCaptureDeviceNameLength =256}; //Max capture device name lenght
     27 enum {kVideoCaptureProductIdLength =128}; //Max product id length
     28 
     29 // Enums
     30 enum VideoCaptureRotation
     31 {
     32     kCameraRotate0 = 0,
     33     kCameraRotate90 = 5,
     34     kCameraRotate180 = 10,
     35     kCameraRotate270 = 15
     36 };
     37 
     38 struct VideoCaptureCapability
     39 {
     40     int32_t width;
     41     int32_t height;
     42     int32_t maxFPS;
     43     int32_t expectedCaptureDelay;
     44     RawVideoType rawType;
     45     VideoCodecType codecType;
     46     bool interlaced;
     47 
     48     VideoCaptureCapability()
     49     {
     50         width = 0;
     51         height = 0;
     52         maxFPS = 0;
     53         expectedCaptureDelay = 0;
     54         rawType = kVideoUnknown;
     55         codecType = kVideoCodecUnknown;
     56         interlaced = false;
     57     }
     58     ;
     59     bool operator!=(const VideoCaptureCapability &other) const
     60     {
     61         if (width != other.width)
     62             return true;
     63         if (height != other.height)
     64             return true;
     65         if (maxFPS != other.maxFPS)
     66             return true;
     67         if (rawType != other.rawType)
     68             return true;
     69         if (codecType != other.codecType)
     70             return true;
     71         if (interlaced != other.interlaced)
     72             return true;
     73         return false;
     74     }
     75     bool operator==(const VideoCaptureCapability &other) const
     76     {
     77         return !operator!=(other);
     78     }
     79 };
     80 
     81 enum VideoCaptureAlarm
     82 {
     83     Raised = 0,
     84     Cleared = 1
     85 };
     86 
     87 /* External Capture interface. Returned by Create
     88  and implemented by the capture module.
     89  */
     90 class VideoCaptureExternal
     91 {
     92 public:
     93     // |capture_time| must be specified in the NTP time format in milliseconds.
     94     virtual int32_t IncomingFrame(uint8_t* videoFrame,
     95                                   int32_t videoFrameLength,
     96                                   const VideoCaptureCapability& frameInfo,
     97                                   int64_t captureTime = 0) = 0;
     98     virtual int32_t IncomingI420VideoFrame(I420VideoFrame* video_frame,
     99                                            int64_t captureTime = 0) = 0;
    100 
    101 protected:
    102     ~VideoCaptureExternal() {}
    103 };
    104 
    105 // Callback class to be implemented by module user
    106 class VideoCaptureDataCallback
    107 {
    108 public:
    109     virtual void OnIncomingCapturedFrame(const int32_t id,
    110                                          I420VideoFrame& videoFrame) = 0;
    111     virtual void OnCaptureDelayChanged(const int32_t id,
    112                                        const int32_t delay) = 0;
    113 protected:
    114     virtual ~VideoCaptureDataCallback(){}
    115 };
    116 
    117 class VideoCaptureFeedBack
    118 {
    119 public:
    120     virtual void OnCaptureFrameRate(const int32_t id,
    121                                     const uint32_t frameRate) = 0;
    122     virtual void OnNoPictureAlarm(const int32_t id,
    123                                   const VideoCaptureAlarm alarm) = 0;
    124 protected:
    125     virtual ~VideoCaptureFeedBack(){}
    126 };
    127 
    128 }  // namespace webrtc
    129 
    130 #endif  // WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_DEFINES_H_
    131