#ifndef MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
#define MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_MAC_H_
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "media/video/capture/video_capture_device.h"
#include "media/video/capture/video_capture_types.h"
@protocol PlatformVideoCapturingMac;
namespace base {
class SingleThreadTaskRunner;
}
namespace media {
class VideoCaptureDeviceMac : public VideoCaptureDevice {
public:
explicit VideoCaptureDeviceMac(const Name& device_name);
virtual ~VideoCaptureDeviceMac();
virtual void AllocateAndStart(const VideoCaptureParams& params,
scoped_ptr<VideoCaptureDevice::Client> client)
OVERRIDE;
virtual void StopAndDeAllocate() OVERRIDE;
bool Init();
void ReceiveFrame(const uint8* video_frame,
int video_frame_length,
const VideoCaptureFormat& frame_format,
int aspect_numerator,
int aspect_denominator);
void ReceiveError(const std::string& reason);
private:
void SetErrorState(const std::string& reason);
bool UpdateCaptureResolution();
enum InternalState {
kNotInitialized,
kIdle,
kCapturing,
kError
};
Name device_name_;
scoped_ptr<VideoCaptureDevice::Client> client_;
VideoCaptureFormat capture_format_;
bool final_resolution_selected_;
bool tried_to_square_pixels_;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
InternalState state_;
id<PlatformVideoCapturingMac> capture_device_;
base::WeakPtrFactory<VideoCaptureDeviceMac> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceMac);
};
}
#endif