Home | History | Annotate | Download | only in mac
      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
      3 // found in the LICENSE file.
      4 
      5 // OS X implementation of VideoCaptureDevice, using QTKit as native capture API.
      6 
      7 #ifndef MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
      8 #define MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
      9 
     10 #include <string>
     11 
     12 #include "base/compiler_specific.h"
     13 #include "media/video/capture/video_capture_device.h"
     14 #include "media/video/capture/video_capture_types.h"
     15 
     16 @class VideoCaptureDeviceQTKit;
     17 
     18 namespace media {
     19 
     20 // Called by VideoCaptureManager to open, close and start, stop video capture
     21 // devices.
     22 class VideoCaptureDeviceMac : public VideoCaptureDevice {
     23  public:
     24   explicit VideoCaptureDeviceMac(const Name& device_name);
     25   virtual ~VideoCaptureDeviceMac();
     26 
     27   // VideoCaptureDevice implementation.
     28   virtual void Allocate(const VideoCaptureCapability& capture_format,
     29                          VideoCaptureDevice::EventHandler* observer) OVERRIDE;
     30   virtual void Start() OVERRIDE;
     31   virtual void Stop() OVERRIDE;
     32   virtual void DeAllocate() OVERRIDE;
     33   virtual const Name& device_name() OVERRIDE;
     34 
     35   bool Init();
     36 
     37   // Called to deliver captured video frames.
     38   void ReceiveFrame(const uint8* video_frame, int video_frame_length,
     39                     const VideoCaptureCapability& frame_info);
     40 
     41  private:
     42   void SetErrorState(const std::string& reason);
     43 
     44   // Flag indicating the internal state.
     45   enum InternalState {
     46     kNotInitialized,
     47     kIdle,
     48     kAllocated,
     49     kCapturing,
     50     kError
     51   };
     52 
     53   Name device_name_;
     54   VideoCaptureDevice::EventHandler* observer_;
     55   InternalState state_;
     56 
     57   VideoCaptureDeviceQTKit* capture_device_;
     58 
     59   DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac);
     60 };
     61 
     62 }  // namespace media
     63 
     64 #endif  // MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
     65