Merge branch 'devel-s210a' into devel-s210a-image-pipeline

This commit is contained in:
kalman 2018-12-18 10:56:52 +08:00
commit 9c540db149
65 changed files with 7546 additions and 116 deletions

View File

@ -132,7 +132,25 @@ endif()
if(OS_WIN) if(OS_WIN)
set(UVC_SRC src/mynteye/uvc/win/uvc-wmf.cc) set(UVC_SRC src/mynteye/uvc/win/uvc-wmf.cc)
elseif(OS_MAC) elseif(OS_MAC)
set(UVC_SRC src/mynteye/uvc/macosx/uvc-libuvc.cc) add_compile_options(-x objective-c++)
## INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx)
## INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/VVUVCKit)
## aux_source_directory(src/mynteye/uvc/macosx/VVUVCKit/ MAC_VVUVCKIT_SRC_LIST)
## aux_source_directory(src/mynteye/uvc/macosx/USBBusProber/ MAC_USBBUSPROBER_SRC_LIST)
## add_library(usbBusProber SHARED ${MAC_USBBUSPROBER_SRC_LIST})
## set_target_properties(usbBusProber PROPERTIES FRAMEWORK TRUE )
## add_library(vvuvckit SHARED ${MAC_VVUVCKIT_SRC_LIST})
## set_target_properties(vvuvckit PROPERTIES FRAMEWORK TRUE )
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/USBBusProber.framework/Headers)
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/VVUVCKit.framework/Headers)
find_library(VVUVCKIT_LIBRARY VVUVCKit PATHS src/mynteye/uvc/macosx)
find_library(USB_LIBRARY USBBusProber PATHS src/mynteye/uvc/macosx)
MARK_AS_ADVANCED (VVUVCKIT_LIBRARY USB_LIBRARY)
SET(OSX_EXTRA_LIBS ${VVUVCKIT_LIBRARY} ${USB_LIBRARY})
set(UVC_SRC src/mynteye/uvc/macosx/CameraEngine.cpp src/mynteye/uvc/macosx/AVfoundationCamera.mm src/mynteye/uvc/macosx/uvc-vvuvckit.cc )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework CoreFoundation -framework AVFoundation -framework IOKit -framework AppKit -framework Cocoa -framework CoreMedia -framework CoreData -framework Foundation -framework CoreVideo ${__MACUVCLOG_FLAGS}")
find_package(libuvc REQUIRED) find_package(libuvc REQUIRED)
set(UVC_LIB ${libuvc_LIBRARIES}) set(UVC_LIB ${libuvc_LIBRARIES})
@ -190,6 +208,9 @@ endif()
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS}) add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS}) target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS})
if(OS_MAC)
target_link_libraries( ${MYNTEYE_NAME} ${OSX_EXTRA_LIBS} )
endif()
target_link_threads(${MYNTEYE_NAME}) target_link_threads(${MYNTEYE_NAME})
if(OS_WIN) if(OS_WIN)

View File

@ -1,6 +1,6 @@
# MYNT® EYE S SDK # MYNT® EYE S SDK
[![](https://img.shields.io/badge/MYNT%20EYE%20S%20SDK-2.2.2--rc1-brightgreen.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK) [![](https://img.shields.io/badge/MYNT%20EYE%20S%20SDK-2.2.2-brightgreen.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK)
## Overview ## Overview
@ -17,11 +17,11 @@ Please follow the guide doc to install the SDK on different platforms.
## Documentations ## Documentations
* [API Doc](https://github.com/slightech/MYNT-EYE-S-SDK/releases): API reference, some guides and data spec. * [API Doc](https://github.com/slightech/MYNT-EYE-S-SDK/releases): API reference, some guides and data spec.
* en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2612865/mynt-eye-s-sdk-apidoc-2.2.2-rc1-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2612866/mynt-eye-s-sdk-apidoc-2.2.2-rc1-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK/) * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683636/mynt-eye-s-sdk-apidoc-2.2.2-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683637/mynt-eye-s-sdk-apidoc-2.2.2-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK/)
* zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2612867/mynt-eye-s-sdk-apidoc-2.2.2-rc1-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2612868/mynt-eye-s-sdk-apidoc-2.2.2-rc1-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/api/mynt-eye-s-sdk-apidoc-2.2.2-rc1-zh-Hans/mynt-eye-s-sdk-apidoc-2.2.2-rc1-zh-Hans/index.html) * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683638/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683639/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/api/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans/index.html)
* [Guide Doc](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/releases): How to install and start using the SDK. * [Guide Doc](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/releases): How to install and start using the SDK.
* en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2612872/mynt-eye-s-sdk-guide-2.2.2-rc1-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2612873/mynt-eye-s-sdk-guide-2.2.2-rc1-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK-Guide/) * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683625/mynt-eye-s-sdk-guide-2.2.2-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683626/mynt-eye-s-sdk-guide-2.2.2-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK-Guide/)
* zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2612874/mynt-eye-s-sdk-guide-2.2.2-rc1-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2612875/mynt-eye-s-sdk-guide-2.2.2-rc1-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/sdk/mynt-eye-s-sdk-guide-2.2.2-rc1-zh-Hans/mynt-eye-s-sdk-guide-2.2.2-rc1-zh-Hans/index.html) * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683627/mynt-eye-s-sdk-guide-2.2.2-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683628/mynt-eye-s-sdk-guide-2.2.2-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/sdk/mynt-eye-s-sdk-guide-2.2.2-zh-Hans/mynt-eye-s-sdk-guide-2.2.2-zh-Hans/index.html)
> Supported languages: `en`, `zh-Hans`. > Supported languages: `en`, `zh-Hans`.

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE S SDK"
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 2.2.2-rc1 PROJECT_NUMBER = 2.2.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE S SDK"
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 2.2.2-rc1 PROJECT_NUMBER = 2.2.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View File

@ -15,6 +15,7 @@
#define MYNTEYE_API_API_H_ #define MYNTEYE_API_API_H_
#pragma once #pragma once
#include <functional>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <string> #include <string>

View File

@ -75,7 +75,7 @@ add_subdirectory(device)
# samples above uvc layer # samples above uvc layer
add_subdirectory(uvc) #add_subdirectory(uvc)
# tutorials # tutorials

View File

@ -124,7 +124,6 @@ make_executable2(ctrl_manual_exposure
SRCS control/manual_exposure.cc util/cv_painter.cc SRCS control/manual_exposure.cc util/cv_painter.cc
WITH_OPENCV WITH_OPENCV
) )
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
# intermediate level # intermediate level

View File

@ -24,16 +24,19 @@ int main(int argc, char *argv[]) {
auto &&api = API::Create(argc, argv); auto &&api = API::Create(argc, argv);
if (!api) if (!api)
return 1; return 1;
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
// auto-exposure: 0 // auto-exposure: 0
api->SetOptionValue(Option::EXPOSURE_MODE, 0); api->SetOptionValue(Option::EXPOSURE_MODE, 0);
// max_gain: range [0,48], default 48 // max_gain: range [0,255], default 8
api->SetOptionValue(Option::MAX_GAIN, 48); api->SetOptionValue(Option::MAX_GAIN, 8);
// max_exposure_time: range [0,240], default 240 // max_exposure_time: range [0,1000], default 333
api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 240); api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 333);
// desired_brightness: range [0,255], default 192 // desired_brightness: range [1,255], default 122
api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 192); api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 122);
// min_exposure_time: range [0,1000], default 0
api->SetOptionValue(Option::MIN_EXPOSURE_TIME, 0);
LOG(INFO) << "Enable auto-exposure"; LOG(INFO) << "Enable auto-exposure";
LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN); LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN);
@ -41,10 +44,12 @@ int main(int argc, char *argv[]) {
<< api->GetOptionValue(Option::MAX_EXPOSURE_TIME); << api->GetOptionValue(Option::MAX_EXPOSURE_TIME);
LOG(INFO) << "Set DESIRED_BRIGHTNESS to " LOG(INFO) << "Set DESIRED_BRIGHTNESS to "
<< api->GetOptionValue(Option::DESIRED_BRIGHTNESS); << api->GetOptionValue(Option::DESIRED_BRIGHTNESS);
LOG(INFO) << "Set MIN_EXPOSURE_TIME to "
<< api->GetOptionValue(Option::MIN_EXPOSURE_TIME);
api->Start(Source::VIDEO_STREAMING); api->Start(Source::VIDEO_STREAMING);
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE)); CVPainter painter(30);
cv::namedWindow("frame"); cv::namedWindow("frame");

View File

@ -22,22 +22,11 @@
MYNTEYE_USE_NAMESPACE MYNTEYE_USE_NAMESPACE
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
auto &&api = API::Create(argc, argv); auto &&api = API::Create(Resolution::RES_1280x400);
// auto &&api = API::Create(argc, argv);
if (!api) if (!api)
return 1; return 1;
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
// Attention: must set FRAME_RATE and IMU_FREQUENCY together, otherwise won't
// succeed.
// FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
api->SetOptionValue(Option::FRAME_RATE, 25);
// IMU_FREQUENCY values: 100, 200, 250, 333, 500
api->SetOptionValue(Option::IMU_FREQUENCY, 500);
LOG(INFO) << "Set FRAME_RATE to " << api->GetOptionValue(Option::FRAME_RATE);
LOG(INFO) << "Set IMU_FREQUENCY to "
<< api->GetOptionValue(Option::IMU_FREQUENCY);
// Count img // Count img
std::atomic_uint img_count(0); std::atomic_uint img_count(0);
api->SetStreamCallback( api->SetStreamCallback(
@ -46,13 +35,6 @@ int main(int argc, char *argv[]) {
++img_count; ++img_count;
}); });
// Count imu
std::atomic_uint imu_count(0);
api->SetMotionCallback([&imu_count](const api::MotionData &data) {
CHECK_NOTNULL(data.imu);
++imu_count;
});
api->Start(Source::ALL); api->Start(Source::ALL);
cv::namedWindow("frame"); cv::namedWindow("frame");
@ -85,7 +67,5 @@ int main(int argc, char *argv[]) {
<< ", cost: " << elapsed_ms << "ms"; << ", cost: " << elapsed_ms << "ms";
LOG(INFO) << "Img count: " << img_count LOG(INFO) << "Img count: " << img_count
<< ", fps: " << (1000.f * img_count / elapsed_ms); << ", fps: " << (1000.f * img_count / elapsed_ms);
LOG(INFO) << "Imu count: " << imu_count
<< ", hz: " << (1000.f * imu_count / elapsed_ms);
return 0; return 0;
} }

View File

@ -1,61 +0,0 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include "mynteye/logger.h"
#include "mynteye/api/api.h"
MYNTEYE_USE_NAMESPACE
int main(int argc, char *argv[]) {
auto &&api = API::Create(argc, argv);
if (!api)
return 1;
// Detect infrared add-ons
LOG(INFO) << "Support infrared: " << std::boolalpha
<< api->Supports(AddOns::INFRARED);
LOG(INFO) << "Support infrared2: " << std::boolalpha
<< api->Supports(AddOns::INFRARED2);
// Get infrared intensity range
auto &&info = api->GetOptionInfo(Option::IR_CONTROL);
LOG(INFO) << Option::IR_CONTROL << ": {" << info << "}";
// Set infrared intensity value
api->SetOptionValue(Option::IR_CONTROL, 80);
api->Start(Source::VIDEO_STREAMING);
cv::namedWindow("frame");
while (true) {
api->WaitForStreams();
auto &&left_data = api->GetStreamData(Stream::LEFT);
auto &&right_data = api->GetStreamData(Stream::RIGHT);
cv::Mat img;
cv::hconcat(left_data.frame, right_data.frame, img);
cv::imshow("frame", img);
char key = static_cast<char>(cv::waitKey(1));
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
break;
}
}
api->Stop(Source::VIDEO_STREAMING);
return 0;
}

View File

@ -24,25 +24,20 @@ int main(int argc, char *argv[]) {
auto &&api = API::Create(argc, argv); auto &&api = API::Create(argc, argv);
if (!api) if (!api)
return 1; return 1;
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
// manual-exposure: 1 // manual-exposure: 1
api->SetOptionValue(Option::EXPOSURE_MODE, 1); api->SetOptionValue(Option::EXPOSURE_MODE, 1);
// gain: range [0,48], default 24
api->SetOptionValue(Option::GAIN, 24);
// brightness/exposure_time: range [0,240], default 120 // brightness/exposure_time: range [0,240], default 120
api->SetOptionValue(Option::BRIGHTNESS, 120); api->SetOptionValue(Option::BRIGHTNESS, 120);
// contrast/black_level_calibration: range [0,255], default 127
api->SetOptionValue(Option::CONTRAST, 127);
LOG(INFO) << "Enable manual-exposure"; LOG(INFO) << "Enable manual-exposure";
LOG(INFO) << "Set GAIN to " << api->GetOptionValue(Option::GAIN);
LOG(INFO) << "Set BRIGHTNESS to " << api->GetOptionValue(Option::BRIGHTNESS); LOG(INFO) << "Set BRIGHTNESS to " << api->GetOptionValue(Option::BRIGHTNESS);
LOG(INFO) << "Set CONTRAST to " << api->GetOptionValue(Option::CONTRAST);
api->Start(Source::VIDEO_STREAMING); api->Start(Source::VIDEO_STREAMING);
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE)); CVPainter painter(30);
cv::namedWindow("frame"); cv::namedWindow("frame");

View File

