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

added Camera feature #8

Open
wants to merge 2 commits into
base: QStreamer_feature
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions application/sources/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ void MainWindow::makeDeviceConnections(DeviceWidget* device) {
connect(device, &DeviceWidget::sendStartAudioSession, &streaming_session_manager, &SessionManager::onStartAudioSession);
connect(device, &DeviceWidget::sendStopAudioSession, &streaming_session_manager, &SessionManager::onKillAudioSession);

// connect(devoce, &DeviceWidget::sendChangeBitrait, &streaming_session_manager, &SessionManager::);
// connect(devoce, &DeviceWidget::sendChangeVolume, &streaming_session_manager, &SessionManager::);
// connect(devoce, &DeviceWidget::sendSetCameraCaptureMode, &streaming_session_manager, &SessionManager::);
// connect(devoce, &DeviceWidget::sendSetScreenCaptureMode, &streaming_session_manager, &SessionManager::);
// connect(devoce, &DeviceWidget::sendToggleRecording, &streaming_session_manager, &SessionManager::);
connect(device, &DeviceWidget::sendChangeBitrait, &streaming_session_manager, &SessionManager::onSetBitrate);
connect(device, &DeviceWidget::sendChangeVolume, &streaming_session_manager, &SessionManager::onSetVolume);
connect(device, &DeviceWidget::sendSetCameraCaptureMode, &streaming_session_manager, &SessionManager::setCameraCaptureMode);
connect(device, &DeviceWidget::sendSetScreenCaptureMode, &streaming_session_manager, &SessionManager::setScreenCaptureMode);
//connect(devoce, &DeviceWidget::sendToggleRecording, &streaming_session_manager, &SessionManager::);
}

