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

Client watcher #2

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0c2b8a4
primary layout
ygimm Oct 18, 2022
6fd178e
Added unit test support.
ivan12093 Oct 18, 2022
fbf17ba
Added coverage scripts and test env.
ivan12093 Oct 20, 2022
988a8cc
deleted submodule.
ivan12093 Oct 20, 2022
d1d3e69
added submodule.
ivan12093 Oct 20, 2022
b630793
add ci and linters
ilyaaid Oct 22, 2022
73ee087
ci correction
ilyaaid Oct 22, 2022
9ef17ff
ci correction 2
ilyaaid Oct 22, 2022
d4b9ad0
allowed execution sh
ilyaaid Oct 22, 2022
709857a
ci correction 3
ilyaaid Oct 22, 2022
d58e2a5
fix makefile
ilyaaid Oct 22, 2022
a5b3294
add gtest to dockerfile
ilyaaid Oct 25, 2022
1ec1974
change container in ci
ilyaaid Oct 25, 2022
534de82
add .dockerignore
ilyaaid Oct 25, 2022
e98944f
update dockerfile
ilyaaid Oct 25, 2022
6bb67c2
Removed submodule and add coverage workflow.
ivan12093 Oct 28, 2022
c92b28a
Resolved issue in workflow.
ivan12093 Oct 28, 2022
b6a7f25
Resolved issue in workflow.
ivan12093 Oct 28, 2022
22aa92e
auto commit coverage report
github-actions[bot] Oct 28, 2022
7639397
added artifact.
ivan12093 Oct 28, 2022
f0c5fde
Merge branch 'dz1_ci' of github.com:cpp-park-vk-education/2022_2_cash…
ivan12093 Oct 28, 2022
a471659
fixed workflow.
ivan12093 Oct 28, 2022
b437f34
fixed workflow.
ivan12093 Oct 28, 2022
80fabee
add lcov to project image
ilyaaid Oct 28, 2022
f7b2387
Added uml for client watcher.
ivan12093 Nov 21, 2022
5f75bc6
Каркас кода и кое-какие тесты
ivan12093 Nov 21, 2022
943549d
Merge branch
ivan12093 Nov 21, 2022
dbd1221
Каркас кода и кое-какие тесты.
ivan12093 Nov 21, 2022
71af158
YoutubeWatcher Done.
ivan12093 Dec 11, 2022
9156c08
Added tests and fixed some bugs for videowather.
ivan12093 Dec 12, 2022
f60bc9a
Fixed small bugs
ivan12093 Dec 12, 2022
8ec3d50
Fixed remarks.
ivan12093 Dec 19, 2022
a3e9bc1
Added signal for ready to watch.
ivan12093 Dec 21, 2022
5f32715
Remove unneseccary bool from signal.
ivan12093 Dec 21, 2022
d0418cc
Fixed bug with client.
ivan12093 Dec 21, 2022
4f6ab9e
added rutube.
ivan12093 Dec 25, 2022
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake-build-debug/
cmake-build-wsl/
.idea/
build/
Dockerfile
.git
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on: push

jobs:
check:
runs-on: ubuntu-latest
container: ilyaaid/watch_up
steps:
- uses: actions/checkout@v3
- run: make check

build:
runs-on: ubuntu-latest
container: ilyaaid/watch_up
steps:
- uses: actions/checkout@v3
- run: make build

test:
runs-on: ubuntu-latest
container: ilyaaid/watch_up
steps:
- uses: actions/checkout@v3
- run: make test

coverage:
runs-on: ubuntu-latest
container: ilyaaid/watch_up
steps:
- uses: actions/checkout@v3
- run: git config --global --add safe.directory /__w/2022_2_cash_map/2022_2_cash_map
- run: git submodule update --init
- run: make coverage
- run: gcovr -r . -s | sed '/tests/d' | sed '/server/d' > client/README.txt
- run: gcovr -r . -s | sed '/tests/d' | sed '/client/d' > server/README.txt
- run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git config --global user.name "github-actions[bot]"
- run: git add client/README.txt server/README.txt
- run: git commit -m "auto commit coverage report" && git push || echo "coverage not changed."
- uses: actions/upload-artifact@v3
with:
name: coverage-report
path: build/lcov/html
retention-days: 5
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake-build-debug/
cmake-build-docker/
cmake-build-wsl/
cmake-build-mingw/
.idea/
build/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "externals/CMake-codecov"]
path = externals/CMake-codecov
url = https://github.com/ivan12093/CMake-codecov.git
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.18)

include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.314.tar.gz"
SHA1 "95c47c92f68edb091b5d6d18924baabe02a6962a"
)

project(watch_up_project)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_TESTS "Build tests" ON)
option(BUILD_DOCS "Build documentation" OFF)
option(BUILD_COVERAGE "Build code coverage" OFF)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Werror -Wall -Wextra")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")

find_package(GTest CONFIG)
if (NOT GTest_FOUND)
hunter_add_package(GTest)
endif()
find_package(GTest CONFIG REQUIRED)

if (BUILD_TESTS)
include(GoogleTest)
enable_testing()
endif()