@ -98,7 +98,7 @@ bool DisparityProcessor::OnProcess(
// whereas other algorithms output 32-bit floating-point disparity map. // whereas other algorithms output 32-bit floating-point disparity map.
sgbm_->compute(input->first, input->second, disparity); sgbm_->compute(input->first, input->second, disparity);
#endif #endif
output->value = disparity / 16 + 1; disparity.convertTo(output->value, CV_32F, 1./16, 1);
output->id = input->first_id; output->id = input->first_id;
output->data = input->first_data; output->data = input->first_data;
return true; return true;

View File

@ -36,7 +36,7 @@ std::shared_ptr<Device> select() {
LOG(ERROR) << "No MYNT EYE devices :("; LOG(ERROR) << "No MYNT EYE devices :(";
return nullptr; return nullptr;
} }
/*
LOG(INFO) << "MYNT EYE devices:"; LOG(INFO) << "MYNT EYE devices:";
for (size_t i = 0; i < n; i++) { for (size_t i = 0; i < n; i++) {
auto &&device = devices[i]; auto &&device = devices[i];
@ -44,7 +44,7 @@ std::shared_ptr<Device> select() {
<< ", name: " << device->GetInfo(Info::DEVICE_NAME) << ", name: " << device->GetInfo(Info::DEVICE_NAME)
<< ", sn: " << device->GetInfo(Info::SERIAL_NUMBER); << ", sn: " << device->GetInfo(Info::SERIAL_NUMBER);
} }
*/
std::shared_ptr<Device> device = nullptr; std::shared_ptr<Device> device = nullptr;
if (n <= 1) { if (n <= 1) {
device = devices[0]; device = devices[0];

View File

@ -0,0 +1,91 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef AVfoundationCamera_H
#define AVfoundationCamera_H
#import <AVFoundation/AVFoundation.h>
#import <Cocoa/Cocoa.h>
#import "VVUVCKit.h"
#include "CameraEngine.h"
static int32_t codec_table[] = { 0, 40, 0, 24, 0, 0, 0, 0, 0, 0, 'yuvs', '2vuy', 0, 'v308', '420v', '410v', 0, 0, 0, 0, 'dmb1', 'dmb1', 'mp1v', 'mp2v', 'mp4v', 'h263', 'avc1', 'dvcp', 'dvc ' };
@interface FrameGrabber : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>
{
bool new_frame;
int cam_width, cam_height;
int frm_width, frm_height;
int xoff, yoff;
unsigned char *buffer;
bool crop;
bool color;
}
- (id) initWithCameraSize:(int)w :(int)h :(int)b;
- (id) initWithCropSize:(int)cw :(int)ch :(int)b :(int)fw :(int)fh :(int)xo :(int)yo;
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection;
- (unsigned char*) getFrame;
@end
class AVfoundationCamera : public CameraEngine
{
public:
AVfoundationCamera(CameraConfig* cam_cfg);
~AVfoundationCamera();
static int getDeviceCount();
static std::vector<CameraConfig> getCameraConfigs(int dev_id = -1);
static CameraEngine* getCamera(CameraConfig* cam_cfg);
bool initCamera();
bool startCamera();
unsigned char* getFrame();
bool stopCamera();
bool stillRunning();
bool resetCamera();
bool closeCamera();
int getCameraSettingStep(int mode);
bool setCameraSettingAuto(int mode, bool flag);
bool getCameraSettingAuto(int mode);
bool setCameraSetting(int mode, int value);
int getCameraSetting(int mode);
int getMaxCameraSetting(int mode);
int getMinCameraSetting(int mode);
bool setDefaultCameraSetting(int mode);
int getDefaultCameraSetting(int mode);
bool hasCameraSetting(int mode);
bool hasCameraSettingAuto(int mode);
bool showSettingsDialog(bool lock);
private:
bool disconnected;
VVUVCController *uvcController;
FrameGrabber *grabber;
AVCaptureSession *session;
AVCaptureDeviceInput *videoDeviceInput;
AVCaptureVideoDataOutput *videoOutput;
AVCaptureDevice *videoDevice;
};
#endif

View File

@ -0,0 +1,739 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "AVfoundationCamera.h"
#include <iostream>
#include <vector>
// #include "CameraTool.h"
#ifdef OSC_HOST_BIG_ENDIAN
#define FourCC2Str(fourcc) (const char[]){*((char*)&fourcc), *(((char*)&fourcc)+1), *(((char*)&fourcc)+2), *(((char*)&fourcc)+3),0}
#else
#define FourCC2Str(fourcc) (const char[]){*(((char*)&fourcc)+3), *(((char*)&fourcc)+2), *(((char*)&fourcc)+1), *(((char*)&fourcc)+0),0}
#endif
@implementation FrameGrabber
- (id) initWithCameraSize:(int)cw :(int)ch :(int) bytes
{
self = [super init];
cam_width = cw;
cam_height = ch;
new_frame = false;
crop = false;
if(bytes==3) color = true;
else color = false;
buffer = new unsigned char[cam_width*cam_height*bytes];
return self;
}
- (id) initWithCropSize:(int)cw :(int)ch :(int)bytes :(int)fw :(int)fh :(int)xo :(int)yo
{
self = [super init];
cam_width = cw;
cam_height = ch;
frm_width = fw;
frm_height = fh;
xoff = xo;
yoff = yo;
new_frame = false;
crop = true;
if(bytes==3) color = true;
else color = false;
buffer = new unsigned char[frm_width*frm_height*bytes];
return self;
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
new_frame = false;
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
if (CVPixelBufferLockBaseAddress(imageBuffer, 0) == kCVReturnSuccess) {
unsigned char *src = (unsigned char*)CVPixelBufferGetBaseAddress(imageBuffer);
unsigned char *dest = buffer;
if (color) {
if (crop) {
unsigned char *src_buf = src + 3*(yoff*cam_width + xoff);
for (int i=0;i<frm_height;i++) {
memcpy(dest, src_buf, 3*frm_width);
src_buf += 3*cam_width;
dest += 3*frm_width;
}
} else {
memcpy(dest,src,cam_width*cam_height*3);
}
} else {
if (crop) {
src += 2*(yoff*cam_width);
int xend = (cam_width-(frm_width+xoff));
for (int i=0;i<frm_height;i++) {
src += 2*xoff;
for (int j=frm_width/2;j>0;j--) {
*dest++ = *src++;
src++;
*dest++ = *src++;
src++;
}
src += 2*xend;
}
} else {
int size = cam_width*cam_height/2;
for (int i=size;i>0;i--) {
*dest++ = *src++;
src++;
*dest++ = *src++;
src++;
}
}
}
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
new_frame = true;
}
}
- (unsigned char*) getFrame
{
if (new_frame){
new_frame = false;
return buffer;
} else return NULL;
}
- (void)dealloc
{
if(buffer) delete []buffer;
[super dealloc];
}
@end
AVfoundationCamera::AVfoundationCamera(CameraConfig *cam_cfg):CameraEngine(cam_cfg)
{
disconnected = false;
running=false;
lost_frames=0;
timeout = 1000;
uvcController = NULL;
session = NULL;
videoDeviceInput = NULL;
videoOutput = NULL;
videoDevice = NULL;
grabber = NULL;
cam_cfg->driver = DRIVER_DEFAULT;
}
AVfoundationCamera::~AVfoundationCamera()
{
if (uvcController) [uvcController release];
//if (videoDevice) [videoDevice release];
if (videoOutput) [videoOutput release];
if (grabber) [grabber release];
}
int AVfoundationCamera::getDeviceCount() {
NSInteger dev_count0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo].count;
NSInteger dev_count1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed].count;
return (dev_count0 + dev_count1);
}
std::vector<CameraConfig> AVfoundationCamera::getCameraConfigs(int dev_id) {
std::vector<CameraConfig> cfg_list;
int dev_count = getDeviceCount();
if (dev_count==0) return cfg_list;
NSMutableArray *captureDevices = [NSMutableArray arrayWithCapacity:dev_count];
NSArray *dev_list0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice* device in dev_list0) [captureDevices addObject:device];
NSArray *dev_list1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];
for (AVCaptureDevice* device in dev_list1)[captureDevices addObject:device];
int cam_id = -1;
for (AVCaptureDevice* device in captureDevices) {
cam_id ++;
if ((dev_id>=0) && (dev_id!=cam_id)) continue;
CameraConfig cam_cfg;
// CameraTool::initCameraConfig(&cam_cfg);
cam_cfg.driver = DRIVER_DEFAULT;
cam_cfg.device = cam_id;
if ([device localizedName]!=NULL)
sprintf(cam_cfg.name,"%s",[[device localizedName] cStringUsingEncoding:NSUTF8StringEncoding]);
else sprintf(cam_cfg.name,"unknown device");
std::vector<CameraConfig> fmt_list;
int last_format = FORMAT_UNKNOWN;
NSArray *captureDeviceFormats = [device formats];
for (AVCaptureDeviceFormat *format in captureDeviceFormats) {
int32_t codec = CMVideoFormatDescriptionGetCodecType((CMVideoFormatDescriptionRef)[format formatDescription]);
if (codec == '420f') codec = '420v';
cam_cfg.cam_format = FORMAT_UNKNOWN;
for (int i=FORMAT_MAX-1;i>0;i--) {
if (codec == codec_table[i]) {
cam_cfg.cam_format = i;
break;
}
}
if (cam_cfg.cam_format != last_format) {
std::sort(fmt_list.begin(), fmt_list.end());
cfg_list.insert( cfg_list.end(), fmt_list.begin(), fmt_list.end() );
fmt_list.clear();
last_format = cam_cfg.cam_format;
}
CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
cam_cfg.cam_width = dim.width;
cam_cfg.cam_height = dim.height;
for (AVFrameRateRange *frameRateRange in [format videoSupportedFrameRateRanges]) {
cam_cfg.cam_fps = roundf([frameRateRange maxFrameRate]*10)/10.0f;
fmt_list.push_back(cam_cfg);
}
}
std::sort(fmt_list.begin(), fmt_list.end());
cfg_list.insert( cfg_list.end(), fmt_list.begin(), fmt_list.end() );
}
//[captureDevices release];
return cfg_list;
}
CameraEngine* AVfoundationCamera::getCamera(CameraConfig *cam_cfg) {
int dev_count = getDeviceCount();
if (dev_count==0) return NULL;
if ((cam_cfg->device==SETTING_MIN) || (cam_cfg->device==SETTING_DEFAULT)) cam_cfg->device=0;
else if (cam_cfg->device==SETTING_MAX) cam_cfg->device=dev_count-1;
std::vector<CameraConfig> cfg_list = AVfoundationCamera::getCameraConfigs(cam_cfg->device);
if (cam_cfg->cam_format==FORMAT_UNKNOWN) cam_cfg->cam_format = cfg_list[0].cam_format;
setMinMaxConfig(cam_cfg,cfg_list);
if (cam_cfg->force) return new AVfoundationCamera(cam_cfg);
for (int i=0;i<cfg_list.size();i++) {
if (cam_cfg->cam_format != cfg_list[i].cam_format) continue;
if ((cam_cfg->cam_width >=0) && (cam_cfg->cam_width != cfg_list[i].cam_width)) continue;
if ((cam_cfg->cam_height >=0) && (cam_cfg->cam_height != cfg_list[i].cam_height)) continue;
if ((cam_cfg->cam_fps >=0) && (cam_cfg->cam_fps != cfg_list[i].cam_fps)) continue;
return new AVfoundationCamera(cam_cfg);
}
return NULL;
}
bool AVfoundationCamera::initCamera() {
int dev_count = getDeviceCount();
if ((dev_count==0) || (cfg->device < 0) || (cfg->device>=dev_count)) return false;
NSMutableArray *videoDevices = [NSMutableArray arrayWithCapacity:dev_count];
NSArray *dev_list0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice* dev in dev_list0) [videoDevices addObject:dev];
NSArray *dev_list1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];
for (AVCaptureDevice* dev in dev_list1) [videoDevices addObject:dev];
videoDevice = [videoDevices objectAtIndex:cfg->device];
if (videoDevice==NULL) return false;
//else [videoDevices release];
if ([videoDevice localizedName]!=NULL)
sprintf(cfg->name,"%s",[[videoDevice localizedName] cStringUsingEncoding:NSUTF8StringEncoding]);
else sprintf(cfg->name,"unknown");
session = [[AVCaptureSession alloc] init];
if (session==NULL) return false;
NSError *error = nil;
videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (videoDeviceInput == NULL) return false;
std::vector<CameraConfig> cfg_list = getCameraConfigs(cfg->device);
if (cfg->cam_format==FORMAT_UNKNOWN) cfg->cam_format = cfg_list[0].cam_format;
setMinMaxConfig(cfg, cfg_list);
AVCaptureDeviceFormat *selectedFormat = NULL;
AVFrameRateRange *selectedFrameRateRange = NULL;
NSArray *videoDeviceFormats = [videoDevice formats];
for (AVCaptureDeviceFormat *format in videoDeviceFormats) {
CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
if ((dim.width!=cfg->cam_width) || (dim.height!=cfg->cam_height)) continue; // wrong size
int cam_format=0;
int32_t codec = CMVideoFormatDescriptionGetCodecType((CMVideoFormatDescriptionRef)[format formatDescription]);
if (codec == '420f') codec = '420v';
for (int i=FORMAT_MAX-1;i>0;i--) {
if ((codec == codec_table[i]) && (cfg->cam_format==i)) {
cam_format = i;
break;
}
}
if (!cam_format) continue; // wrong format
else selectedFormat = format;
for (AVFrameRateRange *frameRateRange in [selectedFormat videoSupportedFrameRateRanges]) {
float framerate = roundf([frameRateRange maxFrameRate]*10)/10.0f;
if (framerate==cfg->cam_fps) { // found exact framerate
selectedFrameRateRange = frameRateRange;
break;
}
}
if (selectedFrameRateRange) break;
}
if ((selectedFrameRateRange==NULL) || (selectedFormat==NULL)) return false;
[videoDevice lockForConfiguration:&error];
[videoDevice setActiveFormat:selectedFormat];
if ([[[videoDevice activeFormat] videoSupportedFrameRateRanges] containsObject:selectedFrameRateRange]) {
//[videoDevice setActiveVideoMaxFrameDuration:[selectedFrameRateRange maxFrameDuration]];
[videoDevice setActiveVideoMinFrameDuration:[selectedFrameRateRange minFrameDuration]];
}
[videoDevice unlockForConfiguration];
CMVideoDimensions dimensions =
CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[[videoDevice activeFormat] formatDescription]);
cfg->cam_width = dimensions.width;
cfg->cam_height = dimensions.height;
for (AVFrameRateRange *frameRateRange in [[videoDevice activeFormat] videoSupportedFrameRateRanges])
{
cfg->cam_fps = roundf([frameRateRange maxFrameRate]*10)/10.0f;
if (CMTIME_COMPARE_INLINE([frameRateRange minFrameDuration], ==, [videoDevice activeVideoMinFrameDuration])) {
break;
}
}
videoOutput = [[AVCaptureVideoDataOutput alloc] init];
unsigned int pixelformat = kCVPixelFormatType_422YpCbCr8_yuvs;
cfg->src_format = FORMAT_YUYV;
if (cfg->color) {
pixelformat = kCVPixelFormatType_24RGB;
cfg->src_format = FORMAT_RGB;
}
NSDictionary *pixelBufferOptions = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithDouble:cfg->cam_width], (id)kCVPixelBufferWidthKey,
[NSNumber numberWithDouble:cfg->cam_height], (id)kCVPixelBufferHeightKey,
[NSNumber numberWithUnsignedInt: pixelformat ],
(id)kCVPixelBufferPixelFormatTypeKey, nil];
[videoOutput setVideoSettings:pixelBufferOptions];
videoOutput.alwaysDiscardsLateVideoFrames = YES;
[session addInput:videoDeviceInput];
[session addOutput:videoOutput];
// configure output.
setupFrame();
dispatch_queue_t queue = dispatch_queue_create("queue", NULL);
if (cfg->frame) {
grabber = [[FrameGrabber alloc] initWithCropSize:cfg->cam_width :cfg->cam_height :cfg->buf_format :cfg->frame_width :cfg->frame_height :cfg->frame_xoff :cfg->frame_yoff];
} else {
grabber = [[FrameGrabber alloc] initWithCameraSize:cfg->cam_width :cfg->cam_height: cfg->buf_format];
}
[videoOutput setSampleBufferDelegate:grabber queue:queue];
dispatch_release(queue);
NSString *uniqueID = [videoDevice uniqueID];
if (uniqueID!=NULL) {
uvcController = [[VVUVCController alloc] initWithDeviceIDString:[videoDevice uniqueID]];
if (uvcController) [uvcController resetParamsToDefaults];
} // else std::cout << "VVUVCController NULL" << std::endl;
return true;
}
unsigned char* AVfoundationCamera::getFrame()
{
unsigned char *cambuffer = [grabber getFrame];
if (cambuffer!=NULL) {
timeout=100;
lost_frames=0;
return cambuffer;
} else {
usleep(10000);
lost_frames++;
if (lost_frames>timeout) {
disconnected=true;
running=false;
}
return NULL;
}
return NULL;
}
bool AVfoundationCamera::startCamera()
{
[session startRunning];
applyCameraSettings();
running = true;
return true;
}
bool AVfoundationCamera::stopCamera()
{
[session stopRunning];
running=false;
return true;
}
bool AVfoundationCamera::stillRunning() {
return running;
}
bool AVfoundationCamera::resetCamera()
{
return (stopCamera() && startCamera());
}
bool AVfoundationCamera::closeCamera()
{
if ((uvcController) && (!disconnected)) {
updateSettings();
// CameraTool::saveSettings();
}
[session release];
return true;
}
bool AVfoundationCamera::showSettingsDialog(bool lock) {
if (uvcController) {
[uvcController closeSettingsWindow];
[uvcController openSettingsWindow];
}
return lock;
}
bool AVfoundationCamera::hasCameraSettingAuto(int mode) {
if (uvcController==NULL) return false;
switch (mode) {
case EXPOSURE:
return [uvcController autoExposureModeSupported];
case WHITE:
return [uvcController autoWhiteBalanceSupported];
case FOCUS:
return [uvcController autoFocusSupported];
case COLOR_HUE:
return [uvcController autoHueSupported];
}
return false;
}
bool AVfoundationCamera::getCameraSettingAuto(int mode) {
if (uvcController==NULL) return false;
if (!hasCameraSettingAuto(mode)) return false;
switch (mode) {
case EXPOSURE:
if ([uvcController autoExposureMode]>UVC_AEMode_Manual) return true;
else return false;
case WHITE:
return [uvcController autoWhiteBalance];
case FOCUS:
return [uvcController autoFocus];
case COLOR_HUE:
return [uvcController autoHue];
}
return false;
}
bool AVfoundationCamera::setCameraSettingAuto(int mode, bool flag) {
if (uvcController==NULL) return false;
if (!hasCameraSettingAuto(mode)) return false;
switch (mode) {
case EXPOSURE:
if (flag==true) [uvcController setAutoExposureMode:UVC_AEMode_Auto];
else [uvcController setAutoExposureMode:UVC_AEMode_Manual];
return true;
case WHITE:
[uvcController setAutoWhiteBalance:flag];
return true;
case FOCUS:
[uvcController setAutoFocus:flag];
return true;
case COLOR_HUE:
[uvcController setAutoHue:flag];
return true;
}
return false;
}
bool AVfoundationCamera::hasCameraSetting(int mode) {
if (uvcController==NULL) return false;
switch (mode) {
case BRIGHTNESS: return [uvcController brightSupported];
case CONTRAST: return [uvcController contrastSupported];
case SHARPNESS: return [uvcController sharpnessSupported];
case GAMMA: return [uvcController gammaSupported];
case GAIN: return [uvcController gainSupported];
case AUTO_GAIN: return hasCameraSettingAuto(GAIN);
case EXPOSURE: return [uvcController exposureTimeSupported];
case AUTO_EXPOSURE: return hasCameraSettingAuto(EXPOSURE);
case FOCUS: return [uvcController focusSupported];
case AUTO_FOCUS: return hasCameraSettingAuto(FOCUS);
case WHITE: return [uvcController whiteBalanceSupported];
case AUTO_WHITE: return hasCameraSettingAuto(WHITE);
case BACKLIGHT: return [uvcController backlightSupported];
case SATURATION: return [uvcController saturationSupported];
case COLOR_HUE: return [uvcController hueSupported];
case AUTO_HUE: return hasCameraSettingAuto(COLOR_HUE);
case POWERLINE: return [uvcController powerLineSupported];
}
return false;
}
bool AVfoundationCamera::setCameraSetting(int mode, int setting) {
if (uvcController==NULL) return false;
if (!hasCameraSetting(mode)) return false;
setCameraSettingAuto(mode, false);
switch (mode) {
case BRIGHTNESS: [uvcController setBright:setting]; return true;
case CONTRAST: [uvcController setContrast:setting]; return true;
case SHARPNESS: [uvcController setSharpness:setting]; return true;
case GAIN: [uvcController setGain:setting]; return true;
case GAMMA: [uvcController setGamma:setting]; return true;
case EXPOSURE: [uvcController setExposureTime:setting]; return true;
case FOCUS: [uvcController setFocus:setting]; return true;
case WHITE: [uvcController setWhiteBalance:setting]; return true;
case BACKLIGHT: [uvcController setBacklight:setting]; return true;
case SATURATION: [uvcController setSaturation:setting]; return true;
case COLOR_HUE: [uvcController setHue:setting]; return true;
case POWERLINE: [uvcController setPowerLine:setting]; return true;
}
return false;
}
int AVfoundationCamera::getCameraSetting(int mode) {
if (uvcController==NULL) return 0;
if (!hasCameraSetting(mode)) return 0;
//if (getCameraSettingAuto(mode)) return 0;
switch (mode) {
case BRIGHTNESS: return [uvcController bright];
case CONTRAST: return [uvcController contrast];
case SHARPNESS: return [uvcController sharpness];
case GAIN: return [uvcController gain];
case GAMMA: return [uvcController gamma];
case EXPOSURE: return [uvcController exposureTime];
case FOCUS: return [uvcController focus];
case WHITE: return [uvcController whiteBalance];
case BACKLIGHT: return [uvcController backlight];
case SATURATION: return [uvcController saturation];
case COLOR_HUE: return [uvcController hue];
case POWERLINE: return [uvcController powerLine];
}
return 0;
}
int AVfoundationCamera::getMaxCameraSetting(int mode) {
if (uvcController==NULL) return 0;
if (!hasCameraSetting(mode)) return 0;
//if (getCameraSettingAuto(mode)) return 0;
switch (mode) {
case BRIGHTNESS: return [uvcController maxBright];
case CONTRAST: return [uvcController maxContrast];
case SHARPNESS: return [uvcController maxSharpness];
case GAIN: return [uvcController maxGain];
case GAMMA: return [uvcController maxGamma];
case EXPOSURE: return [uvcController maxExposureTime];
case FOCUS: return [uvcController maxFocus];
case WHITE: return [uvcController maxWhiteBalance];
case BACKLIGHT: return [uvcController maxBacklight];
case SATURATION: return [uvcController maxSaturation];
case COLOR_HUE: return [uvcController maxHue];
case POWERLINE: return [uvcController maxPowerLine];
}
return 0;
}
int AVfoundationCamera::getMinCameraSetting(int mode) {
if (uvcController==NULL) return 0;
if (!hasCameraSetting(mode)) return 0;
//if (getCameraSettingAuto(mode)) return 0;
switch (mode) {
case BRIGHTNESS: return [uvcController minBright];
case CONTRAST: return [uvcController minContrast];
case GAIN: return [uvcController minGain];
case GAMMA: return [uvcController minGamma];
case EXPOSURE: return [uvcController minExposureTime];
case SHARPNESS: return [uvcController minSharpness];
case FOCUS: return [uvcController minFocus];
case WHITE: return [uvcController minWhiteBalance];
case BACKLIGHT: return [uvcController minBacklight];
case SATURATION: return [uvcController minSaturation];
case COLOR_HUE: return [uvcController minHue];
case POWERLINE: return [uvcController minPowerLine];
}
return 0;
}
bool AVfoundationCamera::setDefaultCameraSetting(int mode) {
if (uvcController==NULL) return false;
if (!hasCameraSetting(mode)) return false;
setCameraSettingAuto(mode, false);
switch (mode) {
case BRIGHTNESS:
[uvcController resetBright];
default_brightness = [uvcController bright];
break;
case CONTRAST:
[uvcController resetContrast];
default_contrast = [uvcController contrast];
break;
case SHARPNESS:
[uvcController resetSharpness];
default_sharpness = [uvcController sharpness];
break;
case GAIN:
[uvcController resetGain];
default_gain = [uvcController gain];
break;
case GAMMA:
[uvcController resetGamma];
default_gamma = [uvcController gamma];
break;
case EXPOSURE:
[uvcController resetExposureTime];
default_exposure = [uvcController exposureTime];
break;
case FOCUS:
[uvcController resetFocus];
default_focus = [uvcController focus];
break;
case WHITE:
[uvcController resetWhiteBalance];
default_white = [uvcController whiteBalance];
break;
case BACKLIGHT:
[uvcController resetBacklight];
default_backlight = [uvcController backlight];
break;
case SATURATION:
[uvcController resetSaturation];
default_saturation = [uvcController saturation];
break;
case COLOR_HUE:
[uvcController resetHue];
default_hue = [uvcController hue];
break;
case POWERLINE:
[uvcController resetPowerLine];
default_powerline = [uvcController powerLine];
break;
}
return false;
}
int AVfoundationCamera::getDefaultCameraSetting(int mode) {
if (uvcController==NULL) return 0;
if (!hasCameraSetting(mode)) return 0;
switch (mode) {
case BRIGHTNESS: return default_brightness;
case CONTRAST: return default_contrast;
case GAIN: return default_gain;
case GAMMA: return default_gamma;
case EXPOSURE: return default_exposure;
case SHARPNESS: return default_sharpness;
case FOCUS: return default_focus;
case WHITE: return default_white;
case BACKLIGHT: return default_backlight;
case SATURATION: return default_saturation;
case COLOR_HUE: return default_hue;
case POWERLINE: return default_powerline;
}
return 0;
}
int AVfoundationCamera::getCameraSettingStep(int mode) {
if (!hasCameraSetting(mode)) return 0;
return 1;
}

