| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // VideoCaptureDevice is the abstract base class for realizing video capture | 5 // VideoCaptureDevice is the abstract base class for realizing video capture |
| 6 // device support in Chromium. It provides the interface for OS dependent | 6 // device support in Chromium. It provides the interface for OS dependent |
| 7 // implementations. | 7 // implementations. |
| 8 // The class is created and functions are invoked on a thread owned by | 8 // The class is created and functions are invoked on a thread owned by |
| 9 // VideoCaptureManager. Capturing is done on other threads depended on the OS | 9 // VideoCaptureManager. Capturing is done on other threads depended on the OS |
| 10 // specific implementation. | 10 // specific implementation. |
| 11 | 11 |
| 12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| 13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| 14 | 14 |
| 15 #include <list> | 15 #include <list> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "media/base/media_export.h" | 19 #include "media/base/media_export.h" |
| 20 #include "media/video/capture/video_capture_types.h" |
| 20 | 21 |
| 21 namespace media { | 22 namespace media { |
| 22 | 23 |
| 23 class MEDIA_EXPORT VideoCaptureDevice { | 24 class MEDIA_EXPORT VideoCaptureDevice { |
| 24 public: | 25 public: |
| 25 | 26 |
| 26 struct Name { | 27 struct Name { |
| 27 // Friendly name of a device | 28 // Friendly name of a device |
| 28 std::string device_name; | 29 std::string device_name; |
| 29 | 30 |
| 30 // Unique name of a device. Even if there are multiple devices with the same | 31 // Unique name of a device. Even if there are multiple devices with the same |
| 31 // friendly name connected to the computer this will be unique. | 32 // friendly name connected to the computer this will be unique. |
| 32 std::string unique_id; | 33 std::string unique_id; |
| 33 }; | 34 }; |
| 34 typedef std::list<Name> Names; | 35 typedef std::list<Name> Names; |
| 35 | 36 |
| 36 // Color formats from camera. | |
| 37 enum Format { | |
| 38 kColorUnknown, // Color format not set. | |
| 39 kI420, | |
| 40 kYUY2, | |
| 41 kUYVY, | |
| 42 kRGB24, | |
| 43 kARGB, | |
| 44 kMJPEG, // Currently only supported on Windows. | |
| 45 kNV21, | |
| 46 kYV12, | |
| 47 }; | |
| 48 | |
| 49 // Describes the format a camera capture video in. | |
| 50 struct Capability { | |
| 51 Capability() | |
| 52 : width(0), | |
| 53 height(0), | |
| 54 frame_rate(0), | |
| 55 color(kColorUnknown) {} | |
| 56 int width; | |
| 57 int height; | |
| 58 int frame_rate; | |
| 59 Format color; | |
| 60 }; | |
| 61 | |
| 62 class EventHandler { | 37 class EventHandler { |
| 63 public: | 38 public: |
| 64 // Captured a new video frame. | 39 // Captured a new video frame. |
| 65 virtual void OnIncomingCapturedFrame(const uint8* data, | 40 virtual void OnIncomingCapturedFrame(const uint8* data, |
| 66 int length, | 41 int length, |
| 67 base::Time timestamp) = 0; | 42 base::Time timestamp) = 0; |
| 68 // An error has occurred that can not be handled | 43 // An error has occurred that can not be handled |
| 69 // and VideoCaptureDevice must be DeAllocated. | 44 // and VideoCaptureDevice must be DeAllocated. |
| 70 virtual void OnError() = 0; | 45 virtual void OnError() = 0; |
| 71 // Called when VideoCaptureDevice::Allocate has been called | 46 // Called when VideoCaptureDevice::Allocate has been called |
| 72 // to inform of the resulting frame size and color format. | 47 // to inform of the resulting frame size and color format. |
| 73 virtual void OnFrameInfo(const Capability& info) = 0; | 48 virtual void OnFrameInfo(const VideoCaptureCapability& info) = 0; |
| 74 | 49 |
| 75 protected: | 50 protected: |
| 76 virtual ~EventHandler() {} | 51 virtual ~EventHandler() {} |
| 77 }; | 52 }; |
| 78 // Creates a VideoCaptureDevice object. | 53 // Creates a VideoCaptureDevice object. |
| 79 // Return NULL if the hardware is not available. | 54 // Return NULL if the hardware is not available. |
| 80 static VideoCaptureDevice* Create(const Name& device_name); | 55 static VideoCaptureDevice* Create(const Name& device_name); |
| 81 virtual ~VideoCaptureDevice() {} | 56 virtual ~VideoCaptureDevice() {} |
| 82 | 57 |
| 83 // Gets the names of all video capture devices connected to this computer. | 58 // Gets the names of all video capture devices connected to this computer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 // state it was when created. | 79 // state it was when created. |
| 105 virtual void DeAllocate() = 0; | 80 virtual void DeAllocate() = 0; |
| 106 | 81 |
| 107 // Get the name of the capture device. | 82 // Get the name of the capture device. |
| 108 virtual const Name& device_name() = 0; | 83 virtual const Name& device_name() = 0; |
| 109 }; | 84 }; |
| 110 | 85 |
| 111 } // namespace media | 86 } // namespace media |
| 112 | 87 |
| 113 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 88 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |