Remove dead video_capture for QuickTime.
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4339 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* video_capture_quick_time.h
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_H_
|
|
||||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_H_
|
|
||||||
|
|
||||||
#include <QuickTime/QuickTime.h>
|
|
||||||
|
|
||||||
#include "../../device_info_impl.h"
|
|
||||||
#include "../../video_capture_impl.h"
|
|
||||||
#include "list_wrapper.h"
|
|
||||||
|
|
||||||
#define START_CODEC_WIDTH 352
|
|
||||||
#define START_CODEC_HEIGHT 288
|
|
||||||
#define SLEEP(x) usleep(x * 1000);
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
class CriticalSectionWrapper;
|
|
||||||
class EventWrapper;
|
|
||||||
class ThreadWrapper;
|
|
||||||
|
|
||||||
class VideoCaptureMacQuickTime : public VideoCaptureImpl {
|
|
||||||
|
|
||||||
public:
|
|
||||||
VideoCaptureMacQuickTime(const int32_t id);
|
|
||||||
virtual ~VideoCaptureMacQuickTime();
|
|
||||||
|
|
||||||
static void Destroy(VideoCaptureModule* module);
|
|
||||||
|
|
||||||
int32_t Init(const int32_t id, const uint8_t* deviceUniqueIdUTF8);
|
|
||||||
virtual int32_t StartCapture(const VideoCaptureCapability& capability);
|
|
||||||
virtual int32_t StopCapture();
|
|
||||||
virtual bool CaptureStarted();
|
|
||||||
virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
|
|
||||||
|
|
||||||
// TODO: remove?
|
|
||||||
int VideoCaptureInitThreadContext();
|
|
||||||
int VideoCaptureTerminate();
|
|
||||||
int VideoCaptureSetCaptureDevice(const char* deviceName, int size);
|
|
||||||
int UpdateCaptureSettings(int channel, webrtc::VideoCodec& inst, bool def);
|
|
||||||
int VideoCaptureRun();
|
|
||||||
int VideoCaptureStop();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
private: // functions
|
|
||||||
|
|
||||||
struct VideoCaptureMacName {
|
|
||||||
VideoCaptureMacName();
|
|
||||||
|
|
||||||
enum {
|
|
||||||
kVideoCaptureMacNameMaxSize = 64
|
|
||||||
};
|
|
||||||
char _name[kVideoCaptureMacNameMaxSize];
|
|
||||||
CFIndex _size;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Timeout value [ms] if we want to create a new device list or not
|
|
||||||
enum {
|
|
||||||
kVideoCaptureDeviceListTimeout = 5000
|
|
||||||
};
|
|
||||||
// Temporary constant allowing this size from builtin iSight webcams.
|
|
||||||
enum {
|
|
||||||
kYuy2_1280_1024_length = 2621440
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Capture device callback
|
|
||||||
static OSErr SendProcess(SGChannel sgChannel, Ptr p, long len, long* offset,
|
|
||||||
long chRefCon, TimeValue time, short writeType,
|
|
||||||
long refCon);
|
|
||||||
int SendFrame(SGChannel sgChannel, char* data, long length, TimeValue time);
|
|
||||||
|
|
||||||
// Capture device functions
|
|
||||||
int CreateLocalGWorld(int width, int height);
|
|
||||||
int RemoveLocalGWorld();
|
|
||||||
int ConnectCaptureDevice();
|
|
||||||
int DisconnectCaptureDevice();
|
|
||||||
virtual bool IsCaptureDeviceSelected();
|
|
||||||
|
|
||||||
// Process to make sure the capture device won't stop
|
|
||||||
static bool GrabberUpdateThread(void*);
|
|
||||||
bool GrabberUpdateProcess();
|
|
||||||
|
|
||||||
// Starts and stops the capture
|
|
||||||
int StartQuickTimeCapture();
|
|
||||||
int StopQuickTimeCapture(bool* wasCapturing = NULL);
|
|
||||||
|
|
||||||
static CFIndex PascalStringToCString(const unsigned char* pascalString,
|
|
||||||
char* cString, CFIndex bufferSize);
|
|
||||||
|
|
||||||
private : // variables
|
|
||||||
int32_t _id;
|
|
||||||
bool _isCapturing;
|
|
||||||
VideoCaptureCapability _captureCapability;
|
|
||||||
CriticalSectionWrapper* _grabberCritsect;
|
|
||||||
CriticalSectionWrapper* _videoMacCritsect;
|
|
||||||
bool _terminated;
|
|
||||||
webrtc::ThreadWrapper* _grabberUpdateThread;
|
|
||||||
webrtc::EventWrapper* _grabberUpdateEvent;
|
|
||||||
SeqGrabComponent _captureGrabber;
|
|
||||||
Component _captureDevice;
|
|
||||||
char _captureDeviceDisplayName[64];
|
|
||||||
RawVideoType _captureVideoType;
|
|
||||||
bool _captureIsInitialized;
|
|
||||||
GWorldPtr _gWorld;
|
|
||||||
SGChannel _captureChannel;
|
|
||||||
ImageSequence _captureSequence;
|
|
||||||
bool _sgPrepared;
|
|
||||||
bool _sgStarted;
|
|
||||||
int _trueCaptureWidth;
|
|
||||||
int _trueCaptureHeight;
|
|
||||||
ListWrapper _captureDeviceList;
|
|
||||||
unsigned long _captureDeviceListTime;
|
|
||||||
ListWrapper _captureCapabilityList;
|
|
||||||
};
|
|
||||||
} // namespace webrtc
|
|
||||||
#endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_H_
|
|
@@ -1,391 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* video_capture_quick_time_info.cc
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../../video_capture_config.h"
|
|
||||||
#include "video_capture_quick_time_info.h"
|
|
||||||
|
|
||||||
#include "critical_section_wrapper.h"
|
|
||||||
#include "event_wrapper.h"
|
|
||||||
#include "thread_wrapper.h"
|
|
||||||
#include "trace.h"
|
|
||||||
#include "video_capture.h"
|
|
||||||
|
|
||||||
namespace webrtc
|
|
||||||
{
|
|
||||||
|
|
||||||
VideoCaptureMacQuickTimeInfo::VideoCaptureMacQuickTimeInfo(
|
|
||||||
const int32_t iID) :
|
|
||||||
DeviceInfoImpl(iID), _id(iID),
|
|
||||||
_grabberCritsect(CriticalSectionWrapper::CreateCriticalSection())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoCaptureMacQuickTimeInfo::~VideoCaptureMacQuickTimeInfo()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::Init()
|
|
||||||
{
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t VideoCaptureMacQuickTimeInfo::NumberOfDevices()
|
|
||||||
{
|
|
||||||
int numOfDevices = 0;
|
|
||||||
|
|
||||||
// don't care about these variables... dummy vars to call GetCaptureDevices
|
|
||||||
const int kNameLength = 1024;
|
|
||||||
char deviceNameUTF8[kNameLength] = "";
|
|
||||||
char deviceUniqueIdUTF8[kNameLength] = "";
|
|
||||||
char productUniqueIdUTF8[kNameLength] = "";
|
|
||||||
|
|
||||||
if (GetCaptureDevices(0, deviceNameUTF8, kNameLength, deviceUniqueIdUTF8,
|
|
||||||
kNameLength, productUniqueIdUTF8, kNameLength,
|
|
||||||
numOfDevices) != 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return numOfDevices;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::GetDeviceName(
|
|
||||||
uint32_t deviceNumber, char* deviceNameUTF8,
|
|
||||||
uint32_t deviceNameUTF8Length, char* deviceUniqueIdUTF8,
|
|
||||||
uint32_t deviceUniqueIdUTF8Length, char* productUniqueIdUTF8,
|
|
||||||
uint32_t productUniqueIdUTF8Length)
|
|
||||||
{
|
|
||||||
|
|
||||||
int numOfDevices = 0; // not needed for this function
|
|
||||||
return GetCaptureDevices(deviceNumber, deviceNameUTF8,
|
|
||||||
deviceNameUTF8Length, deviceUniqueIdUTF8,
|
|
||||||
deviceUniqueIdUTF8Length, productUniqueIdUTF8,
|
|
||||||
productUniqueIdUTF8Length, numOfDevices);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::NumberOfCapabilities(
|
|
||||||
const char* deviceUniqueIdUTF8)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"NumberOfCapabilities is not supported on the Mac platform.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::GetCapability(
|
|
||||||
const char* deviceUniqueIdUTF8,
|
|
||||||
const uint32_t deviceCapabilityNumber,
|
|
||||||
VideoCaptureCapability& capability)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"NumberOfCapabilities is not supported on the Mac platform.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::GetBestMatchedCapability(
|
|
||||||
const char*deviceUniqueIdUTF8,
|
|
||||||
const VideoCaptureCapability& requested, VideoCaptureCapability& resulting)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"NumberOfCapabilities is not supported on the Mac platform.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::DisplayCaptureSettingsDialogBox(
|
|
||||||
const char* deviceUniqueIdUTF8,
|
|
||||||
const char* dialogTitleUTF8, void* parentWindow,
|
|
||||||
uint32_t positionX, uint32_t positionY)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t VideoCaptureMacQuickTimeInfo::CreateCapabilityMap(
|
|
||||||
const char* deviceUniqueIdUTF8)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"NumberOfCapabilities is not supported on the Mac platform.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int VideoCaptureMacQuickTimeInfo::GetCaptureDevices(
|
|
||||||
uint32_t deviceNumber, char* deviceNameUTF8,
|
|
||||||
uint32_t deviceNameUTF8Length, char* deviceUniqueIdUTF8,
|
|
||||||
uint32_t deviceUniqueIdUTF8Length, char* productUniqueIdUTF8,
|
|
||||||
uint32_t productUniqueIdUTF8Length, int& numberOfDevices)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
numberOfDevices = 0;
|
|
||||||
memset(deviceNameUTF8, 0, deviceNameUTF8Length);
|
|
||||||
memset(deviceUniqueIdUTF8, 0, deviceUniqueIdUTF8Length);
|
|
||||||
memset(productUniqueIdUTF8, 0, productUniqueIdUTF8Length);
|
|
||||||
|
|
||||||
if (deviceNumber < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Invalid deviceNumber", __FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component captureDevice = NULL;
|
|
||||||
SeqGrabComponent captureGrabber = NULL;
|
|
||||||
SGChannel captureChannel = NULL;
|
|
||||||
bool closeChannel = false;
|
|
||||||
|
|
||||||
ComponentDescription compCaptureType;
|
|
||||||
|
|
||||||
compCaptureType.componentType = SeqGrabComponentType;
|
|
||||||
compCaptureType.componentSubType = 0;
|
|
||||||
compCaptureType.componentManufacturer = 0;
|
|
||||||
compCaptureType.componentFlags = 0;
|
|
||||||
compCaptureType.componentFlagsMask = 0;
|
|
||||||
|
|
||||||
// Get the number of sequence grabbers
|
|
||||||
long numSequenceGrabbers = CountComponents(&compCaptureType);
|
|
||||||
|
|
||||||
if (deviceNumber > numSequenceGrabbers)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Invalid deviceNumber", __FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numSequenceGrabbers <= 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d No sequence grabbers available", __FUNCTION__,
|
|
||||||
__LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open a sequence grabber
|
|
||||||
for (int seqGrabberIndex = 0;
|
|
||||||
seqGrabberIndex < numSequenceGrabbers;
|
|
||||||
seqGrabberIndex++)
|
|
||||||
{
|
|
||||||
captureDevice = FindNextComponent(0, &compCaptureType);
|
|
||||||
captureGrabber = OpenComponent(captureDevice);
|
|
||||||
if (captureGrabber != NULL)
|
|
||||||
{
|
|
||||||
// We've found a sequencegrabber
|
|
||||||
if (SGInitialize(captureGrabber) != noErr)
|
|
||||||
{
|
|
||||||
CloseComponent(captureGrabber);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture,
|
|
||||||
_id, "%s:%d Could not init the sequence grabber",
|
|
||||||
__FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (seqGrabberIndex == numSequenceGrabbers - 1)
|
|
||||||
{
|
|
||||||
// Couldn't open a sequence grabber
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Could not open a sequence grabber",
|
|
||||||
__FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a temporary channel to get the names of the capture devices.
|
|
||||||
// Takes time, make this in a nother way...
|
|
||||||
if (SGNewChannel(captureGrabber, VideoMediaType, &captureChannel) != noErr)
|
|
||||||
{
|
|
||||||
// Could not create a video channel...
|
|
||||||
SGRelease(captureGrabber);
|
|
||||||
CloseComponent(captureGrabber);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Could not create a sequence grabber video channel",
|
|
||||||
__FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
closeChannel = true;
|
|
||||||
|
|
||||||
// Find the type of capture devices, e.g. USB-devices, Firewire, DV, ...
|
|
||||||
SGDeviceList deviceList = NULL;
|
|
||||||
if (SGGetChannelDeviceList(captureChannel, sgDeviceListIncludeInputs,
|
|
||||||
&deviceList) != noErr)
|
|
||||||
{
|
|
||||||
if (closeChannel)
|
|
||||||
SGDisposeChannel(captureGrabber, captureChannel);
|
|
||||||
if (captureGrabber)
|
|
||||||
{
|
|
||||||
SGRelease(captureGrabber);
|
|
||||||
CloseComponent(captureGrabber);
|
|
||||||
}
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Could not create a device list", __FUNCTION__,
|
|
||||||
__LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through all device types and all devices for each type
|
|
||||||
// and store in a list.
|
|
||||||
int numDevices = (*deviceList)->count;
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Found %d devices", __FUNCTION__, __LINE__, numDevices);
|
|
||||||
|
|
||||||
for (int i = 0; i < numDevices; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
SGDeviceName sgDeviceName = (*deviceList)->entry[i];
|
|
||||||
// Get the list with input devices for this type of device
|
|
||||||
if (sgDeviceName.inputs)
|
|
||||||
{
|
|
||||||
SGDeviceInputList inputList = sgDeviceName.inputs;
|
|
||||||
int numInputDev = (*inputList)->count;
|
|
||||||
|
|
||||||
for (int inputDevIndex = 0;
|
|
||||||
inputDevIndex < numInputDev;
|
|
||||||
inputDevIndex++)
|
|
||||||
{
|
|
||||||
// Get the name for this capture device
|
|
||||||
SGDeviceInputName deviceInputName =
|
|
||||||
(*inputList)->entry[inputDevIndex];
|
|
||||||
|
|
||||||
VideoCaptureMacName* deviceName = new VideoCaptureMacName();
|
|
||||||
|
|
||||||
deviceName->_size = PascalStringToCString(
|
|
||||||
deviceInputName.name, deviceName->_name,
|
|
||||||
sizeof(deviceName->_name));
|
|
||||||
|
|
||||||
if (deviceName->_size > 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceDebug,webrtc::kTraceVideoCapture,
|
|
||||||
_id,
|
|
||||||
"%s:%d Capture device %d: %s was successfully "
|
|
||||||
"set", __FUNCTION__, __LINE__, numberOfDevices,
|
|
||||||
deviceName->_name);
|
|
||||||
|
|
||||||
if (numberOfDevices == deviceNumber)
|
|
||||||
{
|
|
||||||
strcpy((char*) deviceNameUTF8, deviceName->_name);
|
|
||||||
strcpy((char*) deviceUniqueIdUTF8, deviceName->_name);
|
|
||||||
}
|
|
||||||
numberOfDevices++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete deviceName;
|
|
||||||
|
|
||||||
if (deviceName->_size < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError,
|
|
||||||
webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d Error in PascalStringToCString",
|
|
||||||
__FUNCTION__, __LINE__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
SGDisposeDeviceList(captureGrabber, deviceList);
|
|
||||||
if (closeChannel)
|
|
||||||
{
|
|
||||||
SGDisposeChannel(captureGrabber, captureChannel);
|
|
||||||
}
|
|
||||||
if (captureGrabber)
|
|
||||||
{
|
|
||||||
SGRelease(captureGrabber);
|
|
||||||
CloseComponent(captureGrabber);
|
|
||||||
}
|
|
||||||
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCapture, _id,
|
|
||||||
"%s:%d End function successfully", __FUNCTION__, __LINE__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert a Pascal string to a C string.
|
|
||||||
|
|
||||||
\param[in] pascalString
|
|
||||||
Pascal string to convert. Pascal strings contain the number of
|
|
||||||
characters in the first byte and are not null-terminated.
|
|
||||||
|
|
||||||
\param[out] cString
|
|
||||||
The C string buffer into which to copy the converted string.
|
|
||||||
|
|
||||||
\param[in] bufferSize
|
|
||||||
The size of the C string buffer in bytes.
|
|
||||||
|
|
||||||
\return The number of characters in the string on success and -1 on failure.
|
|
||||||
*/
|
|
||||||
CFIndex VideoCaptureMacQuickTimeInfo::PascalStringToCString(
|
|
||||||
const unsigned char* pascalString, char* cString, CFIndex bufferSize)
|
|
||||||
{
|
|
||||||
if (pascalString == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cString == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bufferSize == 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFIndex cStringLength = 0;
|
|
||||||
CFIndex maxStringLength = bufferSize - 1;
|
|
||||||
|
|
||||||
CFStringRef cfString = CFStringCreateWithPascalString(
|
|
||||||
NULL, pascalString, kCFStringEncodingMacRoman);
|
|
||||||
if (cfString == NULL)
|
|
||||||
{
|
|
||||||
CFRelease(cfString);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFIndex cfLength = CFStringGetLength(cfString);
|
|
||||||
cStringLength = cfLength;
|
|
||||||
if (cfLength > maxStringLength)
|
|
||||||
{
|
|
||||||
cStringLength = maxStringLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean success = CFStringGetCString(cfString, cString, bufferSize,
|
|
||||||
kCFStringEncodingMacRoman);
|
|
||||||
|
|
||||||
// Ensure the problem isn't insufficient buffer length.
|
|
||||||
// This is fine; we will return a partial string.
|
|
||||||
if (success == false && cfLength <= maxStringLength)
|
|
||||||
{
|
|
||||||
CFRelease(cfString);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(cfString);
|
|
||||||
return cStringLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Functions for handling capture devices
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
VideoCaptureMacQuickTimeInfo::VideoCaptureMacName::VideoCaptureMacName() :
|
|
||||||
_size(0)
|
|
||||||
{
|
|
||||||
memset(_name, 0, kVideoCaptureMacNameMaxSize);
|
|
||||||
}
|
|
||||||
} // namespace webrtc
|
|
@@ -1,166 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* video_capture_quick_time_info.h
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_
|
|
||||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_
|
|
||||||
|
|
||||||
#include <QuickTime/QuickTime.h>
|
|
||||||
|
|
||||||
#include "../../video_capture_impl.h"
|
|
||||||
#include "../../device_info_impl.h"
|
|
||||||
#include "list_wrapper.h"
|
|
||||||
#include "map_wrapper.h"
|
|
||||||
|
|
||||||
class VideoRenderCallback;
|
|
||||||
|
|
||||||
namespace webrtc
|
|
||||||
{
|
|
||||||
class CriticalSectionWrapper;
|
|
||||||
class EventWrapper;
|
|
||||||
class ThreadWrapper;
|
|
||||||
class Trace;
|
|
||||||
|
|
||||||
class VideoCaptureMacQuickTimeInfo: public DeviceInfoImpl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
static DeviceInfo* Create(const int32_t id);
|
|
||||||
static void Destroy(DeviceInfo* deviceInfo);
|
|
||||||
|
|
||||||
VideoCaptureMacQuickTimeInfo(const int32_t id);
|
|
||||||
virtual ~VideoCaptureMacQuickTimeInfo();
|
|
||||||
|
|
||||||
int32_t Init();
|
|
||||||
|
|
||||||
virtual uint32_t NumberOfDevices();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the available capture devices.
|
|
||||||
* deviceNumber -[in] index of capture device
|
|
||||||
* deviceNameUTF8 - friendly name of the capture device
|
|
||||||
* deviceUniqueIdUTF8 - unique name of the capture device if it exist.
|
|
||||||
* Otherwise same as deviceNameUTF8
|
|
||||||
* productUniqueIdUTF8 - unique product id if it exist. Null terminated
|
|
||||||
* otherwise.
|
|
||||||
*/
|
|
||||||
virtual int32_t GetDeviceName(
|
|
||||||
uint32_t deviceNumber, char* deviceNameUTF8,
|
|
||||||
uint32_t deviceNameLength, char* deviceUniqueIdUTF8,
|
|
||||||
uint32_t deviceUniqueIdUTF8Length,
|
|
||||||
char* productUniqueIdUTF8 = 0,
|
|
||||||
uint32_t productUniqueIdUTF8Length = 0);
|
|
||||||
|
|
||||||
|
|
||||||
// ************** The remaining public functions are not supported on Mac
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the number of capabilities for this device
|
|
||||||
*/
|
|
||||||
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets the capabilities of the named device
|
|
||||||
*/
|
|
||||||
virtual int32_t GetCapability(
|
|
||||||
const char* deviceUniqueIdUTF8,
|
|
||||||
const uint32_t deviceCapabilityNumber,
|
|
||||||
VideoCaptureCapability& capability);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets the capability that best matches the requested width, height and frame rate.
|
|
||||||
* Returns the deviceCapabilityNumber on success.
|
|
||||||
*/
|
|
||||||
virtual int32_t GetBestMatchedCapability(
|
|
||||||
const char* deviceUniqueIdUTF8,
|
|
||||||
const VideoCaptureCapability& requested,
|
|
||||||
VideoCaptureCapability& resulting);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Display OS /capture device specific settings dialog
|
|
||||||
*/
|
|
||||||
virtual int32_t DisplayCaptureSettingsDialogBox(
|
|
||||||
const char* deviceUniqueIdUTF8,
|
|
||||||
const char* dialogTitleUTF8, void* parentWindow,
|
|
||||||
uint32_t positionX, uint32_t positionY);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int32_t CreateCapabilityMap(
|
|
||||||
const char* deviceUniqueIdUTF8);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
struct VideoCaptureMacName
|
|
||||||
{
|
|
||||||
VideoCaptureMacName();
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kVideoCaptureMacNameMaxSize = 64
|
|
||||||
};
|
|
||||||
char _name[kVideoCaptureMacNameMaxSize];
|
|
||||||
CFIndex _size;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kVideoCaptureMacDeviceListTimeout = 5000
|
|
||||||
}; // Timeout value [ms] if we want to create a new device list or not
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kYuy2_1280_1024_length = 2621440
|
|
||||||
}; // Temporary constant allowing this size from built-in iSight webcams.
|
|
||||||
|
|
||||||
private:
|
|
||||||
// private methods
|
|
||||||
|
|
||||||
int GetCaptureDevices(uint32_t deviceNumber,
|
|
||||||
char* deviceNameUTF8,
|
|
||||||
uint32_t deviceNameUTF8Length,
|
|
||||||
char* deviceUniqueIdUTF8,
|
|
||||||
uint32_t deviceUniqueIdUTF8Length,
|
|
||||||
char* productUniqueIdUTF8,
|
|
||||||
uint32_t productUniqueIdUTF8Length,
|
|
||||||
int& numberOfDevices);
|
|
||||||
|
|
||||||
static CFIndex PascalStringToCString(const unsigned char* pascalString,
|
|
||||||
char* cString, CFIndex bufferSize);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// member vars
|
|
||||||
int32_t _id;
|
|
||||||
bool _terminated;
|
|
||||||
CriticalSectionWrapper* _grabberCritsect;
|
|
||||||
webrtc::Trace* _trace;
|
|
||||||
webrtc::ThreadWrapper* _grabberUpdateThread;
|
|
||||||
webrtc::EventWrapper* _grabberUpdateEvent;
|
|
||||||
SeqGrabComponent _captureGrabber;
|
|
||||||
Component _captureDevice;
|
|
||||||
char _captureDeviceDisplayName[64];
|
|
||||||
bool _captureIsInitialized;
|
|
||||||
GWorldPtr _gWorld;
|
|
||||||
SGChannel _captureChannel;
|
|
||||||
ImageSequence _captureSequence;
|
|
||||||
bool _sgPrepared;
|
|
||||||
bool _sgStarted;
|
|
||||||
int _codecWidth;
|
|
||||||
int _codecHeight;
|
|
||||||
int _trueCaptureWidth;
|
|
||||||
int _trueCaptureHeight;
|
|
||||||
ListWrapper _captureDeviceList;
|
|
||||||
int64_t _captureDeviceListTime;
|
|
||||||
ListWrapper _captureCapabilityList;
|
|
||||||
};
|
|
||||||
} // namespace webrtc
|
|
||||||
#endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_MAC_QUICKTIME_VIDEO_CAPTURE_QUICK_TIME_INFO_H_
|
|
Reference in New Issue
Block a user