View File

@ -0,0 +1,697 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <vector>
#include "CameraEngine.h"
const char* dstr[] = { "default","dc1394","ps3eye","raspi","uvccam","","","","","","file","folder"};
const char* fstr[] = { "unknown", "mono8", "mono16", "rgb8", "rgb16", "mono16s", "rgb16s", "raw8", "raw16", "rgba", "yuyv", "uyvy", "yuv411", "yuv444", "yuv420p", "yuv410p", "yvyu", "yuv211", "", "", "jpeg", "mjpeg", "mpeg", "mpeg2", "mpeg4", "h263", "h264", "", "", "", "dvpal", "dvntsc" };
void CameraEngine::printInfo() {
printf("camera: %s\n",cfg->name);
printf("driver: %s\n",dstr[cfg->driver]);
printf("codec: %s\n",fstr[cfg->cam_format]);
if (cfg->frame_mode<0) {
if (cfg->cam_fps==(int)cfg->cam_fps) printf("format: %dx%d, %dfps\n",cfg->frame_width,cfg->frame_height,(int)cfg->cam_fps);
else printf("format: %dx%d, %.1ffps\n",cfg->frame_width,cfg->frame_height,cfg->cam_fps);
}
else printf("format7_%d: %dx%d\n",cfg->frame_mode,cfg->frame_width,cfg->frame_height);
}
void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list) {
if ((cam_cfg->cam_width>0) && (cam_cfg->cam_height>0) && (cam_cfg->cam_fps>0)) return;
int max_width = 0;
int max_height = 0;
int min_width = INT_MAX;
int min_height = INT_MAX;
float max_fps = 0;
float min_fps = INT_MAX;
for (unsigned int i=0;i<cfg_list.size();i++) {
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
if (cfg_list[i].cam_width>max_width) max_width = cfg_list[i].cam_width;
if (cfg_list[i].cam_width<min_width) min_width = cfg_list[i].cam_width;
if (cfg_list[i].cam_height>max_height) max_height = cfg_list[i].cam_height;
if (cfg_list[i].cam_width<min_height) min_height = cfg_list[i].cam_height;
}
if ((cam_cfg->cam_width==SETTING_MAX) || (cam_cfg->cam_width>max_width)) cam_cfg->cam_width = max_width;
else if ((cam_cfg->cam_width==SETTING_MIN) || (cam_cfg->cam_width<min_width)) cam_cfg->cam_width = min_width;
if ((cam_cfg->cam_height==SETTING_MAX) || (cam_cfg->cam_height>max_height)) cam_cfg->cam_height = max_height;
else if ((cam_cfg->cam_height==SETTING_MIN) || (cam_cfg->cam_height<min_height)) cam_cfg->cam_height = min_height;
if (cam_cfg->cam_fps>0) return;
for (unsigned int i=0;i<cfg_list.size();i++) {
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
if ((cfg_list[i].cam_width!=cam_cfg->cam_width) || (cfg_list[i].cam_height!=cam_cfg->cam_height)) continue; // wrong size
if (cfg_list[i].cam_fps>max_fps) max_fps = cfg_list[i].cam_fps;
if (cfg_list[i].cam_fps<min_fps) min_fps = cfg_list[i].cam_fps;
}
if ((cam_cfg->cam_fps==SETTING_MAX) || (cam_cfg->cam_fps>max_fps)) cam_cfg->cam_fps = max_fps;
if ((cam_cfg->cam_fps==SETTING_MIN) || (cam_cfg->cam_fps<min_fps)) cam_cfg->cam_fps = min_fps;
}
bool CameraEngine::showSettingsDialog(bool lock) {
return true;
}
void CameraEngine::control(unsigned char key) {
if(!settingsDialog) return;
int step = 0;
switch(key) {
case VALUE_DECREASE:
step = getCameraSettingStep(currentCameraSetting);
if (step==1) step = (int)((float)ctrl_max/256.0f);
if (step<1) step=1;
ctrl_val -= step;
if (ctrl_val<ctrl_min) ctrl_val=ctrl_min;
setCameraSetting(currentCameraSetting,ctrl_val);
break;
case VALUE_INCREASE:
step = getCameraSettingStep(currentCameraSetting);
if (step==1) step = (int)((float)ctrl_max/256.0f);
if (step<1) step=1;
ctrl_val += step;
if (ctrl_val>ctrl_max) ctrl_val=ctrl_max;
setCameraSetting(currentCameraSetting,ctrl_val);
break;
case SETTING_PREVIOUS:
currentCameraSetting--;
if(currentCameraSetting<0) {
if (cfg->color) currentCameraSetting=COLOR_BLUE;
else currentCameraSetting=BACKLIGHT;
}
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
control(SETTING_PREVIOUS);
break;
case SETTING_NEXT:
currentCameraSetting++;
if ((cfg->color) && (currentCameraSetting>COLOR_BLUE)) currentCameraSetting=0;
else if ((!cfg->color) && (currentCameraSetting>BACKLIGHT)) currentCameraSetting=0;
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
control(SETTING_NEXT);
break;
case KEY_D:
resetCameraSettings();
break;
}
ctrl_val = getCameraSetting(currentCameraSetting);
ctrl_max = getMaxCameraSetting(currentCameraSetting);
ctrl_min = getMinCameraSetting(currentCameraSetting);
}
void CameraEngine::uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest) {
for (int i=height*width/2;i>0;i--) {
src++;
*dest++ = *src++;
src++;
*dest++ = *src++;
}
}
void CameraEngine::crop_uyvy2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
cam_buf += 2*x_off;
for (int j=frm_w/2;j>0;j--) {
cam_buf++;
*frm_buf++ = *cam_buf++;
cam_buf++;
*frm_buf++ = *cam_buf++;
}
cam_buf += 2*x_end;
}
}
void CameraEngine::yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest) {
for (int i=height*width/2;i>0;i--) {
*dest++ = *src++;
src++;
*dest++ = *src++;
src++;
}
}
void CameraEngine::crop_yuyv2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
cam_buf += 2*x_off;
for (int j=frm_w/2;j>0;j--) {
*frm_buf++ = *cam_buf++;
cam_buf++;
*frm_buf++ = *cam_buf++;
cam_buf++;
}
cam_buf += 2*x_end;
}
}
//void yuv2rgb_conv(int Y1, int Y2, int U, int V, unsigned char *dest) {
void yuv2rgb_conv(int Y, int U, int V, unsigned char *dest) {
/*int R = (int)(Y + 1.370705f * V);
int G = (int)(Y - 0.698001f * V - 0.337633f * U);
int B = (int)(Y + 1.732446f * U);*/
// integer method is twice as fast
int C = 298*(Y - 16);
int R = (C + 409*V + 128) >> 8;
int G = (C - 100*U - 208*V + 128) >> 8;
int B = (C + 516*U + 128) >> 8;
SAT(R);
SAT(G);
SAT(B);
*dest++ = R;
*dest++ = G;
*dest++ = B;
}
void CameraEngine::uyvy2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
int Y1,Y2,U,V;
for(int i=width*height/2;i>0;i--) {
// U and V are +-0.5
U = *src++ - 128;
Y1 = *src++;
V = *src++ - 128;
Y2 = *src++;
yuv2rgb_conv(Y1,U,V,dest);
yuv2rgb_conv(Y2,U,V,dest+=3);
dest+=3;
}
}
void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
int Y1,Y2,U,V;
cam_buf += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
cam_buf += 2*x_off;
for (int j=frm_w/2;j>0;j--) {
// U and V are +-0.5
U = *cam_buf++ - 128;
Y1 = *cam_buf++;
V = *cam_buf++ - 128;
Y2 = *cam_buf++;
yuv2rgb_conv(Y1,U,V,frm_buf);
yuv2rgb_conv(Y2,U,V,frm_buf+=3);
frm_buf+=3;
}
cam_buf += 2*x_end;
}
}
void CameraEngine::yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
int Y1,Y2,U,V;
for(int i=width*height/2;i>0;i--) {
Y1 = *src++;
U = *src++ - 128;
Y2 = *src++;
V = *src++ - 128;
yuv2rgb_conv(Y1,U,V,dest);
yuv2rgb_conv(Y2,U,V,dest+=3);
dest+=3;
}
}
void CameraEngine::crop_yuyv2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
int Y1,Y2,U,V;
cam_buf += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
cam_buf += 2*x_off;
for (int j=frm_w/2;j>0;j--) {
// U and V are +-0.5
Y1 = *cam_buf++;
U = *cam_buf++ - 128;
Y2 = *cam_buf++;
V = *cam_buf++ - 128;
yuv2rgb_conv(Y1,U,V,frm_buf);
yuv2rgb_conv(Y2,U,V,frm_buf+=3);
frm_buf+=3;
}
cam_buf += 2*x_end;
}
}
void CameraEngine::gray2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
int size = width*height;
for (int i=size;i>0;i--) {
unsigned char pixel = *src++;
*dest++ = pixel;
*dest++ = pixel;
*dest++ = pixel;
}
}
void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
cam_buf += x_off;
for (int j=frm_w;j>0;j--) {
unsigned char pixel = *cam_buf++;
*frm_buf++ = pixel;
*frm_buf++ = pixel;
*frm_buf++ = pixel;
}
cam_buf += x_end;
}
}
void CameraEngine::grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
unsigned short src_pixel;
unsigned char dest_pixel;
unsigned char pixel;
for(int i=width*height;i>0;i--) {
pixel = *src++ ;
src_pixel = pixel | (*src++ << 8);
dest_pixel = (unsigned char)(src_pixel/4);
*dest++ = dest_pixel;
*dest++ = dest_pixel;
*dest++ = dest_pixel;
}
}
void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src, unsigned char *dest) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
unsigned short src_pixel;
unsigned char dest_pixel;
unsigned char pixel;
src += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
src += 2*x_off;
for (int j=frm_w;j>0;j--) {
pixel = *src++;
src_pixel = pixel | (*src++ << 8);
dest_pixel = (unsigned char)(src_pixel/4);
*dest++ = dest_pixel;
*dest++ = dest_pixel;
*dest++ = dest_pixel;
}
src += 2*x_end;
}
}
void CameraEngine::grayw2gray(int width, int height, unsigned char *src, unsigned char *dest) {
unsigned short value;
unsigned char pixel;
for(int i=width*height;i>0;i--) {
pixel = *src++;
value = pixel | (*src++ << 8);
*dest++ = (unsigned char)(value/4);
}
}
void CameraEngine::crop_grayw2gray(int cam_w, unsigned char *src, unsigned char *dest) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
unsigned short src_pixel;
unsigned char pixel;
src += 2*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
for (int i=frm_h;i>0;i--) {
src += 2*x_off;
for (int j=frm_w;j>0;j--) {
pixel = *src++;
src_pixel = pixel | (*src++ << 8);
*dest++ = (unsigned char)(src_pixel/4);
}
src += 2*x_end;
}
}
void CameraEngine::crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += b*(y_off*cam_w + x_off);
for (int i=frm_h;i>0;i--) {
memcpy(frm_buf, cam_buf, b*cam_w);
cam_buf += b*cam_w;
frm_buf += b*frm_w;
}
}
void CameraEngine::flip(int width, int height, unsigned char *src, unsigned char *dest, int b) {
int size = b*width*height;
dest += size-1;
for(int i=size;i>0;i--) {
*dest-- = *src++;
}
}
void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += b*y_off*cam_w;
frm_buf += b*frm_w*frm_h-1;
int xend = (cam_w-(frm_w+x_off));
for (int i=frm_h;i>0;i--) {
cam_buf += b*x_off;
for (int j=b*frm_w;j>0;j--) {
*frm_buf-- = *cam_buf++;
}
cam_buf += b*xend;
}
}
void CameraEngine::rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
int R,G,B;
for (int i=width*height;i>0;i--) {
R = *src++;
G = *src++;
B = *src++;
*dest++ = HBT(R*77 + G*151 + B*28);
}
}
void CameraEngine::flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
int size = width*height;
dest += size-1;
int R,G,B;
for (int i=size;i>0;i--) {
R = *src++;
G = *src++;
B = *src++;
*dest-- = HBT(R*77 + G*151 + B*28);
}
}
void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += 3*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
int R,G,B;
for (int i=frm_h;i>0;i--) {
cam_buf += 3*x_off;
for (int j=frm_w;j>0;j--) {
R = *cam_buf++;
G = *cam_buf++;
B = *cam_buf++;
*frm_buf++ = HBT(R*77 + G*151 + B*28);
}
cam_buf += 3*x_end;
}
}
void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
if(!cfg->frame) return;
int x_off = cfg->frame_xoff;
int y_off = cfg->frame_yoff;
int frm_w = cfg->frame_width;
int frm_h = cfg->frame_height;
cam_buf += 3*y_off*cam_w;
int x_end = cam_w-(frm_w+x_off);
frm_buf += frm_w*frm_h-1;
int R,G,B;
for (int i=frm_h;i>0;i--) {
cam_buf += 3*x_off;
for (int j=frm_w;j>0;j--) {
R = *cam_buf++;
G = *cam_buf++;
B = *cam_buf++;
*frm_buf-- = HBT(R*77 + G*151 + B*28);
}
cam_buf += 3*x_end;
}
}
void CameraEngine::setupFrame() {
if(!cfg->frame) {
cfg->frame_width = cfg->cam_width;
cfg->frame_height = cfg->cam_height;
return;
}
// size sanity check
if (cfg->frame_width%2!=0) cfg->frame_width--;
if (cfg->frame_height%2!=0) cfg->frame_height--;
if (cfg->frame_width<=0) cfg->frame_width = cfg->cam_width;
if (cfg->frame_height<=0) cfg->frame_height = cfg->cam_height;
if (cfg->frame_width > cfg->cam_width) cfg->frame_width = cfg->cam_width;
if (cfg->frame_height > cfg->cam_height) cfg->frame_height = cfg->cam_height;
// no cropping if same size
if ((cfg->frame_width==cfg->cam_width) && (cfg->frame_height==cfg->cam_height)) {
cfg->frame_width = cfg->cam_width;
cfg->frame_height = cfg->cam_height;
cfg->frame = false;
return;
}
// offset sanity check
int xdiff = cfg->cam_width-cfg->frame_width;
if (xdiff<0) cfg->frame_xoff = 0;
else if (cfg->frame_xoff > xdiff) cfg->frame_xoff = xdiff;
int ydiff = cfg->cam_height-cfg->frame_height;
if (ydiff<0) cfg->frame_yoff = 0;
else if (cfg->frame_yoff > ydiff) cfg->frame_yoff = ydiff;
}
void CameraEngine::applyCameraSetting(int mode, int value) {
if (!hasCameraSetting(mode)) return;
switch (value) {
case SETTING_AUTO:
if (hasCameraSettingAuto(mode)) {
setCameraSettingAuto(mode,true);
return;
}
case SETTING_OFF:
case SETTING_DEFAULT:
setDefaultCameraSetting(mode);
return;
case SETTING_MIN:
setCameraSettingAuto(mode,false);
setCameraSetting(mode,getMinCameraSetting(mode)); return;
case SETTING_MAX:
setCameraSettingAuto(mode,false);
setCameraSetting(mode,getMaxCameraSetting(mode)); return;
default: {
int max = getMaxCameraSetting(mode);
int min = getMinCameraSetting(mode);
if (value<min) value = min;
else if (value>max) value = max;
setCameraSettingAuto(mode,false);
setCameraSetting(mode,value);
}
}
}
void CameraEngine::resetCameraSettings() {
for (int mode=MODE_MIN;mode<=MODE_MAX;mode++)
setDefaultCameraSetting(mode);
}
void CameraEngine::applyCameraSettings() {
resetCameraSettings();
applyCameraSetting(BRIGHTNESS,cfg->brightness);
applyCameraSetting(CONTRAST,cfg->contrast);
applyCameraSetting(SHARPNESS,cfg->sharpness);
applyCameraSetting(GAIN,cfg->gain);
applyCameraSetting(EXPOSURE,cfg->exposure);
applyCameraSetting(SHUTTER,cfg->shutter);
applyCameraSetting(FOCUS,cfg->focus);
applyCameraSetting(WHITE,cfg->white);
applyCameraSetting(POWERLINE,cfg->powerline);
applyCameraSetting(BACKLIGHT,cfg->backlight);
applyCameraSetting(GAMMA,cfg->gamma);
applyCameraSetting(SATURATION,cfg->saturation);
applyCameraSetting(COLOR_HUE,cfg->hue);
applyCameraSetting(COLOR_RED,cfg->red);
applyCameraSetting(COLOR_GREEN,cfg->green);
applyCameraSetting(COLOR_BLUE,cfg->blue);
}
int CameraEngine::updateSetting(int mode) {
if (!hasCameraSetting(mode)) return SETTING_OFF;
if (getCameraSettingAuto(mode)) return SETTING_AUTO;
int value = getCameraSetting(mode);
if (value==getDefaultCameraSetting(mode)) value = SETTING_DEFAULT;
else if (value==getMinCameraSetting(mode)) value = SETTING_MIN;
else if (value==getMaxCameraSetting(mode)) value = SETTING_MAX;
return value;
}
void CameraEngine::updateSettings() {
cfg->brightness = updateSetting(BRIGHTNESS);
cfg->contrast = updateSetting(CONTRAST);
cfg->sharpness = updateSetting(SHARPNESS);
cfg->gain = updateSetting(GAIN);
cfg->exposure = updateSetting(EXPOSURE);
cfg->shutter = updateSetting(SHUTTER);
cfg->focus = updateSetting(FOCUS);
cfg->white = updateSetting(WHITE);
cfg->backlight = updateSetting(BACKLIGHT);
cfg->powerline = updateSetting(POWERLINE);
cfg->gamma = updateSetting(GAMMA);
if (cfg->color) {
cfg->saturation = updateSetting(SATURATION);
cfg->hue = updateSetting(COLOR_HUE);
cfg->red = updateSetting(COLOR_RED);
cfg->green = updateSetting(COLOR_GREEN);
cfg->blue = updateSetting(COLOR_BLUE);
} else {
cfg->saturation = SETTING_OFF;
cfg->hue = SETTING_OFF;
cfg->red = SETTING_OFF;
cfg->green = SETTING_OFF;
cfg->blue = SETTING_OFF;
}
}

View File

