mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Set up wpiformat (#86)
This commit is contained in:
committed by
Peter Johnson
parent
dd85b1e519
commit
06636a0e1c
@@ -1,65 +1,89 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: true
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AlwaysBreakAfterDefinitionReturnType: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BinPackParameters: true
|
||||
BinPackArguments: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
DerivePointerAlignment: true
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
IndentFunctionDeclarationAfterType: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
Cpp11BracedListStyle: true
|
||||
Standard: Auto
|
||||
IndentWidth: 2
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
BreakBeforeBraces: Attach
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpacesInAngles: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
ContinuationIndentWidth: 4
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
SpaceBeforeParens: ControlStatements
|
||||
DisableFormat: false
|
||||
Standard: Auto
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
|
||||
35
.styleguide
Normal file
35
.styleguide
Normal file
@@ -0,0 +1,35 @@
|
||||
cppHeaderExtensions {
|
||||
h
|
||||
hpp
|
||||
inc
|
||||
}
|
||||
|
||||
cppSrcExtensions {
|
||||
cpp
|
||||
}
|
||||
|
||||
otherExtensions {
|
||||
java
|
||||
}
|
||||
|
||||
genFileExclude {
|
||||
gmock/
|
||||
src/arm-linux-jni/
|
||||
src/main/native/cpp/jni/CameraServerJNI\.cpp$
|
||||
}
|
||||
|
||||
licenseUpdateExclude {
|
||||
src/main/native/cpp/default_init_allocator\.h$
|
||||
}
|
||||
|
||||
includeGuardRoots {
|
||||
src/main/native/cpp/
|
||||
src/main/native/include/
|
||||
}
|
||||
|
||||
includeOtherLibs {
|
||||
^llvm/
|
||||
^opencv2/
|
||||
^support/
|
||||
^tcpsockets/
|
||||
}
|
||||
6
.styleguide-license
Normal file
6
.styleguide-license
Normal file
@@ -0,0 +1,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) {year} FIRST. All Rights Reserved.{padding}*/
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -1,7 +1,14 @@
|
||||
#include "cscore.h"
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
|
||||
#include "cscore.h"
|
||||
|
||||
int main() {
|
||||
CS_Status status = 0;
|
||||
@@ -17,7 +24,8 @@ int main() {
|
||||
llvm::outs() << " " << prop.GetName();
|
||||
switch (prop.GetKind()) {
|
||||
case cs::VideoProperty::kBoolean:
|
||||
llvm::outs() << " (bool): " << "value=" << prop.Get()
|
||||
llvm::outs() << " (bool): "
|
||||
<< "value=" << prop.Get()
|
||||
<< " default=" << prop.GetDefault();
|
||||
break;
|
||||
case cs::VideoProperty::kInteger:
|
||||
@@ -30,7 +38,8 @@ int main() {
|
||||
llvm::outs() << " (string): " << prop.GetString(buf);
|
||||
break;
|
||||
case cs::VideoProperty::kEnum: {
|
||||
llvm::outs() << " (enum): " << "value=" << prop.Get();
|
||||
llvm::outs() << " (enum): "
|
||||
<< "value=" << prop.Get();
|
||||
auto choices = prop.GetChoices();
|
||||
for (size_t i = 0; i < choices.size(); ++i) {
|
||||
if (choices[i].empty()) continue;
|
||||
@@ -48,10 +57,18 @@ int main() {
|
||||
for (const auto& mode : camera.EnumerateVideoModes()) {
|
||||
llvm::outs() << " PixelFormat:";
|
||||
switch (mode.pixelFormat) {
|
||||
case cs::VideoMode::kMJPEG: llvm::outs() << "MJPEG"; break;
|
||||
case cs::VideoMode::kYUYV: llvm::outs() << "YUYV"; break;
|
||||
case cs::VideoMode::kRGB565: llvm::outs() << "RGB565"; break;
|
||||
default: llvm::outs() << "Unknown"; break;
|
||||
case cs::VideoMode::kMJPEG:
|
||||
llvm::outs() << "MJPEG";
|
||||
break;
|
||||
case cs::VideoMode::kYUYV:
|
||||
llvm::outs() << "YUYV";
|
||||
break;
|
||||
case cs::VideoMode::kRGB565:
|
||||
llvm::outs() << "RGB565";
|
||||
break;
|
||||
default:
|
||||
llvm::outs() << "Unknown";
|
||||
break;
|
||||
}
|
||||
llvm::outs() << " Width:" << mode.width;
|
||||
llvm::outs() << " Height:" << mode.height;
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
#include "cscore.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "cscore.h"
|
||||
|
||||
int main() {
|
||||
cs::HttpCamera camera{"httpcam", "http://localhost:8081/?action=stream"};
|
||||
@@ -21,7 +29,8 @@ int main() {
|
||||
std::cout << "error: " << cvsink.GetError() << std::endl;
|
||||
continue;
|
||||
}
|
||||
std::cout << "got frame at time " << time << " size " << test.size() << std::endl;
|
||||
std::cout << "got frame at time " << time << " size " << test.size()
|
||||
<< std::endl;
|
||||
cv::flip(test, flip, 0);
|
||||
cvsource.PutFrame(flip);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "cscore.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "cscore.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2) {
|
||||
@@ -25,9 +32,9 @@ int main(int argc, char** argv) {
|
||||
int arg = 2;
|
||||
llvm::StringRef propName;
|
||||
for (; arg < argc && llvm::StringRef{argv[arg]} != "--"; ++arg) {
|
||||
if (propName.empty())
|
||||
if (propName.empty()) {
|
||||
propName = argv[arg];
|
||||
else {
|
||||
} else {
|
||||
llvm::StringRef propVal{argv[arg]};
|
||||
int intVal;
|
||||
if (propVal.getAsInteger(10, intVal))
|
||||
@@ -46,9 +53,9 @@ int main(int argc, char** argv) {
|
||||
// Set rest
|
||||
propName = llvm::StringRef{};
|
||||
for (; arg < argc; ++arg) {
|
||||
if (propName.empty())
|
||||
if (propName.empty()) {
|
||||
propName = argv[arg];
|
||||
else {
|
||||
} else {
|
||||
llvm::StringRef propVal{argv[arg]};
|
||||
int intVal;
|
||||
if (propVal.getAsInteger(10, intVal))
|
||||
@@ -66,7 +73,8 @@ int main(int argc, char** argv) {
|
||||
llvm::outs() << " " << prop.GetName();
|
||||
switch (prop.GetKind()) {
|
||||
case cs::VideoProperty::kBoolean:
|
||||
llvm::outs() << " (bool): " << "value=" << prop.Get()
|
||||
llvm::outs() << " (bool): "
|
||||
<< "value=" << prop.Get()
|
||||
<< " default=" << prop.GetDefault();
|
||||
break;
|
||||
case cs::VideoProperty::kInteger:
|
||||
@@ -79,7 +87,8 @@ int main(int argc, char** argv) {
|
||||
llvm::outs() << " (string): " << prop.GetString(buf);
|
||||
break;
|
||||
case cs::VideoProperty::kEnum: {
|
||||
llvm::outs() << " (enum): " << "value=" << prop.Get();
|
||||
llvm::outs() << " (enum): "
|
||||
<< "value=" << prop.Get();
|
||||
auto choices = prop.GetChoices();
|
||||
for (size_t i = 0; i < choices.size(); ++i) {
|
||||
if (choices[i].empty()) continue;
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
#include "cscore.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "cscore.h"
|
||||
|
||||
int main() {
|
||||
cs::UsbCamera camera{"usbcam", 0};
|
||||
@@ -23,7 +31,8 @@ int main() {
|
||||
std::cout << "error: " << cvsink.GetError() << std::endl;
|
||||
continue;
|
||||
}
|
||||
std::cout << "got frame at time " << time << " size " << test.size() << std::endl;
|
||||
std::cout << "got frame at time " << time << " size " << test.size()
|
||||
<< std::endl;
|
||||
cv::flip(test, flip, 0);
|
||||
cvsource.PutFrame(flip);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <llvm/raw_ostream.h>
|
||||
|
||||
#include "cscore.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
|
||||
int main() {
|
||||
llvm::outs() << "hostname: " << cs::GetHostname() << '\n';
|
||||
llvm::outs() << "IPv4 network addresses:\n";
|
||||
@@ -14,5 +21,5 @@ int main() {
|
||||
cs::MjpegServer mjpegServer{"httpserver", 8081};
|
||||
mjpegServer.SetSource(camera);
|
||||
|
||||
getchar();
|
||||
std::getchar();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import edu.wpi.cscore.CameraServerJNI;
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "cscore.h"
|
||||
|
||||
int main() {
|
||||
std::cout << cs::GetHostname() << std::endl;
|
||||
}
|
||||
int main() { std::cout << cs::GetHostname() << std::endl; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -84,7 +84,7 @@ public class CvSource extends VideoSource {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle, name, kind.getValue(), minimum, maximum, step, defaultValue, value));
|
||||
}
|
||||
|
||||
|
||||
/// Create an integer property.
|
||||
/// @param name Property name
|
||||
/// @param minimum Minimum value
|
||||
@@ -97,7 +97,7 @@ public class CvSource extends VideoSource {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle, name, VideoProperty.Kind.kInteger.getValue(), minimum, maximum, step, defaultValue, value));
|
||||
}
|
||||
|
||||
|
||||
/// Create a boolean property.
|
||||
/// @param name Property name
|
||||
/// @param defaultValue Default value
|
||||
@@ -107,7 +107,7 @@ public class CvSource extends VideoSource {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle, name, VideoProperty.Kind.kBoolean.getValue(), 0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
/// Create a string property.
|
||||
/// @param name Property name
|
||||
/// @param value Current value
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,16 +7,16 @@
|
||||
|
||||
#include "CvSinkImpl.h"
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "c_util.h"
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
@@ -35,8 +35,7 @@ void CvSinkImpl::Stop() {
|
||||
m_active = false;
|
||||
|
||||
// wake up any waiters by forcing an empty frame to be sent
|
||||
if (auto source = GetSource())
|
||||
source->Wakeup();
|
||||
if (auto source = GetSource()) source->Wakeup();
|
||||
|
||||
// join thread
|
||||
if (m_thread.joinable()) m_thread.join();
|
||||
@@ -225,7 +224,7 @@ uint64_t CS_GrabSinkFrameTimeout(CS_Sink sink, struct CvMat* image,
|
||||
}
|
||||
|
||||
uint64_t CS_GrabSinkFrameCpp(CS_Sink sink, cv::Mat* image, CS_Status* status) {
|
||||
return cs::GrabSinkFrame(sink, *image, status);
|
||||
return cs::GrabSinkFrame(sink, *image, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabSinkFrameTimeoutCpp(CS_Sink sink, cv::Mat* image,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_CVSINKIMPL_H_
|
||||
#define CS_CVSINKIMPL_H_
|
||||
#ifndef CSCORE_CVSINKIMPL_H_
|
||||
#define CSCORE_CVSINKIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
@@ -15,13 +15,13 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include "support/raw_socket_ostream.h"
|
||||
#include "tcpsockets/NetworkAcceptor.h"
|
||||
#include "tcpsockets/NetworkStream.h"
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/NetworkAcceptor.h>
|
||||
#include <tcpsockets/NetworkStream.h>
|
||||
|
||||
#include "SinkImpl.h"
|
||||
|
||||
@@ -31,7 +31,7 @@ class SourceImpl;
|
||||
|
||||
class CvSinkImpl : public SinkImpl {
|
||||
public:
|
||||
CvSinkImpl(llvm::StringRef name);
|
||||
explicit CvSinkImpl(llvm::StringRef name);
|
||||
CvSinkImpl(llvm::StringRef name,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
~CvSinkImpl() override;
|
||||
@@ -51,4 +51,4 @@ class CvSinkImpl : public SinkImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_CVSINKIMPL_H_
|
||||
#endif // CSCORE_CVSINKIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
#include "CvSourceImpl.h"
|
||||
|
||||
#include "llvm/STLExtras.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "support/timestamp.h"
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <support/timestamp.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "c_util.h"
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
@@ -346,8 +346,7 @@ void CS_PutSourceFrame(CS_Source source, struct CvMat* image,
|
||||
return cs::PutSourceFrame(source, mat, status);
|
||||
}
|
||||
|
||||
void CS_PutSourceFrameCpp(CS_Source source, cv::Mat* image,
|
||||
CS_Status* status) {
|
||||
void CS_PutSourceFrameCpp(CS_Source source, cv::Mat* image, CS_Status* status) {
|
||||
return cs::PutSourceFrame(source, *image, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_CVSOURCEIMPL_H_
|
||||
#define CS_CVSOURCEIMPL_H_
|
||||
#ifndef CSCORE_CVSOURCEIMPL_H_
|
||||
#define CSCORE_CVSOURCEIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
@@ -58,7 +60,7 @@ class CvSourceImpl : public SourceImpl {
|
||||
class PropertyData : public PropertyImpl {
|
||||
public:
|
||||
PropertyData() = default;
|
||||
PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(llvm::StringRef name_, CS_PropertyKind kind_, int minimum_,
|
||||
int maximum_, int step_, int defaultValue_, int value_)
|
||||
: PropertyImpl{name_, kind_, step_, defaultValue_, value_} {
|
||||
@@ -84,4 +86,4 @@ class CvSourceImpl : public SourceImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_CVSOURCEIMPL_H_
|
||||
#endif // CSCORE_CVSOURCEIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "Frame.h"
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "Log.h"
|
||||
#include "SourceImpl.h"
|
||||
@@ -200,11 +200,11 @@ Image* Frame::Convert(Image* image, VideoMode::PixelFormat pixelFormat,
|
||||
return ConvertBGRToGray(cur);
|
||||
case VideoMode::kBGR:
|
||||
case VideoMode::kMJPEG:
|
||||
if (cur->pixelFormat == VideoMode::kYUYV)
|
||||
if (cur->pixelFormat == VideoMode::kYUYV) {
|
||||
cur = ConvertYUYVToBGR(cur);
|
||||
else if (cur->pixelFormat == VideoMode::kRGB565)
|
||||
} else if (cur->pixelFormat == VideoMode::kRGB565) {
|
||||
cur = ConvertRGB565ToBGR(cur);
|
||||
else if (cur->pixelFormat == VideoMode::kGray) {
|
||||
} else if (cur->pixelFormat == VideoMode::kGray) {
|
||||
if (pixelFormat == VideoMode::kBGR)
|
||||
return ConvertGrayToBGR(cur);
|
||||
else
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_FRAME_H_
|
||||
#define CS_FRAME_H_
|
||||
#ifndef CSCORE_FRAME_H_
|
||||
#define CSCORE_FRAME_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/SmallVector.h"
|
||||
#include <llvm/SmallVector.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "Image.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -29,7 +32,7 @@ class Frame {
|
||||
|
||||
private:
|
||||
struct Impl {
|
||||
Impl(SourceImpl& source_) : source(source_) {}
|
||||
explicit Impl(SourceImpl& source_) : source(source_) {}
|
||||
|
||||
std::recursive_mutex mutex;
|
||||
std::atomic_int refcount{0};
|
||||
@@ -95,7 +98,7 @@ class Frame {
|
||||
return m_impl->images[0]->pixelFormat;
|
||||
}
|
||||
|
||||
Image* GetExistingImage(std::size_t i = 0) const {
|
||||
Image* GetExistingImage(size_t i = 0) const {
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
if (i >= m_impl->images.size()) return nullptr;
|
||||
@@ -156,4 +159,4 @@ class Frame {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_FRAME_H_
|
||||
#endif // CSCORE_FRAME_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_HANDLE_H_
|
||||
#define CS_HANDLE_H_
|
||||
#ifndef CSCORE_HANDLE_H_
|
||||
#define CSCORE_HANDLE_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "cscore_c.h"
|
||||
#include "UnlimitedHandleResource.h"
|
||||
#include "cscore_c.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -27,16 +29,10 @@ class SourceImpl;
|
||||
|
||||
class Handle {
|
||||
public:
|
||||
enum Type {
|
||||
kUndefined = 0,
|
||||
kProperty = 0x40,
|
||||
kSource,
|
||||
kSink,
|
||||
kListener
|
||||
};
|
||||
enum Type { kUndefined = 0, kProperty = 0x40, kSource, kSink, kListener };
|
||||
enum { kIndexMax = 0xffff };
|
||||
|
||||
Handle(CS_Handle handle) : m_handle(handle) {}
|
||||
Handle(CS_Handle handle) : m_handle(handle) {} // NOLINT
|
||||
operator CS_Handle() const { return m_handle; }
|
||||
|
||||
Handle(int index, Type type) {
|
||||
@@ -129,4 +125,4 @@ class Sinks : public UnlimitedHandleResource<Handle, SinkData, Handle::kSink> {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_HANDLE_H_
|
||||
#endif // CSCORE_HANDLE_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
#include "HttpCameraImpl.h"
|
||||
|
||||
#include "llvm/STLExtras.h"
|
||||
#include "support/timestamp.h"
|
||||
#include "tcpsockets/TCPConnector.h"
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <tcpsockets/TCPConnector.h>
|
||||
|
||||
#include "c_util.h"
|
||||
#include "Handle.h"
|
||||
#include "JpegUtil.h"
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
#include "c_util.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
@@ -569,8 +569,7 @@ char** CS_GetHttpCameraUrls(CS_Source source, int* count, CS_Status* status) {
|
||||
auto urls = cs::GetHttpCameraUrls(source, status);
|
||||
char** out = static_cast<char**>(std::malloc(urls.size() * sizeof(char*)));
|
||||
*count = urls.size();
|
||||
for (std::size_t i = 0; i < urls.size(); ++i)
|
||||
out[i] = cs::ConvertToC(urls[i]);
|
||||
for (size_t i = 0; i < urls.size(); ++i) out[i] = cs::ConvertToC(urls[i]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_HTTPCAMERAIMPL_H_
|
||||
#define CS_HTTPCAMERAIMPL_H_
|
||||
#ifndef CSCORE_HTTPCAMERAIMPL_H_
|
||||
#define CSCORE_HTTPCAMERAIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/StringMap.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/StringMap.h>
|
||||
#include <support/raw_istream.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "HttpUtil.h"
|
||||
#include "SourceImpl.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -60,7 +62,7 @@ class HttpCameraImpl : public SourceImpl {
|
||||
class PropertyData : public PropertyImpl {
|
||||
public:
|
||||
PropertyData() = default;
|
||||
PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(llvm::StringRef name_, llvm::StringRef httpParam_,
|
||||
bool viaSettings_, CS_PropertyKind kind_, int minimum_,
|
||||
int maximum_, int step_, int defaultValue_, int value_)
|
||||
@@ -122,7 +124,7 @@ class HttpCameraImpl : public SourceImpl {
|
||||
CS_HttpCameraKind m_kind;
|
||||
|
||||
std::vector<HttpLocation> m_locations;
|
||||
std::size_t m_nextLocation{0};
|
||||
size_t m_nextLocation{0};
|
||||
int m_prefLocation{-1}; // preferred location
|
||||
|
||||
std::condition_variable m_sinkEnabledCond;
|
||||
@@ -136,7 +138,8 @@ class HttpCameraImpl : public SourceImpl {
|
||||
|
||||
class AxisCameraImpl : public HttpCameraImpl {
|
||||
public:
|
||||
AxisCameraImpl(llvm::StringRef name) : HttpCameraImpl{name, CS_HTTP_AXIS} {}
|
||||
explicit AxisCameraImpl(llvm::StringRef name)
|
||||
: HttpCameraImpl{name, CS_HTTP_AXIS} {}
|
||||
#if 0
|
||||
void SetProperty(int property, int value, CS_Status* status) override;
|
||||
void SetStringProperty(int property, llvm::StringRef value,
|
||||
@@ -148,4 +151,4 @@ class AxisCameraImpl : public HttpCameraImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_HTTPCAMERAIMPL_H_
|
||||
#endif // CSCORE_HTTPCAMERAIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include <cctype>
|
||||
|
||||
#include "llvm/STLExtras.h"
|
||||
#include "support/Base64.h"
|
||||
#include "llvm/StringExtras.h"
|
||||
#include "tcpsockets/TCPConnector.h"
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <llvm/StringExtras.h>
|
||||
#include <support/Base64.h>
|
||||
#include <tcpsockets/TCPConnector.h>
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ llvm::StringRef UnescapeURI(llvm::StringRef str,
|
||||
|
||||
llvm::StringRef EscapeURI(llvm::StringRef str, llvm::SmallVectorImpl<char>& buf,
|
||||
bool spacePlus) {
|
||||
static const char *const hexLut = "0123456789ABCDEF";
|
||||
static const char* const hexLut = "0123456789ABCDEF";
|
||||
|
||||
buf.clear();
|
||||
for (auto i = str.begin(), end = str.end(); i != end; ++i) {
|
||||
@@ -104,7 +104,6 @@ llvm::StringRef EscapeURI(llvm::StringRef str, llvm::SmallVectorImpl<char>& buf,
|
||||
bool ParseHttpHeaders(wpi::raw_istream& is,
|
||||
llvm::SmallVectorImpl<char>* contentType,
|
||||
llvm::SmallVectorImpl<char>* contentLength) {
|
||||
|
||||
if (contentType) contentType->clear();
|
||||
if (contentLength) contentLength->clear();
|
||||
|
||||
@@ -176,11 +175,9 @@ bool FindMultipartBoundary(wpi::raw_istream& is, llvm::StringRef boundary,
|
||||
// Fast-scan for '-'
|
||||
size_t pos = searchBuf.find('-', searchBuf[0] == '-' ? 1 : 0);
|
||||
if (pos == llvm::StringRef::npos) {
|
||||
if (saveBuf)
|
||||
saveBuf->append(searchBuf.data(), searchBuf.size());
|
||||
if (saveBuf) saveBuf->append(searchBuf.data(), searchBuf.size());
|
||||
} else {
|
||||
if (saveBuf)
|
||||
saveBuf->append(searchBuf.data(), pos);
|
||||
if (saveBuf) saveBuf->append(searchBuf.data(), pos);
|
||||
|
||||
// move '-' and following to start of buffer (next read will fill)
|
||||
std::memmove(searchBuf.data(), searchBuf.data() + pos,
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_HTTPUTIL_H_
|
||||
#define CS_HTTPUTIL_H_
|
||||
#ifndef CSCORE_HTTPUTIL_H_
|
||||
#define CSCORE_HTTPUTIL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/ArrayRef.h"
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/StringMap.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include "support/raw_socket_istream.h"
|
||||
#include "support/raw_socket_ostream.h"
|
||||
#include "tcpsockets/NetworkStream.h"
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringMap.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <support/raw_socket_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/NetworkStream.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -85,7 +87,8 @@ class HttpRequest {
|
||||
public:
|
||||
HttpRequest() = default;
|
||||
|
||||
HttpRequest(const HttpLocation& loc) : host{loc.host}, port{loc.port} {
|
||||
explicit HttpRequest(const HttpLocation& loc)
|
||||
: host{loc.host}, port{loc.port} {
|
||||
SetPath(loc.path, loc.params);
|
||||
SetAuth(loc);
|
||||
}
|
||||
@@ -116,13 +119,17 @@ class HttpRequest {
|
||||
void SetPath(llvm::StringRef path_, const T& params);
|
||||
|
||||
template <typename T>
|
||||
static llvm::StringRef GetFirst(const T& elem) { return elem.first; }
|
||||
static llvm::StringRef GetFirst(const T& elem) {
|
||||
return elem.first;
|
||||
}
|
||||
template <typename T>
|
||||
static llvm::StringRef GetFirst(const llvm::StringMapEntry<T>& elem) {
|
||||
return elem.getKey();
|
||||
}
|
||||
template <typename T>
|
||||
static llvm::StringRef GetSecond(const T& elem) { return elem.second; }
|
||||
static llvm::StringRef GetSecond(const T& elem) {
|
||||
return elem.second;
|
||||
}
|
||||
};
|
||||
|
||||
class HttpConnection {
|
||||
@@ -147,4 +154,4 @@ class HttpConnection {
|
||||
|
||||
#include "HttpUtil.inl"
|
||||
|
||||
#endif // CS_HTTPUTIL_H_
|
||||
#endif // CSCORE_HTTPUTIL_H_
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_IMAGE_H_
|
||||
#define CS_IMAGE_H_
|
||||
#ifndef CSCORE_IMAGE_H_
|
||||
#define CSCORE_IMAGE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include <llvm/StringRef.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "default_init_allocator.h"
|
||||
@@ -25,13 +24,10 @@ class Image {
|
||||
friend class Frame;
|
||||
|
||||
public:
|
||||
|
||||
#ifndef __linux__
|
||||
explicit Image(std::size_t capacity) {
|
||||
m_data.reserve(capacity);
|
||||
}
|
||||
explicit Image(size_t capacity) { m_data.reserve(capacity); }
|
||||
#else
|
||||
explicit Image(std::size_t capacity)
|
||||
explicit Image(size_t capacity)
|
||||
: m_data{capacity, default_init_allocator<uchar>{}} {
|
||||
m_data.resize(0);
|
||||
}
|
||||
@@ -43,18 +39,18 @@ class Image {
|
||||
// Getters
|
||||
operator llvm::StringRef() const { return str(); }
|
||||
llvm::StringRef str() const { return llvm::StringRef(data(), size()); }
|
||||
std::size_t capacity() const { return m_data.capacity(); }
|
||||
size_t capacity() const { return m_data.capacity(); }
|
||||
const char* data() const {
|
||||
return reinterpret_cast<const char*>(m_data.data());
|
||||
}
|
||||
char* data() { return reinterpret_cast<char*>(m_data.data()); }
|
||||
std::size_t size() const { return m_data.size(); }
|
||||
size_t size() const { return m_data.size(); }
|
||||
|
||||
const std::vector<uchar>& vec() const { return m_data; }
|
||||
std::vector<uchar>& vec() { return m_data; }
|
||||
|
||||
void resize(std::size_t size) { m_data.resize(size); }
|
||||
void SetSize(std::size_t size) { m_data.resize(size); }
|
||||
void resize(size_t size) { m_data.resize(size); }
|
||||
void SetSize(size_t size) { m_data.resize(size); }
|
||||
|
||||
cv::Mat AsMat() {
|
||||
int type;
|
||||
@@ -103,4 +99,4 @@ class Image {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_IMAGE_H_
|
||||
#endif // CSCORE_IMAGE_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "JpegUtil.h"
|
||||
|
||||
#include "support/raw_istream.h"
|
||||
#include <support/raw_istream.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -54,8 +54,7 @@ bool IsJpeg(llvm::StringRef data) {
|
||||
|
||||
// Check for valid SOI
|
||||
auto bytes = data.bytes_begin();
|
||||
if (bytes[0] != 0xff || bytes[1] != 0xd8)
|
||||
return false;
|
||||
if (bytes[0] != 0xff || bytes[1] != 0xd8) return false;
|
||||
#if 0
|
||||
// Check for valid JPEG header (null terminated JFIF)
|
||||
if (bytes[2] == 0xff && bytes[3] == 0xe0) {
|
||||
@@ -72,7 +71,7 @@ bool GetJpegSize(llvm::StringRef data, int* width, int* height) {
|
||||
auto bytes = data.bytes_begin();
|
||||
size_t blockLength = bytes[4] * 256 + bytes[5] + 4;
|
||||
for (;;) {
|
||||
data = data.substr(blockLength); // Get to the next block
|
||||
data = data.substr(blockLength); // Get to the next block
|
||||
if (data.size() < 4) return false; // EOF
|
||||
bytes = data.bytes_begin();
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
@@ -88,7 +87,7 @@ bool GetJpegSize(llvm::StringRef data, int* width, int* height) {
|
||||
}
|
||||
}
|
||||
|
||||
bool JpegNeedsDHT(const char* data, std::size_t* size, std::size_t* locSOF) {
|
||||
bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) {
|
||||
llvm::StringRef sdata(data, *size);
|
||||
if (!IsJpeg(sdata)) return false;
|
||||
|
||||
@@ -98,12 +97,12 @@ bool JpegNeedsDHT(const char* data, std::size_t* size, std::size_t* locSOF) {
|
||||
auto bytes = sdata.bytes_begin();
|
||||
size_t blockLength = bytes[4] * 256 + bytes[5] + 4;
|
||||
for (;;) {
|
||||
sdata = sdata.substr(blockLength); // Get to the next block
|
||||
sdata = sdata.substr(blockLength); // Get to the next block
|
||||
if (sdata.size() < 4) return false; // EOF
|
||||
bytes = sdata.bytes_begin();
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[1] == 0xda) break; // SOS
|
||||
if (bytes[1] == 0xc4) return false; // DHT
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[1] == 0xda) break; // SOS
|
||||
if (bytes[1] == 0xc4) return false; // DHT
|
||||
if (bytes[1] == 0xc0) *locSOF = sdata.data() - data; // SOF
|
||||
// Go to the next block
|
||||
blockLength = bytes[2] * 256 + bytes[3] + 2;
|
||||
@@ -129,8 +128,7 @@ static inline void ReadInto(wpi::raw_istream& is, std::string& buf,
|
||||
is.read(&(*buf.begin()) + oldSize, len);
|
||||
}
|
||||
|
||||
bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width,
|
||||
int* height) {
|
||||
bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height) {
|
||||
// in case we don't get a SOF
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
@@ -163,7 +161,7 @@ bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width,
|
||||
pos += blockLength;
|
||||
|
||||
bytes = reinterpret_cast<const unsigned char*>(buf.data() + pos);
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[1] == 0xda) {
|
||||
// SOS: need to keep reading until we reach a normal marker.
|
||||
// Byte stuffing ensures we don't get false markers.
|
||||
@@ -178,15 +176,16 @@ bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width,
|
||||
(bytes[0] < 0xd0 || bytes[0] > 0xd7))
|
||||
break;
|
||||
maybeMarker = false;
|
||||
} else if (bytes[0] == 0xff)
|
||||
} else if (bytes[0] == 0xff) {
|
||||
maybeMarker = true;
|
||||
}
|
||||
}
|
||||
// Point back to the start of the block
|
||||
--pos;
|
||||
bytes = reinterpret_cast<const unsigned char*>(buf.data() + pos);
|
||||
}
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[1] == 0xd9) return true; // EOI, we're done
|
||||
if (bytes[0] != 0xff) return false; // not a tag
|
||||
if (bytes[1] == 0xd9) return true; // EOI, we're done
|
||||
if (bytes[1] == 0xc0) sofBlock = true; // SOF
|
||||
|
||||
// Go to the next block
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_JPEGUTIL_H_
|
||||
#define CS_JPEGUTIL_H_
|
||||
#ifndef CSCORE_JPEGUTIL_H_
|
||||
#define CSCORE_JPEGUTIL_H_
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
namespace wpi {
|
||||
class raw_istream;
|
||||
@@ -20,7 +22,7 @@ bool IsJpeg(llvm::StringRef data);
|
||||
|
||||
bool GetJpegSize(llvm::StringRef data, int* width, int* height);
|
||||
|
||||
bool JpegNeedsDHT(const char* data, std::size_t* size, std::size_t* locSOF);
|
||||
bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF);
|
||||
|
||||
llvm::StringRef JpegGetDHT();
|
||||
|
||||
@@ -28,4 +30,4 @@ bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height);
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_JPEGUTIL_H_
|
||||
#endif // CSCORE_JPEGUTIL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,19 +7,20 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#ifdef _WIN32
|
||||
#include <cstdlib>
|
||||
#else
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <libgen.h>
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <libgen.h>
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <cstdlib>
|
||||
#else
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
using namespace cs;
|
||||
@@ -49,9 +50,9 @@ static void def_log_func(unsigned int level, const char* file,
|
||||
std::fprintf(stderr, "CS: %s: %s (%s%s:%d)\n", levelmsg, msg, fname, ext,
|
||||
line);
|
||||
#elif __APPLE__
|
||||
int len = strlen(msg) + 1;
|
||||
int len = std::strlen(msg) + 1;
|
||||
char* basestr = new char[len + 1];
|
||||
strncpy(basestr, file, len);
|
||||
std::strncpy(basestr, file, len);
|
||||
std::fprintf(stderr, "CS: %s: %s (%s:%d)\n", levelmsg, msg, basename(basestr),
|
||||
line);
|
||||
delete[] basestr;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_LOG_H_
|
||||
#define CS_LOG_H_
|
||||
#ifndef CSCORE_LOG_H_
|
||||
#define CSCORE_LOG_H_
|
||||
|
||||
#include "support/atomic_static.h"
|
||||
#include "support/Logger.h"
|
||||
#include <support/Logger.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -52,6 +52,6 @@ class Logger : public wpi::Logger {
|
||||
#define SDEBUG3(x) DEBUG3(GetName() << ": " << x)
|
||||
#define SDEBUG4(x) DEBUG4(GetName() << ": " << x)
|
||||
|
||||
} // namespace cs
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_LOG_H_
|
||||
#endif // CSCORE_LOG_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,23 +9,22 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "support/raw_socket_istream.h"
|
||||
#include "support/raw_socket_ostream.h"
|
||||
#include "tcpsockets/TCPAcceptor.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <support/raw_socket_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/TCPAcceptor.h>
|
||||
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
#include "Handle.h"
|
||||
#include "HttpUtil.h"
|
||||
#include "JpegUtil.h"
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
#include "SourceImpl.h"
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
|
||||
// The boundary used for the M-JPEG stream.
|
||||
// It separates the multipart stream of pictures
|
||||
#define BOUNDARY "boundarydonotcross"
|
||||
@@ -38,11 +37,13 @@ static const char* emptyRootPage =
|
||||
"</body></html>";
|
||||
|
||||
// An HTML page to be sent when a source exists
|
||||
static const char* startRootPage = "<html><head>\n"
|
||||
static const char* startRootPage =
|
||||
"<html><head>\n"
|
||||
"<script>\n"
|
||||
"function httpGetAsync(name, val)\n"
|
||||
"{\n"
|
||||
" var host = location.protocol + '//' + location.host + '/?action=command&' + name + '=' + val;\n"
|
||||
" var host = location.protocol + '//' + location.host + "
|
||||
"'/?action=command&' + name + '=' + val;\n"
|
||||
" var xmlHttp = new XMLHttpRequest();\n"
|
||||
" xmlHttp.open(\"GET\", host, true);\n"
|
||||
" xmlHttp.send(null);\n"
|
||||
@@ -69,11 +70,11 @@ static const char* startRootPage = "<html><head>\n"
|
||||
"<a href=\"/settings.json\">Settings JSON</a>\n"
|
||||
"</div>\n"
|
||||
"<div class=\"settings\">\n";
|
||||
static const char* endRootPage ="</div></body></html>";
|
||||
static const char* endRootPage = "</div></body></html>";
|
||||
|
||||
class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
public:
|
||||
ConnThread(llvm::StringRef name) : m_name(name) {}
|
||||
explicit ConnThread(llvm::StringRef name) : m_name(name) {}
|
||||
|
||||
void Main();
|
||||
|
||||
@@ -372,7 +373,8 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
if (choice->empty()) continue; // skip empty choices
|
||||
// replace any non-printable characters in name with spaces
|
||||
llvm::SmallString<128> ch_name;
|
||||
for (char ch : *choice) ch_name.push_back(isprint(ch) ? ch : ' ');
|
||||
for (char ch : *choice)
|
||||
ch_name.push_back(std::isprint(ch) ? ch : ' ');
|
||||
os << "<input id=\"" << name << j << "\" type=\"radio\" name=\""
|
||||
<< name << "\" value=\"" << ch_name << "\" onclick=\"update('"
|
||||
<< name << "', " << j << ")\"";
|
||||
@@ -407,12 +409,24 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
for (auto mode : source.EnumerateVideoModes(&status)) {
|
||||
os << "<tr><td>";
|
||||
switch (mode.pixelFormat) {
|
||||
case VideoMode::kMJPEG: os << "MJPEG"; break;
|
||||
case VideoMode::kYUYV: os << "YUYV"; break;
|
||||
case VideoMode::kRGB565: os << "RGB565"; break;
|
||||
case VideoMode::kBGR: os << "BGR"; break;
|
||||
case VideoMode::kGray: os << "gray"; break;
|
||||
default: os << "unknown"; break;
|
||||
case VideoMode::kMJPEG:
|
||||
os << "MJPEG";
|
||||
break;
|
||||
case VideoMode::kYUYV:
|
||||
os << "YUYV";
|
||||
break;
|
||||
case VideoMode::kRGB565:
|
||||
os << "RGB565";
|
||||
break;
|
||||
case VideoMode::kBGR:
|
||||
os << "BGR";
|
||||
break;
|
||||
case VideoMode::kGray:
|
||||
os << "gray";
|
||||
break;
|
||||
default:
|
||||
os << "unknown";
|
||||
break;
|
||||
}
|
||||
os << "</td><td>" << mode.width;
|
||||
os << "</td><td>" << mode.height;
|
||||
@@ -480,7 +494,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
if (j != 0) os << ", ";
|
||||
// replace any non-printable characters in name with spaces
|
||||
llvm::SmallString<128> ch_name;
|
||||
for (char ch : *choice) ch_name.push_back(isprint(ch) ? ch : ' ');
|
||||
for (char ch : *choice) ch_name.push_back(std::isprint(ch) ? ch : ' ');
|
||||
os << '"' << j << "\": \"" << ch_name << '"';
|
||||
}
|
||||
os << "}\n";
|
||||
@@ -497,12 +511,24 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
os << '{';
|
||||
os << "\n\"pixelFormat\": \"";
|
||||
switch (mode.pixelFormat) {
|
||||
case VideoMode::kMJPEG: os << "MJPEG"; break;
|
||||
case VideoMode::kYUYV: os << "YUYV"; break;
|
||||
case VideoMode::kRGB565: os << "RGB565"; break;
|
||||
case VideoMode::kBGR: os << "BGR"; break;
|
||||
case VideoMode::kGray: os << "gray"; break;
|
||||
default: os << "unknown"; break;
|
||||
case VideoMode::kMJPEG:
|
||||
os << "MJPEG";
|
||||
break;
|
||||
case VideoMode::kYUYV:
|
||||
os << "YUYV";
|
||||
break;
|
||||
case VideoMode::kRGB565:
|
||||
os << "RGB565";
|
||||
break;
|
||||
case VideoMode::kBGR:
|
||||
os << "BGR";
|
||||
break;
|
||||
case VideoMode::kGray:
|
||||
os << "gray";
|
||||
break;
|
||||
default:
|
||||
os << "unknown";
|
||||
break;
|
||||
}
|
||||
os << "\",\n\"width\": \"" << mode.width << '"';
|
||||
os << ",\n\"height\": \"" << mode.height << '"';
|
||||
@@ -550,8 +576,7 @@ void MjpegServerImpl::Stop() {
|
||||
}
|
||||
|
||||
// wake up connection threads by forcing an empty frame to be sent
|
||||
if (auto source = GetSource())
|
||||
source->Wakeup();
|
||||
if (auto source = GetSource()) source->Wakeup();
|
||||
}
|
||||
|
||||
// Send HTTP response and a stream of JPG-frames
|
||||
@@ -602,9 +627,9 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
}
|
||||
|
||||
const char* data = image->data();
|
||||
std::size_t size = image->size();
|
||||
size_t size = image->size();
|
||||
bool addDHT = false;
|
||||
std::size_t locSOF = size;
|
||||
size_t locSOF = size;
|
||||
switch (image->pixelFormat) {
|
||||
case VideoMode::kMJPEG:
|
||||
// Determine if we need to add DHT to it, and allocate enough space
|
||||
@@ -731,7 +756,8 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
ProcessCommand(os, *source, parameters, true);
|
||||
} else {
|
||||
SendHeader(os, 200, "OK", "text/plain");
|
||||
os << "Ignored due to no connected source." << "\r\n";
|
||||
os << "Ignored due to no connected source."
|
||||
<< "\r\n";
|
||||
SDEBUG("Ignored due to no connected source.");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_MJPEGSERVERIMPL_H_
|
||||
#define CS_MJPEGSERVERIMPL_H_
|
||||
#ifndef CSCORE_MJPEGSERVERIMPL_H_
|
||||
#define CSCORE_MJPEGSERVERIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include "support/SafeThread.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include "support/raw_socket_ostream.h"
|
||||
#include "tcpsockets/NetworkAcceptor.h"
|
||||
#include "tcpsockets/NetworkStream.h"
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/NetworkAcceptor.h>
|
||||
#include <tcpsockets/NetworkStream.h>
|
||||
|
||||
#include "SinkImpl.h"
|
||||
|
||||
@@ -58,4 +59,4 @@ class MjpegServerImpl : public SinkImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_MJPEGSERVERIMPL_H_
|
||||
#endif // CSCORE_MJPEGSERVERIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "NetworkListener.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <errno.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <sys/eventfd.h>
|
||||
@@ -17,6 +16,8 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cerrno>
|
||||
#endif
|
||||
|
||||
#include "Log.h"
|
||||
@@ -58,14 +59,15 @@ void NetworkListener::Thread::Main() {
|
||||
// Create event socket so we can be shut down
|
||||
m_command_fd = ::eventfd(0, 0);
|
||||
if (m_command_fd < 0) {
|
||||
ERROR("NetworkListener: could not create eventfd: " << strerror(errno));
|
||||
ERROR(
|
||||
"NetworkListener: could not create eventfd: " << std::strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
// Create netlink socket
|
||||
int sd = ::socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||
if (sd < 0) {
|
||||
ERROR("NetworkListener: could not create socket: " << strerror(errno));
|
||||
ERROR("NetworkListener: could not create socket: " << std::strerror(errno));
|
||||
::close(m_command_fd);
|
||||
m_command_fd = -1;
|
||||
return;
|
||||
@@ -77,7 +79,7 @@ void NetworkListener::Thread::Main() {
|
||||
addr.nl_family = AF_NETLINK;
|
||||
addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
|
||||
if (bind(sd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) {
|
||||
ERROR("NetworkListener: could not create socket: " << strerror(errno));
|
||||
ERROR("NetworkListener: could not create socket: " << std::strerror(errno));
|
||||
::close(sd);
|
||||
::close(m_command_fd);
|
||||
m_command_fd = -1;
|
||||
@@ -96,11 +98,11 @@ void NetworkListener::Thread::Main() {
|
||||
fd_set readfds;
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(m_command_fd, &readfds);
|
||||
FD_SET(sd, &readfds);
|
||||
FD_SET(sd, &readfds);
|
||||
int nfds = std::max(m_command_fd, sd) + 1;
|
||||
|
||||
if (::select(nfds, &readfds, nullptr, nullptr, &tv) < 0) {
|
||||
ERROR("NetworkListener: select(): " << strerror(errno));
|
||||
ERROR("NetworkListener: select(): " << std::strerror(errno));
|
||||
break; // XXX: is this the right thing to do here?
|
||||
}
|
||||
|
||||
@@ -115,7 +117,8 @@ void NetworkListener::Thread::Main() {
|
||||
int len = ::recvmsg(sd, &msg, 0);
|
||||
if (len < 0) {
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN) continue;
|
||||
ERROR("NetworkListener: could not read netlink: " << strerror(errno));
|
||||
ERROR(
|
||||
"NetworkListener: could not read netlink: " << std::strerror(errno));
|
||||
break; // XXX: is this the right thing to do here?
|
||||
}
|
||||
if (len == 0) continue; // EOF?
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_NETWORKLISTENER_H_
|
||||
#define CS_NETWORKLISTENER_H_
|
||||
#ifndef CSCORE_NETWORKLISTENER_H_
|
||||
#define CSCORE_NETWORKLISTENER_H_
|
||||
|
||||
#include "support/atomic_static.h"
|
||||
#include "support/SafeThread.h"
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -35,4 +35,4 @@ class NetworkListener {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_NETWORKLISTENER_H_
|
||||
#endif // CSCORE_NETWORKLISTENER_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -77,7 +77,7 @@ class Notifier::Thread : public wpi::SafeThread {
|
||||
int eventMask_)
|
||||
: callback(callback_), eventMask(eventMask_) {}
|
||||
|
||||
explicit operator bool() const { return bool(callback); }
|
||||
explicit operator bool() const { return static_cast<bool>(callback); }
|
||||
|
||||
std::string prefix;
|
||||
std::function<void(const RawEvent& event)> callback;
|
||||
@@ -118,7 +118,7 @@ void Notifier::Thread::Main() {
|
||||
m_notifications.pop();
|
||||
|
||||
// Use index because iterator might get invalidated.
|
||||
for (std::size_t i = 0; i < m_listeners.size(); ++i) {
|
||||
for (size_t i = 0; i < m_listeners.size(); ++i) {
|
||||
if (!m_listeners[i]) continue; // removed
|
||||
|
||||
// Event type must be within requested set for this listener.
|
||||
@@ -139,8 +139,8 @@ done:
|
||||
if (m_on_exit) m_on_exit();
|
||||
}
|
||||
|
||||
int Notifier::AddListener(
|
||||
std::function<void(const RawEvent& event)> callback, int eventMask) {
|
||||
int Notifier::AddListener(std::function<void(const RawEvent& event)> callback,
|
||||
int eventMask) {
|
||||
Start();
|
||||
auto thr = m_owner.GetThread();
|
||||
return thr->m_listeners.emplace_back(callback, eventMask);
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015-2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_NOTIFIER_H_
|
||||
#define CS_NOTIFIER_H_
|
||||
#ifndef CSCORE_NOTIFIER_H_
|
||||
#define CSCORE_NOTIFIER_H_
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "support/atomic_static.h"
|
||||
#include "support/SafeThread.h"
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
namespace cs {
|
||||
@@ -70,4 +71,4 @@ class Notifier {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_NOTIFIER_H_
|
||||
#endif // CSCORE_NOTIFIER_H_
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_PROPERTYIMPL_H_
|
||||
#define CS_PROPERTYIMPL_H_
|
||||
#ifndef CSCORE_PROPERTYIMPL_H_
|
||||
#define CSCORE_PROPERTYIMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace cs {
|
||||
class PropertyImpl {
|
||||
public:
|
||||
PropertyImpl() = default;
|
||||
PropertyImpl(llvm::StringRef name_) : name{name_} {}
|
||||
explicit PropertyImpl(llvm::StringRef name_) : name{name_} {}
|
||||
PropertyImpl(llvm::StringRef name_, CS_PropertyKind kind_, int step_,
|
||||
int defaultValue_, int value_)
|
||||
: name{name_},
|
||||
@@ -73,4 +73,4 @@ class PropertyImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_PROPERTYIMPL_H_
|
||||
#endif // CSCORE_PROPERTYIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_SINKIMPL_H_
|
||||
#define CS_SINKIMPL_H_
|
||||
#ifndef CSCORE_SINKIMPL_H_
|
||||
#define CSCORE_SINKIMPL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
|
||||
@@ -22,7 +22,7 @@ class Frame;
|
||||
|
||||
class SinkImpl {
|
||||
public:
|
||||
SinkImpl(llvm::StringRef name);
|
||||
explicit SinkImpl(llvm::StringRef name);
|
||||
virtual ~SinkImpl();
|
||||
SinkImpl(const SinkImpl& queue) = delete;
|
||||
SinkImpl& operator=(const SinkImpl& queue) = delete;
|
||||
@@ -60,4 +60,4 @@ class SinkImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_SINKIMPL_H_
|
||||
#endif // CSCORE_SINKIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,15 +10,15 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "llvm/STLExtras.h"
|
||||
#include "support/timestamp.h"
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <support/timestamp.h>
|
||||
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
static constexpr std::size_t kMaxImagesAvail = 32;
|
||||
static constexpr size_t kMaxImagesAvail = 32;
|
||||
|
||||
SourceImpl::SourceImpl(llvm::StringRef name) : m_name{name} {
|
||||
m_frame = Frame{*this, llvm::StringRef{}, 0};
|
||||
@@ -202,8 +202,9 @@ int SourceImpl::GetPropertyDefault(int property, CS_Status* status) const {
|
||||
return prop->defaultValue;
|
||||
}
|
||||
|
||||
llvm::StringRef SourceImpl::GetStringProperty(
|
||||
int property, llvm::SmallVectorImpl<char>& buf, CS_Status* status) const {
|
||||
llvm::StringRef SourceImpl::GetStringProperty(int property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return llvm::StringRef{};
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
@@ -239,8 +240,7 @@ std::vector<std::string> SourceImpl::GetEnumPropertyChoices(
|
||||
}
|
||||
|
||||
VideoMode SourceImpl::GetVideoMode(CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return VideoMode{};
|
||||
if (!m_properties_cached && !CacheProperties(status)) return VideoMode{};
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return m_mode;
|
||||
}
|
||||
@@ -277,14 +277,13 @@ std::vector<VideoMode> SourceImpl::EnumerateVideoModes(
|
||||
}
|
||||
|
||||
std::unique_ptr<Image> SourceImpl::AllocImage(
|
||||
VideoMode::PixelFormat pixelFormat, int width, int height,
|
||||
std::size_t size) {
|
||||
VideoMode::PixelFormat pixelFormat, int width, int height, size_t size) {
|
||||
std::unique_ptr<Image> image;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{m_poolMutex};
|
||||
// find the smallest existing frame that is at least big enough.
|
||||
int found = -1;
|
||||
for (std::size_t i = 0; i < m_imagesAvail.size(); ++i) {
|
||||
for (size_t i = 0; i < m_imagesAvail.size(); ++i) {
|
||||
// is it big enough?
|
||||
if (m_imagesAvail[i] && m_imagesAvail[i]->capacity() >= size) {
|
||||
// is it smaller than the last found?
|
||||
@@ -317,9 +316,10 @@ void SourceImpl::PutFrame(VideoMode::PixelFormat pixelFormat, int width,
|
||||
auto image = AllocImage(pixelFormat, width, height, data.size());
|
||||
|
||||
// Copy in image data
|
||||
SDEBUG4("Copying data to " << ((void*)image->data()) << " from "
|
||||
<< ((void*)data.data()) << " (" << data.size()
|
||||
<< " bytes)");
|
||||
SDEBUG4("Copying data to "
|
||||
<< reinterpret_cast<const void*>(image->data()) << " from "
|
||||
<< reinterpret_cast<const void*>(data.data()) << " (" << data.size()
|
||||
<< " bytes)");
|
||||
std::memcpy(image->data(), data.data(), data.size());
|
||||
|
||||
PutFrame(std::move(image), time);
|
||||
@@ -382,9 +382,9 @@ void SourceImpl::ReleaseImage(std::unique_ptr<Image> image) {
|
||||
// Return the frame to the pool. First try to find an empty slot, otherwise
|
||||
// add it to the end.
|
||||
auto it = std::find(m_imagesAvail.begin(), m_imagesAvail.end(), nullptr);
|
||||
if (it != m_imagesAvail.end())
|
||||
if (it != m_imagesAvail.end()) {
|
||||
*it = std::move(image);
|
||||
else if (m_imagesAvail.size() > kMaxImagesAvail) {
|
||||
} else if (m_imagesAvail.size() > kMaxImagesAvail) {
|
||||
// Replace smallest buffer; don't need to check for null because the above
|
||||
// find would have found it.
|
||||
auto it2 = std::min_element(
|
||||
@@ -393,8 +393,9 @@ void SourceImpl::ReleaseImage(std::unique_ptr<Image> image) {
|
||||
return a->capacity() < b->capacity();
|
||||
});
|
||||
if ((*it2)->capacity() < image->capacity()) *it2 = std::move(image);
|
||||
} else
|
||||
} else {
|
||||
m_imagesAvail.emplace_back(std::move(image));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Frame::Impl> SourceImpl::AllocFrameImpl() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_SOURCEIMPL_H_
|
||||
#define CS_SOURCEIMPL_H_
|
||||
#ifndef CSCORE_SOURCEIMPL_H_
|
||||
#define CSCORE_SOURCEIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
@@ -16,14 +16,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/ArrayRef.h"
|
||||
#include "llvm/StringMap.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/StringMap.h>
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "Frame.h"
|
||||
#include "Image.h"
|
||||
#include "PropertyImpl.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -31,7 +31,7 @@ class SourceImpl {
|
||||
friend class Frame;
|
||||
|
||||
public:
|
||||
SourceImpl(llvm::StringRef name);
|
||||
explicit SourceImpl(llvm::StringRef name);
|
||||
virtual ~SourceImpl();
|
||||
SourceImpl(const SourceImpl& oth) = delete;
|
||||
SourceImpl& operator=(const SourceImpl& oth) = delete;
|
||||
@@ -135,7 +135,7 @@ class SourceImpl {
|
||||
std::vector<VideoMode> EnumerateVideoModes(CS_Status* status) const;
|
||||
|
||||
std::unique_ptr<Image> AllocImage(VideoMode::PixelFormat pixelFormat,
|
||||
int width, int height, std::size_t size);
|
||||
int width, int height, size_t size);
|
||||
|
||||
protected:
|
||||
void PutFrame(VideoMode::PixelFormat pixelFormat, int width, int height,
|
||||
@@ -220,4 +220,4 @@ class SourceImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_SOURCEIMPL_H_
|
||||
#endif // CSCORE_SOURCEIMPL_H_
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_UNLIMITEDHANDLERESOURCE_H_
|
||||
#define CS_UNLIMITEDHANDLERESOURCE_H_
|
||||
#ifndef CSCORE_UNLIMITEDHANDLERESOURCE_H_
|
||||
#define CSCORE_UNLIMITEDHANDLERESOURCE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/ArrayRef.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "support/atomic_static.h"
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <support/atomic_static.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -116,8 +116,7 @@ inline std::shared_ptr<TStruct> UnlimitedHandleResource<
|
||||
handle.GetTypedIndex(static_cast<typename THandle::Type>(typeValue));
|
||||
if (index < 0) return nullptr;
|
||||
std::lock_guard<TMutex> sync(m_handleMutex);
|
||||
if (index >= static_cast<int>(m_structures.size()))
|
||||
return nullptr;
|
||||
if (index >= static_cast<int>(m_structures.size())) return nullptr;
|
||||
return m_structures[index];
|
||||
}
|
||||
|
||||
@@ -182,4 +181,4 @@ class StaticUnlimitedHandleResource
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_UNLIMITEDHANDLERESOURCE_H_
|
||||
#endif // CSCORE_UNLIMITEDHANDLERESOURCE_H_
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_USBCAMERABUFFER_H_
|
||||
#define CS_USBCAMERABUFFER_H_
|
||||
#ifndef CSCORE_USBCAMERABUFFER_H_
|
||||
#define CSCORE_USBCAMERABUFFER_H_
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace cs {
|
||||
|
||||
class UsbCameraBuffer {
|
||||
@@ -55,4 +57,4 @@ class UsbCameraBuffer {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_USBCAMERABUFFER_H_
|
||||
#endif // CSCORE_USBCAMERABUFFER_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#include "UsbCameraImpl.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
@@ -24,21 +22,21 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#endif
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "llvm/SmallString.h"
|
||||
#include "support/timestamp.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/timestamp.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "c_util.h"
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
#include "UsbUtil.h"
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
using namespace cs;
|
||||
|
||||
@@ -327,7 +325,7 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
DoFdSet(notify_fd, &readfds, &nfds);
|
||||
|
||||
if (select(nfds, &readfds, nullptr, nullptr, &tv) < 0) {
|
||||
SERROR("select(): " << strerror(errno));
|
||||
SERROR("select(): " << std::strerror(errno));
|
||||
break; // XXX: is this the right thing to do here?
|
||||
}
|
||||
|
||||
@@ -476,7 +474,7 @@ void UsbCameraImpl::DeviceConnect() {
|
||||
// Restore settings
|
||||
SDEBUG3("restoring settings");
|
||||
std::unique_lock<std::mutex> lock2(m_mutex);
|
||||
for (std::size_t i = 0; i < m_propertyData.size(); ++i) {
|
||||
for (size_t i = 0; i < m_propertyData.size(); ++i) {
|
||||
const auto prop =
|
||||
static_cast<const UsbCameraProperty*>(m_propertyData[i].get());
|
||||
if (!prop || !prop->valueSet || prop->percentage) continue;
|
||||
@@ -981,11 +979,12 @@ void UsbCameraImpl::DeviceCacheProperties() {
|
||||
int fd = m_fd.load();
|
||||
if (fd < 0) return;
|
||||
|
||||
constexpr __u32 nextFlags = V4L2_CTRL_FLAG_NEXT_CTRL
|
||||
#ifdef V4L2_CTRL_FLAG_NEXT_COMPOUND
|
||||
| V4L2_CTRL_FLAG_NEXT_COMPOUND
|
||||
constexpr __u32 nextFlags =
|
||||
V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
|
||||
#else
|
||||
constexpr __u32 nextFlags = V4L2_CTRL_FLAG_NEXT_CTRL;
|
||||
#endif
|
||||
;
|
||||
__u32 id = nextFlags;
|
||||
|
||||
while (auto prop = UsbCameraProperty::DeviceQuery(fd, &id)) {
|
||||
@@ -1280,7 +1279,7 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
}
|
||||
closedir(dp);
|
||||
} else {
|
||||
//*status = ;
|
||||
// *status = ;
|
||||
ERROR("Could not open /dev");
|
||||
return retval;
|
||||
}
|
||||
@@ -1316,7 +1315,7 @@ CS_UsbCameraInfo* CS_EnumerateUsbCameras(int* count, CS_Status* status) {
|
||||
CS_UsbCameraInfo* out = static_cast<CS_UsbCameraInfo*>(
|
||||
std::malloc(cameras.size() * sizeof(CS_UsbCameraInfo)));
|
||||
*count = cameras.size();
|
||||
for (std::size_t i = 0; i < cameras.size(); ++i) {
|
||||
for (size_t i = 0; i < cameras.size(); ++i) {
|
||||
out[i].dev = cameras[i].dev;
|
||||
out[i].path = ConvertToC(cameras[i].path);
|
||||
out[i].name = ConvertToC(cameras[i].name);
|
||||
@@ -1360,10 +1359,8 @@ CS_UsbCameraInfo* CS_EnumerateUsbCameras(int* count, CS_Status* status) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CS_FreeEnumeratedUsbCameras(CS_UsbCameraInfo* cameras, int count) {
|
||||
}
|
||||
void CS_FreeEnumeratedUsbCameras(CS_UsbCameraInfo* cameras, int count) {}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_USBCAMERAIMPL_H_
|
||||
#define CS_USBCAMERAIMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#ifndef CSCORE_USBCAMERAIMPL_H_
|
||||
#define CSCORE_USBCAMERAIMPL_H_
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/videodev2.h>
|
||||
#endif
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/STLExtras.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/raw_istream.h>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
#include "UsbCameraBuffer.h"
|
||||
@@ -70,14 +73,15 @@ class UsbCameraImpl : public SourceImpl {
|
||||
kCmdSetFPS,
|
||||
kCmdSetProperty,
|
||||
kCmdSetPropertyStr,
|
||||
kNumSinksChanged, // no response
|
||||
kNumSinksChanged, // no response
|
||||
kNumSinksEnabledChanged, // no response
|
||||
// Responses
|
||||
kOk,
|
||||
kError
|
||||
};
|
||||
|
||||
Message(Kind kind_) : kind(kind_), from(std::this_thread::get_id()) {}
|
||||
explicit Message(Kind kind_)
|
||||
: kind(kind_), from(std::this_thread::get_id()) {}
|
||||
|
||||
Kind kind;
|
||||
int data[4];
|
||||
@@ -174,4 +178,4 @@ class UsbCameraImpl : public SourceImpl {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_USBCAMERAIMPL_H_
|
||||
#endif // CSCORE_USBCAMERAIMPL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "UsbCameraProperty.h"
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/STLExtras.h"
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <llvm/SmallString.h>
|
||||
|
||||
#include "UsbUtil.h"
|
||||
|
||||
@@ -73,8 +73,7 @@ static int SetIntCtrlIoctl(int fd, unsigned id, int type, int64_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
static int GetStringCtrlIoctl(int fd, int id, int maximum,
|
||||
std::string* value) {
|
||||
static int GetStringCtrlIoctl(int fd, int id, int maximum, std::string* value) {
|
||||
struct v4l2_ext_control ctrl;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
std::memset(&ctrl, 0, sizeof(ctrl));
|
||||
@@ -120,8 +119,9 @@ static llvm::StringRef NormalizeName(llvm::StringRef name,
|
||||
if (newWord) buf.push_back('_');
|
||||
newWord = false;
|
||||
buf.push_back(std::tolower(ch));
|
||||
} else if (!buf.empty())
|
||||
} else if (!buf.empty()) {
|
||||
newWord = true;
|
||||
}
|
||||
}
|
||||
return llvm::StringRef(buf.data(), buf.size());
|
||||
}
|
||||
@@ -158,7 +158,7 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl)
|
||||
}
|
||||
|
||||
// name
|
||||
std::size_t len = 0;
|
||||
size_t len = 0;
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len;
|
||||
llvm::SmallString<64> name_buf;
|
||||
name = NormalizeName(llvm::StringRef(ctrl.name, len), name_buf);
|
||||
@@ -196,7 +196,7 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl)
|
||||
}
|
||||
|
||||
// name
|
||||
std::size_t len = 0;
|
||||
size_t len = 0;
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len;
|
||||
llvm::SmallString<64> name_buf;
|
||||
name = NormalizeName(
|
||||
@@ -317,5 +317,4 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<std::mutex>& lock, int fd,
|
||||
return rv >= 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // __linux__
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_USBCAMERAPROPERTY_H_
|
||||
#define CS_USBCAMERAPROPERTY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#ifndef CSCORE_USBCAMERAPROPERTY_H_
|
||||
#define CSCORE_USBCAMERAPROPERTY_H_
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/videodev2.h>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "PropertyImpl.h"
|
||||
|
||||
namespace cs {
|
||||
@@ -23,7 +23,7 @@ namespace cs {
|
||||
class UsbCameraProperty : public PropertyImpl {
|
||||
public:
|
||||
UsbCameraProperty() = default;
|
||||
UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
explicit UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
|
||||
// Normalized property constructor
|
||||
UsbCameraProperty(llvm::StringRef name_, int rawIndex_,
|
||||
@@ -42,9 +42,9 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef VIDIOC_QUERY_EXT_CTRL
|
||||
UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl);
|
||||
explicit UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl);
|
||||
#endif
|
||||
UsbCameraProperty(const struct v4l2_queryctrl& ctrl);
|
||||
explicit UsbCameraProperty(const struct v4l2_queryctrl& ctrl);
|
||||
|
||||
static std::unique_ptr<UsbCameraProperty> DeviceQuery(int fd, __u32* id);
|
||||
|
||||
@@ -61,9 +61,9 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
int propPair{0};
|
||||
|
||||
unsigned id{0}; // implementation-level id
|
||||
int type{0}; // implementation type, not CS_PropertyKind!
|
||||
int type{0}; // implementation type, not CS_PropertyKind!
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_USBCAMERAPROPERTY_H_
|
||||
#endif // CSCORE_USBCAMERAPROPERTY_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -8,15 +8,16 @@
|
||||
#include "UsbUtil.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <libgen.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "llvm/Format.h"
|
||||
#include "llvm/SmallString.h"
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "support/raw_istream.h"
|
||||
#include <llvm/Format.h>
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/raw_istream.h>
|
||||
|
||||
#include "HttpUtil.h"
|
||||
#include "Log.h"
|
||||
@@ -86,25 +87,63 @@ llvm::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
case 0x046d:
|
||||
os << "Logitech, Inc. ";
|
||||
switch (product) {
|
||||
case 0x0802: os << "Webcam C200"; break;
|
||||
case 0x0804: os << "Webcam C250"; break;
|
||||
case 0x0805: os << "Webcam C300"; break;
|
||||
case 0x0807: os << "Webcam B500"; break;
|
||||
case 0x0808: os << "Webcam C600"; break;
|
||||
case 0x0809: os << "Webcam Pro 9000"; break;
|
||||
case 0x080a: os << "Portable Webcam C905"; break;
|
||||
case 0x080f: os << "Webcam C120"; break;
|
||||
case 0x0819: os << "Webcam C210"; break;
|
||||
case 0x081b: os << "Webcam C310"; break;
|
||||
case 0x081d: os << "HD Webcam C510"; break;
|
||||
case 0x0821: os << "HD Webcam C910"; break;
|
||||
case 0x0825: os << "Webcam C270"; break;
|
||||
case 0x0826: os << "HD Webcam C525"; break;
|
||||
case 0x0828: os << "HD Webcam B990"; break;
|
||||
case 0x082b: os << "Webcam C170"; break;
|
||||
case 0x082d: os << "HD Pro Webcam C920"; break;
|
||||
case 0x0836: os << "B525 HD Webcam"; break;
|
||||
case 0x0843: os << "Webcam C930e"; break;
|
||||
case 0x0802:
|
||||
os << "Webcam C200";
|
||||
break;
|
||||
case 0x0804:
|
||||
os << "Webcam C250";
|
||||
break;
|
||||
case 0x0805:
|
||||
os << "Webcam C300";
|
||||
break;
|
||||
case 0x0807:
|
||||
os << "Webcam B500";
|
||||
break;
|
||||
case 0x0808:
|
||||
os << "Webcam C600";
|
||||
break;
|
||||
case 0x0809:
|
||||
os << "Webcam Pro 9000";
|
||||
break;
|
||||
case 0x080a:
|
||||
os << "Portable Webcam C905";
|
||||
break;
|
||||
case 0x080f:
|
||||
os << "Webcam C120";
|
||||
break;
|
||||
case 0x0819:
|
||||
os << "Webcam C210";
|
||||
break;
|
||||
case 0x081b:
|
||||
os << "Webcam C310";
|
||||
break;
|
||||
case 0x081d:
|
||||
os << "HD Webcam C510";
|
||||
break;
|
||||
case 0x0821:
|
||||
os << "HD Webcam C910";
|
||||
break;
|
||||
case 0x0825:
|
||||
os << "Webcam C270";
|
||||
break;
|
||||
case 0x0826:
|
||||
os << "HD Webcam C525";
|
||||
break;
|
||||
case 0x0828:
|
||||
os << "HD Webcam B990";
|
||||
break;
|
||||
case 0x082b:
|
||||
os << "Webcam C170";
|
||||
break;
|
||||
case 0x082d:
|
||||
os << "HD Pro Webcam C920";
|
||||
break;
|
||||
case 0x0836:
|
||||
os << "B525 HD Webcam";
|
||||
break;
|
||||
case 0x0843:
|
||||
os << "Webcam C930e";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -112,8 +151,8 @@ llvm::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
return os.str();
|
||||
}
|
||||
|
||||
int CheckedIoctl(int fd, unsigned long req, void* data, const char* name,
|
||||
const char* file, int line, bool quiet) {
|
||||
int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
const char* name, const char* file, int line, bool quiet) {
|
||||
int retval = ioctl(fd, req, data);
|
||||
if (!quiet && retval < 0) {
|
||||
llvm::SmallString<64> localfile{file};
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_USBUTIL_H_
|
||||
#define CS_USBUTIL_H_
|
||||
#ifndef CSCORE_USBUTIL_H_
|
||||
#define CSCORE_USBUTIL_H_
|
||||
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -18,8 +20,8 @@ namespace cs {
|
||||
llvm::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
llvm::SmallVectorImpl<char>& buf);
|
||||
|
||||
int CheckedIoctl(int fd, unsigned long req, void* data, const char* name,
|
||||
const char* file, int line, bool quiet);
|
||||
int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
const char* name, const char* file, int line, bool quiet);
|
||||
|
||||
#define DoIoctl(fd, req, data) \
|
||||
CheckedIoctl(fd, req, data, #req, __FILE__, __LINE__, false)
|
||||
@@ -30,4 +32,4 @@ int CheckedIoctl(int fd, unsigned long req, void* data, const char* name,
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_USBUTIL_H_
|
||||
#endif // CSCORE_USBUTIL_H_
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_C_UTIL_H_
|
||||
#define CS_C_UTIL_H_
|
||||
#ifndef CSCORE_C_UTIL_H_
|
||||
#define CSCORE_C_UTIL_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -19,4 +24,4 @@ inline char* ConvertToC(llvm::StringRef in) {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_C_UTIL_H_
|
||||
#endif // CSCORE_C_UTIL_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "llvm/SmallString.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -70,7 +70,7 @@ char** CS_GetEnumPropertyChoices(CS_Property property, int* count,
|
||||
auto choices = cs::GetEnumPropertyChoices(property, status);
|
||||
char** out = static_cast<char**>(std::malloc(choices.size() * sizeof(char*)));
|
||||
*count = choices.size();
|
||||
for (std::size_t i = 0; i < choices.size(); ++i)
|
||||
for (size_t i = 0; i < choices.size(); ++i)
|
||||
out[i] = cs::ConvertToC(choices[i]);
|
||||
return out;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void CS_GetSourceVideoMode(CS_Source source, CS_VideoMode* mode,
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceVideoMode(CS_Source source, const CS_VideoMode* mode,
|
||||
CS_Status* status) {
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceVideoMode(
|
||||
source, static_cast<const cs::VideoMode&>(*mode), status);
|
||||
}
|
||||
@@ -341,9 +341,7 @@ void CS_ReleaseEnumeratedSinks(CS_Sink* sinks, int count) {
|
||||
std::free(sinks);
|
||||
}
|
||||
|
||||
void CS_FreeString(char* str) {
|
||||
std::free(str);
|
||||
}
|
||||
void CS_FreeString(char* str) { std::free(str); }
|
||||
|
||||
void CS_FreeEnumPropertyChoices(char** choices, int count) {
|
||||
if (!choices) return;
|
||||
@@ -359,16 +357,14 @@ void CS_FreeEnumeratedVideoModes(CS_VideoMode* modes, int count) {
|
||||
std::free(modes);
|
||||
}
|
||||
|
||||
char* CS_GetHostname() {
|
||||
return cs::ConvertToC(cs::GetHostname());
|
||||
}
|
||||
char* CS_GetHostname() { return cs::ConvertToC(cs::GetHostname()); }
|
||||
|
||||
char** CS_GetNetworkInterfaces(int* count) {
|
||||
auto interfaces = cs::GetNetworkInterfaces();
|
||||
char** out =
|
||||
static_cast<char**>(std::malloc(interfaces.size() * sizeof(char*)));
|
||||
*count = interfaces.size();
|
||||
for (std::size_t i = 0; i < interfaces.size(); ++i)
|
||||
for (size_t i = 0; i < interfaces.size(); ++i)
|
||||
out[i] = cs::ConvertToC(interfaces[i]);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "llvm/SmallString.h"
|
||||
#include <llvm/SmallString.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -28,8 +28,7 @@ std::vector<VideoSink> VideoSource::EnumerateSinks() {
|
||||
|
||||
std::vector<VideoSink> sinks;
|
||||
sinks.reserve(handles.size());
|
||||
for (int handle : handles)
|
||||
sinks.emplace_back(VideoSink{handle});
|
||||
for (int handle : handles) sinks.emplace_back(VideoSink{handle});
|
||||
return sinks;
|
||||
}
|
||||
|
||||
@@ -40,8 +39,7 @@ std::vector<VideoSource> VideoSource::EnumerateSources() {
|
||||
|
||||
std::vector<VideoSource> sources;
|
||||
sources.reserve(handles.size());
|
||||
for (int handle : handles)
|
||||
sources.emplace_back(VideoSource{handle});
|
||||
for (int handle : handles) sources.emplace_back(VideoSource{handle});
|
||||
return sources;
|
||||
}
|
||||
|
||||
@@ -52,7 +50,6 @@ std::vector<VideoSink> VideoSink::EnumerateSinks() {
|
||||
|
||||
std::vector<VideoSink> sinks;
|
||||
sinks.reserve(handles.size());
|
||||
for (int handle : handles)
|
||||
sinks.emplace_back(VideoSink{handle});
|
||||
for (int handle : handles) sinks.emplace_back(VideoSink{handle});
|
||||
return sinks;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// From: http://stackoverflow.com/questions/21028299/is-this-behavior-of-vectorresizesize-type-n-under-c11-and-boost-container
|
||||
// From:
|
||||
// http://stackoverflow.com/questions/21028299/is-this-behavior-of-vectorresizesize-type-n-under-c11-and-boost-container
|
||||
// Credits: Casey and Howard Hinnant
|
||||
#ifndef DEFAULT_INIT_ALLOCATOR_H_
|
||||
#define DEFAULT_INIT_ALLOCATOR_H_
|
||||
|
||||
#ifndef CSCORE_DEFAULT_INIT_ALLOCATOR_H_
|
||||
#define CSCORE_DEFAULT_INIT_ALLOCATOR_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -35,4 +38,4 @@ class default_init_allocator : public A {
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // DEFAULT_INIT_ALLOCATOR_H_
|
||||
#endif // CSCORE_DEFAULT_INIT_ALLOCATOR_H_
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "edu_wpi_cscore_CameraServerJNI.h"
|
||||
|
||||
#include "llvm/raw_ostream.h"
|
||||
#include "llvm/SmallString.h"
|
||||
#include "support/jni_util.h"
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/jni_util.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "edu_wpi_cscore_CameraServerJNI.h"
|
||||
|
||||
using namespace wpi::java;
|
||||
|
||||
@@ -20,7 +19,7 @@ using namespace wpi::java;
|
||||
//
|
||||
|
||||
// Used for callback.
|
||||
static JavaVM *jvm = nullptr;
|
||||
static JavaVM* jvm = nullptr;
|
||||
static JClass usbCameraInfoCls;
|
||||
static JClass videoModeCls;
|
||||
static JClass videoEventCls;
|
||||
@@ -28,17 +27,17 @@ static JException videoEx;
|
||||
static JException nullPointerEx;
|
||||
static JException unsupportedEx;
|
||||
// Thread-attached environment for listener callbacks.
|
||||
static JNIEnv *listenerEnv = nullptr;
|
||||
static JNIEnv* listenerEnv = nullptr;
|
||||
|
||||
static void ListenerOnStart() {
|
||||
if (!jvm) return;
|
||||
JNIEnv *env;
|
||||
JNIEnv* env;
|
||||
JavaVMAttachArgs args;
|
||||
args.version = JNI_VERSION_1_2;
|
||||
args.name = const_cast<char*>("CSListener");
|
||||
args.group = nullptr;
|
||||
if (jvm->AttachCurrentThreadAsDaemon(reinterpret_cast<void **>(&env),
|
||||
&args) != JNI_OK)
|
||||
if (jvm->AttachCurrentThreadAsDaemon(reinterpret_cast<void**>(&env), &args) !=
|
||||
JNI_OK)
|
||||
return;
|
||||
if (!env || !env->functions) return;
|
||||
listenerEnv = env;
|
||||
@@ -52,11 +51,11 @@ static void ListenerOnExit() {
|
||||
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
jvm = vm;
|
||||
|
||||
JNIEnv *env;
|
||||
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
return JNI_ERR;
|
||||
|
||||
// Cache references to classes
|
||||
@@ -85,9 +84,9 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
JNIEnv *env;
|
||||
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
|
||||
return;
|
||||
// Delete global references
|
||||
usbCameraInfoCls.free(env);
|
||||
@@ -107,16 +106,15 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
template <typename T>
|
||||
class JGlobal {
|
||||
public:
|
||||
JGlobal(JNIEnv *env, T obj)
|
||||
: m_obj(static_cast<T>(env->NewGlobalRef(obj))) {}
|
||||
JGlobal(JNIEnv* env, T obj) : m_obj(static_cast<T>(env->NewGlobalRef(obj))) {}
|
||||
~JGlobal() {
|
||||
if (!jvm || cs::NotifierDestroyed()) return;
|
||||
JNIEnv *env;
|
||||
JNIEnv* env;
|
||||
bool attached = false;
|
||||
// don't attach and de-attach if already attached to a thread.
|
||||
if (jvm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) ==
|
||||
if (jvm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) ==
|
||||
JNI_EDETACHED) {
|
||||
if (jvm->AttachCurrentThread(reinterpret_cast<void **>(&env), nullptr) !=
|
||||
if (jvm->AttachCurrentThread(reinterpret_cast<void**>(&env), nullptr) !=
|
||||
JNI_OK)
|
||||
return;
|
||||
attached = true;
|
||||
@@ -132,7 +130,7 @@ class JGlobal {
|
||||
T m_obj;
|
||||
};
|
||||
|
||||
static void ReportError(JNIEnv *env, CS_Status status) {
|
||||
static void ReportError(JNIEnv* env, CS_Status status) {
|
||||
if (status == CS_OK) return;
|
||||
llvm::SmallString<64> msg;
|
||||
switch (status) {
|
||||
@@ -172,13 +170,13 @@ static void ReportError(JNIEnv *env, CS_Status status) {
|
||||
videoEx.Throw(env, msg);
|
||||
}
|
||||
|
||||
static inline bool CheckStatus(JNIEnv *env, CS_Status status) {
|
||||
static inline bool CheckStatus(JNIEnv* env, CS_Status status) {
|
||||
if (status != CS_OK) ReportError(env, status);
|
||||
return status == CS_OK;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
static jobject MakeJObject(JNIEnv *env, const cs::UsbCameraInfo &info) {
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::UsbCameraInfo &info) {
|
||||
static jmethodID constructor = env->GetMethodID(
|
||||
usbCameraInfoCls, "<init>", "(ILjava/lang/String;Ljava/lang/String;)V");
|
||||
JLocal<jstring> path(env, MakeJString(env, info.path));
|
||||
@@ -188,7 +186,7 @@ static jobject MakeJObject(JNIEnv *env, const cs::UsbCameraInfo &info) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static jobject MakeJObject(JNIEnv *env, const cs::VideoMode &videoMode) {
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::VideoMode& videoMode) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(videoModeCls, "<init>", "(IIII)V");
|
||||
return env->NewObject(
|
||||
@@ -197,12 +195,13 @@ static jobject MakeJObject(JNIEnv *env, const cs::VideoMode &videoMode) {
|
||||
static_cast<jint>(videoMode.fps));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv *env, const cs::RawEvent &event) {
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::RawEvent& event) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(videoEventCls, "<init>",
|
||||
"(IIILjava/lang/String;IIIIIIILjava/lang/String;)V");
|
||||
JLocal<jstring> name(env, MakeJString(env, event.name));
|
||||
JLocal<jstring> valueStr(env, MakeJString(env, event.valueStr));
|
||||
// clang-format off
|
||||
return env->NewObject(
|
||||
videoEventCls,
|
||||
constructor,
|
||||
@@ -218,6 +217,7 @@ static jobject MakeJObject(JNIEnv *env, const cs::RawEvent &event) {
|
||||
static_cast<jint>(event.propertyKind),
|
||||
static_cast<jint>(event.value),
|
||||
valueStr.obj());
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
@@ -228,7 +228,7 @@ extern "C" {
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyKind
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyKind(property, &status);
|
||||
@@ -242,7 +242,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyKind
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -257,7 +257,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getProperty
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetProperty(property, &status);
|
||||
@@ -271,7 +271,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getProperty
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setProperty
|
||||
(JNIEnv *env, jclass, jint property, jint value)
|
||||
(JNIEnv* env, jclass, jint property, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetProperty(property, value, &status);
|
||||
@@ -284,7 +284,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setProperty
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyMin
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyMin(property, &status);
|
||||
@@ -298,7 +298,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyMin
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyMax
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyMax(property, &status);
|
||||
@@ -312,7 +312,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyMax
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyStep
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyStep(property, &status);
|
||||
@@ -326,7 +326,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyStep
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyDefault
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyDefault(property, &status);
|
||||
@@ -340,7 +340,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyDefault
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -355,7 +355,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setStringProperty
|
||||
(JNIEnv *env, jclass, jint property, jstring value)
|
||||
(JNIEnv* env, jclass, jint property, jstring value)
|
||||
{
|
||||
if (!value) {
|
||||
nullPointerEx.Throw(env, "value cannot be null");
|
||||
@@ -372,7 +372,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setStringProperty
|
||||
* Signature: (I)[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_getEnumPropertyChoices
|
||||
(JNIEnv *env, jclass, jint property)
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::GetEnumPropertyChoices(property, &status);
|
||||
@@ -386,7 +386,7 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_getEnumProper
|
||||
* Signature: (Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraDev
|
||||
(JNIEnv *env, jclass, jstring name, jint dev)
|
||||
(JNIEnv* env, jclass, jstring name, jint dev)
|
||||
{
|
||||
#ifndef __linux__
|
||||
unsupportedEx.Throw(env, "USB is not supported yet");
|
||||
@@ -409,7 +409,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraDev
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraPath
|
||||
(JNIEnv *env, jclass, jstring name, jstring path)
|
||||
(JNIEnv* env, jclass, jstring name, jstring path)
|
||||
{
|
||||
#ifndef __linux__
|
||||
unsupportedEx.Throw(env, "USB is not supported yet");
|
||||
@@ -437,7 +437,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createUsbCameraPath
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCamera
|
||||
(JNIEnv *env, jclass, jstring name, jstring url, jint kind)
|
||||
(JNIEnv* env, jclass, jstring name, jstring url, jint kind)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -461,7 +461,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCamera
|
||||
* Signature: (Ljava/lang/String;[Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
|
||||
(JNIEnv *env, jclass, jstring name, jobjectArray urls, jint kind)
|
||||
(JNIEnv* env, jclass, jstring name, jobjectArray urls, jint kind)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -497,8 +497,8 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
|
||||
* Signature: (Ljava/lang/String;IIII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSource
|
||||
(JNIEnv *env, jclass, jstring name, jint pixelFormat, jint width, jint height,
|
||||
jint fps)
|
||||
(JNIEnv* env, jclass, jstring name, jint pixelFormat, jint width,
|
||||
jint height, jint fps)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -521,7 +521,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSource
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceKind
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceKind(source, &status);
|
||||
@@ -535,7 +535,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceKind
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceName
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -550,7 +550,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceDescription
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -565,7 +565,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceDescripti
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceLastFrameTime
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceLastFrameTime(source, &status);
|
||||
@@ -579,7 +579,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceLastFrameTi
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_isSourceConnected
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::IsSourceConnected(source, &status);
|
||||
@@ -593,7 +593,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_isSourceConnected
|
||||
* Signature: (ILjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceProperty
|
||||
(JNIEnv *env, jclass, jint source, jstring name)
|
||||
(JNIEnv* env, jclass, jint source, jstring name)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -611,7 +611,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceProperty
|
||||
* Signature: (I)[I
|
||||
*/
|
||||
JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceProperties
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Property, 32> buf;
|
||||
@@ -626,7 +626,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceP
|
||||
* Signature: (I)Ledu/wpi/cameraserver/VideoMode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceVideoMode
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceVideoMode(source, &status);
|
||||
@@ -640,7 +640,7 @@ JNIEXPORT jobject JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceVideoMode
|
||||
* Signature: (IIIII)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceVideoMode
|
||||
(JNIEnv *env, jclass, jint source, jint pixelFormat, jint width, jint height,
|
||||
(JNIEnv* env, jclass, jint source, jint pixelFormat, jint width, jint height,
|
||||
jint fps)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
@@ -659,7 +659,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceVideoMod
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourcePixelFormat
|
||||
(JNIEnv *env, jclass, jint source, jint pixelFormat)
|
||||
(JNIEnv* env, jclass, jint source, jint pixelFormat)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourcePixelFormat(
|
||||
@@ -674,7 +674,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourcePixelFor
|
||||
* Signature: (III)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceResolution
|
||||
(JNIEnv *env, jclass, jint source, jint width, jint height)
|
||||
(JNIEnv* env, jclass, jint source, jint width, jint height)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceResolution(source, width, height, &status);
|
||||
@@ -688,7 +688,7 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceResoluti
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceFPS
|
||||
(JNIEnv *env, jclass, jint source, jint fps)
|
||||
(JNIEnv* env, jclass, jint source, jint fps)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceFPS(source, fps, &status);
|
||||
@@ -702,13 +702,12 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceFPS
|
||||
* Signature: (I)[Ledu/wpi/cameraserver/VideoMode;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceVideoModes
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::EnumerateSourceVideoModes(source, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
jobjectArray jarr =
|
||||
env->NewObjectArray(arr.size(), videoModeCls, nullptr);
|
||||
jobjectArray jarr = env->NewObjectArray(arr.size(), videoModeCls, nullptr);
|
||||
if (!jarr) return nullptr;
|
||||
for (size_t i = 0; i < arr.size(); ++i) {
|
||||
JLocal<jobject> jelem{env, MakeJObject(env, arr[i])};
|
||||
@@ -723,7 +722,7 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSour
|
||||
* Signature: (I)[I
|
||||
*/
|
||||
JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceSinks
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Sink, 16> buf;
|
||||
@@ -738,7 +737,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceS
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_copySource
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CopySource(source, &status);
|
||||
@@ -752,7 +751,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_copySource
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_releaseSource
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::ReleaseSource(source, &status);
|
||||
@@ -765,7 +764,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_releaseSource
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraBrightness
|
||||
(JNIEnv *env, jclass, jint source, jint brightness)
|
||||
(JNIEnv* env, jclass, jint source, jint brightness)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraBrightness(source, brightness, &status);
|
||||
@@ -778,7 +777,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraBrightness
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getCameraBrightness
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetCameraBrightness(source, &status);
|
||||
@@ -792,7 +791,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getCameraBrightness
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceAuto
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceAuto(source, &status);
|
||||
@@ -805,7 +804,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalance
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceHoldCurrent(source, &status);
|
||||
@@ -818,7 +817,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalance
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalanceManual
|
||||
(JNIEnv *env, jclass, jint source, jint value)
|
||||
(JNIEnv* env, jclass, jint source, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceManual(source, value, &status);
|
||||
@@ -831,7 +830,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraWhiteBalance
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureAuto
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureAuto(source, &status);
|
||||
@@ -844,7 +843,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureAuto
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureHoldCurrent
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureHoldCurrent(source, &status);
|
||||
@@ -857,7 +856,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureHold
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureManual
|
||||
(JNIEnv *env, jclass, jint source, jint value)
|
||||
(JNIEnv* env, jclass, jint source, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureManual(source, value, &status);
|
||||
@@ -870,7 +869,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setCameraExposureManu
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraPath
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
#ifndef __linux__
|
||||
unsupportedEx.Throw(env, "USB is not supported yet");
|
||||
@@ -889,7 +888,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getUsbCameraPath
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraKind
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto kind = cs::GetHttpCameraKind(source, &status);
|
||||
@@ -903,7 +902,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraKind
|
||||
* Signature: (I[Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
|
||||
(JNIEnv *env, jclass, jint source, jobjectArray urls)
|
||||
(JNIEnv* env, jclass, jint source, jobjectArray urls)
|
||||
{
|
||||
if (!urls) {
|
||||
nullPointerEx.Throw(env, "urls cannot be null");
|
||||
@@ -932,7 +931,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
|
||||
* Signature: (I)[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHttpCameraUrls
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::GetHttpCameraUrls(source, &status);
|
||||
@@ -946,7 +945,7 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHttpCamera
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_putSourceFrame
|
||||
(JNIEnv *env, jclass, jint source, jlong imageNativeObj)
|
||||
(JNIEnv* env, jclass, jint source, jlong imageNativeObj)
|
||||
{
|
||||
cv::Mat& image = *((cv::Mat*)imageNativeObj);
|
||||
CS_Status status = 0;
|
||||
@@ -960,7 +959,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_putSourceFrame
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_notifySourceError
|
||||
(JNIEnv *env, jclass, jint source, jstring msg)
|
||||
(JNIEnv* env, jclass, jint source, jstring msg)
|
||||
{
|
||||
if (!msg) {
|
||||
nullPointerEx.Throw(env, "msg cannot be null");
|
||||
@@ -977,7 +976,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_notifySourceError
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceConnected
|
||||
(JNIEnv *env, jclass, jint source, jboolean connected)
|
||||
(JNIEnv* env, jclass, jint source, jboolean connected)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSourceConnected(source, connected, &status);
|
||||
@@ -990,7 +989,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceConnected
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceDescription
|
||||
(JNIEnv *env, jclass, jint source, jstring description)
|
||||
(JNIEnv* env, jclass, jint source, jstring description)
|
||||
{
|
||||
if (!description) {
|
||||
nullPointerEx.Throw(env, "description cannot be null");
|
||||
@@ -1007,7 +1006,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceDescription
|
||||
* Signature: (ILjava/lang/String;IIIIII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createSourceProperty
|
||||
(JNIEnv *env, jclass, jint source, jstring name, jint kind, jint minimum, jint maximum, jint step, jint defaultValue, jint value)
|
||||
(JNIEnv* env, jclass, jint source, jstring name, jint kind, jint minimum,
|
||||
jint maximum, jint step, jint defaultValue, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateSourceProperty(
|
||||
@@ -1023,7 +1023,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createSourceProperty
|
||||
* Signature: (II[Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumPropertyChoices
|
||||
(JNIEnv *env, jclass, jint source, jint property, jobjectArray choices)
|
||||
(JNIEnv* env, jclass, jint source, jint property, jobjectArray choices)
|
||||
{
|
||||
if (!choices) {
|
||||
nullPointerEx.Throw(env, "choices cannot be null");
|
||||
@@ -1052,7 +1052,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumProperty
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createMjpegServer
|
||||
(JNIEnv *env, jclass, jstring name, jstring listenAddress, jint port)
|
||||
(JNIEnv* env, jclass, jstring name, jstring listenAddress, jint port)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -1075,7 +1075,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createMjpegServer
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSink
|
||||
(JNIEnv *env, jclass, jstring name)
|
||||
(JNIEnv* env, jclass, jstring name)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -1093,7 +1093,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSink
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkKind
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkKind(sink, &status);
|
||||
@@ -1107,7 +1107,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkKind
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkName
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -1122,7 +1122,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -1137,7 +1137,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkSource
|
||||
(JNIEnv *env, jclass, jint sink, jint source)
|
||||
(JNIEnv* env, jclass, jint sink, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSinkSource(sink, source, &status);
|
||||
@@ -1150,7 +1150,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkSource
|
||||
* Signature: (ILjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkSourceProperty
|
||||
(JNIEnv *env, jclass, jint sink, jstring name)
|
||||
(JNIEnv* env, jclass, jint sink, jstring name)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
@@ -1168,7 +1168,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkSourceProperty
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkSource
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkSource(sink, &status);
|
||||
@@ -1182,7 +1182,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkSource
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_copySink
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CopySink(sink, &status);
|
||||
@@ -1196,7 +1196,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_copySink
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_releaseSink
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::ReleaseSink(sink, &status);
|
||||
@@ -1209,7 +1209,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_releaseSink
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerListenAddress
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto str = cs::GetMjpegServerListenAddress(sink, &status);
|
||||
@@ -1223,7 +1223,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerList
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerPort
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetMjpegServerPort(sink, &status);
|
||||
@@ -1237,7 +1237,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getMjpegServerPort
|
||||
* Signature: (ILjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkDescription
|
||||
(JNIEnv *env, jclass, jint sink, jstring description)
|
||||
(JNIEnv* env, jclass, jint sink, jstring description)
|
||||
{
|
||||
if (!description) {
|
||||
nullPointerEx.Throw(env, "description cannot be null");
|
||||
@@ -1254,7 +1254,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkDescription
|
||||
* Signature: (IJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrame
|
||||
(JNIEnv *env, jclass, jint sink, jlong imageNativeObj)
|
||||
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj)
|
||||
{
|
||||
cv::Mat& image = *((cv::Mat*)imageNativeObj);
|
||||
CS_Status status = 0;
|
||||
@@ -1269,7 +1269,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrame
|
||||
* Signature: (IJD)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrameTimeout
|
||||
(JNIEnv *env, jclass, jint sink, jlong imageNativeObj, jdouble timeout)
|
||||
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj, jdouble timeout)
|
||||
{
|
||||
cv::Mat& image = *((cv::Mat*)imageNativeObj);
|
||||
CS_Status status = 0;
|
||||
@@ -1284,7 +1284,7 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrameTimeout
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkError
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
@@ -1299,7 +1299,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkError
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled
|
||||
(JNIEnv *env, jclass, jint sink, jboolean enabled)
|
||||
(JNIEnv* env, jclass, jint sink, jboolean enabled)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSinkEnabled(sink, enabled, &status);
|
||||
@@ -1312,7 +1312,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled
|
||||
* Signature: (Ljava/util/function/Consumer;IZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener
|
||||
(JNIEnv *envouter, jclass, jobject listener, jint eventMask, jboolean immediateNotify)
|
||||
(JNIEnv* envouter, jclass, jobject listener, jint eventMask,
|
||||
jboolean immediateNotify)
|
||||
{
|
||||
if (!listener) {
|
||||
nullPointerEx.Throw(envouter, "listener cannot be null");
|
||||
@@ -1320,11 +1321,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener
|
||||
}
|
||||
// the shared pointer to the weak global will keep it around until the
|
||||
// entry listener is destroyed
|
||||
auto listener_global =
|
||||
std::make_shared<JGlobal<jobject>>(envouter, listener);
|
||||
auto listener_global = std::make_shared<JGlobal<jobject>>(envouter, listener);
|
||||
|
||||
// cls is a temporary here; cannot be used within callback functor
|
||||
jclass cls = envouter->GetObjectClass(listener);
|
||||
jclass cls = envouter->GetObjectClass(listener);
|
||||
if (!cls) return 0;
|
||||
|
||||
// method ids, on the other hand, are safe to retain
|
||||
@@ -1333,8 +1333,8 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener
|
||||
|
||||
CS_Status status = 0;
|
||||
CS_Listener handle = cs::AddListener(
|
||||
[=](const cs::RawEvent &event) {
|
||||
JNIEnv *env = listenerEnv;
|
||||
[=](const cs::RawEvent& event) {
|
||||
JNIEnv* env = listenerEnv;
|
||||
if (!env || !env->functions) return;
|
||||
|
||||
// get the handler
|
||||
@@ -1366,7 +1366,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_removeListener
|
||||
(JNIEnv *env, jclass, jint handle)
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::RemoveListener(handle, &status);
|
||||
@@ -1379,7 +1379,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_removeListener
|
||||
* Signature: ()[Ledu/wpi/cameraserver/UsbCameraInfo;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateUsbCameras
|
||||
(JNIEnv *env, jclass)
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
#ifndef __linux__
|
||||
unsupportedEx.Throw(env, "USB is not supported yet");
|
||||
@@ -1405,7 +1405,7 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateUsbC
|
||||
* Signature: ()[I
|
||||
*/
|
||||
JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
|
||||
(JNIEnv *env, jclass)
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Source, 16> buf;
|
||||
@@ -1420,7 +1420,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
|
||||
* Signature: ()[I
|
||||
*/
|
||||
JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
|
||||
(JNIEnv *env, jclass)
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Sink, 16> buf;
|
||||
@@ -1435,7 +1435,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHostname
|
||||
(JNIEnv *env, jclass)
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
return MakeJString(env, cs::GetHostname());
|
||||
}
|
||||
@@ -1446,7 +1446,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getHostname
|
||||
* Signature: ()[Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_getNetworkInterfaces
|
||||
(JNIEnv *env, jclass)
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
return MakeJStringArray(env, cs::GetNetworkInterfaces());
|
||||
}
|
||||
@@ -1457,15 +1457,15 @@ namespace {
|
||||
|
||||
struct LogMessage {
|
||||
public:
|
||||
LogMessage(unsigned int level, const char *file, unsigned int line,
|
||||
const char *msg)
|
||||
LogMessage(unsigned int level, const char* file, unsigned int line,
|
||||
const char* msg)
|
||||
: m_level(level), m_file(file), m_line(line), m_msg(msg) {}
|
||||
|
||||
void CallJava(JNIEnv* env, jobject func, jmethodID mid) {
|
||||
JLocal<jstring> file{env, MakeJString(env, m_file)};
|
||||
JLocal<jstring> msg{env, MakeJString(env, m_msg)};
|
||||
env->CallVoidMethod(func, mid, (jint)m_level, file.obj(),
|
||||
(jint)m_line, msg.obj());
|
||||
env->CallVoidMethod(func, mid, (jint)m_level, file.obj(), (jint)m_line,
|
||||
msg.obj());
|
||||
}
|
||||
|
||||
static const char* GetName() { return "CSLogger"; }
|
||||
@@ -1492,7 +1492,7 @@ extern "C" {
|
||||
* Signature: (Ledu/wpi/cscore/CameraServerJNI/LoggerFunction;I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setLogger
|
||||
(JNIEnv *env, jclass, jobject func, jint minLevel)
|
||||
(JNIEnv* env, jclass, jobject func, jint minLevel)
|
||||
{
|
||||
if (!func) {
|
||||
nullPointerEx.Throw(env, "func cannot be null");
|
||||
@@ -1503,8 +1503,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setLogger
|
||||
if (!cls) return;
|
||||
|
||||
// method ids, on the other hand, are safe to retain
|
||||
jmethodID mid = env->GetMethodID(
|
||||
cls, "apply", "(ILjava/lang/String;ILjava/lang/String;)V");
|
||||
jmethodID mid = env->GetMethodID(cls, "apply",
|
||||
"(ILjava/lang/String;ILjava/lang/String;)V");
|
||||
if (!mid) return;
|
||||
|
||||
auto& logger = LoggerJNI::GetInstance();
|
||||
@@ -1512,8 +1512,8 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setLogger
|
||||
logger.SetFunc(env, func, mid);
|
||||
|
||||
cs::SetLogger(
|
||||
[](unsigned int level, const char *file, unsigned int line,
|
||||
const char *msg) {
|
||||
[](unsigned int level, const char* file, unsigned int line,
|
||||
const char* msg) {
|
||||
LoggerJNI::GetInstance().Send(level, file, line, msg);
|
||||
},
|
||||
minLevel);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CSCORE_H_
|
||||
#define CSCORE_H_
|
||||
#ifndef CSCORE_CSCORE_H_
|
||||
#define CSCORE_CSCORE_H_
|
||||
|
||||
/* C API */
|
||||
#include "cscore_c.h"
|
||||
@@ -15,6 +15,6 @@
|
||||
/* C++ API */
|
||||
#include "cscore_cpp.h"
|
||||
#include "cscore_oo.h"
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CSCORE_H_ */
|
||||
#endif /* CSCORE_CSCORE_H_ */
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CSCORE_C_H_
|
||||
#define CSCORE_C_H_
|
||||
#ifndef CSCORE_CSCORE_C_H_
|
||||
#define CSCORE_CSCORE_C_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -46,7 +47,7 @@ typedef CS_Handle CS_Source;
|
||||
enum CS_StatusValue {
|
||||
CS_PROPERTY_WRITE_FAILED = 2000,
|
||||
CS_OK = 0,
|
||||
CS_INVALID_HANDLE = -2000, // handle was invalid (does not exist)
|
||||
CS_INVALID_HANDLE = -2000, // handle was invalid (does not exist)
|
||||
CS_WRONG_HANDLE_SUBTYPE = -2001,
|
||||
CS_INVALID_PROPERTY = -2002,
|
||||
CS_WRONG_PROPERTY_TYPE = -2003,
|
||||
@@ -127,11 +128,7 @@ enum CS_HttpCameraKind {
|
||||
//
|
||||
// Sink kinds
|
||||
//
|
||||
enum CS_SinkKind {
|
||||
CS_SINK_UNKNOWN = 0,
|
||||
CS_SINK_MJPEG = 2,
|
||||
CS_SINK_CV = 4
|
||||
};
|
||||
enum CS_SinkKind { CS_SINK_UNKNOWN = 0, CS_SINK_MJPEG = 2, CS_SINK_CV = 4 };
|
||||
|
||||
//
|
||||
// Listener event kinds
|
||||
@@ -165,7 +162,7 @@ struct CS_Event {
|
||||
CS_Sink sink;
|
||||
|
||||
// Source/sink/property name
|
||||
const char *name;
|
||||
const char* name;
|
||||
|
||||
// Fields for CS_SOURCE_VIDEOMODE_CHANGED event
|
||||
CS_VideoMode mode;
|
||||
@@ -383,4 +380,4 @@ void CS_FreeNetworkInterfaces(char** interfaces, int count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CSCORE_C_H_ */
|
||||
#endif // CSCORE_CSCORE_C_H_
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CSCORE_CPP_H_
|
||||
#define CSCORE_CPP_H_
|
||||
#ifndef CSCORE_CSCORE_CPP_H_
|
||||
#define CSCORE_CSCORE_CPP_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/ArrayRef.h"
|
||||
#include "llvm/SmallVector.h"
|
||||
#include "llvm/StringRef.h"
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
@@ -88,7 +88,7 @@ struct RawEvent {
|
||||
};
|
||||
|
||||
RawEvent() = default;
|
||||
RawEvent(RawEvent::Kind kind_) : kind{kind_} {}
|
||||
explicit RawEvent(RawEvent::Kind kind_) : kind{kind_} {}
|
||||
RawEvent(llvm::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_)
|
||||
: kind{kind_}, name{name_} {
|
||||
if (kind_ == kSinkCreated || kind_ == kSinkDestroyed ||
|
||||
@@ -339,4 +339,4 @@ uint64_t CS_GrabSinkFrameTimeoutCpp(CS_Sink sink, cv::Mat* image,
|
||||
void CS_PutSourceFrameCpp(CS_Source source, cv::Mat* image, CS_Status* status);
|
||||
}
|
||||
|
||||
#endif // CSCORE_CPP_H_
|
||||
#endif // CSCORE_CSCORE_CPP_H_
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CSCORE_OO_H_
|
||||
#define CSCORE_OO_H_
|
||||
#ifndef CSCORE_CSCORE_OO_H_
|
||||
#define CSCORE_CSCORE_OO_H_
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
@@ -416,18 +419,18 @@ class CvSource : public VideoSource {
|
||||
/// @param defaultValue Default value
|
||||
/// @param value Current value
|
||||
/// @return Property
|
||||
VideoProperty CreateIntegerProperty(llvm::StringRef name,
|
||||
int minimum, int maximum, int step,
|
||||
int defaultValue, int value);
|
||||
VideoProperty CreateIntegerProperty(llvm::StringRef name, int minimum,
|
||||
int maximum, int step, int defaultValue,
|
||||
int value);
|
||||
|
||||
/// Create a boolean property.
|
||||
/// @param name Property name
|
||||
/// @param defaultValue Default value
|
||||
/// @param value Current value
|
||||
/// @return Property
|
||||
VideoProperty CreateBooleanProperty(llvm::StringRef name,
|
||||
bool defaultValue, bool value);
|
||||
|
||||
VideoProperty CreateBooleanProperty(llvm::StringRef name, bool defaultValue,
|
||||
bool value);
|
||||
|
||||
/// Create a string property.
|
||||
/// @param name Property name
|
||||
/// @param defaultValue Default value
|
||||
@@ -641,4 +644,4 @@ class VideoListener {
|
||||
|
||||
#include "cscore_oo.inl"
|
||||
|
||||
#endif // CSCORE_OO_H_
|
||||
#endif // CSCORE_CSCORE_OO_H_
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "cscore.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
class CameraSourceTest : public ::testing::Test {
|
||||
protected:
|
||||
CameraSourceTest() {
|
||||
}
|
||||
CameraSourceTest() {}
|
||||
};
|
||||
|
||||
TEST_F(CameraSourceTest, HTTPCamera) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2015. All Rights Reserved. */
|
||||
/* Copyright (c) 2015-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,9 +7,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user