void MainWindow::onSettingsButtonPressed() {
Expand Down
4 changes: 2 additions & 2 deletions general_use/include/variables.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <QDir>

#define PROJECT_PATH "/home/anton/Documents/GitHubSide/2023_1_RelayTeam"
#define PROJECT_PATH "/home/andr/project/2023_1_RelayTeam"

#define RESOURCES_PATH "/home/anton/Documents/GitHubSide/2023_1_RelayTeam/resources"
#define RESOURCES_PATH "/home/andr/project/2023_1_RelayTeam/resources"

const QDir Q_RESOURCE_DIR(RESOURCES_PATH);
46 changes: 28 additions & 18 deletions gstreamer_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
project(gstreamer_interface VERSION 0.1 LANGUAGES CXX)

find_package(Qt${QT_VERSION} REQUIRED COMPONENTS
Core
Network
MultimediaWidgets
Multimedia
Widgets
Core
Network

)


file(GLOB SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/sources/*.cpp
${CMAKE_CURRENT_LIST_DIR}/include/*.h
Expand All @@ -15,9 +20,14 @@ add_library(${PROJECT_NAME} SHARED
)

target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION}::MultimediaWidgets

Qt${QT_VERSION}::Multimedia
Qt${QT_VERSION}::Widgets
Qt${QT_VERSION}::Core
Qt${QT_VERSION}::Network
general_use
gstvideo-1.0
)

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down Expand Up @@ -60,37 +70,37 @@ else()
pkg_check_modules(GST REQUIRED gstreamer-1.0)

target_link_libraries(${PROJECT_NAME} PRIVATE
${GST_LIBRARIES}
${GST_LIBRARIES}
)

message("====${GST_INCLUDE_DIRS}")

target_include_directories(${PROJECT_NAME} PUBLIC
${GST_INCLUDE_DIRS}
${GST_INCLUDE_DIRS}
)
endif()



if(BUILD_TESTS)
file(GLOB TEST_FILES
${CMAKE_CURRENT_LIST_DIR}/tests/*.cpp
)
file(GLOB TEST_FILES
${CMAKE_CURRENT_LIST_DIR}/tests/*.cpp
)

find_package(GTest REQUIRED)
add_executable(gstreamer_interface_tests
${TEST_FILES}
)
add_executable(gstreamer_interface_tests
${TEST_FILES}
)

target_link_libraries(gstreamer_interface_tests
GTest::Main
${PROJECT_NAME}
Qt${QT_VERSION}::Core
Qt${QT_VERSION}::Network
general_use
${GSTREAMER_LIBRARIES}
)
GTest::Main
${PROJECT_NAME}
Qt${QT_VERSION}::Core
Qt${QT_VERSION}::Network
general_use
${GSTREAMER_LIBRARIES}
)

enable_testing()
add_test(NAME unit_tests COMMAND tests)
add_test(NAME unit_tests COMMAND tests)
endif()
27 changes: 18 additions & 9 deletions gstreamer_interface/include/Reciver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@

#include <QString>
#include <QThread>
#include <QTimer>
#include <QWidget>

#include "Session.h"

class Reciver : public Session {
private:
Q_OBJECT

QWidget* windowCamera;
QWidget* window;
QWidget* full;
GstElement* volume;

void addLinkVideo();

void addLinkAudio();
Expand All @@ -22,29 +29,31 @@ class Reciver : public Session {

void startReceive();

protected:
bool eventFilter(QObject* obj, QEvent* event) override;

public:
explicit Reciver(const qint16 video_port, const qint16 audio_port);
explicit Reciver(const qint16 audio_port);
explicit Reciver(const QHostAddress& ip_address_, const qint16 video_port, const qint16 audio_port);
explicit Reciver(const QHostAddress& ip_address_, const qint16 audio_port);

~Reciver();

public slots:
void onStartCameraRecording(WId id, QWidget* window1) override;

void onEnableVideo() override;
void onGetCameraWidget(QWidget* camera);

void onEnableAudio() override;
void onEbableCamera() override;

void onDisableVideo() override;
void onEnableVideo() override;

void onDisableAudio() override;
void onEnableAudio() override;

void onStartSession() override;

void onKillSession() override;

void onSetVolume(const float volume) override;

void onSetBitrate(const int bitrate) override;
void onSetVolume(const float volume);

signals:
void mainWindowClosed();
Expand Down
40 changes: 27 additions & 13 deletions gstreamer_interface/include/Session.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
#pragma once

#include <gst/gst.h>
#include <gst/video/videooverlay.h>

#include <QApplication>
#include <QMainWindow>
#include <QString>
#include <QThread>
#include <QtNetwork/QAbstractSocket>
#include <QtNetwork/QHostAddress>
#include <QtWidgets/QMainWindow>
#include <string>

#include <QtMultimedia/QCameraDevice>
#include <QtMultimedia/QMediaDevices>
#include <QtMultimedia/QCamera>
#include <QtMultimedia/QImageCapture>
#include <QtMultimedia/QMediaRecorder>

#include <QtMultimedia/QMediaCaptureSession>

#include <QtMultimedia/QMediaPlayer>
#include <QLabel>
#include <QWidget>




class Session : public QObject {
private:
Q_OBJECT
Expand All @@ -27,37 +45,31 @@ class Session : public QObject {
Session(const QHostAddress& ip_address_, const qint32 video_port_, const qint32 audio_port_);
Session(const QHostAddress& ip_address_, const qint32 audio_port_);
Session(const qint32 video_port_, const qint32 audio_port_);
Session(const qint32 audio_port_);
~Session();
Session(const qint32 audio_port_);

CustomData data;
CustomData customData;
QHostAddress ip_address;
qint32 video_port;
qint32 audio_port;
GstElement* volume;
GstElement* vp8enc;

public:
const static char* representIP(const QHostAddress& ext_ip_address);

~Session();

public slots:
virtual void onStartCameraRecording(WId id, QWidget* window1) = 0;

virtual void onEbableCamera() = 0;

virtual void onEnableVideo() = 0;

virtual void onEnableAudio() = 0;

virtual void onDisableVideo() = 0;

virtual void onDisableAudio() = 0;

virtual void onStartSession() = 0;

virtual void onKillSession() = 0;

virtual void onSetVolume(const float volume) = 0;

virtual void onSetBitrate(const int bitrate) = 0;

signals:
void EnableVideo();

Expand All @@ -68,4 +80,6 @@ public slots:
void DisableAudio();

void sendSessionKilled();

void closeWindow(const QHostAddress& ip_address_, QString pipelineName);
};
53 changes: 47 additions & 6 deletions gstreamer_interface/include/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,47 @@
#include <QtNetwork/QHostAddress>
#include <cstring>

#include <QtMultimedia/QCameraDevice>
#include <QtMultimedia/QMediaDevices>
#include <QtMultimedia/QCamera>
#include <QtMultimedia/QImageCapture>
#include <QtMultimedia/QMediaRecorder>

#include <QtMultimedia/QMediaCaptureSession>

#include <QtMultimedia/QMediaPlayer>

#include <QWidget>


class SessionManager : public QObject {
private:
Q_OBJECT
QHash<QPair<QHostAddress, QString>, std::shared_ptr<Session>> live_sessions; // map<session_id, session>
// void handleException(GstreamerError error); // Provides flowless application work after gstreamer errors.
QHash<QPair<QHostAddress, QString>, Session*> live_sessions;
QMediaCaptureSession *captureSession;
QWidget* window1;
QCamera* camera;



void startThread(Session* session, const QString session_type);

void killSessionIp4(const QHostAddress ip_address, const QString key);

void killSessionIp6(const QHostAddress ip_address, const QString key);

public:
SessionManager();

~SessionManager();

public slots:
WId onStartCameraRecording();

void onStartVideoSession(const QHostAddress ip_address);

void onStartCameraSession(const QHostAddress ip_address);

void onStartAudioSession(const QHostAddress ip_address);

void onKillVideoSession(const QHostAddress ip_address);
Expand All @@ -32,19 +57,31 @@ public slots:

void onStartReceivingSession(const QHostAddress ip_address, const QString session_type);

void onKillVideoReciver(const QHostAddress ip_address);

void onKillAudioReciver(const QHostAddress ip_address);
void onKillCameraSession(const QHostAddress ip_address);

void onReceivedPorts(const QHostAddress ip_address, qint32 video_port, qint32 audio_port);

void onReceivedCameraPorts(const QHostAddress ip_address, qint32 video_port);

void onCloseWindow(const QHostAddress& ip_address_, const QString session_type);

void onSetVolume(const QHostAddress ip_address, const int volume);

void onSetBitrate(const QHostAddress ip_address, const int bitrate);

void setCameraCaptureMode(const QHostAddress ip_address);

void setScreenCaptureMode(const QHostAddress ip_address);

signals:
void sendErrorOccured(const QString error_string);

void sendCameraSession(const QHostAddress ip_address, const qint32 video_port);

void senStartCameraSession(const QHostAddress ip_address,const qint32 video_port);

void sendSetCameraPort(const QHostAddress ip_address, const qint32 video_port);

void setVolume(const int volume);

void setBitrate(const int bitrate);
Expand All @@ -59,7 +96,11 @@ public slots:

void sendKillAll();

void setPorts(const QHostAddress ip_address, const qint32 session_type);

void sendStartReciver(const QHostAddress local_ip6, const QString session_type);

void sendSetPorts(const QHostAddress ip_address, qint32 video_port, qint32 audio_port);
void sendSetPorts(const QHostAddress ip_address, const qint32 video_port, const qint32 audio_port);

void sendCameraRecording(WId id);
};
Loading