@ -0,0 +1,306 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CAMERAENGINE_H
#define CAMERAENGINE_H
#include <list>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <CoreFoundation/CFBundle.h>
#define SAT(c) \
if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
#define HBT(x) (unsigned char)((x)>>8)
#define KEY_A 4
#define KEY_B 5
#define KEY_C 6
#define KEY_D 7
#define KEY_E 8
#define KEY_F 9
#define KEY_G 10
#define KEY_H 11
#define KEY_I 12
#define KEY_J 13
#define KEY_K 14
#define KEY_L 15
#define KEY_M 16
#define KEY_N 17
#define KEY_O 18
#define KEY_P 19
#define KEY_Q 20
#define KEY_R 21
#define KEY_S 22
#define KEY_T 23
#define KEY_U 24
#define KEY_V 25
#define KEY_W 26
#define KEY_X 27
#define KEY_Y 29
#define KEY_Z 28
#define KEY_SPACE 44
#define KEY_RIGHT 79
#define KEY_LEFT 80
#define KEY_DOWN 81
#define KEY_UP 82
#define WIDTH 640
#define HEIGHT 480
#define SETTING_DEFAULT -100000
#define SETTING_AUTO -200000
#define SETTING_MIN -300000
#define SETTING_MAX -400000
#define SETTING_OFF -500000
#define FORMAT_UNSUPPORTED -1
#define FORMAT_UNKNOWN 0
#define FORMAT_GRAY 1
#define FORMAT_GRAY16 2
#define FORMAT_RGB 3
#define FORMAT_RGB16 4
#define FORMAT_GRAY16S 5
#define FORMAT_RGB16S 6
#define FORMAT_RAW8 7
#define FORMAT_RAW16 8
#define FORMAT_RGBA 9
#define FORMAT_YUYV 10
#define FORMAT_UYVY 11
#define FORMAT_YUV411 12
#define FORMAT_YUV444 13
#define FORMAT_420P 14
#define FORMAT_410P 15
#define FORMAT_YVYU 16
#define FORMAT_YUV211 17
#define FORMAT_JPEG 20
#define FORMAT_MJPEG 21
#define FORMAT_MPEG 22
#define FORMAT_MPEG2 23
#define FORMAT_MPEG4 24
#define FORMAT_H263 25
#define FORMAT_H264 26
#define FORMAT_DVPAL 30
#define FORMAT_DVNTSC 31
#define FORMAT_MAX 31
extern const char* fstr[];
extern const char* dstr[];
#define DRIVER_DEFAULT 0
#define DRIVER_DC1394 1
#define DRIVER_PS3EYE 2
#define DRIVER_RASPI 3
#define DRIVER_UVCCAM 4
#define DRIVER_FILE 10
#define DRIVER_FOLDER 11
#define VALUE_INCREASE 79
#define VALUE_DECREASE 80
#define SETTING_NEXT 81
#define SETTING_PREVIOUS 82
enum CameraSetting { BRIGHTNESS, CONTRAST, SHARPNESS, AUTO_GAIN, GAIN, AUTO_EXPOSURE, EXPOSURE, SHUTTER, AUTO_FOCUS, FOCUS, AUTO_WHITE, WHITE, GAMMA, POWERLINE, BACKLIGHT, SATURATION, AUTO_HUE, COLOR_HUE, COLOR_RED, COLOR_GREEN, COLOR_BLUE };
#define MODE_MIN BRIGHTNESS
#define MODE_MAX COLOR_BLUE
struct CameraConfig {
char path[256];
int driver;
int device;
char name[256];
char src[256];
bool color;
bool frame;
int cam_format;
int src_format;
int buf_format;
int cam_width;
int cam_height;
float cam_fps;
int frame_width;
int frame_height;
int frame_xoff;
int frame_yoff;
int frame_mode;
int brightness;
int contrast;
int sharpness;
int gain;
int shutter;
int exposure;
int focus;
int gamma;
int white;
int powerline;
int backlight;
int saturation;
int hue;
int red;
int blue;
int green;
bool force;
bool operator < (const CameraConfig& c) const {
//if (device < c.device) return true;
//if (cam_format < c.cam_format) return true;
if (cam_width > c.cam_width || (cam_width == c.cam_width && cam_height < c.cam_height))
return true;
if (cam_width == c.cam_width && cam_height == c.cam_height) {
return (cam_fps > c.cam_fps);
} else return false;
}
};
class CameraEngine
{
public:
CameraEngine(CameraConfig *cam_cfg) {
cfg = cam_cfg;
settingsDialog=false;
if (cfg->color) cfg->buf_format=FORMAT_RGB;
else cfg->buf_format=FORMAT_GRAY;
}
virtual ~CameraEngine() {};
virtual bool initCamera() = 0;
virtual bool startCamera() = 0;
virtual unsigned char* getFrame() = 0;
virtual bool stopCamera() = 0;
virtual bool resetCamera() = 0;
virtual bool closeCamera() = 0;
virtual bool stillRunning() = 0;
void printInfo();
static void setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list);
virtual int getCameraSettingStep(int mode) = 0;
virtual int getMinCameraSetting(int mode) = 0;
virtual int getMaxCameraSetting(int mode) = 0;
virtual int getCameraSetting(int mode) = 0;
virtual bool setCameraSetting(int mode, int value) = 0;
virtual bool setCameraSettingAuto(int mode, bool flag) = 0;
virtual bool getCameraSettingAuto(int mode) = 0;
virtual bool setDefaultCameraSetting(int mode) = 0;
virtual int getDefaultCameraSetting(int mode) = 0;
virtual bool hasCameraSetting(int mode) = 0;
virtual bool hasCameraSettingAuto(int mode) = 0;
virtual bool showSettingsDialog(bool lock);
virtual void control(unsigned char key);
int getId() { return cfg->device; }
int getFps() { return (int)floor(cfg->cam_fps+0.5f); }
int getWidth() { return cfg->frame_width; }
int getHeight() { return cfg->frame_height; }
int getFormat() { return cfg->buf_format; }
char* getName() { return cfg->name; }
protected:
CameraConfig *cfg;
unsigned char* frm_buffer;
unsigned char* cam_buffer;
int lost_frames, timeout;
bool running;
bool settingsDialog;
int currentCameraSetting;
void crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
void flip(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
void flip_crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
void rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
void crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
void flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
void flip_crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
void uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest);
void crop_uyvy2gray(int width, unsigned char *src, unsigned char *dest);
void yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest);
void crop_yuyv2gray(int width, unsigned char *src, unsigned char *dest);
void yuv2gray(int width, int height, unsigned char *src, unsigned char *dest);
void crop_yuv2gray(int width, unsigned char *src, unsigned char *dest);
void gray2rgb(int width, int height, unsigned char *src, unsigned char *dest);
void crop_gray2rgb(int width, unsigned char *src, unsigned char *dest);
void uyvy2rgb(int width, int height, unsigned char *src, unsigned char *dest);
void crop_uyvy2rgb(int width, unsigned char *src, unsigned char *dest);
void yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest);
void crop_yuyv2rgb(int width, unsigned char *src, unsigned char *dest);
void grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest);
void crop_grayw2rgb(int width, unsigned char *src, unsigned char *dest);
void grayw2gray(int width, int height, unsigned char *src, unsigned char *dest);
void crop_grayw2gray(int width, unsigned char *src, unsigned char *dest);
void resetCameraSettings();
void applyCameraSettings();
void applyCameraSetting(int mode, int value);
void updateSettings();
int updateSetting(int mode);
void setupFrame();
int default_brightness;
int default_contrast;
int default_sharpness;
int default_gain;
int default_shutter;
int default_exposure;
int default_focus;
int default_gamma;
int default_powerline;
int default_white;
int default_backlight;
int default_saturation;
int default_hue;
int default_red;
int default_blue;
int default_green;
int ctrl_min;
int ctrl_max;
int ctrl_val;
};
#endif

View File

@ -0,0 +1 @@
Versions/Current/Headers

View File

@ -0,0 +1 @@
Versions/Current/Resources

View File

@ -0,0 +1 @@
Versions/Current/USBBusProber

View File

@ -0,0 +1,55 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
@interface BusProbeClass : NSObject {
UInt8 _classNum;
UInt8 _subclassNum;
UInt8 _protocolNum;
NSString * _className;
NSString * _subclassName;
NSString * _protocolName;
}
+ (BusProbeClass *)withClass:(UInt8)classNum subclass:(UInt8)subclassNum protocol:(UInt8)protocolNum;
- (UInt8)classNum;
- (void)setClassNum:(UInt8)classNum;
- (UInt8)subclassNum;
- (void)setSubclassNum:(UInt8)subclassNum;
- (UInt8)protocolNum;
- (void)setProtocolNum:(UInt8)protocolNum;
- (NSString *)className;
- (void)setClassName:(NSString *)deviceClass;
- (NSString *)subclassName;
- (void)setSubclassName:(NSString *)deviceSubclass;
- (NSString *)protocolName;
- (void)setProtocolName:(NSString *)deviceProtocol;
- (NSString *)classDescription;
- (NSString *)subclassDescription;
- (NSString *)protocolDescription;
-(NSMutableDictionary *)dictionaryVersionOfMe;
@end

View File

@ -0,0 +1,82 @@
/*
* Copyright <EFBFBD> 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import <IOKit/usb/USB.h>
#import "BusProberSharedFunctions.h"
#import "OutlineViewNode.h"
#import "BusProbeClass.h"
@interface BusProbeDevice : NSObject {
OutlineViewNode * _rootNode;
UInt8 _speed;
USBDeviceAddress _address;
UInt32 _locationID;
UInt32 _vendorID;
UInt32 _productID;
UInt16 _usbRelease;
BusProbeClass * _deviceClassInfo;
BusProbeClass * _lastInterfaceClassInfo;
UInt8 _lastInterfaceSubclass;
int _currentInterfaceNumber;
uint32_t _portInfo;
}
- (OutlineViewNode *)rootNode;
- (void)addProperty:(char *)property withValue:(char *)value atDepth:(int)depth;
- (void)addNumberProperty:(char *)property value:(UInt32)value size:(int)sizeInBytes atDepth:(int)depth usingStyle:(int)style;
- (void)addStringProperty:(char *)property fromStringIndex:(UInt8)strIndex fromDeviceInterface:(IOUSBDeviceRef)deviceIntf atDepth:(int)depth;
- (NSString *)deviceName;
- (void)setDeviceName:(NSString *)name;
- (NSString *)deviceDescription;
- (void)setDeviceDescription:(NSString *)description;
- (UInt8)speed;
- (void)setSpeed:(UInt8)speed;
- (USBDeviceAddress)address;
- (void)setAddress:(USBDeviceAddress)address;
- (uint32_t)portInfo;
- (void)setPortInfo:(uint32_t)portInfo;
//- (UInt32)locationID;
//- (void)setLocationID:(UInt32)locationID;
- (UInt32)vendorID;
- (void)setVendorID:(UInt32)vendorID;
- (UInt32)productID;
- (void)setProductID:(UInt32)productID;
- (UInt32)locationID;
- (void)setLocationID:(UInt32)locationID;
- (BusProbeClass *)deviceClassInfo;
- (void)setDeviceClassInfo:(BusProbeClass *)classInfo;
- (BusProbeClass *)lastInterfaceClassInfo;
- (void)setLastInterfaceClassInfo:(BusProbeClass *)classInfo;
- (int)currentInterfaceNumber;
- (void)setCurrentInterfaceNumber:(int)currentNum;
- (UInt16)usbRelease;
- (void)setUSBRelease:(UInt16)usbRelease;
- (NSString *)descriptionForName:(NSString*)name;
- (NSString *)description;
- (NSMutableDictionary *)dictionaryVersionOfMe;
@end

View File

@ -0,0 +1,65 @@
/*
* Copyright <EFBFBD> 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import <IOKit/usb/IOUSBLib.h>
#import <IOKit/usb/USB.h>
#import <IOKit/usb/USBSpec.h>
#import <IOKit/IOCFPlugIn.h>
#import <mach/mach_port.h>
#import "BusProberSharedFunctions.h"
#import "OutlineViewNode.h"
#import "BusProbeDevice.h"
#import "BusProbeClass.h"
#import "DescriptorDecoder.h"
@interface BusProber : NSObject {
id _listener;
NSMutableArray * _devicesArray;
CFRunLoopSourceRef _runLoopSource;
}
- (BOOL)registerForUSBNotifications;
- (void)unregisterForUSBNotifications;
- (void)refreshData:(BOOL)shouldForce;
- (void)processDevice:(IOUSBDeviceRef)deviceIntf deviceNumber:(int)deviceNumber usbName:(NSString*)usbName;
- (void)PrintPortInfo: (uint32_t)portInfo forDevice:(BusProbeDevice *)thisDevice;
- (void)GetAndPrintNumberOfEndpoints:(IOUSBDeviceRef)deviceIntf forDevice:(BusProbeDevice *)thisDevice portInfo:(UInt32)portInfo;
- (NSMutableArray *) devicesArray;
@end
@protocol BusProberListener <NSObject>
- (void)busProberInformationDidChange:(BusProber *)aProber;
@end

View File

@ -0,0 +1,87 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <AvailabilityMacros.h>
#import <Foundation/Foundation.h>
#import <IOKit/usb/IOUSBLib.h>
#import <IOKit/usb/USB.h>
#import <IOKit/usb/USBSpec.h>
#import <IOKit/IOCFPlugIn.h>
#import "BusProbeClass.h"
typedef struct IOUSBDeviceStruct320** IOUSBDeviceRef ;
typedef struct IOUSBInterfaceStruct220** IOUSBInterfaceRef ;
#define ROOT_LEVEL 0
#define DEVICE_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define CONFIGURATION_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define INTERFACE_LEVEL CONFIGURATION_DESCRIPTOR_LEVEL + 1
#define ENDPOINT_LEVEL INTERFACE_LEVEL + 1
#define HID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define DFU_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define CCID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define HUB_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define DEVICE_QUAL_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define BOS_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
enum {
kIntegerOutputStyle = 0,
kHexOutputStyle = 1
};
IOReturn GetNumberOfConfigurations( IOUSBDeviceRef deviceIntf, uint8_t * numberOfConfigs );
IOReturn GetConfigurationDescriptor( IOUSBDeviceRef deviceIntf, uint8_t config, IOUSBConfigurationDescriptorPtr * description );
IOReturn GetConfiguration( IOUSBDeviceRef deviceIntf, uint8_t * currentConfig );
IOReturn GetPortInformation( IOUSBDeviceRef deviceIntf, uint32_t * portInfo );
int GetDeviceLocationID( IOUSBDeviceRef deviceIntf, UInt32 * locationID );
int GetDeviceSpeed( IOUSBDeviceRef deviceIntf, UInt8 * speed );
int GetDeviceAddress( IOUSBDeviceRef deviceIntf, USBDeviceAddress * address );
int SuspendDevice( IOUSBDeviceRef deviceIntf, BOOL suspend );
IOReturn GetDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len, IOReturn *actError);
int GetStringDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descIndex, void *buf, UInt16 len, UInt16 lang);
int GetClassDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len);
int GetDescriptorFromInterface(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, UInt16 wIndex, void *buf, UInt16 len, Boolean inCurrentConfig);
int GetCurrentConfiguration(IOUSBDeviceRef deviceIntf);
BusProbeClass * GetDeviceClassAndSubClass(UInt8 * pcls);
BusProbeClass * GetInterfaceClassAndSubClass(UInt8 * pcls);
char * GetStringFromNumber(UInt32 value, int sizeInBytes, int style);
char * GetStringFromIndex(UInt8 strIndex, IOUSBDeviceRef deviceIntf);
NSString * VendorNameFromVendorID(NSString * intValueAsString);
NSString * GetUSBProductNameFromRegistry(io_registry_entry_t entry);
void FreeString(char * cstr);
UInt16 Swap16(void *p);
uint32_t Swap32(void *p);
uint64_t Swap64(void *p);
uint32_t Swap24(void *p);
const char * USBErrorToString(IOReturn status);
IOUSBDescriptorHeader * NextDescriptor(const void *desc);
IOUSBDescriptorHeader* FindNextDescriptor(IOUSBConfigurationDescriptor *curConfDesc, const void *cur, UInt8 descType);
IOReturn FindNextInterfaceDescriptor(const IOUSBConfigurationDescriptor *configDescIn, const IOUSBInterfaceDescriptor *intfDesc,IOUSBInterfaceDescriptor **descOut);

View File

@ -0,0 +1,477 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
#define kUSBAudioInterfaceDesc (0x24)
#define kUSBAudioEndPointDesc (0x25)
// <rdar://10009579>
#define kUSBAudioDescriptorBytesPerLine 16
// String buffer size to log desciptor:
// Each byte in descriptor requires 3 chars: 2 for nibbles + a space char
// One byte for null terminator
#define kUSBAudioMaxDescriptorStringSize ( ( kUSBAudioDescriptorBytesPerLine * 3 ) + 1 ) * sizeof ( char )
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descContents[32];
} GenericAudioDescriptor, *GenericAudioDescriptorPtr;
#pragma options align=reset
enum AudioClassSpecific {
ACS_HEADER = 0x01,
ACS_INPUT_TERMINAL = 0x02,
ACS_OUTPUT_TERMINAL = 0x03,
ACS_MIXER_UNIT = 0x04,
ACS_SELECTOR_UNIT = 0x05,
ACS_FEATURE_UNIT = 0x06,
ACS_PROCESSING_UNIT = 0x07,
ACS_EXTENSION_UNIT = 0x08,
ACS_UNDEFINED = 0x20,
ACS_DEVICE = 0x21,
ACS_CONFIGURATION = 0x22,
ACS_STRING = 0x23,
ACS_INTERFACE = 0x24,
ACS_ENDPOINT = 0x25,
ACS_FORMAT_TYPE = 0x02,
ACS_FORMAT_SPECIFIC = 0x03,
ACS_FORMAT_TYPE_UNDEF = 0x00,
ACS_FORMAT_TYPE_I = 0x01,
ACS_FORMAT_TYPE_II = 0x02,
ACS_FORMAT_TYPE_III = 0x03,
ACS_ASTREAM_UNDEF = 0x00,
ACS_ASTREAM_GENERAL = 0x01,
ACS_ASTREAM_TYPE = 0x02,
ACS_ASTREAM_SPECIFIC = 0x03,
AC_CONTROL_SUBCLASS = 0x01,
AC_STREAM_SUBCLASS = 0x02,
AC_MIDI_SUBCLASS = 0x03
};
// Standard Audio Stream Isoc Audio Data Endpoint Descriptor
// Refer to USB Audio Class Devices pp. 61-62.
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 asAddress;
UInt8 asAttributes;
UInt16 asMaxPacketSize;
UInt8 asInterval;
UInt8 asRefresh;
UInt8 asSynchAddress;
} AS_IsocEndPtDesc, *AS_IsocEndPtDescPtr;
#pragma options align=reset
// Class Specific Audio Stream Isoc Audio Data Endpoint Descriptor
// Refer to USB Audio Class Devices pp. 62-63.
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubtype;
UInt8 asAttributes;
UInt8 bLockDelayUnits;
UInt16 wLockDelay;
} CSAS_IsocEndPtDesc, *CSAS_IsocEndPtDescPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt16 descVersNum;
UInt16 descTotalLength;
UInt8 descAICNum; /* Number of elements in the Audio Interface Collection. */
UInt8 descInterfaceNum[1];
} AudioCtrlHdrDescriptor, *AudioCtrlHdrDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descTermID;
UInt16 descTermType;
UInt8 descOutTermID;
UInt8 descNumChannels;
UInt16 descChannelConfig;
UInt8 descChannelNames;
UInt8 descTermName;
} AudioCtrlInTermDescriptor, *AudioCtrlInTermDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descTermID;
UInt16 descTermType;
UInt8 descInTermID;
UInt8 descSourceID;
UInt8 descTermName;
} AudioCtrlOutTermDescriptor, *AudioCtrlOutTermDescriptorPtr;
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt8 descNumPins;
UInt8 descSourcePID[1];
} AudioCtrlMixerDescriptor, *AudioCtrlMixerDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt8 descNumPins;
UInt8 descSourcePID[1];
} AudioCtrlSelectorDescriptor, *AudioCtrlSelectorDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt8 descSourceID;
UInt8 descCtrlSize;
UInt8 descControls[1];
} AudioCtrlFeatureDescriptor, *AudioCtrlFeatureDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt16 descExtensionCode;
UInt8 descNumPins;
UInt8 descSourcePID[1];
} AudioCtrlExtDescriptor, *AudioCtrlExtDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 terminalID;
UInt8 delay;
UInt16 formatTag;
} CSAS_InterfaceDescriptor, *CSAS_InterfaceDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct acProcessingDescriptor{ // ¥¥¥¥ WARNING ¥¥¥ ADDING ELEMENTS WILL KILL CODE!!!
UInt8 descLen; // size of this descriptor in bytes
UInt8 bDescriptorType; // const CS_INTERFACE
UInt8 bDescriptorSubtype; // const FEATURE_UNIT
UInt8 bUnitID;
UInt16 wProcessType;
UInt8 bNrPins;
UInt8 bSourceID;
}acProcessingDescriptor;
#pragma options align=reset
typedef acProcessingDescriptor *acProcessingDescriptorPtr;
#pragma pack(1)
typedef struct acProcessingDescriptorCont{
UInt8 bNrChannels;
UInt16 wChannelConfig;
UInt8 iChannelNames;
UInt8 bControlSize;
UInt16 bmControls;
UInt8 iProcessing;
}acProcessingDescriptorCont;
#pragma options align=reset
typedef acProcessingDescriptorCont *acProcessingDescriptorContPtr;
/* Refer to USB PDF files for Frmts10.pdf pp. 10 for Type I Format Descriptor. */
#pragma pack(1)
typedef struct {
UInt8 byte1;
UInt8 byte2;
UInt8 byte3;
} CSAS_Freq3, *CSAS_Freq3Ptr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
CSAS_Freq3 lowerSamFreq;
CSAS_Freq3 upperSamFreq;
} CSAS_ContTbl, *CSAS_ContTblPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
CSAS_Freq3 samFreq[1];
} CSAS_DiscreteTbl, *CSAS_DiscreteTblPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 formatType;
UInt8 numberOfChannels;
UInt8 subFrameSize;
UInt8 bitResolution;
UInt8 sampleFreqType;
union {
CSAS_ContTbl cont;
CSAS_DiscreteTbl discrete;
} sampleFreqTables;
} CSAS_FormatTypeIDesc, *CSAS_FormatTypeIDescPtr;
#pragma options align=reset
enum Audio20ClassSpecific {
AC20S_HEADER = 0x01,
AC20S_INPUT_TERMINAL = 0x02,
AC20S_OUTPUT_TERMINAL = 0x03,
AC20S_MIXER_UNIT = 0x04,
AC20S_SELECTOR_UNIT = 0x05,
AC20S_FEATURE_UNIT = 0x06,
AC20S_EFFECT_UNIT = 0x07,
AC20S_PROCESSING_UNIT = 0x08,
AC20S_EXTENSION_UNIT = 0x09,
AC20S_CLOCK_SOURCE = 0x0A,
AC20S_CLOCK_SELECTOR = 0x0B,
AC20S_CLOCK_MULTIPLIER = 0x0C,
AC20S_SAMPLE_RATE_CONVERTER = 0x0D,
AC20S_FORMAT_TYPE_IV = 0x04,
AC20S_EXTENDED_FORMAT_TYPE_I = 0x81,
AC20S_EXTENDED_FORMAT_TYPE_II = 0x82,
AC20S_EXTENDED_FORMAT_TYPE_III = 0x83
};
// Standard Audio Stream Isoc Audio Data Endpoint Descriptor
// Refer to USB Audio Class Devices pp. 61-62.
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 asAddress;
UInt8 asAttributes;
UInt16 asMaxPacketSize;
UInt8 asInterval;
} AS20_IsocEndPtDesc, *AS20_IsocEndPtDescPtr;
#pragma options align=reset
// Class Specific Audio Stream Isoc Audio Data Endpoint Descriptor
// Refer to USB Audio Class Devices pp. 62-63.
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubtype;
UInt8 asAttributes;
UInt8 bmControls;
UInt8 bLockDelayUnits;
UInt16 wLockDelay;
} CSA20S_IsocEndPtDesc, *CSAS20_IsocEndPtDescPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt16 descVersNum;
UInt8 descCategory;
UInt16 descTotalLength;
UInt8 descbmControls;
} Audio20CtrlHdrDescriptor, *Audio20CtrlHdrDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descTermID;
UInt16 descTermType;
UInt8 descOutTermID;
UInt8 descClockSourceID;
UInt8 descNumChannels;
UInt32 descChannelConfig;
UInt8 descChannelNames;
UInt16 descbmControls;
UInt8 descTermName;
} Audio20CtrlInTermDescriptor, *Audio20CtrlInTermDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descClockID;
UInt8 descAttributes;
UInt8 descbmControls;
UInt8 descAssocTermID;
UInt8 desciClockSourceName;
} Audio20ClockSourceDescriptor, *Audio20ClockSourceDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descClockID;
UInt8 descNumPins;
UInt8 descClockPID[1];
} Audio20ClockSelectorDescriptor, *Audio20ClockSelectorDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descClockID;
UInt8 descClockSourceID;
UInt8 descbmControls;
UInt8 desciClockMultiplierName;
} Audio20ClockMultiplierDescriptor, *Audio20ClockMultiplierDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descTermID;
UInt16 descTermType;
UInt8 descInTermID;
UInt8 descSourceID;
UInt8 descClockSourceID;
UInt16 bmControls;
UInt8 descTermName;
} Audio20CtrlOutTermDescriptor, *Audio20CtrlOutTermDescriptorPtr;
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt8 descSourceID;
UInt8 descControls[1];
} Audio20CtrlFeatureDescriptor, *Audio20CtrlFeatureDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 descUnitID;
UInt16 descExtensionCode;
UInt8 descNumPins;
UInt8 descSourcePID[1];
} Audio20CtrlExtDescriptor, *Audio20CtrlExtDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 terminalID;
UInt8 bmControls;
UInt8 formatType;
UInt32 bmFormats;
UInt8 numChannels;
UInt32 channelConfig;
UInt8 channelNames;
} CS20AS_InterfaceDescriptor, *CS20AS_InterfaceDescriptorPtr;
#pragma options align=reset
#pragma pack(1)
typedef struct ac20ProcessingDescriptor{ // ¥¥¥¥ WARNING ¥¥¥ ADDING ELEMENTS WILL KILL CODE!!!
UInt8 descLen; // size of this descriptor in bytes
UInt8 bDescriptorType; // const CS_INTERFACE
UInt8 bDescriptorSubtype; // const FEATURE_UNIT
UInt8 bUnitID;
UInt16 wProcessType;
UInt8 bNrPins;
UInt8 bSourceID[1];
}ac20ProcessingDescriptor, *ac20ProcessingDescriptorPtr;
#pragma options align=reset
typedef ac20ProcessingDescriptor *a20cProcessingDescriptorPtr;
#pragma pack(1)
typedef struct ac20ProcessingDescriptorCont{
UInt8 bNrChannels;
UInt32 wChannelConfig;
UInt8 iChannelNames;
UInt16 bmControls;
UInt8 iProcessing;
}ac20ProcessingDescriptorCont;
#pragma options align=reset
typedef ac20ProcessingDescriptorCont *ac20ProcessingDescriptorContPtr;
/* Refer to USB PDF files for Frmts10.pdf pp. 10 for Type I Format Descriptor. */
#pragma pack(1)
typedef struct {
UInt8 descLen;
UInt8 descType;
UInt8 descSubType;
UInt8 formatType;
UInt8 slotSize;
UInt8 bitResolution;
} CS20AS_FormatTypeIDesc, *CS20AS_FormatTypeIDescPtr;
#pragma options align=reset
@interface DecodeAudioInterfaceDescriptor : NSObject {
}
+(void)decodeBytes:(UInt8 *)descriptor forDevice:(BusProbeDevice *)thisDevice;
void decodeBytes10( UInt8 *descriptor, BusProbeDevice * thisDevice );
void decodeBytes20( UInt8 *descriptor, BusProbeDevice * thisDevice );
@end

View File

@ -0,0 +1,35 @@
/*
* Copyright © 2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeBOSDescriptor : NSObject {
}
+ (void)decodeBytes:(IOUSBBOSDescriptor *)bosDescriptor forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf;
@end

View File

@ -0,0 +1,44 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeCommClassDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
@end
@interface DecodeMassStorageDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
@end

View File

@ -0,0 +1,37 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeConfigurationDescriptor : NSObject {
}
+ (void)decodeBytes:(IOUSBConfigurationDescHeader *)cfg forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf configNumber:(int)iconfig currentConfig:(int)cconfig isOtherSpeedDesc:(BOOL)isOtherSpeedDesc;
@end

View File

@ -0,0 +1,36 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeDeviceDescriptor : NSObject {
}
+ (void)decodeBytes:(IOUSBDeviceDescriptor *)dev forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf wasSuspended:(BOOL)wasSuspended;
@end

View File

@ -0,0 +1,37 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeDeviceQualifierDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
@end

View File

@ -0,0 +1,40 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
enum {
kEndpointAddressBit = 7,
kEndpointAddressMask = ( 1 << kEndpointAddressBit )
};
@interface DecodeEndpointDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice isOtherSpeedDesc:(BOOL)isOtherSpeedDesc;
+ (void)decodeBytesCompanion:(Byte *)p forDevice:(BusProbeDevice *)thisDevice endpoint:(UInt8)epType;
@end

View File

@ -0,0 +1,226 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import <IOKit/hid/IOHIDUsageTables.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
#define UnpackReportSize(packedByte) ((packedByte) & 0x03)
#define UnpackReportType(packedByte) (((packedByte) & 0x0C) >> 2)
#define UnpackReportTag(packedByte) (((packedByte) & 0xF0) >> 4)
enum
{
kReport_TypeMain = 0,
kReport_TypeGlobal = 1,
kReport_TypeLocal = 2,
kReport_TypeReserved = 3,
kReport_TagLongItem = 0x0F,
// main items
kReport_TagInput = 0x08,
kReport_TagOutput = 0x09,
kReport_TagFeature = 0x0B,
kReport_TagCollection = 0x0A,
kReport_TagEndCollection = 0x0C,
// global items
kReport_TagUsagePage = 0x00,
kReport_TagLogicalMin = 0x01,
kReport_TagLogicalMax = 0x02,
kReport_TagPhysicalMin = 0x03,
kReport_TagPhysicalMax = 0x04,
kReport_TagUnitExponent = 0x05,
kReport_TagUnit = 0x06,
kReport_TagReportSize = 0x07,
kReport_TagReportID = 0x08,
kReport_TagReportCount = 0x09,
kReport_TagPush = 0x0A,
kReport_TagPop = 0x0B,
// local items
kReport_TagUsage = 0x00,
kReport_TagUsageMin = 0x01,
kReport_TagUsageMax = 0x02,
kReport_TagDesignatorIndex = 0x03,
kReport_TagDesignatorMin = 0x04,
kReport_TagDesignatorMax = 0x05,
kReport_TagStringIndex = 0x07,
kReport_TagStringMin = 0x08,
kReport_TagStringMax = 0x09,
kReport_TagSetDelimiter = 0x0A
};
// Collection constants
enum
{
kCollection_Physical = 0x00,
kCollection_Application = 0x01,
kCollection_Logical = 0x02
};
// I/O constants (used for Input/Output/Feature tags)
enum
{
kIO_Data_or_Constant = 0x0001,
kIO_Array_or_Variable = 0x0002,
kIO_Absolute_or_Relative = 0x0004,
kIO_NoWrap_or_Wrap = 0x0008,
kIO_Linear_or_NonLinear = 0x0010,
kIO_PreferredState_or_NoPreferred = 0x0020,
kIO_NoNullPosition_or_NullState = 0x0040,
kIO_NonVolatile_or_Volatile = 0x0080, // reserved for Input
kIO_BitField_or_BufferedBytes = 0x0100
};
// Usage pages from HID Usage Tables spec 1.0
enum
{
kUsage_PageGenericDesktop = 0x01,
kUsage_PageSimulationControls = 0x02,
kUsage_PageVRControls = 0x03,
kUsage_PageSportControls = 0x04,
kUsage_PageGameControls = 0x05,
kUsage_PageKeyboard = 0x07,
kUsage_PageLED = 0x08,
kUsage_PageButton = 0x09,
kUsage_PageOrdinal = 0x0A,
kUsage_PageTelephonyDevice = 0x0B,
kUsage_PageConsumer = 0x0C,
kUsage_PageDigitizers = 0x0D,
kUsage_PagePID = 0x0F,
kUsage_PageUnicode = 0x10,
kUsage_PageAlphanumericDisplay = 0x14,
kUsage_PageMonitor = 0x80,
kUsage_PageMonitorEnumeratedValues = 0x81,
kUsage_PageMonitorVirtualControl = 0x82,
kUsage_PageMonitorReserved = 0x83,
kUsage_PagePowerDevice = 0x84,
kUsage_PageBatterySystem = 0x85,
kUsage_PowerClassReserved = 0x86,
kUsage_PowerClassReserved2 = 0x87,
kUsage_VendorDefinedStart = 0xff00
};
// Usage constants for Generic Desktop page (01) from HID Usage Tables spec 1.0
enum
{
kUsage_01_Pointer = 0x01,
kUsage_01_Mouse = 0x02,
kUsage_01_Joystick = 0x04,
kUsage_01_GamePad = 0x05,
kUsage_01_Keyboard = 0x06,
kUsage_01_Keypad = 0x07,
kUsage_01_X = 0x30,
kUsage_01_Y = 0x31,
kUsage_01_Z = 0x32,
kUsage_01_Rx = 0x33,
kUsage_01_Ry = 0x34,
kUsage_01_Rz = 0x35,
kUsage_01_Slider = 0x36,
kUsage_01_Dial = 0x37,
kUsage_01_Wheel = 0x38,
kUsage_01_HatSwitch = 0x39,
kUsage_01_CountedBuffer = 0x3A,
kUsage_01_ByteCount = 0x3B,
kUsage_01_MotionWakeup = 0x3C,
kUsage_01_Vx = 0x40,
kUsage_01_Vy = 0x41,
kUsage_01_Vz = 0x42,
kUsage_01_Vbrx = 0x43,
kUsage_01_Vbry = 0x44,
kUsage_01_Vbrz = 0x45,
kUsage_01_Vno = 0x46,
kUsage_01_SystemControl = 0x80,
kUsage_01_SystemPowerDown = 0x81,
kUsage_01_SystemSleep = 0x82,
kUsage_01_SystemWakeup = 0x83,
kUsage_01_SystemContextMenu = 0x84,
kUsage_01_SystemMainMenu = 0x85,
kUsage_01_SystemAppMenu = 0x86,
kUsage_01_SystemMenuHelp = 0x87,
kUsage_01_SystemMenuExit = 0x88,
kUsage_01_SystemMenuSelect = 0x89,
kUsage_01_SystemMenuRight = 0x8A,
kUsage_01_SystemMenuLeft = 0x8B,
kUsage_01_SystemMenuUp = 0x8C,
kUsage_01_SystemMenuDown = 0x8D
};
/*!
@typedef IOUSBCCIDDescriptor
@discussion USB Device CHIP CARD ID Descriptor. See the USB CCID Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.
*/
#pragma pack(1)
struct IOUSBCCIDDescriptor
{
UInt8 bLength;
UInt8 bDescriptorType;
UInt16 bcdCCID;
UInt8 bMaxSlotIndex;
UInt8 bVoltageSupport;
UInt32 dwProtocols;
UInt32 dwDefaultClock;
UInt32 dwMaximumClock;
UInt8 bNumClockSupported;
UInt32 dwDataRate;
UInt32 dwMaxDataRate;
UInt8 bNumDataRatesSupported;
UInt32 dwMaxIFSD;
UInt32 dwSyncProtocols;
UInt32 dwMechanical;
UInt32 dwFeatures;
UInt32 dwMaxCCIDMessageLength;
UInt8 bClassGetResponse;
UInt8 bClassEnvelope;
UInt16 wLcdLayout;
UInt8 bPINSupport;
UInt8 bMaxCCIDBusySlots;
};
typedef struct IOUSBCCIDDescriptor IOUSBCCIDDescriptor;
typedef IOUSBCCIDDescriptor * IOUSBCCIDDescriptorPtr;
#pragma options align=reset
/* end HID Constants Spec 1.0 */
@interface DecodeHIDDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf isinCurrentConfig:(Boolean)inCurrentConfig;
+(void)decodeHIDReport:(UInt8 *)reportDesc forDevice:(BusProbeDevice *)thisDevice atDepth:(UInt16)depth reportLen:(UInt16)length;
@end

View File

@ -0,0 +1,68 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
struct IOUSBHubDescriptor {
UInt8 length;
UInt8 hubType;
UInt8 numPorts;
UInt16 characteristics __attribute__((packed));
UInt8 powerOnToGood; // Port settling time, in 2ms
UInt8 hubCurrent;
// These are received packed, will have to be unpacked
UInt8 removablePortFlags[9];
UInt8 pwrCtlPortFlags[9];
};
typedef struct IOUSBHubDescriptor IOUSBHubDescriptor;
// To cope with the extra fields in a USB3 hub descriptor
struct IOUSB3HubDescriptor {
UInt8 length;
UInt8 hubType;
UInt8 numPorts;
UInt16 characteristics __attribute__((packed));
UInt8 powerOnToGood; // Port settling time, in 2ms
UInt8 hubCurrent;
UInt8 hubHdrDecLat; // Header decode latency, new 3.0 field
UInt16 hubDelay __attribute__((packed)); // new in 3.0
// These are received packed, will have to be unpacked
UInt8 removablePortFlags[9];
UInt8 pwrCtlPortFlags[9]; // This field does not exist in the 3.0 descriptor
};
typedef struct IOUSB3HubDescriptor IOUSB3HubDescriptor;
@interface DecodeHubDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
@end

View File

@ -0,0 +1,45 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
@interface DecodeInterfaceDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
@end
@interface DecodeInterfaceAssociationDescriptor : NSObject {
}
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
@end

View File

