forked from ChrisAJS/lgx2userspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed need V4L changed build method
- Loading branch information
1 parent
c755ddd
commit e1508b9
Showing
116 changed files
with
49,648 additions
and
190 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
CXX ?= g++ | ||
CC ?= gcc | ||
LD := lld | ||
AR := ar | ||
FORMAT := clang-format-11 | ||
|
||
UNAME := $(shell uname) | ||
UNAMEM := $(shell uname -m) | ||
|
||
ASAN ?= 0 | ||
DEBUG ?= 1 | ||
OPTFLAGS ?= -O0 | ||
LTO ?= 0 | ||
|
||
WARN := \ | ||
-Wno-return-type \ | ||
-funsigned-char \ | ||
-fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ | ||
|
||
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib | ||
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib | ||
LDFLAGS := | ||
|
||
ifeq ($(UNAME), Linux) #LINUX | ||
CXXFLAGS += -mhard-float -msse2 -mfpmath=sse | ||
CFLAGS += -mhard-float -msse2 -mfpmath=sse | ||
endif | ||
|
||
CPPFLAGS := -MMD | ||
|
||
|
||
ifeq ($(UNAME), Linux) #LINUX | ||
TARGET := lgxuserspace.elf | ||
endif | ||
|
||
INC_DIRS := $(addprefix -I, \ | ||
. \ | ||
src \ | ||
utils \ | ||
) | ||
|
||
ifeq ($(UNAME), Linux) #LINUX | ||
INC_DIRS += $(addprefix -I, \ | ||
/opt/X11/include \ | ||
) | ||
endif | ||
|
||
|
||
LDLIBS := \ | ||
$(addprefix -l, \ | ||
usb-1.0 \ | ||
pcap \ | ||
) | ||
|
||
ifeq ($(UNAME), Linux) #LINUX | ||
LDLIBS += \ | ||
$(addprefix -l, \ | ||
X11 \ | ||
SDL2 \ | ||
GL \ | ||
GLEW \ | ||
pulse-simple \ | ||
) | ||
endif | ||
|
||
CXX_FILES := \ | ||
$(shell find src -type f -name "*.cpp") | ||
|
||
C_FILES := \ | ||
$(shell find utils -type f -name "*.c") | ||
|
||
O_FILES := \ | ||
$(C_FILES:%.c=build/%.o) \ | ||
$(CXX_FILES:%.cpp=build/%.o) | ||
D_FILES := $(O_FILES:%.o=%.d) | ||
|
||
# create build directory | ||
SRC_DIRS := $(shell find . -type d -a -not -path "*build*") | ||
$(shell mkdir -p $(SRC_DIRS:%=build/%)) | ||
|
||
all: | ||
$(MAKE) $(TARGET) | ||
|
||
clean: | ||
rm -rf build $(TARGET) | ||
|
||
.PHONY: all clean | ||
|
||
build/%.o: %.cpp | ||
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@ | ||
|
||
build/%.o: %.c | ||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@ | ||
|
||
|
||
$(TARGET): $(O_FILES) | ||
$(CXX) $^ -o $@ $(LDFLAGS) $(LDDIRS) $(LDLIBS) | ||
|
||
-include $(D_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# LGX2 Userspace driver (with LGX support) | ||
This software is little more than a POC and no guarantees of functionality are given and it may even be dangerous to use this software. Please | ||
consider contacting AverMedia for a supported Linux driver. | ||
|
||
This project contains a userspace driver for the [AverMedia LGX2 (GC551)](https://avermedia.com/LGX2) as well support for the [AverMedia LGX (GC550)](https://avermedia.com/LGX). | ||
|
||
It can be used to display the captured video and audio in a standalone window or | ||
to forward the captured video and audio to a virtual video capture device. | ||
|
||
## Building | ||
To build the project, you will need: | ||
* CMake | ||
* Libusb | ||
* Libpcap | ||
* SDL2 | ||
* V4L2Loopback | ||
|
||
Execute the following commands to build in the root of the project: | ||
|
||
```bash | ||
mkdir build && cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
## Setup | ||
The userspace driver will require read and write access to the LGX/LGX2. | ||
|
||
On a Linux system, this can be granted to the user by adding the following rules to Udev. | ||
|
||
```bash | ||
sudo cp 999-avermedia.rules /etc/udev/rules.d/999-avermedia.rules | ||
sudo udevadm control --reload-rules | ||
``` | ||
|
||
After the rule has been added, unplug and re-plug in the LGX/LGX2. | ||
|
||
## Running | ||
Once udev has been configured to grant read and write permission to the device it | ||
will be possible to run the application by executing `lgx2userspace`. | ||
|
||
If you are using the LGX GC550, use the command line option `x` - `./lgx2userspace -x`. | ||
|
||
The application will take a few seconds to run as it streams setup information to the device, | ||
and it will eventually display a window that will then start to display captured frames. | ||
|
||
In my limited testing, certain devices may need to be re-plugged in after the application has | ||
started. For example, a Nintendo Switch will not recognise the LGX/LGX2 as an output source until | ||
it is undocked and re-docked. | ||
|
||
### Options when running | ||
When using the default SDL2 renderer for video output, it is possible to toggle fullscreen | ||
by pressing `F` and to exit fullscreen by pressing `G`. | ||
|
||
### Gathering diagnostic information | ||
To help diagnose problems that may be fixed in the future, when submitting an issue | ||
please try to give as much information about your setup as possible and in the case of | ||
inadequate video or audio output, run the userspace driver with the `-v` switch enabled. | ||
|
||
With the `-v` switch enabled, the driver will output information regarding time taken to | ||
process frame data and time taken to render both audio and video. | ||
|
||
This information could be valuable when identifying issues so please try your best to include it | ||
in any issues you raise, thank you! | ||
|
||
## Running with V4L2 Output and Pulseaudio Output | ||
### V4L2 Output setup | ||
To output video to a virtual webcam output source, load the V4L2 Loopback Linux module with an easy to identify device | ||
number: | ||
|
||
```bash | ||
sudo modprobe v4l2loopback video_nr=99 exclusive_caps=1 card_label="LGX2" | ||
``` | ||
|
||
You should now see `/dev/video99` exists: | ||
|
||
```bash | ||
ls /dev/video99 | ||
/dev/video99 | ||
``` | ||
|
||
### Pulseaudio Setup | ||
Pulseaudio can be configured by issuing the following commands: | ||
```bash | ||
pactl load-module module-null-sink sink_name=lgx2 sink_properties=device.description=LGX2 | ||
pactl load-module module-remap-source master=lgx2.monitor source_name=lgx2 source_properties=device.description=LGX2Audio | ||
``` | ||
This will create an audio sink called `LGX2 Audio Sink` which can be added to OBS as a Pulseaudio output capture device. | ||
|
||
**NOTE: Even if you are using the LGX GC550- leaving the names as lgx2 is required and will not affect behaviour.** | ||
**NOTE: The best way to control the audio volume is to use the gain OBS filter whilst leaving the sink volume at max.** | ||
|
||
### Running with configure V4L2 device | ||
Run the userspace driver with the `-d` option to specify which V4L2Loopback device to use: | ||
|
||
```bash | ||
./lgx2userspace -d /dev/video99 | ||
``` | ||
|
||
To run using the Pulseaudio sink that you created, use the `-a` switch with the name of the sink: | ||
|
||
```bash | ||
./lgx2userspace -a lgx2 | ||
``` | ||
|
||
**NOTE: You may need to unplug and replug in your video source.** | ||
|
||
Go to OBS or other streaming software and select the LGX2 V4L2 source. You should now see video from the input device being output. | ||
|
||
## Demo | ||
See it in action over at [YouTube](https://www.youtube.com/watch?v=-yzHMbUn-w0). |
Binary file not shown.
Oops, something went wrong.