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_VIDEO_CAPTURE_DEFINES_H_ 12 #define WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_ 13 14 #include "webrtc/modules/include/module_common_types.h" 15 #include "webrtc/typedefs.h" 16 #include "webrtc/video_frame.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 struct VideoCaptureCapability 30 { 31 int32_t width; 32 int32_t height; 33 int32_t maxFPS; 34 int32_t expectedCaptureDelay; 35 RawVideoType rawType; 36 VideoCodecType codecType; 37 bool interlaced; 38 VideoCaptureCapabilityVideoCaptureCapability39 VideoCaptureCapability() 40 { 41 width = 0; 42 height = 0; 43 maxFPS = 0; 44 expectedCaptureDelay = 0; 45 rawType = kVideoUnknown; 46 codecType = kVideoCodecUnknown; 47 interlaced = false; 48 } 49 ; 50 bool operator!=(const VideoCaptureCapability &other) const 51 { 52 if (width != other.width) 53 return true; 54 if (height != other.height) 55 return true; 56 if (maxFPS != other.maxFPS) 57 return true; 58 if (rawType != other.rawType) 59 return true; 60 if (codecType != other.codecType) 61 return true; 62 if (interlaced != other.interlaced) 63 return true; 64 return false; 65 } 66 bool operator==(const VideoCaptureCapability &other) const 67 { 68 return !operator!=(other); 69 } 70 }; 71 72 enum VideoCaptureAlarm 73 { 74 Raised = 0, 75 Cleared = 1 76 }; 77 78 /* External Capture interface. Returned by Create 79 and implemented by the capture module. 80 */ 81 class VideoCaptureExternal 82 { 83 public: 84 // |capture_time| must be specified in the NTP time format in milliseconds. 85 virtual int32_t IncomingFrame(uint8_t* videoFrame, 86 size_t videoFrameLength, 87 const VideoCaptureCapability& frameInfo, 88 int64_t captureTime = 0) = 0; 89 protected: ~VideoCaptureExternal()90 ~VideoCaptureExternal() {} 91 }; 92 93 // Callback class to be implemented by module user 94 class VideoCaptureDataCallback 95 { 96 public: 97 virtual void OnIncomingCapturedFrame(const int32_t id, 98 const VideoFrame& videoFrame) = 0; 99 virtual void OnCaptureDelayChanged(const int32_t id, 100 const int32_t delay) = 0; 101 protected: ~VideoCaptureDataCallback()102 virtual ~VideoCaptureDataCallback(){} 103 }; 104 105 class VideoCaptureFeedBack 106 { 107 public: 108 virtual void OnCaptureFrameRate(const int32_t id, 109 const uint32_t frameRate) = 0; 110 virtual void OnNoPictureAlarm(const int32_t id, 111 const VideoCaptureAlarm alarm) = 0; 112 protected: ~VideoCaptureFeedBack()113 virtual ~VideoCaptureFeedBack(){} 114 }; 115 116 } // namespace webrtc 117 118 #endif // WEBRTC_MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_ 119