if (BUILD_COVERAGE)
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/CMake-codecov/cmake")
find_package(codecov)
string(APPEND CMAKE_CXX_FLAGS " --coverage")
endif()

add_subdirectory(server)
add_subdirectory(client)

if (BUILD_COVERAGE)
coverage_evaluate()
endif()
8 changes: 8 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
headers=h,hpp
linelength=110
filter=-whitespace/tab
filter=-runtime/int
filter=-legal/copyright
filter=-build/include_subdir
filter=-build/include
filter=-readability/casting
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu
ENV DEBIAN_FRONTEND noninteractive
WORKDIR cash_map
COPY . .
RUN apt -y update && \
apt -y install python3 cppcheck clang-tidy make git lcov \
gcovr python3-pip libgtest-dev build-essential gcc g++ gdb clang cmake && \
pip3 install cpplint && \
pip3 install --upgrade cmake && \
apt clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.PHONY: all build rebuild check test testextra memtest memtestextra clean coverage

all: clean check build test coverage

clean:
rm -rf build

check:
cd scripts && chmod +x run_linters.sh && ./run_linters.sh

build:
cd scripts && chmod +x build.sh && ./build.sh

test: build
cd scripts && chmod +x run_tests.sh && ./run_tests.sh

coverage:
cd scripts && chmod +x coverage.sh && ./coverage.sh
33 changes: 33 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
project(client)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

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

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS WebSockets Core Gui WebEngineWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS WebSockets Core Gui WebEngineWidgets)

file(GLOB SOURCES "src/*.cpp")

list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/client.cpp")

add_library(${PROJECT_NAME}_lib STATIC ${SOURCES})
target_include_directories(${PROJECT_NAME}_lib PUBLIC include)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Qt${QT_VERSION_MAJOR}::WebSockets
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::WebEngineWidgets)

add_executable(${PROJECT_NAME} ./src/client.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::WebSockets
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::WebEngineWidgets)

if (BUILD_TESTS)
add_subdirectory(tests)
endif()

if (BUILD_COVERAGE)
add_coverage(${PROJECT_NAME})
add_coverage(${PROJECT_NAME}_lib)
endif()
13 changes: 13 additions & 0 deletions client/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
client/src/client.cpp 5 0 0% 5-9
client/src/lib.cpp 2 2 100%
------------------------------------------------------------------------------
TOTAL 21 12 57%
------------------------------------------------------------------------------
lines: 57.1% (12 out of 21)
branches: 23.8% (10 out of 42)
97 changes: 97 additions & 0 deletions client/include/videowatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef VIDEOWATCHER_H
#define VIDEOWATCHER_H

#include <QObject>

#include <QtWebEngineWidgets>
#include <iostream>

struct PlayerState {
bool playing = false;
QString content_url = "";
double speed = 1.0;
double timestamp = 0;

PlayerState() = default;
};

class IVideoWatcher : public QObject {
Q_OBJECT
public:
virtual void togglePlay() = 0;
virtual void setCurrentTime(double time) = 0;
virtual void setCurrentSpeed(double speed) = 0;
virtual void setContentPath(const QString& path) = 0;

virtual bool isPlaying() const = 0;
virtual double getCurrentTime() const = 0;
virtual double getCurrentSpeed() const = 0;
virtual QString getContentPath() const = 0;

virtual PlayerState getState() const = 0;

signals:
void ReadyToWatch(bool ok);

};

class YoutubeWatcher : public IVideoWatcher {
Q_OBJECT
private:
void handleLoading(int loaded_percent);
public:
YoutubeWatcher() = delete;

explicit YoutubeWatcher(QWebEngineView *_view);
void togglePlay() override;
void setCurrentTime(double time) override;
void setCurrentSpeed(double speed) override;
void setContentPath(const QString& path) override;

bool isPlaying() const override;
double getCurrentTime() const override;
double getCurrentSpeed() const override;
QString getContentPath() const override;

PlayerState getState() const override;

static QString getLinkByVideoId(const QString& id);
static QString getVideoIdByRawLink(const QUrl& url);

private:
QWebEngineView *view = nullptr;
bool urlWasSetted = false;
};

class RutubeWatcher : public IVideoWatcher {
Q_OBJECT
private:
void handleLoading(int loaded_percent);
void removeAdverts();
void initPlayerAfterSetContent();
public:
RutubeWatcher() = delete;

explicit RutubeWatcher(QWebEngineView *_view);
void togglePlay() override;
void setCurrentTime(double time) override;
void setCurrentSpeed(double speed) override;
void setContentPath(const QString& path) override;

bool isPlaying() const override;
double getCurrentTime() const override;
double getCurrentSpeed() const override;
QString getContentPath() const override;

PlayerState getState() const override;

static QString getLinkByVideoId(const QString& id);
static QString getVideoIdByRawLink(const QUrl& url);

private:
QWebEngineView *view = nullptr;
bool urlWasSetted = false;
};


#endif // VIDEOWATCHER_H
4 changes: 4 additions & 0 deletions client/src/client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "videowatcher.h"
int main() {
return 0;
}
Loading