Skip to content

Commit

Permalink
Have some chapters CRUD
Browse files Browse the repository at this point in the history
Started on movie producing
  • Loading branch information
sergei committed Sep 14, 2023
1 parent 8051ce7 commit 4541091
Show file tree
Hide file tree
Showing 46 changed files with 3,989 additions and 133 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "n2k/canboat"]
path = n2k/canboat
url = [email protected]:sergei/canboat.git
[submodule "cxxopts"]
path = cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "gopro/gpmf-parser"]
path = gopro/gpmf-parser
url = https://github.com/gopro/gpmf-parser.git
106 changes: 103 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,25 @@ project(sailvue)

set(CMAKE_CXX_STANDARD 17)

add_executable(sailvue main.cpp
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Network)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Positioning)
find_package(Qt6 COMPONENTS Location)
find_package(Qt6 REQUIRED COMPONENTS Multimedia)

qt_add_executable(sailvue WIN32 MACOSX_BUNDLE
main.cpp
InstrDataReader.h

n2k/canboat/analyzer/pgn.c
n2k/canboat/analyzer/pgn.h
n2k/canboat/analyzer/lookup.c
Expand All @@ -15,10 +33,92 @@ add_executable(sailvue main.cpp
n2k/canboat/common/utf.c
n2k/YdvrReader.cpp
n2k/YdvrReader.h
n2k/InitCanBoat.c n2k/InitCanBoat.h n2k/geo/Quantity.h n2k/geo/Angle.h n2k/InstrumentInput.h n2k/geo/Quantity.cpp n2k/geo/Direction.h n2k/geo/Speed.h n2k/geo/UtcTime.h
n2k/geo/GeoLoc.h)
n2k/InitCanBoat.c
n2k/InitCanBoat.h
n2k/geo/Quantity.h
n2k/geo/Angle.h
n2k/geo/Quantity.cpp
n2k/geo/Direction.h
n2k/geo/Speed.h
n2k/geo/UtcTime.h
n2k/geo/GeoLoc.h

gopro/GoPro.cpp
gopro/GoPro.h
gopro/gpmf-parser/GPMF_parser.c
gopro/gpmf-parser/demo/GPMF_mp4reader.c

navcomputer/InstrumentInput.h
navcomputer/IProgressListener.h
navcomputer/RaceData.cpp
navcomputer/RaceData.h
navcomputer/Chapter.cpp
navcomputer/Chapter.h

gui/Worker.cpp
gui/Worker.h
gui/Project.cpp
gui/Project.h
movie/MovieProducer.cpp
movie/MovieProducer.h
movie/InstrOverlayMaker.cpp
movie/InstrOverlayMaker.h
ffmpeg/FFMpeg.cpp
ffmpeg/FFMpeg.h
)

target_include_directories(sailvue PUBLIC
n2k/canboat/analyzer
n2k/canboat/common
cxxopts/include
gopro/gpmf-parser
gopro/gpmf-parser/demo
gui
)

target_link_libraries(sailvue PUBLIC
Qt::Core
Qt::Gui
Qt::LocationPrivate
Qt::Positioning
Qt::Qml
Qt::Quick
Qt6::Multimedia
)

# Resources:
set(qml_resource_files
"gui/main.qml"
"gui/RaceEditor.qml"
"gui/ChapterEditor.qml"
"gui/ChapterMapElement.qml"
"gui/InputDataDialog.qml"
)

qt6_add_resources(sailvue "qml"
PREFIX
"/"
FILES
${qml_resource_files}
)

qt_add_resources(sailvue "app_images"
PREFIX "/"
FILES
"images/mapmarker.png"
)

# Suppress policy warning
qt_policy(
SET QTP0001 NEW
)

qt_add_qml_module(sailvue
URI sails
VERSION 1.0
SOURCES gui/RaceTreeModel.h
SOURCES gui/RaceTreeModel.cpp
SOURCES gui/GoProMediaPlayer.h
SOURCES gui/GoProMediaPlayer.cpp
)

19 changes: 19 additions & 0 deletions InstrDataReader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Created by Sergei on 8/16/23.
//

#ifndef SAILVUE_INSTRDATAREADER_H
#define SAILVUE_INSTRDATAREADER_H


#include <ctime>
#include <list>
#include "navcomputer/InstrumentInput.h"

class InstrDataReader {
public:
virtual void read(uint64_t ulStartUtcMs, uint64_t ulEndUtcMs, std::list<InstrumentInput> &listInputs) = 0;
};


#endif //SAILVUE_INSTRDATAREADER_H
1 change: 1 addition & 0 deletions cxxopts
Submodule cxxopts added at c8c932
8 changes: 8 additions & 0 deletions data/pgn-src.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
129029,ZG100 Antenna-100022#, GNSS Position Data
129025,ZG100 Antenna-100022#, Position, Rapid Update
129026,ZG100 Antenna-100022#, COG & SOG, Rapid Update
127250,Precision-9 Compass-120196210, Vessel Heading
128259,H5000 CPU-007060#, Speed
130306,H5000 CPU-007060#, Wind Data
127245,RF25 _Rudder feedback-038249#, Rudder
127257,Precision-9 Compass-120196210, Attitude
54 changes: 54 additions & 0 deletions ffmpeg/FFMpeg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "FFMpeg.h"
#include <iostream>
#include <sstream>
#include <filesystem>

std::string FFMpeg::s_ffmpeg = "/dev/null";
std::string FFMpeg::s_ffprobe = "/dev/null";

bool FFMpeg::setBinDir(const std::string &binDir) {
std::filesystem::path ffmpegPath(binDir);
std::filesystem::path absoluteFfmpegPath = std::filesystem::absolute(binDir);


// Check if the directory exist
if (!std::filesystem::exists(absoluteFfmpegPath)) {
std::cerr << "FFMpeg::setBinDir: " << absoluteFfmpegPath << " does not exist" << std::endl;
return false;
}

// Check if ffmpeg and ffprobe files exist
s_ffmpeg = absoluteFfmpegPath / "ffmpeg";
s_ffprobe = absoluteFfmpegPath / "ffprobe";

if (!std::filesystem::is_regular_file(s_ffmpeg )) {
std::cerr << "FFMpeg::setBinDir: " << s_ffmpeg << " does not exist" << std::endl;
return false;
}

if (!std::filesystem::is_regular_file(s_ffprobe )) {
std::cerr << "FFMpeg::setBinDir: " << s_ffprobe << " does not exist" << std::endl;
return false;
}

return true;
}

std::tuple<int, int> FFMpeg::getVideoResolution(const std::string &mp4name) {
// Build the ffprobe command
std::string cmd = s_ffprobe
+ " -v error -select_streams v:0 -show_entries stream=width,height,fps -of csv=p=0 "
+ "\"" + mp4name + "\"";

// Execute it
CommandResult res = Command::exec(cmd);
if ( res.exitstatus == 0){
std::istringstream iss(res.output);
std::string width;
std::string height;
std::getline(iss, width, ',');
std::getline(iss, height, ',');
return {stoi(width), stoi(height)};
}
return {-1, -1};
}
78 changes: 78 additions & 0 deletions ffmpeg/FFMpeg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#ifndef SAILVUE_FFMPEG_H
#define SAILVUE_FFMPEG_H

#include <string>
#include <array>
#include <ostream>
#include <string>
#include <cstdio>

struct CommandResult {
std::string output;
int exitstatus;
friend std::ostream &operator<<(std::ostream &os, const CommandResult &result) {
os << "command exitstatus: " << result.exitstatus << " output: " << result.output;
return os;
}
bool operator==(const CommandResult &rhs) const {
return output == rhs.output &&
exitstatus == rhs.exitstatus;
}
bool operator!=(const CommandResult &rhs) const {
return !(rhs == *this);
}
};

class Command {
public:
/**
* Execute system command and get STDOUT result.
* Regular system() only gives back exit status, this gives back output as well.
* @param command system command to execute
* @return commandResult containing STDOUT (not stderr) output & exitstatus
* of command. Empty if command failed (or has no output). If you want stderr,
* use shell redirection (2&>1).
*/
static CommandResult exec(const std::string &command) {
int exitcode = 0;
std::array<char, 8192> buffer{};
std::string result;
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#define WEXITSTATUS
#endif
FILE *pipe = popen(command.c_str(), "r");
if (pipe == nullptr) {
throw std::runtime_error("popen() failed!");
}
try {
std::size_t bytesread;
while ((bytesread = std::fread(buffer.data(), sizeof(buffer.at(0)), sizeof(buffer), pipe)) != 0) {
result += std::string(buffer.data(), bytesread);
}
} catch (...) {
pclose(pipe);
throw;
}
// Workaround "error: cannot take the address of an rvalue of type 'int'" on MacOS
// see e.g. https://github.com/BestImageViewer/geeqie/commit/75c7df8b96592e10f7936dc1a28983be4089578c
int res = pclose(pipe);
exitcode = WEXITSTATUS(res);
return CommandResult{result, exitcode};
}

};

class FFMpeg {
public:
static bool setBinDir(const std::string &binDir);
static std::tuple<int , int > getVideoResolution(const std::string &mp4name);

private:
static std::string s_ffmpeg;
static std::string s_ffprobe;
};


#endif //SAILVUE_FFMPEG_H
Binary file added ffmpeg/bin/osx/ffmpeg
Binary file not shown.
Binary file added ffmpeg/bin/osx/ffprobe
Binary file not shown.
Loading

0 comments on commit 4541091

Please sign in to comment.