Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,26 @@
"typeinfo": "cpp",
"variant": "cpp",
"cstring": "cpp",
"complex": "cpp"
"complex": "cpp",
"any": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"bitset": "cpp",
"codecvt": "cpp",
"forward_list": "cpp",
"set": "cpp",
"unordered_set": "cpp",
"fstream": "cpp",
"future": "cpp",
"queue": "cpp",
"ranges": "cpp",
"shared_mutex": "cpp",
"text_encoding": "cpp",
"cfenv": "cpp",
"typeindex": "cpp",
"valarray": "cpp",
"regex": "cpp",
"stack": "cpp"
},
"cmake.sourceDirectory": "${workspaceFolder}/linux/"
}
24 changes: 12 additions & 12 deletions libausbc/src/main/jni/UVCCamera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22)

set(UVCCAMERA ${CMAKE_CURRENT_LIST_DIR}/)
include_directories(
${UVCCAMERA}/
${UVCCAMERA}/include/
)


Expand All @@ -20,15 +20,15 @@ endif ()
add_compile_definitions(USE_TURBOJPEG)

list(APPEND SOURCES
${UVCCAMERA}/_onload.cpp
${UVCCAMERA}/UVCCamera.cpp
${UVCCAMERA}/ImageUseCases.cpp
${UVCCAMERA}/UVCPreviewBase.cpp
${UVCCAMERA}/UVCPreviewJni.cpp
${UVCCAMERA}/UVCCameraAdjustments.cpp
${UVCCAMERA}/ProgressObserver.cpp
${UVCCAMERA}/JniUVCCamera.cpp
${UVCCAMERA}/JpegBenchmark.cpp
${UVCCAMERA}/LoadJpegImageFromAssetsUseCase.cpp
${UVCCAMERA}/JniJpegBenchmark.cpp
${UVCCAMERA}/src/_onload.cpp
${UVCCAMERA}/src/UVCCamera.cpp
${UVCCAMERA}/src/ImageUseCases.cpp
${UVCCAMERA}/src/UVCPreviewBase.cpp
${UVCCAMERA}/src/UVCPreviewJni.cpp
${UVCCAMERA}/src/UVCCameraAdjustments.cpp
${UVCCAMERA}/src/ProgressObserver.cpp
${UVCCAMERA}/src/JniUVCCamera.cpp
${UVCCAMERA}/src/JpegBenchmark.cpp
${UVCCAMERA}/src/LoadJpegImageFromAssetsUseCase.cpp
${UVCCAMERA}/src/JniJpegBenchmark.cpp
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the updated file paths in the CMakeLists.txt accurately reflect the new directory layout and that no outdated references remain.

Suggested change
${UVCCAMERA}/src/JniJpegBenchmark.cpp
# Assuming the file has been removed from the project:
# Remove the reference to JniJpegBenchmark.cpp
# If the file has been moved, replace the path with the correct one.
# Example if the file has been moved to a new location:
# ${UVCCAMERA}/new_path/JniJpegBenchmark.cpp
# Example if the file has been removed:
# (Remove the line entirely)

Copilot uses AI. Check for mistakes.
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "jpeglib.h"
#endif
#ifdef USE_TURBOJPEG
#include <turbojpeg.h>
#include "turbojpeg.h"
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify whether the change from angle brackets to quotes for turbojpeg is intentional. If turbojpeg is provided as a system library, consider using angle brackets for clarity.

Suggested change
#include "turbojpeg.h"
#include <turbojpeg.h>

Copilot uses AI. Check for mistakes.
#endif

LoadJpegImageUseCase::Result LoadJpegImageFromFileUseCase::load(std::string imageId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include "JpegBenchmark.h"
#include "utilbase.h"
#include <map>
#include <thread>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Files in the jni/libjpeg, jni/libusb, jin/libuvc, jni/rapidjson folder may have a different license, see the respective files.
*/

#include <stdlib.h>
#include <cstdlib>
#include <unistd.h>
#include "utilbase.h"
#include "UVCPreviewBase.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Files in the jni/libjpeg, jni/libusb, jin/libuvc folder may have a different license, see the respective files.
*/

#include <stdlib.h>
#include <cstdlib>
#include "UVCPreviewJni.h"

int UVCPreviewJni::setPreviewDisplay(ANativeWindow *preview_window) {
Expand Down
59 changes: 47 additions & 12 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,41 @@ cmake_minimum_required(VERSION 3.22)

project(LinuxUvcTests)

cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH ROOT_DIR)
set(UVCCAMERA ${ROOT_DIR}/libausbc/src/main/jni/UVCCamera)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)

find_package( Threads REQUIRED )
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.5.3
)
FetchContent_MakeAvailable(Catch2)

