diff --git a/meson.build b/meson.build index ad8d2b7..21270e1 100644 --- a/meson.build +++ b/meson.build @@ -7,6 +7,6 @@ gst_rtsp_dep = dependency('gstreamer-rtsp-1.0') gst_rtsp_server_dep = dependency('gstreamer-rtsp-server-1.0') thread_dep = dependency('threads') -common_deps = ['src/Common/PipelineManager.cpp', 'src/Common/QoSEstimator.cpp', 'src/Common/FileRecorder.cpp'] +common_deps = ['src/Common/PipelineManager.cpp', 'src/Common/QoSEstimator.cpp'] rtsp_src = ['src/RTSPStreamServer/stream_server.cpp', 'src/RTSPStreamServer/IPCMessageHandler.cpp', 'src/RTSPStreamServer/RTSPAdaptiveStreaming.cpp', 'src/RTSPStreamServer/RTSPStreamServer.cpp'] executable('stream_server', sources: [rtsp_src, common_deps], dependencies: [gst_dep, gst_rtp_dep, gst_rtsp_dep, gst_rtsp_server_dep, thread_dep], cpp_args : '-Werror', install : true) diff --git a/src/Common/Common.h b/src/Common/Common.h index 6b32334..7158c13 100644 --- a/src/Common/Common.h +++ b/src/Common/Common.h @@ -6,6 +6,5 @@ #include "QoSEstimator.h" #include "PipelineManager.h" #include "Constants.h" -#include "FileRecorder.h" #endif diff --git a/src/Common/FileRecorder.cpp b/src/Common/FileRecorder.cpp deleted file mode 100644 index 567e3f3..0000000 --- a/src/Common/FileRecorder.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "FileRecorder.h" - -FileRecorder::FileRecorder() -{ - recording = false; - tee_file_pad = nullptr; - queue_pad = nullptr; - tee = nullptr; - pipeline = nullptr; -} - -bool FileRecorder::init_file_recorder(GstElement* _pipeline, GstElement* _tee) -{ - // In case we are already recording to a file, there's no need to reset the recorder - if (recording) { - cerr << "Recording in progress" << endl; - return false; - } - pipeline = _pipeline; - tee = _tee; - if (!pipeline || !tee) { - return false; - } - - file_queue = gst_element_factory_make("queue", NULL); - file_h264_parser = gst_element_factory_make("h264parse", NULL); - mux = gst_element_factory_make("matroskamux", NULL); - file_sink = gst_element_factory_make("filesink", NULL); - - string file_path; - auto t = std::time(nullptr); - auto tm = *std::localtime(&t); - std::stringstream ss; - ss << put_time(&tm, "%d-%m-%Y_%H:%M:%S") << endl; - file_path = ss.str(); - file_path = "Video_" + file_path + ".mkv"; - - g_object_set(G_OBJECT(file_sink), "location", file_path.c_str(), NULL); - gst_bin_add_many(GST_BIN(pipeline), file_queue, file_h264_parser, mux, file_sink, NULL); - gst_element_link_many(file_queue, file_h264_parser, mux, file_sink, NULL); - - gst_element_sync_state_with_parent(file_queue); - gst_element_sync_state_with_parent(file_h264_parser); - gst_element_sync_state_with_parent(mux); - gst_element_sync_state_with_parent(file_sink); - - tee_file_pad = gst_element_get_request_pad(tee, "src_%u"); - queue_pad = gst_element_get_static_pad(file_queue, "sink"); - gst_pad_link(tee_file_pad, queue_pad); - - recording = true; - return true; -} - -bool FileRecorder::disable_recorder() -{ - if (!recording) { - cerr << "Recording not started" << endl; - return false; - } - - recording = false; - - gst_element_set_state(file_queue, GST_STATE_NULL); - gst_element_set_state(file_h264_parser, GST_STATE_NULL); - gst_element_set_state(mux, GST_STATE_NULL); - gst_element_set_state(file_sink, GST_STATE_NULL); - - gst_bin_remove(GST_BIN(pipeline), file_queue); - gst_bin_remove(GST_BIN(pipeline), file_h264_parser); - gst_bin_remove(GST_BIN(pipeline), mux); - gst_bin_remove(GST_BIN(pipeline), file_sink); - - gst_pad_unlink(tee_file_pad, queue_pad); - gst_element_release_request_pad(tee, tee_file_pad); - gst_object_unref(tee_file_pad); - gst_object_unref(queue_pad); - - tee_file_pad = nullptr; - queue_pad = nullptr; - - return true; -} - -bool FileRecorder::get_recording() -{ - return recording; -} diff --git a/src/Common/FileRecorder.h b/src/Common/FileRecorder.h deleted file mode 100644 index c0d42f8..0000000 --- a/src/Common/FileRecorder.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef FILE_RECORDER_H -#define FILE_RECORDER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Manages the recording of the livestreamed video to a file on the CC -using namespace std; - -class FileRecorder -{ -private: - bool recording; -public: - GstElement* file_sink; - GstElement* file_queue; - GstElement* file_h264_parser; - GstElement* mux; - GstElement* pipeline; - GstElement* tee; - GstPad* tee_file_pad; - GstPad* queue_pad; - - FileRecorder(); - bool init_file_recorder(GstElement* _pipeline, GstElement* _tee); - bool disable_recorder(); - bool get_recording(); -}; - -#endif \ No newline at end of file diff --git a/src/Common/PipelineManager.cpp b/src/Common/PipelineManager.cpp index 4aa4cd5..2eea592 100644 --- a/src/Common/PipelineManager.cpp +++ b/src/Common/PipelineManager.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include #include "PipelineManager.h" PipelineManager::PipelineManager(string _device, int quality, CameraType type) : network_state(NetworkState::STEADY), successive_transmissions(0), diff --git a/src/Common/PipelineManager.h b/src/Common/PipelineManager.h index 1184685..774d51f 100644 --- a/src/Common/PipelineManager.h +++ b/src/Common/PipelineManager.h @@ -15,7 +15,6 @@ #include "QoSEstimator.h" #include "DeviceDatatypes.h" #include "Constants.h" -#include "FileRecorder.h" using namespace std; diff --git a/src/RTSPStreamServer/RTSPStreamServer.cpp b/src/RTSPStreamServer/RTSPStreamServer.cpp index 8274705..3cc3a45 100644 --- a/src/RTSPStreamServer/RTSPStreamServer.cpp +++ b/src/RTSPStreamServer/RTSPStreamServer.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include