@ -0,0 +1,765 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "DescriptorDecoder.h"
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
enum VideoClassSpecific
{
// Video Interface Class Code
CC_VIDEO = 0x0E,
// Video Interface Subclass Codes
//
SC_UNDEFINED = 0x00,
SC_VIDEOCONTROL = 0x01,
SC_VIDEOSTREAMING = 0x02,
SC_VIDEO_INTERFACE_COLLECTION = 0x03,
// Video Interface Protocol Codes
//
PC_PROTOCOL_UNDEFINED = 0x00,
// Video Class Specific Descriptor Types
//
CS_UNDEFINED = 0x20,
CS_DEVICE = 0x21,
CS_CONFIGURATION = 0x22,
CS_STRING = 0x23,
// CS_INTERFACE = 0x24,
// CS_ENDPOINT = 0x25,
// Video Class Specific Control Interface Descriptor Types
//
VC_DESCRIPTOR_UNDEFINED = 0x00,
VC_HEADER = 0x01,
VC_INPUT_TERMINAL = 0x02,
VC_OUTPUT_TERMINAL = 0x03,
VC_SELECTOR_UNIT = 0x04,
VC_PROCESSING_UNIT = 0x05,
VC_EXTENSION_UNIT = 0x06,
// Video Class Specific Streaming Interface Descriptor Types
//
VS_UNDEFINED = 0x00,
VS_INPUT_HEADER = 0x01,
VS_OUTPUT_HEADER = 0x02,
VS_STILL_IMAGE_FRAME = 0x03,
VS_FORMAT_UNCOMPRESSED = 0x04,
VS_FRAME_UNCOMPRESSED = 0x05,
VS_FORMAT_MJPEG = 0x06,
VS_FRAME_MJPEG = 0x07,
VS_FORMAT_MPEG1 = 0x08, // Reserved in 1.1
VS_FORMAT_MPEG2PS = 0x09, // Reserved in 1.1
VS_FORMAT_MPEG2TS = 0x0a,
VS_FORMAT_DV = 0x0c,
VS_COLORFORMAT = 0x0d,
VS_FORMAT_VENDOR = 0x0e, // Reserved in 1.1
VS_FRAME_VENDOR = 0x0f, // Reserved in 1.1
VS_FORMAT_FRAME_BASED = 0x10,
VS_FRAME_FRAME_BASED = 0x11,
VS_FORMAT_STREAM_BASED = 0x12,
VS_FORMAT_MPEG4SL = 0xFF, // Undefined in 1.1
// Video Class Specific Endpoint Descriptor Subtypes
//
EP_UNDEFINED = 0x00,
EP_GENERAL = 0x01,
EP_ENDPOINT = 0x02,
EP_INTERRUPT = 0x03,
// Video Class Specific Request Codes
//
RC_UNDEFINED = 0x00,
SET_CUR = 0x01,
GET_CUR = 0x81,
GET_MIN = 0x82,
GET_MAX = 0x83,
GET_RES = 0x84,
GET_LEN = 0x85,
GET_INFO = 0x86,
GET_DEF = 0x87,
// Video Control Interface Control Selectors
//
VC_CONTROL_UNDEFINED = 0x00,
VC_VIDEO_POWER_MODE_CONTROL = 0x01,
VC_REQUEST_ERROR_CODE_CONTROL = 0x02,
VC_REQUEST_INDICATE_HOST_CLOCK_CONTROL = 0x03,
// Terminal Control Selectors
//
TE_CONTROL_UNDEFINED = 0x00,
// Selector Unit Control Selectors
//
SU_CONTROL_UNDEFINED = 0x00,
SU_INPUT_SELECT_CONTROL = 0x01,
// Camera Terminal Control Selectors
//
CT_CONTROL_UNDEFINED = 0x00,
CT_SCANNING_MODE_CONTROL = 0x01,
CT_AE_MODE_CONTROL = 0x02,
CT_AE_PRIORITY_CONTROL = 0x03,
CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04,
CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05,
CT_FOCUS_ABSOLUTE_CONTROL = 0x06,
CT_FOCUS_RELATIVE_CONTROL = 0x07,
CT_FOCUS_AUTO_CONTROL = 0x08,
CT_IRIS_ABSOLUTE_CONTROL = 0x09,
CT_IRIS_RELATIVE_CONTROL = 0x0A,
CT_ZOOM_ABSOLUTE_CONTROL = 0x0B,
CT_ZOOM_RELATIVE_CONTROL = 0x0C,
CT_PANTILT_ABSOLUTE_CONTROL = 0x0D,
CT_PANTILT_RELATIVE_CONTROL = 0x0E,
CT_ROLL_ABSOLUTE_CONTROL = 0x0F,
CT_ROLL_RELATIVE_CONTROL = 0x10,
CT_PRIVACY_CONTROL = 0x11,
// Processing Unit Control Selectors
//
PU_CONTROL_UNDEFINED = 0x00,
PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01,
PU_BRIGHTNESS_CONTROL = 0x02,
PU_CONTRAST_CONTROL = 0x03,
PU_GAIN_CONTROL = 0x04,
PU_POWER_LINE_FREQUENCY_CONTROL = 0x05,
PU_HUE_CONTROL = 0x06,
PU_SATURATION_CONTROL = 0x07,
PU_SHARPNESS_CONTROL = 0x08,
PU_GAMMA_CONTROL = 0x09,
PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A,
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B,
PU_WHITE_BALANCE_COMPONENT_CONTROL = 0x0C,
PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D,
PU_DIGITAL_MULTIPLIER_CONTROL = 0x0E,
PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL = 0x0F,
PU_HUE_AUTO_CONTROL = 0x10,
// Extension Unit Control Selectors
//
XU_CONTROL_UNDEFINED = 0x00,
// Video Streaming Interface Control Selectors
//
VS_CONTROL_UNDEFINED = 0x00,
VS_PROBE_CONTROL = 0x01,
VS_COMMIT_CONTROL = 0x02,
VS_STILL_PROBE_CONTROL = 0x03,
VS_STILL_COMMIT_CONTROL = 0x04,
VS_STILL_IMAGE_TRIGGER_CONTROL = 0x05,
VS_STREAM_ERROR_CODE_CONTROL = 0x06,
VS_GENERATE_KEY_FRAME_CONTROL = 0x07,
VS_UPDATE_FRAME_SEGMENT_CONTROL = 0x08,
VS_SYNCH_DELAY_CONTROL = 0x09,
// USB Terminal Types
//
TT_VENDOR_SPECIFIC = 0x0100,
TT_STREAMING = 0x0101,
// Input Terminal Types
//
ITT_VENDOR_SPECIFIC = 0x0200,
ITT_CAMERA = 0x0201,
ITT_MEDIA_TRANSPORT_UNIT = 0x0202,
// Output Terminal Types
//
OTT_VENDOR_SPECIFIC = 0x0300,
OTT_DISPLAY = 0x0301,
OTT_MEDIA_TRANSPORT_OUTPUT = 0x0302,
// External Terminal Types
//
EXTERNAL_VENDOR_SPECIFIC = 0x0400,
COMPOSITE_CONNECTOR = 0x0401,
SVIDEO_CONNECTOR = 0x0402,
COMPONENT_CONNECTOR = 0x0403,
// Media Transport Terminal Control Selectors
//
MTT_CONTROL_UNDEFINED = 0x00,
TRANSPORT_CONTROL = 0X01,
ATN_INFORMATION_CONTROL = 0X02,
MEDIA_INFORMATION_CONTROL = 0X03,
TIME_CODE_INFORMATION_CONTROL = 0X04,
};
enum UncompressedFormatGUID
{
UNCOMPRESSED_YUV2_HI = 0x3259555900000010ULL,
UNCOMPRESSED_YUV2_LO = 0x800000aa00389b71ULL,
UNCOMPRESSED_NV12_HI = 0x3231564E00000010ULL,
UNCOMPRESSED_NV12_LO = 0x800000aa00389b71ULL,
};
// Standard Video Class Control Interface Descriptor
//
#pragma pack(1)
struct IOUSBVCInterfaceDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint16_t bcdVDC;
uint16_t wTotalLength;
uint32_t dwClockFrequency;
uint8_t bInCollection; // Number of Video Streaming Interfaces in the collection
uint8_t baInterfaceNr[1];
};
typedef struct IOUSBVCInterfaceDescriptor IOUSBVCInterfaceDescriptor;
#pragma options align=reset
// Video Control Standard Input Terminal Descriptor
//
#pragma pack(1)
struct IOUSBVCInputTerminalDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bTerminalID;
uint16_t wTerminalType;
uint8_t bAssocTerminal;
uint8_t iTerminal;
};
typedef struct IOUSBVCInputTerminalDescriptor IOUSBVCInputTerminalDescriptor;
#pragma options align=reset
// Video Class Standard Output Terminal Descriptor
//
#pragma pack(1)
struct IOUSBVCOutputTerminalDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bTerminalID;
uint16_t wTerminalType;
uint8_t bAssocTerminal;
uint8_t bSourceID;
uint8_t iTerminal;
};
typedef struct IOUSBVCOutputTerminalDescriptor IOUSBVCOutputTerminalDescriptor;
#pragma options align=reset
// Video Class Camera Terminal Descriptor
//
#pragma pack(1)
struct IOUSBVCCameraTerminalDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bTerminalID;
uint16_t wTerminalType;
uint8_t bAssocTerminal;
uint8_t iTerminal;
uint16_t wObjectiveFocalLengthMin;
uint16_t wObjectiveFocalLengthMax;
uint16_t wOcularFocalLength;
uint8_t bControlSize; // Size of the bmControls field
uint8_t bmControls[1];
};
typedef struct IOUSBVCCameraTerminalDescriptor IOUSBVCCameraTerminalDescriptor;
#pragma options align=reset
// Video Class Selector Unit Descriptor
//
#pragma pack(1)
struct IOUSBVCSelectorUnitDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bUnitID;
uint8_t bNrInPins;
uint8_t baSourceID[1];
};
typedef struct IOUSBVCSelectorUnitDescriptor IOUSBVCSelectorUnitDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCSelectorUnit2Descriptor
{
uint8_t iSelector;
};
typedef struct IOUSBVCSelectorUnit2Descriptor IOUSBVCSelectorUnit2Descriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCProcessingUnitDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bUnitID;
uint8_t bSourceID;
uint16_t wMaxMultiplier;
uint8_t bControlSize;
uint8_t bmControls[1];
};
typedef struct IOUSBVCProcessingUnitDescriptor IOUSBVCProcessingUnitDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCProcessingUnit2Descriptor
{
uint8_t iProcessing;
};
typedef struct IOUSBVCProcessingUnit2Descriptor IOUSBVCProcessingUnit2Descriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCExtensionUnitDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bUnitID;
uint8_t guidFormat[16];
uint8_t bNumControls;
uint8_t bNrInPins;
uint8_t baSourceID[1];
};
typedef struct IOUSBVCExtensionUnitDescriptor IOUSBVCExtensionUnitDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCExtensionUnit2Descriptor
{
uint8_t bControlSize;
uint8_t bmControls[1];
};
typedef struct IOUSBVCExtensionUnit2Descriptor IOUSBVCExtensionUnit2Descriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCExtensionUnit3Descriptor
{
uint8_t iExtension;
};
typedef struct IOUSBVCExtensionUnit3Descriptor IOUSBVCExtensionUnit3Descriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVCInterruptEndpointDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint16_t wMaxTransferSize;
};
typedef struct IOUSBVCInterruptEndpointDescriptor IOUSBVCInterruptEndpointDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVSInputHeaderDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bNumFormats;
uint16_t wTotalLength;
uint8_t bEndpointAddress;
uint8_t bmInfo;
uint8_t bTerminalLink;
uint8_t bStillCaptureMethod;
uint8_t bTriggerSupport;
uint8_t bTriggerUsage;
uint8_t bControlSize;
uint8_t bmControls[1];
};
typedef struct IOUSBVSInputHeaderDescriptor IOUSBVSInputHeaderDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVSOutputHeaderDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bNumFormats;
uint16_t wTotalLength;
uint8_t bEndpointAddress;
uint8_t bTerminalLink;
};
typedef struct IOUSBVSOutputHeaderDescriptor IOUSBVSOutputHeaderDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MJPEGFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t bmFlags;
uint8_t bDefaultFrameIndex;
uint8_t bAspectRatioX;
uint8_t bAspectRatioY;
uint8_t bmInterlaceFlags;
uint8_t bCopyProtect;
};
typedef struct IOUSBVDC_MJPEGFormatDescriptor IOUSBVDC_MJPEGFormatDescriptor;
#pragma options align=reset
struct IOSUBVDC_StillImageSize
{
uint16_t wWidth;
uint16_t wHeight;
};
typedef struct IOSUBVDC_StillImageSize IOSUBVDC_StillImageSize;
struct IOSUBVDC_StillImageCompressionPattern
{
uint8_t bNumCompressionPattern;
uint8_t bCompression[1];
};
typedef struct IOSUBVDC_StillImageCompressionPattern IOSUBVDC_StillImageCompressionPattern;
#pragma pack(1)
struct IOUSBVDC_StillImageFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bEndpointAddress;
uint8_t bNumImageSizePatterns;
IOSUBVDC_StillImageSize dwSize[1];
};
typedef struct IOUSBVDC_StillImageFrameDescriptor IOUSBVDC_StillImageFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MJPEGFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwMinFrameInterval;
uint32_t dwMaxFrameInterval;
uint32_t dwFrameIntervalStep;
};
typedef struct IOUSBVDC_MJPEGFrameDescriptor IOUSBVDC_MJPEGFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MJPEGDiscreteFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwFrameInterval[1];
};
typedef struct IOUSBVDC_MJPEGDiscreteFrameDescriptor IOUSBVDC_MJPEGDiscreteFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_UncompressedFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t guidFormat[16];
uint8_t bBitsPerPixel;
uint8_t bDefaultFrameIndex;
uint8_t bAspectRatioX;
uint8_t bAspectRatioY;
uint8_t bmInterlaceFlags;
uint8_t bCopyProtect;
};
typedef struct IOUSBVDC_UncompressedFormatDescriptor IOUSBVDC_UncompressedFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_UncompressedFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwMinFrameInterval;
uint32_t dwMaxFrameInterval;
uint32_t dwFrameIntervalStep;
};
typedef struct IOUSBVDC_UncompressedFrameDescriptor IOUSBVDC_UncompressedFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_UncompressedDiscreteFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwFrameInterval[1];
};
typedef struct IOUSBVDC_UncompressedDiscreteFrameDescriptor IOUSBVDC_UncompressedDiscreteFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_VendorFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t guidMajorFormat[16];
uint8_t guidSubFormat[16];
uint8_t guidSpecifierFormat[16];
uint8_t bPayloadClass;
uint8_t bDefaultFrameIndex;
uint8_t bCopyProtect;
};
typedef struct IOUSBVDC_VendorFormatDescriptor IOUSBVDC_VendorFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_VendorFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwMinFrameInterval;
uint32_t dwMaxFrameInterval;
uint32_t dwFrameIntervalStep;
};
typedef struct IOUSBVDC_VendorFrameDescriptor IOUSBVDC_VendorFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_VendorDiscreteFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwFrameInterval[1];
};
typedef struct IOUSBVDC_VendorDiscreteFrameDescriptor IOUSBVDC_VendorDiscreteFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_DVFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint32_t dwMaxVideoFrameBufferSize;
uint8_t bFormatType;
};
typedef struct IOUSBVDC_DVFormatDescriptor IOUSBVDC_DVFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MPEG1SSFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint16_t wPacketLength;
uint16_t wPackLength;
uint8_t bPackDataType;
};
typedef struct IOUSBVDC_MPEG1SSFormatDescriptor IOUSBVDC_MPEG1SSFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MPEG2PSFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint16_t wPacketLength;
uint16_t wPackLength;
uint8_t bPackDataType;
};
typedef struct IOUSBVDC_MPEG2PSFormatDescriptor IOUSBVDC_MPEG2PSFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_MPEG2PTSFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bDataOffset;
uint8_t bPacketLength;
uint8_t bStrideLength;
};
typedef struct IOUSBVDC_MPEG2PTSFormatDescriptor IOUSBVDC_MPEG2PTSFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_ColorFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bColorPrimaries;
uint8_t bTransferCharacteristics;
uint8_t bMatrixCoefficients;
};
typedef struct IOUSBVDC_ColorFormatDescriptor IOUSBVDC_ColorFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_FrameBasedFormatDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t guidFormat[16];
uint8_t bBitsPerPixel;
uint8_t bDefaultFrameIndex;
uint8_t bAspectRatioX;
uint8_t bAspectRatioY;
uint8_t bmInterlaceFlags;
uint8_t bCopyProtect;
uint8_t bVariableSize;
};
typedef struct IOUSBVDC_FrameBasedFormatDescriptor IOUSBVDC_FrameBasedFormatDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_FrameBasedFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwBytesPerLine;
uint32_t dwMinFrameInterval;
uint32_t dwMaxFrameInterval;
uint32_t dwFrameIntervalStep;
};
typedef struct IOUSBVDC_FrameBasedFrameDescriptor IOUSBVDC_FrameBasedFrameDescriptor;
#pragma options align=reset
#pragma pack(1)
struct IOUSBVDC_DiscreteFrameBasedFrameDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
uint16_t wHeight;
uint32_t dwMinBitRate;
uint32_t dwMaxBitRate;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
uint32_t dwBytesPerLine;
uint32_t dwMinFrameInterval;
uint32_t dwMaxFrameInterval;
uint32_t dwFrameInterval[1];
};
typedef struct IOUSBVDC_DiscreteFrameBasedFrameDescriptor IOUSBVDC_DiscreteFrameBasedFrameDescriptor;
#pragma options align=reset
@interface DecodeVideoInterfaceDescriptor : NSObject {
}
+(void)decodeBytes:(uint8_t *)descriptor forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
char MapNumberToVersion( int i );
@end

View File