find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package (JPEG REQUIRED)

#set(USE_TURBOJPEG 1)
set(USE_LIBJPEG 1)

include_directories(
../libausbc/src/main/jni/UVCCamera/
${UVCCAMERA}/include/
./include/
)

find_package(SDL2 REQUIRED)

add_executable(uvccapture
SdlTools.cpp
UvcCamera.cpp
uvccapture.cpp
../libausbc/src/main/jni/UVCCamera/ImageUseCases.cpp
./src/SdlTools.cpp
./src/UvcCamera.cpp
./src/uvccapture.cpp
${UVCCAMERA}/src/ImageUseCases.cpp
)

target_link_libraries(
Expand All @@ -33,10 +46,10 @@ target_link_libraries(


add_executable(jpegbenchmark
jpegdecodebenchmark.cpp
../libausbc/src/main/jni/UVCCamera/ImageUseCases.cpp
../libausbc/src/main/jni/UVCCamera/JpegBenchmark.cpp
../libausbc/src/main/jni/UVCCamera/ProgressObserver.cpp
./src/jpegdecodebenchmark.cpp
${UVCCAMERA}/src/ImageUseCases.cpp
${UVCCAMERA}/src/JpegBenchmark.cpp
${UVCCAMERA}/src/ProgressObserver.cpp
)

if(USE_TURBOJPEG)
Expand All @@ -58,6 +71,28 @@ if (USE_LIBJPEG)
${CMAKE_THREAD_LIBS_INIT})
endif()

# add_executable(unix_socket_client unix_socket_client.cpp)
# add_executable(unix_socket_server unix_socket_server.cpp)
##
## USB Audio devices tests
##

pkg_check_modules(LibUSB REQUIRED libusb-1.0)

if(LibUSB_FOUND)
include_directories(${LibUSB_INCLUDE_DIRS})
else()
message(FATAL_ERROR "LibUSB not found. Please install libusb-dev (or equivalent) on your system.")
endif()

add_executable(uaccapture
./src/uaccapture.cpp
./src/UacSource.cpp
)

target_link_libraries(uaccapture ${LibUSB_LIBRARIES})

# Enable testing with CTest
enable_testing()

# add_test(NAME DemoTests COMMAND catch2_tests)
add_executable(tests test/test_catch2.cpp)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
File renamed without changes.
52 changes: 52 additions & 0 deletions linux/include/UacSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include <string>
#include <libusb-1.0/libusb.h>
#include <fstream> // For writing to a file

class UacSource {
public:
class Error : public std::exception {
private:
std::string message;
public:
Error(const char* msg) : message(msg) {}
Error(const std::string& msg) : message(msg) {}
const char* what() const noexcept {
return message.c_str();
}
};

struct StartConfiguration {
const uint16_t vendor_id;
const uint16_t product_id;
const int interface_number;
const int endpoint_address;
};
public:
virtual ~UacSource() = default;
virtual void init() = 0;
virtual void deinit() = 0;
virtual void test(const StartConfiguration &cfg) = 0;
};

class UacSourceImpl : public UacSource {
public:

protected:
libusb_context* ctx = nullptr;

libusb_device_handle *handle;
int endpoint;
std::ofstream outputFile;
protected:
static void entryPoint(UacSourceImpl* uacSource);
libusb_device_handle *findAudioDevice(const StartConfiguration &cfg);
void handleAudioData();
public:
UacSourceImpl();
~UacSourceImpl() override;
void init() override;
void deinit() override;
void test(const StartConfiguration &cfg) override;
};
File renamed without changes.
File renamed without changes.
Loading