Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List info for connected Magewell USB devices and nosignal tool polishing PR #95

Merged
merged 6 commits into from
Jun 18, 2024
Merged
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
2 changes: 1 addition & 1 deletion Capture/capturelib/include/reprostim/CaptureApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace reprostim {

std::string createOutPath(const std::optional<Timestamp> &ts = std::nullopt, bool fCreateDir = true);
SessionLogger_ptr createSessionLogger(const std::string& name, const std::string& filePath);
void listDevices();
void listDevices(const std::string& devices);
virtual bool loadConfig(AppConfig& cfg, const std::string& pathConfig);
virtual void onCaptureStart();
virtual void onCaptureStop(const std::string& message);
Expand Down
2 changes: 2 additions & 0 deletions Capture/capturelib/include/reprostim/CaptureLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ namespace reprostim {

void listAudioDevices();

void listVideoDevices();

std::string mwcSdkVersion();

AudioVolume parseAudioVolume(const std::string text);
Expand Down
24 changes: 17 additions & 7 deletions Capture/capturelib/src/CaptureApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,25 @@ namespace reprostim {
return nullptr;
}

void CaptureApp::listDevices() {
void CaptureApp::listDevices(const std::string& devices) {
printVersion();
_INFO(" ");
_INFO("[List of available Video devices]:");
_INFO(" N/A in this version.");
_INFO(" ");
if( audioEnabled ) {
if( !(devices == "all" || devices == "audio" || devices == "video") ) {
_ERROR("Invalid device type: " << devices << ", must be 'all', 'audio' or 'video'");
return;
}
if( devices=="all" || devices=="video" ) {
_INFO(" ");
_INFO("[List of available Video devices]:");
listVideoDevices();
}
if( devices=="all" || devices=="audio" ) {
_INFO(" ");
_INFO("[List of available Audio devices]:");
listAudioDevices();
if (audioEnabled) {
listAudioDevices();
} else {
_INFO("Audio capture is disabled in " << appName);
}
}
}

Expand Down
59 changes: 59 additions & 0 deletions Capture/capturelib/src/CaptureLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,65 @@ namespace reprostim {
} while (snd_card_next(&card) >= 0 && card >= 0);
}

void listVideoDevices() {
_VERBOSE("listVideoDevices()")
const int MAX_CAPTURE = 16;
MW_RESULT mr = MW_SUCCEEDED;

BOOL fInit = MWCaptureInitInstance();
if( !fInit )
_ERROR("Failed MWCaptureInitInstance");

for(int k = 0; k<1; k++) {
SLEEP_MS(1);
mr = MWRefreshDevice();
if (mr != MW_SUCCEEDED)
_ERROR("Failed MWRefreshDevice: " << mr);

int n = MWGetChannelCount();
MWCAP_CHANNEL_INFO mci;
MWCAP_VIDEO_SIGNAL_STATUS vss;

for (int i = 0; i < n; i++) {
mr = MWGetChannelInfoByIndex(i, &mci);
if (mr != MW_SUCCEEDED) {
_ERROR("Failed MWGetChannelInfoByIndex[" << std::to_string(i) << "]: " << mr);
continue;
}
_INFO("Channel [" << std::to_string(i) << "]: " << mci);

char wPath[256] = {0};
if (MWGetDevicePath(i, wPath) == MW_SUCCEEDED) {
_INFO(" Device instance path: " << wPath);
} else {
_ERROR("Failed MWGetDevicePath[" << std::to_string(i) << "]");
continue;
}

HCHANNEL hChannel = MWOpenChannelByPath(wPath);
if (hChannel == NULL) {
_ERROR("Failed MWOpenChannelByPath[" << std::to_string(i) << "]");
continue;
}

MWGetChannelInfo(hChannel, &mci);
_INFO("Channel [" << std::to_string(i) << "]: " << mci);

MWGetVideoSignalStatus(hChannel, &vss);
_INFO(" Video Signal Status: " << vss);

safeMWCloseChannel(hChannel);

if (i >= MAX_CAPTURE) {
_ERROR("Max capture limit reached: " << std::to_string(MAX_CAPTURE));
break;
}
}
}

MWCaptureExitInstance();
}

std::string mwcSdkVersion() {
BYTE bMajor = 0;
BYTE bMinor = 0;
Expand Down
Binary file added Capture/nosignal/data/nosignal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Capture/nosignal/docs/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>> Poetry (version 1.8.2)

# set in project venv in poetry
./venv/bin/poetry config virtualenvs.create false
./venv/bin/poetry config virtualenvs.create true
./venv/bin/poetry config virtualenvs.in-project true

# install poetry and run test
Expand Down
78 changes: 78 additions & 0 deletions Capture/nosignal/nosignal-batch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
# chmod +x ns_05.sh

# Define external variables
#NOSIGNAL_ARGS="--number-of-checks 5 --truncated check5"
NOSIGNAL_ARGS="--number-of-checks 100 --truncated fixup --invalid-timing fixup --threshold 0.5"

print_help() {
echo "Usage: $0 <DIRECTORY>"
echo
echo "Arguments:"
echo " <DIRECTORY> The directory containing the .mkv files to process."
echo
echo "Example:"
echo " $0 /data/repronim/reprostim-reproiner/Videos/2024/05"
}

# Check if the DIRECTORY parameter is provided
if [ -z "$1" ]; then
print_help
exit 1
fi


# log all to file
LOG_TIMESTAMP=$(date '+%Y%m%d_%H%M%S')
LOG_FILE="ns_$LOG_TIMESTAMP.log"
# Redirect stdout and stderr to the log file
exec > >(tee -a "$LOG_FILE") 2>&1


#DIRECTORY="/data/repronim/reprostim-reproiner/Videos/2024/05"
DIRECTORY="$1"

TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$TIMESTAMP] Processing nosignal batch:"
echo " - DIRECTORY : $DIRECTORY"
echo " - NOSIGNAL_ARGS : $NOSIGNAL_ARGS"
echo " "

FILES=("$DIRECTORY"/*.mkv)
TOTAL_FILES=${#FILES[@]}


COUNTER=1
NOSIGNAL_COUNTER=0
NOSIGNAL_FILES=()
for FILE in "${FILES[@]}"
do
echo " "
echo "----------------------------------------------"
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$TIMESTAMP] Processing ($COUNTER of $TOTAL_FILES) $FILE ..."
./reprostim/nosignal $NOSIGNAL_ARGS "$FILE"
EXIT_CODE=$?
echo "EXIT_CODE=$EXIT_CODE"
if [ $EXIT_CODE -eq 1 ]; then
echo "[$TIMESTAMP] NOSIGNAL_FILE: $FILE"
((NOSIGNAL_COUNTER++))
NOSIGNAL_FILES+=("$FILE")
fi
((COUNTER++))
done

echo " "
echo "----------------------------------------------"
echo "DIRECTORY : $DIRECTORY"
echo "NOSIGNAL_ARGS : $NOSIGNAL_ARGS"
echo " "
echo "TOTAL_FILES : $TOTAL_FILES"
echo "NOSIGNAL_COUNT : $NOSIGNAL_COUNTER"
for NOSIGNAL_FILE in "${NOSIGNAL_FILES[@]}"
do
echo "$NOSIGNAL_FILE"
done
echo " "


Loading
Loading