@ -0,0 +1,58 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
#import "BusProberSharedFunctions.h"
#import "BusProbeDevice.h"
#import "DecodeDeviceDescriptor.h"
#import "DecodeConfigurationDescriptor.h"
#import "DecodeInterfaceDescriptor.h"
#import "DecodeEndpointDescriptor.h"
#import "DecodeHIDDescriptor.h"
#import "DecodeHubDescriptor.h"
#import "DecodeDeviceQualifierDescriptor.h"
#import "DecodeAudioInterfaceDescriptor.h"
#import "DecodeVideoInterfaceDescriptor.h"
#import "DecodeCommClassDescriptor.h"
#import "DecodeBOSDescriptor.h"
#define HID_DESCRIPTOR 0x21
#define DFU_FUNCTIONAL_DESCRIPTOR 0x21
#define CCID_DESCRIPTOR 0x21
enum ClassSpecific {
CS_INTERFACE = 0x24,
CS_ENDPOINT = 0x25
};
@interface DescriptorDecoder : NSObject {
}
+(void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf userInfo:(void *)userInfo isOtherSpeedDesc:(BOOL)isOtherSpeedDesc isinCurrentConfig:(Boolean)inCurrentConfig;
+(void)dumpRawDescriptor:(Byte *)p forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
+(void)dumpRawConfigDescriptor:(IOUSBConfigurationDescriptor*)cfg forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
+(void)dump:(int)n byte:(Byte *)p forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
+(void)dumpRawBOSDescriptor:(IOUSBBOSDescriptor*)bos forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
@end

View File

@ -0,0 +1,38 @@
/*
* Copyright © 2011-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Cocoa/Cocoa.h>
@interface ExtensionSelector : NSView
{
NSPopUpButton *extensionSelectionButton;
NSSavePanel *theSavePanel;
NSDictionary *itemDictionary;
}
@property (nonatomic, retain) NSPopUpButton *extensionSelectionButton;
@property (nonatomic, retain) NSSavePanel *theSavePanel;
@property (nonatomic, retain) NSDictionary *itemDictionary;
-(void)populatePopuButtonWithArray:(NSDictionary *)addItems;
-(void)setCurrentSelection:(NSString *)currentSelection;
@end

View File

@ -0,0 +1,34 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Cocoa/Cocoa.h>
#import "BusProbeDevice.h"
@interface NSOutlineView(OutlineViewAdditions)
- (void)itemDoubleClicked;
@end

View File

@ -0,0 +1,67 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Foundation/Foundation.h>
@interface OutlineViewNode : NSObject {
NSString * _name;
NSString * _value;
NSMutableArray * _children;
NSString * _tempName;
NSString * _tempValue;
}
- init;
- initWithName:(NSString *)name value:(NSString *)value;
- (void)dealloc;
// Accessor methods for the strings
- (NSString *)name;
- (NSString *)value;
- (void)setName:(NSString *)aString;
- (void)setValue:(NSString *)aString;
// Accessors for the children
- (void)addChild:(OutlineViewNode *)aNode;
- (int)childrenCount;
- (NSArray *)children;
- (OutlineViewNode *)childAtIndex:(int)i;
- (void)removeAllChildren;
- (void)addNode:(OutlineViewNode *)aNode atDepth:(int)depth;
- (void)addNodeWithName:(char *)name value:(char *)value atDepth:(int)depth;
// Other properties
- (BOOL)isExpandable;
- (OutlineViewNode *)deepestChild;
- (NSString*)stringRepresentation:(NSString*)name startingLevel:(int)startingLevel;
- (NSString *)stringRepresentation:(int)startingLevel;
- (NSString *)stringRepresentationOfValues:(int)startingLevel;
- (NSMutableDictionary *)dictionaryVersionOfMe;
@end

View File

@ -0,0 +1,36 @@
/*
* Copyright © 1998-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#import <Cocoa/Cocoa.h>
@interface TableViewWithCopying : NSTableView {
}
- (IBAction)copy:(id)sender;
- (NSString *)stringRepresentation;
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
@end

View File

@ -0,0 +1,6 @@
#import "BusProberSharedFunctions.h"
//#import "BusProbeController.h"
#import "BusProber.h"
//#import "BusProbeDevice.h"
//#import "BusProbeClass.h"

View File

@ -0,0 +1,372 @@
/*!
\page AppleLicense
APPLE PUBLIC SOURCE LICENSE
Version 2.0 - August 6, 2003
Please read this License carefully before downloading this software.
By downloading or using this software, you are agreeing to be bound by
the terms of this License. If you do not or cannot agree to the terms
of this License, please do not download or use the software.
1. General; Definitions. This License applies to any program or other
work which Apple Computer, Inc. ("Apple") makes publicly available and
which contains a notice placed by Apple identifying such program or
work as "Original Code" and stating that it is subject to the terms of
this Apple Public Source License version 2.0 ("License"). As used in
this License:
1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
the grantor of rights, (i) claims of patents that are now or hereafter
acquired, owned by or assigned to Apple and (ii) that cover subject
matter contained in the Original Code, but only to the extent
necessary to use, reproduce and/or distribute the Original Code
without infringement; and (b) in the case where You are the grantor of
rights, (i) claims of patents that are now or hereafter acquired,
owned by or assigned to You and (ii) that cover subject matter in Your
Modifications, taken alone or in combination with Original Code.
1.2 "Contributor" means any person or entity that creates or
contributes to the creation of Modifications.
1.3 "Covered Code" means the Original Code, Modifications, the
combination of Original Code and any Modifications, and/or any
respective portions thereof.
1.4 "Externally Deploy" means: (a) to sublicense, distribute or
otherwise make Covered Code available, directly or indirectly, to
anyone other than You; and/or (b) to use Covered Code, alone or as
part of a Larger Work, in any way to provide a service, including but
not limited to delivery of content, through electronic communication
with a client other than You.
1.5 "Larger Work" means a work which combines Covered Code or portions
thereof with code not governed by the terms of this License.
1.6 "Modifications" mean any addition to, deletion from, and/or change
to, the substance and/or structure of the Original Code, any previous
Modifications, the combination of Original Code and any previous
Modifications, and/or any respective portions thereof. When code is
released as a series of files, a Modification is: (a) any addition to
or deletion from the contents of a file containing Covered Code;
and/or (b) any new file or other representation of computer program
statements that contains any part of Covered Code.
1.7 "Original Code" means (a) the Source Code of a program or other
work as originally made available by Apple under this License,
including the Source Code of any updates or upgrades to such programs
or works made available by Apple under this License, and that has been
expressly identified by Apple as such in the header file(s) of such
work; and (b) the object code compiled from such Source Code and
originally made available by Apple under this License.
1.8 "Source Code" means the human readable form of a program or other
work that is suitable for making modifications to it, including all
modules it contains, plus any associated interface definition files,
scripts used to control compilation and installation of an executable
(object code).
1.9 "You" or "Your" means an individual or a legal entity exercising
rights under this License. For legal entities, "You" or "Your"
includes any entity which controls, is controlled by, or is under
common control with, You, where "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of fifty percent
(50%) or more of the outstanding shares or beneficial ownership of
such entity.
2. Permitted Uses; Conditions & Restrictions. Subject to the terms
and conditions of this License, Apple hereby grants You, effective on
the date You accept this License and download the Original Code, a
world-wide, royalty-free, non-exclusive license, to the extent of
Apple's Applicable Patent Rights and copyrights covering the Original
Code, to do the following:
2.1 Unmodified Code. You may use, reproduce, display, perform,
internally distribute within Your organization, and Externally Deploy
verbatim, unmodified copies of the Original Code, for commercial or
non-commercial purposes, provided that in each instance:
(a) You must retain and reproduce in all copies of Original Code the
copyright and other proprietary notices and disclaimers of Apple as
they appear in the Original Code, and keep intact all notices in the
Original Code that refer to this License; and
(b) You must include a copy of this License with every copy of Source
Code of Covered Code and documentation You distribute or Externally
Deploy, and You may not offer or impose any terms on such Source Code
that alter or restrict this License or the recipients' rights
hereunder, except as permitted under Section 6.
2.2 Modified Code. You may modify Covered Code and use, reproduce,
display, perform, internally distribute within Your organization, and
Externally Deploy Your Modifications and Covered Code, for commercial
or non-commercial purposes, provided that in each instance You also
meet all of these conditions:
(a) You must satisfy all the conditions of Section 2.1 with respect to
the Source Code of the Covered Code;
(b) You must duplicate, to the extent it does not already exist, the
notice in Exhibit A in each file of the Source Code of all Your
Modifications, and cause the modified files to carry prominent notices
stating that You changed the files and the date of any change; and
(c) If You Externally Deploy Your Modifications, You must make
Source Code of all Your Externally Deployed Modifications either
available to those to whom You have Externally Deployed Your
Modifications, or publicly available. Source Code of Your Externally
Deployed Modifications must be released under the terms set forth in
this License, including the license grants set forth in Section 3
below, for as long as you Externally Deploy the Covered Code or twelve
(12) months from the date of initial External Deployment, whichever is
longer. You should preferably distribute the Source Code of Your
Externally Deployed Modifications electronically (e.g. download from a
web site).
2.3 Distribution of Executable Versions. In addition, if You
Externally Deploy Covered Code (Original Code and/or Modifications) in
object code, executable form only, You must include a prominent
notice, in the code itself as well as in related documentation,
stating that Source Code of the Covered Code is available under the
terms of this License with information on how and where to obtain such
Source Code.
2.4 Third Party Rights. You expressly acknowledge and agree that
although Apple and each Contributor grants the licenses to their
respective portions of the Covered Code set forth herein, no
assurances are provided by Apple or any Contributor that the Covered
Code does not infringe the patent or other intellectual property
rights of any other entity. Apple and each Contributor disclaim any
liability to You for claims brought by any other entity based on
infringement of intellectual property rights or otherwise. As a
condition to exercising the rights and licenses granted hereunder, You
hereby assume sole responsibility to secure any other intellectual
property rights needed, if any. For example, if a third party patent
license is required to allow You to distribute the Covered Code, it is
Your responsibility to acquire that license before distributing the
Covered Code.
3. Your Grants. In consideration of, and as a condition to, the
licenses granted to You under this License, You hereby grant to any
person or entity receiving or distributing Covered Code under this
License a non-exclusive, royalty-free, perpetual, irrevocable license,
under Your Applicable Patent Rights and other intellectual property
rights (other than patent) owned or controlled by You, to use,
reproduce, display, perform, modify, sublicense, distribute and
Externally Deploy Your Modifications of the same scope and extent as
Apple's licenses under Sections 2.1 and 2.2 above.
4. Larger Works. You may create a Larger Work by combining Covered
Code with other code not governed by the terms of this License and
distribute the Larger Work as a single product. In each such instance,
You must make sure the requirements of this License are fulfilled for
the Covered Code or any portion thereof.
5. Limitations on Patent License. Except as expressly stated in
Section 2, no other patent rights, express or implied, are granted by
Apple herein. Modifications and/or Larger Works may require additional
patent licenses from Apple which Apple may grant in its sole
discretion.
6. Additional Terms. You may choose to offer, and to charge a fee for,
warranty, support, indemnity or liability obligations and/or other
rights consistent with the scope of the license granted herein
("Additional Terms") to one or more recipients of Covered Code.
However, You may do so only on Your own behalf and as Your sole
responsibility, and not on behalf of Apple or any Contributor. You
must obtain the recipient's agreement that any such Additional Terms
are offered by You alone, and You hereby agree to indemnify, defend
and hold Apple and every Contributor harmless for any liability
incurred by or claims asserted against Apple or such Contributor by
reason of any such Additional Terms.
7. Versions of the License. Apple may publish revised and/or new
versions of this License from time to time. Each version will be given
a distinguishing version number. Once Original Code has been published
under a particular version of this License, You may continue to use it
under the terms of that version. You may also choose to use such
Original Code under the terms of any subsequent version of this
License published by Apple. No one other than Apple has the right to
modify the terms applicable to Covered Code created under this
License.
8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
part pre-release, untested, or not fully tested works. The Covered
Code may contain errors that could cause failures or loss of data, and
may be incomplete or contain inaccuracies. You expressly acknowledge
and agree that use of the Covered Code, or any portion thereof, is at
Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
You acknowledge that the Covered Code is not intended for use in the
operation of nuclear facilities, aircraft navigation, communication
systems, or air traffic control machines in which case the failure of
the Covered Code could lead to death, personal injury, or severe
physical or environmental damage.
9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
TO YOU. In no event shall Apple's total liability to You for all
damages (other than as may be required by applicable law) under this
License exceed the amount of fifty dollars ($50.00).
10. Trademarks. This License does not grant any rights to use the
trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
"QuickTime", "QuickTime Streaming Server" or any other trademarks,
service marks, logos or trade names belonging to Apple (collectively
"Apple Marks") or to any trademark, service mark, logo or trade name
belonging to any Contributor. You agree not to use any Apple Marks in
or as part of the name of products derived from the Original Code or
to endorse or promote products derived from the Original Code other
than as expressly permitted by and in strict compliance at all times
with Apple's third party trademark usage guidelines which are posted
at http://www.apple.com/legal/guidelinesfor3rdparties.html.
11. Ownership. Subject to the licenses granted under this License,
each Contributor retains all rights, title and interest in and to any
Modifications made by such Contributor. Apple retains all rights,
title and interest in and to the Original Code and any Modifications
made by or on behalf of Apple ("Apple Modifications"), and such Apple
Modifications will not be automatically subject to this License. Apple
may, at its sole discretion, choose to license such Apple
Modifications under this License, or on different terms from those
contained in this License or may choose not to license them at all.
12. Termination.
12.1 Termination. This License and the rights granted hereunder will
terminate:
(a) automatically without notice from Apple if You fail to comply with
any term(s) of this License and fail to cure such breach within 30
days of becoming aware of such breach;
(b) immediately in the event of the circumstances described in Section
13.5(b); or
(c) automatically without notice from Apple if You, at any time during
the term of this License, commence an action for patent infringement
against Apple; provided that Apple did not first commence
an action for patent infringement against You in that instance.
12.2 Effect of Termination. Upon termination, You agree to immediately
stop any further use, reproduction, modification, sublicensing and
distribution of the Covered Code. All sublicenses to the Covered Code
which have been properly granted prior to termination shall survive
any termination of this License. Provisions which, by their nature,
should remain in effect beyond the termination of this License shall
survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
12.2 and 13. No party will be liable to any other for compensation,
indemnity or damages of any sort solely as a result of terminating
this License in accordance with its terms, and termination of this
License will be without prejudice to any other right or remedy of
any party.
13. Miscellaneous.
13.1 Government End Users. The Covered Code is a "commercial item" as
defined in FAR 2.101. Government software and technical data rights in
the Covered Code include only those rights customarily provided to the
public as defined in this License. This customary commercial license
in technical data and software is provided in accordance with FAR
12.211 (Technical Data) and 12.212 (Computer Software) and, for
Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
Commercial Items) and 227.7202-3 (Rights in Commercial Computer
Software or Computer Software Documentation). Accordingly, all U.S.
Government End Users acquire Covered Code with only those rights set
forth herein.
13.2 Relationship of Parties. This License will not be construed as
creating an agency, partnership, joint venture or any other form of
legal association between or among You, Apple or any Contributor, and
You will not represent to the contrary, whether expressly, by
implication, appearance or otherwise.
13.3 Independent Development. Nothing in this License will impair
Apple's right to acquire, license, develop, have others develop for
it, market and/or distribute technology or products that perform the
same or similar functions as, or otherwise compete with,
Modifications, Larger Works, technology or products that You may
develop, produce, market or distribute.
13.4 Waiver; Construction. Failure by Apple or any Contributor to
enforce any provision of this License will not be deemed a waiver of
future enforcement of that or any other provision. Any law or
regulation which provides that the language of a contract shall be
construed against the drafter will not apply to this License.
13.5 Severability. (a) If for any reason a court of competent
jurisdiction finds any provision of this License, or portion thereof,
to be unenforceable, that provision of the License will be enforced to
the maximum extent permissible so as to effect the economic benefits
and intent of the parties, and the remainder of this License will
continue in full force and effect. (b) Notwithstanding the foregoing,
if applicable law prohibits or restricts You from fully and/or
specifically complying with Sections 2 and/or 3 or prevents the
enforceability of either of those Sections, this License will
immediately terminate and You must immediately discontinue any use of
the Covered Code and destroy all copies of it that are in your
possession or control.
13.6 Dispute Resolution. Any litigation or other dispute resolution
between You and Apple relating to this License shall take place in the
Northern District of California, and You and Apple hereby consent to
the personal jurisdiction of, and venue in, the state and federal
courts within that District with respect to this License. The
application of the United Nations Convention on Contracts for the
International Sale of Goods is expressly excluded.
13.7 Entire Agreement; Governing Law. This License constitutes the
entire agreement between the parties with respect to the subject
matter hereof. This License shall be governed by the laws of the
United States and the State of California, except that body of
California law concerning conflicts of law.
Where You are located in the province of Quebec, Canada, the following
clause applies: The parties hereby confirm that they have requested
that this License and all related documents be drafted in English. Les
parties ont exige que le present contrat et tous les documents
connexes soient rediges en anglais.
EXHIBIT A.
"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
Reserved.
This file contains Original Code and/or Modifications of Original Code
as defined in and that are subject to the Apple Public Source License
Version 2.0 (the 'License'). You may not use this file except in
compliance with the License. Please obtain a copy of the License at
http://www.opensource.apple.com/apsl/ and read it before using this
file.
The Original Code and all software distributed under the License are
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
Please see the License for the specific language governing rights and
limitations under the License."
*/

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>17F77</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>USBBusProber</string>
<key>CFBundleIdentifier</key>
<string>com.Vidvox.USBBusProber</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>USBBusProber</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>9C40b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>17C76</string>
<key>DTSDKName</key>
<string>macosx10.13</string>
<key>DTXcode</key>
<string>0920</string>
<key>DTXcodeBuild</key>
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Vidvox. All rights reserved.</string>
</dict>
</plist>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
A

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 1998-2012 Apple Inc. All rights reserved. * Copyright <EFBFBD> 1998-2012 Apple Inc. All rights reserved.
* *
* @APPLE_LICENSE_HEADER_START@ * @APPLE_LICENSE_HEADER_START@
* *

View File

@ -0,0 +1 @@
Versions/Current/Headers

View File

@ -0,0 +1 @@
Versions/Current/Resources

View File

@ -0,0 +1 @@
Versions/Current/VVUVCKit

View File

@ -0,0 +1,405 @@
#import <Foundation/Foundation.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>
#import <USBBusProber/USBBusProber.h>
//#import <QTKit/QTKit.h>
#import "VVUVCKitStringAdditions.h"
/**
\defgroup VVUVCController
*/
/*
@protocol VVUVCControllerDelegate
- (void) VVUVCControllerParamsUpdated:(id)c;
@end
*/
/**
\ingroup VVUVCController
Auto-exposure modes described by the USB spec, put in a typedef/enum for convenience
*/
typedef enum {
UVC_AEMode_Undefined = 0x00, /// undefined auto exposure mode
UVC_AEMode_Manual = 0x01, /// manual exposure, manual iris
UVC_AEMode_Auto = 0x02, /// auto exposure, auto iris
UVC_AEMode_ShutterPriority = 0x04, /// manual exposure, auto iris
UVC_AEMode_AperturePriority = 0x08 /// auto exposure, manual iris
} UVC_AEMode;
/* this struct contains all the info necessary to get/set vals from a video control parameter (either terminal/hardware or
processing/software)- but it does not contain info about the value at all! think of this struct as a sort of function
description for the hardware which will be sent out directly via USB. instances of this struct are populated by values
from the USB specification! */
typedef struct {
int unit; // describes whether terminal/hardware or processing/software
int selector; // the address of the "parameter" being changed-
int intendedSize;
BOOL hasMin; // whether or not the video control parameter described by this struct has a min val
BOOL hasMax; // whether or not the video control parameter described by this struct has a max
BOOL hasDef; // whether or not the video control parameter described by this struct has a default
BOOL isSigned; // whether or not the video control parameter described by this struct is a signed val
BOOL isRelative; // whether or not the video control parameter described by this struct is a relative val
} uvc_control_info_t;
/* these variables contain enough info to send data to/get data from the implied attribute. the
variables are global to the class (the contents won't change from instance to instance), and
conceptually act like function descriptions (instances of this class can pass references to these
variables, which can be used to get/set values). these are populated when the class is
initialized by values described in the USB specification. if uvc_control_info_t is a function
description, these variables are essentially pointers to a bunch of different functions. */
extern uvc_control_info_t _scanCtrl;
extern uvc_control_info_t _autoExposureModeCtrl;
extern uvc_control_info_t _autoExposurePriorityCtrl;
extern uvc_control_info_t _exposureTimeCtrl;
extern uvc_control_info_t _irisCtrl;
extern uvc_control_info_t _autoFocusCtrl;
extern uvc_control_info_t _focusCtrl;
extern uvc_control_info_t _zoomCtrl;
extern uvc_control_info_t _panTiltCtrl;
extern uvc_control_info_t _panTiltRelCtrl;
extern uvc_control_info_t _rollCtrl;
extern uvc_control_info_t _rollRelCtrl;
extern uvc_control_info_t _backlightCtrl;
extern uvc_control_info_t _brightCtrl;
extern uvc_control_info_t _contrastCtrl;
extern uvc_control_info_t _gainCtrl;
extern uvc_control_info_t _powerLineCtrl;
extern uvc_control_info_t _autoHueCtrl;
extern uvc_control_info_t _hueCtrl;
extern uvc_control_info_t _saturationCtrl;
extern uvc_control_info_t _sharpnessCtrl;
extern uvc_control_info_t _gammaCtrl;
extern uvc_control_info_t _whiteBalanceAutoTempCtrl;
extern uvc_control_info_t _whiteBalanceTempCtrl;
/* this struct describes a parameter- it contains a pointer to the control info that describes
which parameter, as well as the min/max/default/current value. an instance of this struct will
contain the value of the parameter and the uvc_control_info_t struct necessary to communicate with
this parameter in a camera. */
typedef struct {
BOOL supported; // if YES, this parameter is supported. if NO, either the camera doesn't support this parameter, or the "inputTerminalID" or "processingUnitID" of the camera is wrong!
long min; // the paramter's actual min val
long max; // the parameter's actual max val
long val; // the parameter's actual val
long def; // the parameter's default val
int actualSize;
uvc_control_info_t *ctrlInfo;
} uvc_param;
/// An instance of VVUVCController will control the UVC params for a single USB video device. This is probably the only class you'll have to create or work with in this framework.
/**
\ingroup VVUVCController
This is probably the only class you'll have to work with in this framework. The basic idea is that you create a VVUVCController for an enabled USB video device, and then either tell the controller to open its settings window or interact with it programmatically. If you're looking for a more "embedded" feel, you can remove the VVUVCController's "settingsView" from its superview and add it into your application's NSView hierarchy.
*/
@interface VVUVCController : NSObject {
IOUSBInterfaceInterface190 **interface;
UInt32 deviceLocationID;
UInt8 interfaceNumber; // pulled from interface on generalInit!
int inputTerminalID; // the "address" of the terminal unit, which handles hardware controls like aperture/focus. if this val is wrong, the hardware controls won't be available.
int processingUnitID; // the "address" of the processing unit, which handles software controls like contrast/hue. if this val is wrong, the software controls won't be available.
//id <VVUVCControllerDelegate>delegate;
uvc_param scanningMode;
uvc_param autoExposureMode; // mode functionality described by the type UVC_AEMode
uvc_param autoExposurePriority; // if 1, framerate may be varied. if 0, framerate must remain constant.
uvc_param exposureTime;
uvc_param iris;
uvc_param autoFocus;
uvc_param focus;
uvc_param zoom;
uvc_param panTilt;
uvc_param panTiltRel;
uvc_param roll;
uvc_param rollRel;
uvc_param backlight;
uvc_param bright;
uvc_param contrast;
uvc_param gain;
uvc_param powerLine;
uvc_param autoHue;
uvc_param hue;
uvc_param saturation;
uvc_param sharpness;
uvc_param gamma;
uvc_param autoWhiteBalance;
uvc_param whiteBalance;
// this class has its own .nib which contains a UI for interacting with the class that may be opened directly in a window, or accessed as an NSView instance for use in other UIs/software
NSNib *theNib;
NSArray *nibTopLevelObjects;
IBOutlet id uiCtrlr; // created & owned by the nib!
IBOutlet NSWindow *settingsWindow; // by default, the UI is in a window (it's easiest to just open and close it)
IBOutlet NSView *settingsView; // you can also access the view which contains the UI so you can embed it in other apps
}
/// Use this method to init an instance of VVUVCController from an NSString returned by the AVFoundation or QTCapture APIs as the device's unique ID.
/**
@param n The "deviceIDString" is a string returned by QuickTime and AVFoundation as the unique ID for the USB video device. Technically, this is a hex value with sixteen digits (16 hex digits = an unsigned 64-bit integer). The first 8 hex digits is the USB device's "locationID", the next 4 hex digits is the device's vendor ID, and the last 4 digits are the device's product ID. Only the locationID is needed to create the necessary USB interfaces...
*/
- (id) initWithDeviceIDString:(NSString *)n;
/// Use this method to init an instance of VVUVCController from the USB location ID.
/**
@param locationID The location ID of the USB device you want this instance of VVUVCController to control.
*/
- (id) initWithLocationID:(UInt32)locationID;
- (IOUSBInterfaceInterface190 **) _getControlInferaceWithDeviceInterface:(IOUSBDeviceInterface **)deviceInterface;
- (void) generalInit;
/// Returns a mutable dict representing the current state of the video input parameters
- (NSMutableDictionary *) createSnapshot;
/// Loads a saved state dict created with the "createSnapshot" method
- (void) loadSnapshot:(NSDictionary *)s;
- (BOOL) _sendControlRequest:(IOUSBDevRequest *)controlRequest;
- (int) _requestValType:(int)requestType forControl:(const uvc_control_info_t *)ctrl returnVal:(void **)ret;
- (BOOL) _setBytes:(void *)bytes sized:(int)size toControl:(const uvc_control_info_t *)ctrl;
- (void) _populateAllParams; // populates all the uvc_param variables in this instance, loading their min/max/default vals and determining if they're supported or not
- (void) _populateParam:(uvc_param *)param;
- (BOOL) _pushParamToDevice:(uvc_param *)param;
- (void) _resetParamToDefault:(uvc_param *)param;
/// Resets the parameters to their default values. The default values are supplied by/stored in the device.
- (void) resetParamsToDefaults;
/// Opens a window with a GUI for interacting with the camera parameters
- (void) openSettingsWindow;
/// Closes the GUI window (if it's open).
- (void) closeSettingsWindow;
- (void) setInterlaced:(BOOL)n;
- (BOOL) interlaced;
- (BOOL) interlacedSupported;
- (void) resetInterlaced;
/// Sets the auto exposure mode using one of the basic auto exposure modes defined in the header (vals pulled from the USB spec)
- (void) setAutoExposureMode:(UVC_AEMode)n;
/// Gets the auto exposure mode
- (UVC_AEMode) autoExposureMode;
/// Whether or not this camera supports the use of alternate auto exposure modes
- (BOOL) autoExposureModeSupported;
/// Resets the auto exposure mode to the hardware-defined default
- (void) resetAutoExposureMode;
/// Sets whether or not auto exposure will be given priority
- (void) setAutoExposurePriority:(BOOL)n;
/// Gets whether or not the camera is giving auto exposure priority
- (BOOL) autoExposurePriority;
/// Whether or not this camera supports the use of auto exposure priority
- (BOOL) autoExposurePrioritySupported;
/// Resets the auto exposure priority to the hardware-defined default
- (void) resetAutoExposurePriority;
/// Sets the exposure time to the passed value
- (void) setExposureTime:(long)n;
/// Gets the current exposure time value being used by the camera
- (long) exposureTime;
/// Whether or not this camera supports the exposure time parameter
- (BOOL) exposureTimeSupported;
/// Resets the exposure time value to the hardware-defined default
- (void) resetExposureTime;
/// The min exposure time value
- (long) minExposureTime;
/// The max exposure time value
- (long) maxExposureTime;
/// Sets the iris to the passed value
- (void) setIris:(long)n;
/// Gets the current iris value being used by the camera
- (long) iris;
/// Whether or not this camera supports the iris parameter
- (BOOL) irisSupported;
/// Resets the iris value to the hardware-defined default
- (void) resetIris;
/// The min iris value
- (long) minIris;
/// The max iris value
- (long) maxIris;
/// Sets the auto focus to the passed value
- (void) setAutoFocus:(BOOL)n;
/// Gets the auto focus value being used by the camera
- (BOOL) autoFocus;
/// Whether or not this camera supports the auto focus parameter
- (BOOL) autoFocusSupported;
/// Resets the auto focus value to the hardware-defined default.
- (void) resetAutoFocus;
/// Sets the focus value
- (void) setFocus:(long)n;
/// Gets the focus value currently being used by the camera
- (long) focus;
/// Whether or not this camera supports the focus parameter
- (BOOL) focusSupported;
/// Resets the focus value to the hardware-defined default
- (void) resetFocus;
/// The min focus value
- (long) minFocus;
/// The max focus value
- (long) maxFocus;
/// Sets the zoom value
- (void) setZoom:(long)n;
/// Gets the current zoom value being used by the camera
- (long) zoom;
/// Whether or not this camera supports the zoom parameter
- (BOOL) zoomSupported;
/// Resets the zoom value to the hardware-defined default
- (void) resetZoom;
/// The min zoom value
- (long) minZoom;
/// The max zoom value
- (long) maxZoom;
// pan/tilt/roll aren't enabled
- (BOOL) panSupported;
- (BOOL) tiltSupported;
- (BOOL) rollSupported;
/// Sets the backlight to the passed value
- (void) setBacklight:(long)n;
/// Gets the backlight value currently being used by the camera
- (long) backlight;
/// Whether or not this camera supports the backlight parameter
- (BOOL) backlightSupported;
/// Resets the backlight value to the hardware-defined default
- (void) resetBacklight;
/// The min backlight value
- (long) minBacklight;
/// The max backlight value
- (long) maxBacklight;
/// Sets the bright value to the passed value
- (void) setBright:(long)n;
/// Gets the bright value currently being used by the camera
- (long) bright;
/// Whether or not this camera supports the bright parameter
- (BOOL) brightSupported;
/// Resets the bright parameter to the hardware-defined default
- (void) resetBright;
/// The min bright value
- (long) minBright;
/// The max bright value
- (long) maxBright;
/// Sets the contrast to the passed value
- (void) setContrast:(long)n;
/// Gets the contrast value currently being used by the camera
- (long) contrast;
/// Whether or not this camera supports the contrast parameter
- (BOOL) contrastSupported;
/// Resets the contrast to the hardware-defined default
- (void) resetContrast;
/// The min contrast value
- (long) minContrast;
/// The max contrast value
- (long) maxContrast;
/// Sets the gain to the passed value
- (void) setGain:(long)n;
/// Gets the gain value currently being used by the camera
- (long) gain;
/// Whether or not this camera supports the gain parameter
- (BOOL) gainSupported;
/// Resets the gain value to the hardware-defined default
- (void) resetGain;
/// The min gain value
- (long) minGain;
/// The max gain value
- (long) maxGain;
/// Sets the powerline to the passed value
- (void) setPowerLine:(long)n;
/// Gets the powerline value currently being used by the camera
- (long) powerLine;
/// Whether or not this camera supports the powerline parameter
- (BOOL) powerLineSupported;
/// Resets the powerline value to the hardware-defined default
- (void) resetPowerLine;
/// The min powerline value
- (long) minPowerLine;
/// The max powerline value
- (long) maxPowerLine;
/// Sets the auto hue to the passed value
- (void) setAutoHue:(BOOL)n;
/// The auto hue value currently being used by the camera
- (BOOL) autoHue;
/// Whether or not this camera supports the auto hue parameter
- (BOOL) autoHueSupported;
/// Resets the auto hue parameter to the hardware-defined default
- (void) resetAutoHue;
/// Sets the hue to the passed value
- (void) setHue:(long)n;
/// Gets the hue value currently being used by the camera
- (long) hue;
/// Whether or not this camera supports the hue parameter
- (BOOL) hueSupported;
/// Resets the hue parameter to the hardware-defined default
- (void) resetHue;
/// The min hue value
- (long) minHue;
/// The max hue value
- (long) maxHue;
/// Sets the saturation to the passed value
- (void) setSaturation:(long)n;
/// Gets the saturation value currently being used by the camera
- (long) saturation;
/// Whether or not this camera supports the saturation parameter
- (BOOL) saturationSupported;
/// Resets the saturation to the hardware-defined default
- (void) resetSaturation;
/// The min saturation value
- (long) minSaturation;
/// The max saturation value
- (long) maxSaturation;
/// Sets the sharpness to the passed value
- (void) setSharpness:(long)n;
/// Gets the sharpness value currently being used by the camera
- (long) sharpness;
/// Whether or not this camera supports the sharpness parameter
- (BOOL) sharpnessSupported;
/// Resets the sharpness to the hardware-defined default
- (void) resetSharpness;
/// The min sharpness value
- (long) minSharpness;
/// The max sharpness value
- (long) maxSharpness;
/// Sets the gamma to the passed value
- (void) setGamma:(long)n;
/// Gets the gamma value currently being used by the camera
- (long) gamma;
/// Whether or not this camera supports the gamma parameter
- (BOOL) gammaSupported;
/// Resets the gamma value to the hardware-defined default
- (void) resetGamma;
/// The min gamma value
- (long) minGamma;
/// The max gamma value
- (long) maxGamma;
/// Sets the auto white balance to the passed value
- (void) setAutoWhiteBalance:(BOOL)n;
/// Gets the auto white balance value currently being used by the camera
- (BOOL) autoWhiteBalance;
/// Whether or not this camera supports the auto white balance parameter
- (BOOL) autoWhiteBalanceSupported;
/// Resets the auto white balance to the hardware-defined default
- (void) resetAutoWhiteBalance;
/// Sets the white balance to the passed value
- (void) setWhiteBalance:(long)n;
/// Gets the white balance value currently being used by the camera
- (long) whiteBalance;
/// Whether or not this camera supports the white balance parameter
- (BOOL) whiteBalanceSupported;
/// Resets the white balance value to the hardware-defined default
- (void) resetWhiteBalance;
/// The min white balance value
- (long) minWhiteBalance;
/// The max white balance value
- (long) maxWhiteBalance;
@end

View File

@ -0,0 +1,4 @@
// this is the only class you should need to explicitly instantiate!
#import "VVUVCController.h"

View File

@ -0,0 +1,7 @@
#import <Cocoa/Cocoa.h>
@interface NSString (VVUVCKitStringAdditions)
- (BOOL) containsString:(NSString *)n;
@end

View File

@ -0,0 +1,44 @@
#import <Cocoa/Cocoa.h>
#import "VVUVCUIElement.h"
@interface VVUVCUIController : NSObject <VVUVCUIElementDelegate> {
IBOutlet id device;
IBOutlet NSPopUpButton *autoExpButton;
IBOutlet NSButton *expPriorityButton;
IBOutlet NSButton *autoFocusButton;
//IBOutlet NSSlider *panSlider;
//IBOutlet NSSlider *tiltSlider;
//IBOutlet NSSlider *rollSlider;
IBOutlet NSButton *autoHueButton;
IBOutlet NSButton *autoWBButton;
IBOutlet VVUVCUIElement *expElement;
IBOutlet VVUVCUIElement *irisElement;
IBOutlet VVUVCUIElement *focusElement;
IBOutlet VVUVCUIElement *zoomElement;
IBOutlet VVUVCUIElement *backlightElement;
IBOutlet VVUVCUIElement *brightElement;
IBOutlet VVUVCUIElement *contrastElement;
IBOutlet VVUVCUIElement *powerElement;
IBOutlet VVUVCUIElement *gammaElement;
IBOutlet VVUVCUIElement *hueElement;
IBOutlet VVUVCUIElement *satElement;
IBOutlet VVUVCUIElement *sharpElement;
IBOutlet VVUVCUIElement *gainElement;
IBOutlet VVUVCUIElement *wbElement;
}
- (IBAction) buttonUsed:(id)sender;
- (IBAction) popUpButtonUsed:(id)sender;
- (IBAction) resetToDefaults:(id)sender;
- (void) _pushCameraControlStateToUI;
@end

View File

@ -0,0 +1,36 @@
#import <Cocoa/Cocoa.h>
@protocol VVUVCUIElementDelegate
- (void) controlElementChanged:(id)sender;
@end
@interface VVUVCUIElement : NSBox {
IBOutlet id delegate;
BOOL enabled;
NSSlider *valSlider;
NSTextField *valField;
int val;
int min;
int max;
}
- (void) setEnabled:(BOOL)n;
- (void) _resizeContents;
- (void) uiItemUsed:(id)sender;
@property (assign,readwrite) id delegate;
@property (assign,readwrite) int val;
@property (assign,readwrite) int min;
@property (assign,readwrite) int max;
@end

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>17F77</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>VVUVCKit</string>
<key>CFBundleIdentifier</key>
<string>com.Vidvox.VVUVCKit</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>VVUVCKit</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>9C40b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>17C76</string>
<key>DTSDKName</key>
<string>macosx10.13</string>
<key>DTXcode</key>
<string>0920</string>
<key>DTXcodeBuild</key>
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Vidvox. All rights reserved.</string>
</dict>
</plist>

View File

@ -0,0 +1 @@
A

View File

@ -0,0 +1,90 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <thread>
#include <vector>
#include <atomic>
#include <mutex>
#include "mynteye/logger.h"
#include "mynteye/uvc/uvc.h"
#include "libuvc/libuvc.h"
#include "AVfoundationCamera.h"
// #define ENABLE_DEBUG_SPAM
MYNTEYE_BEGIN_NAMESPACE
namespace uvc {
// Enumerate devices
MYNTEYE_API std::shared_ptr<context> create_context() {
//too
}
MYNTEYE_API std::vector<std::shared_ptr<device>> query_devices(
std::shared_ptr<context> context) {
//todo
}
// Static device properties
MYNTEYE_API std::string get_name(const device &device) {
//todo
}
MYNTEYE_API int get_vendor_id(const device &device) {
//todo
}
MYNTEYE_API int get_product_id(const device &device) {
//todo
}
MYNTEYE_API std::string get_video_name(const device &device) {
//todo
}
MYNTEYE_API bool pu_control_range(
const device &device, Option option, int32_t *min, int32_t *max,
int32_t *def) {
// todo
}
MYNTEYE_API bool pu_control_query(
const device &device, Option option, pu_query query, int32_t *value) {
// todo
}
// Access XU (Extension Unit) controls
MYNTEYE_API bool xu_control_range(
const device &device, const xu &xu, uint8_t selector, uint8_t id,
int32_t *min, int32_t *max, int32_t *def) {
//todo
}
MYNTEYE_API bool xu_control_query( // XU_QUERY_SET, XU_QUERY_GET
const device &device, const xu &xu, uint8_t selector, xu_query query,
uint16_t size, uint8_t *data) {
//todo
}
MYNTEYE_API void set_device_mode(
device &device, int width, int height, int fourcc, int fps, // NOLINT
video_channel_callback callback) {
//todo
}
MYNTEYE_API void start_streaming(device &device, int num_transfer_bufs) {
//todo
}
MYNTEYE_API void stop_streaming(device &device) {
//todo
}
} // namespace uvc
MYNTEYE_END_NAMESPACE

View File

@ -64,7 +64,8 @@ namespace uvc {
const std::map<uint32_t, uint32_t> fourcc_map = { const std::map<uint32_t, uint32_t> fourcc_map = {
{ 0x56595559, 0x32595559 }, // 'VYUY' => '2YUY' { 0x56595559, 0x32595559 }, // 'VYUY' => '2YUY'
{ 0x59555956, 0x59555932 } // 'YUYV' => 'YUY2' { 0x59555956, 0x59555932 }, // 'YUYV' => 'YUY2'
{ 0x33524742, 0x14 }
}; };
struct throw_error { struct throw_error {
@ -756,6 +757,7 @@ void set_device_mode(device &device, int width, int height, int fourcc, int fps,
check("IMFMediaType::GetGUID", media_type->GetGUID(MF_MT_SUBTYPE, &subtype)); check("IMFMediaType::GetGUID", media_type->GetGUID(MF_MT_SUBTYPE, &subtype));
if (subtype.Data1 != fourcc) continue; if (subtype.Data1 != fourcc) continue;
check("MFSetAttributeRatio", MFSetAttributeRatio(media_type, MF_MT_FRAME_RATE, fps, 1));
check("MFGetAttributeRatio", MFGetAttributeRatio(media_type, MF_MT_FRAME_RATE, &uvc_fps_num, &uvc_fps_denom)); check("MFGetAttributeRatio", MFGetAttributeRatio(media_type, MF_MT_FRAME_RATE, &uvc_fps_num, &uvc_fps_denom));
if (uvc_fps_denom == 0) continue; if (uvc_fps_denom == 0) continue;
//int uvc_fps = uvc_fps_num / uvc_fps_denom; //int uvc_fps = uvc_fps_num / uvc_fps_denom;

View File

@ -170,5 +170,37 @@
<param name="gyro_low_filter" value="$(arg gyro_low_filter)" /> <param name="gyro_low_filter" value="$(arg gyro_low_filter)" />
</node> </node>
<!-- disable compressed depth plugin for image topics -->
<group ns="$(arg left_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
<group ns="$(arg left_rect_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
<group ns="$(arg right_rect_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
<group ns="$(arg right_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
<group ns="$(arg disparity_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
<group ns="$(arg disparity_norm_topic)">
<rosparam param="disable_pub_plugins">
- 'image_transport/compressedDepth'
</rosparam>
</group>
</group> <!-- mynteye --> </group> <!-- mynteye -->
</launch> </launch>

View File

@ -348,9 +348,10 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
api_->EnableStreamData(Stream::POINTS); api_->EnableStreamData(Stream::POINTS);
api_->SetStreamCallback( api_->SetStreamCallback(
Stream::POINTS, [this](const api::StreamData &data) { Stream::POINTS, [this](const api::StreamData &data) {
ros::Time stamp = hardTimeToSoftTime(data.img->timestamp);
static std::size_t count = 0; static std::size_t count = 0;
++count; ++count;
publishPoints(data, count, ros::Time::now()); publishPoints(data, count, stamp);
}); });
is_published_[Stream::POINTS] = true; is_published_[Stream::POINTS] = true;
} }
@ -367,10 +368,10 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
api_->EnableStreamData(stream); api_->EnableStreamData(stream);
api_->SetStreamCallback( api_->SetStreamCallback(
stream, [this, stream](const api::StreamData &data) { stream, [this, stream](const api::StreamData &data) {
// data.img is null, not hard timestamp ros::Time stamp = hardTimeToSoftTime(data.img->timestamp);
static std::size_t count = 0; static std::size_t count = 0;
++count; ++count;
publishCamera(stream, data, count, ros::Time::now()); publishCamera(stream, data, count, stamp);
}); });
is_published_[stream] = true; is_published_[stream] = true;
} }