1
0
Fork 0
mirror of https://github.com/fastogt/fastocloud.git synced 2025-03-09 23:18:50 +00:00

Init FastoCloud on Github

This commit is contained in:
topilski 2023-01-21 05:21:27 +03:00
parent d0d234101d
commit d0d6551903
359 changed files with 32676 additions and 23 deletions

480
src/stream/CMakeLists.txt Normal file
View file

@ -0,0 +1,480 @@
SET(GLOBAL_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/gst_macros.h
${CMAKE_SOURCE_DIR}/src/stream/gst_types.h
${CMAKE_SOURCE_DIR}/src/stream/stypes.h
${CMAKE_SOURCE_DIR}/src/stream/commands_factory.h
${CMAKE_SOURCE_DIR}/src/stream/ilinker.h
${CMAKE_SOURCE_DIR}/src/stream/ibase_builder.h
${CMAKE_SOURCE_DIR}/src/stream/ibase_builder_observer.h
${CMAKE_SOURCE_DIR}/src/stream/ibase_stream.h
${CMAKE_SOURCE_DIR}/src/stream/probes.h
${CMAKE_SOURCE_DIR}/src/stream/timeshift.h
${CMAKE_SOURCE_DIR}/src/stream/stream_controller.h
${CMAKE_SOURCE_DIR}/src/stream/stream_server.h
${CMAKE_SOURCE_DIR}/src/stream/stream_wrapper.h
${CMAKE_SOURCE_DIR}/src/stream/gstreamer_init.h
${CMAKE_SOURCE_DIR}/src/stream/gstreamer_utils.h
${CMAKE_SOURCE_DIR}/src/stream/streams_factory.h
${CMAKE_SOURCE_DIR}/src/stream/configs_factory.h
${CMAKE_SOURCE_DIR}/src/stream/config.h
)
SET(GLOBAL_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/gst_types.cpp
${CMAKE_SOURCE_DIR}/src/stream/stypes.cpp
${CMAKE_SOURCE_DIR}/src/stream/commands_factory.cpp
${CMAKE_SOURCE_DIR}/src/stream/ilinker.cpp
${CMAKE_SOURCE_DIR}/src/stream/ibase_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/ibase_builder_observer.cpp
${CMAKE_SOURCE_DIR}/src/stream/ibase_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/probes.cpp
${CMAKE_SOURCE_DIR}/src/stream/timeshift.cpp
${CMAKE_SOURCE_DIR}/src/stream/stream_controller.cpp
${CMAKE_SOURCE_DIR}/src/stream/stream_server.cpp
${CMAKE_SOURCE_DIR}/src/stream/stream_wrapper.cpp
${CMAKE_SOURCE_DIR}/src/stream/gstreamer_init.cpp
${CMAKE_SOURCE_DIR}/src/stream/gstreamer_utils.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams_factory.cpp
${CMAKE_SOURCE_DIR}/src/stream/configs_factory.cpp
${CMAKE_SOURCE_DIR}/src/stream/config.cpp
)
SET(STREAM_CONFIGS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/relay_config.h
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/encode_config.h
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/audio_video_config.h
)
SET(STREAM_CONFIGS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/relay_config.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/encode_config.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/configs/audio_video_config.cpp
)
SET(STREAM_BUILDERS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/gst_base_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/src_decodebin_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/relay_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/rtsp_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/playlist_relay_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_only_audio_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_only_video_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/playlist_encoding_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/device_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/rtsp_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/fake_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/catchup_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/timeshift_player_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/timeshift_recorder_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/test/test_life_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/test/test_input_stream_builder.h
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/display/display_input_stream_builder.h
)
SET(STREAM_BUILDERS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/gst_base_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/src_decodebin_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/relay_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/rtsp_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/relay/playlist_relay_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_only_audio_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/encoding_only_video_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/playlist_encoding_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/device_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/rtsp_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/encoding/fake_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/catchup_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/timeshift_player_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/timeshift/timeshift_recorder_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/test/test_life_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/test/test_input_stream_builder.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/builders/display/display_input_stream_builder.cpp
)
SET(STREAMS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/streams/src_decodebin_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/vod/vod_relay_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/relay_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/rtsp_relay_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/playlist_relay_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/vod/vod_encoding_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_only_audio_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_only_video_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/playlist_encoding_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/device_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/rtsp_encoding_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/fake_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/catchup_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/timeshift_player_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/itimeshift_recorder_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/timeshift_recorder_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/test/test_life_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/test/test_stream.h
${CMAKE_SOURCE_DIR}/src/stream/streams/display/display_stream.h
${STREAM_BUILDERS_HEADERS}
${STREAM_CONFIGS_HEADERS}
)
SET(STREAMS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/streams/src_decodebin_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/vod/vod_relay_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/relay_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/rtsp_relay_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/relay/playlist_relay_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/vod/vod_encoding_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_only_audio_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/encoding_only_video_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/playlist_encoding_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/device_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/rtsp_encoding_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/encoding/fake_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/catchup_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/timeshift_player_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/itimeshift_recorder_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/timeshift/timeshift_recorder_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/test/test_life_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/test/test_stream.cpp
${CMAKE_SOURCE_DIR}/src/stream/streams/display/display_stream.cpp
${STREAM_BUILDERS_SOURCES}
${STREAM_CONFIGS_SOURCES}
)
SET(ELEMENTS_SOURCES_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/element.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/multifilesrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/httpsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/dvbsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/appsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/rtmpsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/rtspsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/udpsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/tcpsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/srtsrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/v4l2src.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/alsasrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/filesrc.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/build_input.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/sources.h
)
SET(ELEMENTS_SOURCES_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/element.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/multifilesrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/httpsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/dvbsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/appsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/rtmpsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/rtspsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/udpsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/tcpsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/srtsrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/v4l2src.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/alsasrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/filesrc.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/build_input.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sources/sources.cpp
)
SET(ELEMENTS_SINKS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/rtmp.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/udp.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/file.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/tcp.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/srt.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/http.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/fake.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/test.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/screen.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/build_output.h
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/sink.h
)
SET(ELEMENTS_SINKS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/rtmp.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/udp.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/file.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/tcp.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/srt.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/http.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/fake.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/test.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/screen.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/build_output.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/sink/sink.cpp
)
SET(ELEMENTS_ENCODERS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/encoders/audio.h
${CMAKE_SOURCE_DIR}/src/stream/elements/encoders/video.h
)
SET(ELEMENTS_ENCODERS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/encoders/audio.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/encoders/video.cpp
)
SET(ELEMENTS_PARSER_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/video.h
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/audio.h
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/parser.h
)
SET(ELEMENTS_PARSER_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/video.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/audio.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/parser/parser.cpp
)
SET(ELEMENTS_PAY_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/pay.h
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/video.h
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/audio.h
)
SET(ELEMENTS_PAY_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/pay.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/video.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/pay/audio.cpp
)
SET(ELEMENTS_DEPAY_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/depay.h
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/video.h
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/audio.h
)
SET(ELEMENTS_DEPAY_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/depay.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/video.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/depay/audio.cpp
)
IF(MACHINE_LEARNING AND FASTOML_FOUND)
SET(ELEMENTS_DEEP_LEARNING_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/video_ml_filter.h
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/tinyyolov2.h
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/tinyyolov3.h
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/detectionoverlay.h
)
SET(ELEMENTS_DEEP_LEARNING_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/video_ml_filter.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/tinyyolov2.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/tinyyolov3.cpp
${CMAKE_SOURCE_DIR}/src/stream/elements/machine_learning/detectionoverlay.cpp
)
ENDIF(MACHINE_LEARNING AND FASTOML_FOUND)
SET(ELEMENTS_VIDEO_HEADERS ${CMAKE_SOURCE_DIR}/src/stream/elements/video/video.h)
SET(ELEMENTS_VIDEO_SOURCES ${CMAKE_SOURCE_DIR}/src/stream/elements/video/video.cpp)
SET(ELEMENTS_AUDIO_HEADERS ${CMAKE_SOURCE_DIR}/src/stream/elements/audio/audio.h)
SET(ELEMENTS_AUDIO_SOURCES ${CMAKE_SOURCE_DIR}/src/stream/elements/audio/audio.cpp)
SET(ELEMENTS_MUXER_HEADERS ${CMAKE_SOURCE_DIR}/src/stream/elements/muxer/muxer.h)
SET(ELEMENTS_MUXER_SOURCES ${CMAKE_SOURCE_DIR}/src/stream/elements/muxer/muxer.cpp)
SET(ELEMENTS_HEADERS
${ELEMENTS_DEEP_LEARNING_HEADERS}
${ELEMENTS_MUXER_HEADERS}
${ELEMENTS_PAY_HEADERS}
${ELEMENTS_DEPAY_HEADERS}
${ELEMENTS_PARSER_HEADERS}
${ELEMENTS_ENCODERS_HEADERS}
${ELEMENTS_SINKS_HEADERS}
${ELEMENTS_SOURCES_HEADERS}
${ELEMENTS_VIDEO_HEADERS}
${ELEMENTS_AUDIO_HEADERS}
)
SET(ELEMENTS_SOURCES
${ELEMENTS_DEEP_LEARNING_SOURCES}
${ELEMENTS_MUXER_SOURCES}
${ELEMENTS_PAY_SOURCES}
${ELEMENTS_DEPAY_SOURCES}
${ELEMENTS_PARSER_SOURCES}
${ELEMENTS_ENCODERS_SOURCES}
${ELEMENTS_SINKS_SOURCES}
${ELEMENTS_SOURCES_SOURCES}
${ELEMENTS_VIDEO_SOURCES}
${ELEMENTS_AUDIO_SOURCES}
)
SET(PAD_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/pad/pad.h
)
SET(PAD_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/pad/pad.cpp
)
SET(DUMPERS_HEADERS
${CMAKE_SOURCE_DIR}/src/stream/dumpers/idumper.h
${CMAKE_SOURCE_DIR}/src/stream/dumpers/htmldump.h
${CMAKE_SOURCE_DIR}/src/stream/dumpers/dumpers_factory.h
)
SET(DUMPERS_SOURCES
${CMAKE_SOURCE_DIR}/src/stream/dumpers/htmldump.cpp
${CMAKE_SOURCE_DIR}/src/stream/dumpers/dumpers_factory.cpp
${CMAKE_SOURCE_DIR}/src/stream/dumpers/idumper.cpp
)
FIND_PACKAGE(GLIB REQUIRED gobject)
FIND_PACKAGE(Gstreamer 1.8.0 REQUIRED)
FIND_PACKAGE(Cairo REQUIRED)
IF(OS_WINDOWS)
SET(PLATFORM_HEADER)
SET(PLATFORM_SOURCES)
SET(PLATFORM_LIBRARIES ws2_32)
ELSEIF(OS_MACOSX)
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation)
SET(PLATFORM_HEADER)
SET(PLATFORM_SOURCES)
SET(PLATFORM_LIBRARIES ${FOUNDATION_LIBRARY})
ELSEIF(OS_POSIX)
SET(PLATFORM_HEADER)
SET(PLATFORM_SOURCES)
SET(PLATFORM_LIBRARIES)
FIND_PACKAGE(X11 REQUIRED)
IF(X11_FOUND)
SET(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${X11_LIBRARIES})
SET(DEPENDENS_INCLUDE_DIRS ${DEPENDENS_INCLUDE_DIRS} ${X11_INCLUDE_DIR})
SET(PRIVATE_COMPILE_DEFINITIONS_CORE ${PRIVATE_COMPILE_DEFINITIONS_CORE} HAVE_X11)
ENDIF(X11_FOUND)
ENDIF(OS_WINDOWS)
IF(USE_PTHREAD)
IF(NOT OS_ANDROID)
SET(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} pthread)
ENDIF(NOT OS_ANDROID)
ENDIF(USE_PTHREAD)
SET(CLIENT_SOURCES
${GLOBAL_HEADERS} ${GLOBAL_SOURCES}
${STREAMS_HEADERS} ${STREAMS_SOURCES}
${ELEMENTS_HEADERS} ${ELEMENTS_SOURCES}
${PAD_HEADERS} ${PAD_SOURCES}
${PLATFORM_HEADER} ${PLATFORM_SOURCES}
${DUMPERS_HEADERS} ${DUMPERS_SOURCES}
)
SET(CLIENT_LIBRARIES
${CLIENT_LIBRARIES}
${GLIB_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES}
${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARY} ${GSTREAMER_VIDEO_LIBRARY}
${CAIRO_LIBRARIES}
${FASTOML_LIBRARIES}
${COMMON_LIBRARIES}
${STREAMER_COMMON}
${PLATFORM_LIBRARIES}
)
SET(PRIVATE_COMPILE_DEFINITIONS_CORE
${PRIVATE_COMPILE_DEFINITIONS_CORE}
)
SET(PRIVATE_INCLUDE_DIRECTORIES_CORE
${PRIVATE_INCLUDE_DIRECTORIES_CORE}
${CMAKE_SOURCE_DIR}/src
${GSTREAMER_INCLUDE_DIR}
${GLIB_INCLUDE_DIR}
${GLIBCONFIG_INCLUDE_DIR}
${CAIRO_INCLUDE_DIRS}
${DEPENDENS_INCLUDE_DIRS}
# ${JSONC_INCLUDE_DIRS}
${COMMON_INCLUDE_DIRS}
)
ADD_LIBRARY(${STREAMER_CORE} SHARED ${CLIENT_SOURCES})
TARGET_INCLUDE_DIRECTORIES(${STREAMER_CORE} PRIVATE ${PRIVATE_INCLUDE_DIRECTORIES_CORE})
TARGET_COMPILE_DEFINITIONS(${STREAMER_CORE} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS_CORE})
TARGET_LINK_LIBRARIES(${STREAMER_CORE} ${CLIENT_LIBRARIES})
IF(PROJECT_BUILD_TYPE_VERSION STREQUAL "release")
STRIP_TARGET(${STREAMER_CORE})
ENDIF(PROJECT_BUILD_TYPE_VERSION STREQUAL "release")
INSTALL(TARGETS ${STREAMER_CORE} DESTINATION ${LIB_INSTALL_DESTINATION} COMPONENT APPLICATIONS)
IF (DEVELOPER_CHECK_STYLE)
SET(CHECK_SOURCES ${CLIENT_SOURCES})
REGISTER_CHECK_STYLE_TARGET(check_style_${STREAMER_CORE} "${CHECK_SOURCES}")
REGISTER_CHECK_INCLUDES_TARGET(${STREAMER_CORE})
ENDIF(DEVELOPER_CHECK_STYLE)
IF(DEVELOPER_ENABLE_TESTS)
FIND_PACKAGE(GTest REQUIRED)
## Unit tests
SET(PRIVATE_INCLUDE_DIRECTORIES_UNIT_TESTS
${PRIVATE_INCLUDE_DIRECTORIES_UNIT_TESTS}
${CMAKE_SOURCE_DIR}/src
${GSTREAMER_INCLUDE_DIR}
${GLIB_INCLUDE_DIR}
${GLIBCONFIG_INCLUDE_DIR}
)
SET(UNIT_TESTS_LIBS
${GTEST_BOTH_LIBRARIES}
${STREAMER_COMMON}
${PLATFORM_LIBRARIES} ${STREAMER_CORE})
SET(UNIT_TESTS unit_tests_stream)
ADD_EXECUTABLE(${UNIT_TESTS}
${CMAKE_SOURCE_DIR}/tests/stream/unit_test_link_gen.cpp
${CMAKE_SOURCE_DIR}/tests/stream/unit_test_types.cpp
${CMAKE_SOURCE_DIR}/tests/stream/unit_test_api.cpp
)
TARGET_INCLUDE_DIRECTORIES(${UNIT_TESTS} PRIVATE ${PRIVATE_INCLUDE_DIRECTORIES_UNIT_TESTS} ${JSONC_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(${UNIT_TESTS} ${UNIT_TESTS_LIBS})
ADD_TEST_TARGET(${UNIT_TESTS})
SET_PROPERTY(TARGET ${UNIT_TESTS} PROPERTY FOLDER "Unit tests")
## Mock tests
SET(PRIVATE_INCLUDE_DIRECTORIES_MOCK_TESTS
${PRIVATE_INCLUDE_DIRECTORIES_MOCK_TESTS}
${CMAKE_SOURCE_DIR}/src
${GSTREAMER_INCLUDE_DIR}
${GLIB_INCLUDE_DIR}
${GLIBCONFIG_INCLUDE_DIR}
)
SET(GMOCK_TESTS_LIBS ${GTEST_BOTH_LIBRARIES} gmock ${STREAMER_CORE})
ADD_EXECUTABLE(gmock_tests
${CMAKE_SOURCE_DIR}/tests/stream/mock_test_job.cpp
)
TARGET_INCLUDE_DIRECTORIES(gmock_tests PRIVATE ${PRIVATE_INCLUDE_DIRECTORIES_MOCK_TESTS})
TARGET_LINK_LIBRARIES(gmock_tests ${GMOCK_TESTS_LIBS})
ADD_TEST_TARGET(gmock_tests)
SET_PROPERTY(TARGET gmock_tests PROPERTY FOLDER "Mock tests")
# Workflow tests
SET(PRIVATE_INCLUDE_DIRECTORIES_WORKFLOW_TESTS
${PRIVATE_INCLUDE_DIRECTORIES_WORKFLOW_TESTS}
${CMAKE_SOURCE_DIR}/src
${GSTREAMER_INCLUDE_DIR}
${GLIB_INCLUDE_DIR}
${GLIBCONFIG_INCLUDE_DIR}
)
SET(WORKFLOW_TESTS_LIBS ${STREAMER_CORE})
ADD_EXECUTABLE(workflow_tests ${CMAKE_SOURCE_DIR}/tests/stream/workflow_tests.cpp)
TARGET_INCLUDE_DIRECTORIES(workflow_tests PRIVATE ${PRIVATE_INCLUDE_DIRECTORIES_WORKFLOW_TESTS})
TARGET_COMPILE_DEFINITIONS(workflow_tests PRIVATE -DPROJECT_TEST_SOURCES_DIR="${CMAKE_SOURCE_DIR}/tests")
TARGET_LINK_LIBRARIES(workflow_tests ${WORKFLOW_TESTS_LIBS})
SET_PROPERTY(TARGET workflow_tests PROPERTY FOLDER "Workflow tests")
ENDIF(DEVELOPER_ENABLE_TESTS)

View file

@ -0,0 +1,71 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/commands_factory.h"
#include <string>
#include "stream_commands/commands.h"
namespace fastocloud {
common::Error ChangedSourcesStreamBroadcast(const ChangedSouresInfo& params, fastotv::protocol::request_t* req) {
if (!req) {
return common::make_error_inval();
}
std::string req_str;
common::Error err_ser = params.SerializeToString(&req_str);
if (err_ser) {
return err_ser;
}
*req = fastotv::protocol::request_t::MakeNotification(CHANGED_SOURCES_STREAM, req_str);
return common::Error();
}
common::Error StatisticStreamBroadcast(const StatisticInfo& params, fastotv::protocol::request_t* req) {
if (!req) {
return common::make_error_inval();
}
std::string req_str;
common::Error err_ser = params.SerializeToString(&req_str);
if (err_ser) {
return err_ser;
}
*req = fastotv::protocol::request_t::MakeNotification(STATISTIC_STREAM, req_str);
return common::Error();
}
#if defined(MACHINE_LEARNING)
common::Error NotificationMlStreamBroadcast(const fastotv::commands_info::ml::NotificationInfo& params,
fastotv::protocol::request_t* req) {
if (!req) {
return common::make_error_inval();
}
std::string req_str;
common::Error err_ser = params.SerializeToString(&req_str);
if (err_ser) {
return err_ser;
}
*req = fastotv::protocol::request_t::MakeNotification(ML_NOTIFICATION_STREAM, req_str);
return common::Error();
}
#endif
} // namespace fastocloud

View file

@ -0,0 +1,37 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <fastotv/protocol/types.h>
#include "stream_commands/commands_info/changed_sources_info.h"
#include "stream_commands/commands_info/statistic_info.h"
#if defined(MACHINE_LEARNING)
#include <fastotv/commands_info/ml/notification_info.h>
#endif
namespace fastocloud {
// Broadcast
common::Error ChangedSourcesStreamBroadcast(const ChangedSouresInfo& params, fastotv::protocol::request_t* req);
common::Error StatisticStreamBroadcast(const StatisticInfo& params, fastotv::protocol::request_t* req);
#if defined(MACHINE_LEARNING)
common::Error NotificationMlStreamBroadcast(const fastotv::commands_info::ml::NotificationInfo& params,
fastotv::protocol::request_t* req);
#endif
} // namespace fastocloud

66
src/stream/config.cpp Normal file
View file

@ -0,0 +1,66 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/config.h"
namespace fastocloud {
namespace stream {
Config::Config(fastotv::StreamType type, size_t max_restart_attempts, const input_t& input, const output_t& output)
: type_(type), max_restart_attempts_(max_restart_attempts), ttl_sec_(), input_(input), output_(output) {}
Config::~Config() {}
fastotv::StreamType Config::GetType() const {
return type_;
}
input_t Config::GetInput() const {
return input_;
}
void Config::SetInput(const input_t& input) {
input_ = input;
}
output_t Config::GetOutput() const {
return output_;
}
void Config::SetOutput(const output_t& output) {
output_ = output;
}
size_t Config::GetMaxRestartAttempts() const {
return max_restart_attempts_;
}
void Config::SetMaxRestartAttempts(size_t attempts) {
max_restart_attempts_ = attempts;
}
const Config::ttl_t& Config::GetTimeToLifeStream() const {
return ttl_sec_;
}
void Config::SetTimeToLifeStream(const ttl_t& ttl) {
ttl_sec_ = ttl;
}
Config* Config::Clone() const {
return new Config(*this);
}
} // namespace stream
} // namespace fastocloud

57
src/stream/config.h Normal file
View file

@ -0,0 +1,57 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/types.h"
#include <fastotv/types/stream_ttl.h>
namespace fastocloud {
namespace stream {
class Config : public common::ClonableBase<Config> {
public:
enum { report_delay_sec = 10 };
typedef common::Optional<fastotv::StreamTTL> ttl_t;
Config(fastotv::StreamType type, size_t max_restart_attempts, const input_t& input, const output_t& output);
virtual ~Config();
fastotv::StreamType GetType() const;
input_t GetInput() const; // all except timeshift_play
void SetInput(const input_t& input);
output_t GetOutput() const; // all except timeshift_rec
void SetOutput(const output_t& output);
size_t GetMaxRestartAttempts() const;
void SetMaxRestartAttempts(size_t attempts);
const ttl_t& GetTimeToLifeStream() const;
void SetTimeToLifeStream(const ttl_t& ttl);
Config* Clone() const override;
private:
fastotv::StreamType type_;
size_t max_restart_attempts_;
ttl_t ttl_sec_;
input_t input_;
output_t output_;
};
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,315 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/configs_factory.h"
#include <string>
#include <common/sprintf.h>
#include <fastotv/types/utils.h>
#include "base/config_fields.h"
#include "base/link_generator/ilink_generator.h"
#include "stream/streams/configs/encode_config.h"
#include "stream/streams/configs/relay_config.h"
namespace fastocloud {
namespace stream {
namespace {
const size_t kDefaultRestartAttempts = 10;
} // namespace
common::Error make_config(const StreamConfig& config_args, Config** config) {
if (!config_args || !config) {
return common::make_error_inval();
}
int64_t type;
common::Value* type_field = config_args->Find(TYPE_FIELD);
if (!type_field || !type_field->GetAsInteger64(&type)) {
return common::make_error("Define " TYPE_FIELD " variable and make it valid");
}
fastotv::StreamType stream_type = static_cast<fastotv::StreamType>(type);
if (stream_type == fastotv::PROXY || stream_type == fastotv::VOD_PROXY) {
return common::make_error("Proxy streams not handled for now");
}
const auto input_urls = ReadInput(config_args);
if (!input_urls) {
return common::make_error("Define " INPUT_FIELD " variable and make it valid");
}
const auto output_urls = ReadOutput(config_args);
if (!output_urls) {
return common::make_error("Define " OUTPUT_FIELD " variable and make it valid");
}
int64_t max_restart_attempts;
common::Value* restart_attempts_field = config_args->Find(RESTART_ATTEMPTS_FIELD);
if (!restart_attempts_field || restart_attempts_field->GetAsInteger64(&max_restart_attempts)) {
max_restart_attempts = kDefaultRestartAttempts;
}
CHECK(max_restart_attempts > 0) << "restart attempts must be grether than 0";
Config conf(static_cast<fastotv::StreamType>(stream_type), max_restart_attempts, *input_urls, *output_urls);
conf.SetTimeToLifeStream(GetTTL(config_args));
streams::AudioVideoConfig aconf(conf);
bool have_video;
common::Value* have_video_field = config_args->Find(HAVE_VIDEO_FIELD);
if (have_video_field && have_video_field->GetAsBoolean(&have_video)) {
aconf.SetHaveVideo(have_video);
}
bool have_audio;
common::Value* have_audio_field = config_args->Find(HAVE_AUDIO_FIELD);
if (have_audio_field && have_audio_field->GetAsBoolean(&have_audio)) {
aconf.SetHaveAudio(have_audio);
}
bool have_subtitle;
common::Value* have_subtitle_field = config_args->Find(HAVE_SUBTITLE_FIELD);
if (have_subtitle_field && have_subtitle_field->GetAsBoolean(&have_subtitle)) {
aconf.SetHaveSubtitle(have_subtitle);
}
int64_t audio_select;
common::Value* audio_select_field = config_args->Find(AUDIO_SELECT_FIELD);
if (audio_select_field && audio_select_field->GetAsInteger64(&audio_select)) {
aconf.SetAudioSelect(audio_select);
}
bool loop;
common::Value* loop_field = config_args->Find(LOOP_FIELD);
if (loop_field && loop_field->GetAsBoolean(&loop)) {
aconf.SetLoop(loop);
}
if (stream_type == fastotv::RELAY || stream_type == fastotv::TIMESHIFT_PLAYER || stream_type == fastotv::TEST_LIFE ||
stream_type == fastotv::VOD_RELAY || stream_type == fastotv::COD_RELAY) {
streams::RelayConfig* rconfig = new streams::RelayConfig(aconf);
std::string video_parser;
common::Value* video_parser_field = config_args->Find(VIDEO_PARSER_FIELD);
if (video_parser_field && video_parser_field->GetAsBasicString(&video_parser)) {
rconfig->SetVideoParser(video_parser);
}
std::string audio_parser;
common::Value* audio_parser_field = config_args->Find(AUDIO_PARSER_FIELD);
if (audio_parser_field && audio_parser_field->GetAsBasicString(&audio_parser)) {
rconfig->SetAudioParser(audio_parser);
}
if (stream_type == fastotv::VOD_RELAY) {
streams::VodRelayConfig* vconf = new streams::VodRelayConfig(*rconfig);
delete rconfig;
rconfig = vconf;
bool cleanup_ts;
common::Value* cleanup_ts_field = config_args->Find(CLEANUP_TS_FIELD);
if (cleanup_ts_field && cleanup_ts_field->GetAsBoolean(&cleanup_ts)) {
vconf->SetCleanupTS(cleanup_ts);
}
}
*config = rconfig;
return common::Error();
} else if (stream_type == fastotv::ENCODE || stream_type == fastotv::VOD_ENCODE ||
stream_type == fastotv::COD_ENCODE || stream_type == fastotv::EVENT) {
streams::EncodeConfig* econfig = new streams::EncodeConfig(aconf);
bool relay_audio;
common::Value* relay_audio_field = config_args->Find(RELAY_AUDIO_FIELD);
if (relay_audio_field && relay_audio_field->GetAsBoolean(&relay_audio)) {
econfig->SetRelayAudio(relay_audio);
}
bool relay_video;
common::Value* relay_video_field = config_args->Find(RELAY_VIDEO_FIELD);
if (relay_video_field && relay_video_field->GetAsBoolean(&relay_video)) {
econfig->SetRelayVideo(relay_video);
}
bool deinterlace;
common::Value* deinterlace_field = config_args->Find(DEINTERLACE_FIELD);
if (deinterlace_field && deinterlace_field->GetAsBoolean(&deinterlace)) {
econfig->SetDeinterlace(deinterlace);
}
common::media::Rational frame_rate;
common::Value* frame_field = config_args->Find(FRAME_RATE_FIELD);
std::string frame_str;
if (frame_field && frame_field->GetAsBasicString(&frame_str) && common::ConvertFromString(frame_str, &frame_rate)) {
econfig->SetFrameRate(frame_rate);
}
double volume;
common::Value* volume_field = config_args->Find(VOLUME_FIELD);
if (volume_field && volume_field->GetAsDouble(&volume)) {
econfig->SetVolume(volume);
}
std::string video_codec;
common::Value* video_codec_field = config_args->Find(VIDEO_CODEC_FIELD);
if (video_codec_field && video_codec_field->GetAsBasicString(&video_codec)) {
econfig->SetVideoEncoder(video_codec);
}
std::string audio_codec;
common::Value* audio_codec_field = config_args->Find(AUDIO_CODEC_FIELD);
if (audio_codec_field && audio_codec_field->GetAsBasicString(&audio_codec)) {
econfig->SetAudioEncoder(audio_codec);
}
int64_t audio_channels;
common::Value* audio_channels_field = config_args->Find(AUDIO_CHANNELS_FIELD);
if (audio_channels_field && audio_channels_field->GetAsInteger64(&audio_channels)) {
econfig->SetAudioChannelsCount(audio_channels);
}
common::HashValue* size_hash = nullptr;
common::Value* size_field = config_args->Find(SIZE_FIELD);
if (size_field && size_field->GetAsHash(&size_hash)) {
auto size = fastotv::MakeSize(size_hash);
econfig->SetSize(size);
}
int64_t v_bitrate;
common::Value* video_bitrate_field = config_args->Find(VIDEO_BIT_RATE_FIELD);
if (video_bitrate_field && video_bitrate_field->GetAsInteger64(&v_bitrate)) {
econfig->SetVideoBitrate(v_bitrate);
}
int64_t a_bitrate;
common::Value* audio_bitrate_field = config_args->Find(AUDIO_BIT_RATE_FIELD);
if (audio_bitrate_field && audio_bitrate_field->GetAsInteger64(&a_bitrate)) {
econfig->SetAudioBitrate(a_bitrate);
}
#if defined(MACHINE_LEARNING)
common::HashValue* deep_learning_hash = nullptr;
common::Value* deep_learning_field = config_args->Find(DEEP_LEARNING_FIELD);
if (deep_learning_field && deep_learning_field->GetAsHash(&deep_learning_hash)) {
auto deep_learning = machine_learning::DeepLearning::MakeDeepLearning(deep_learning_hash);
if (deep_learning) {
econfig->SetDeepLearning(*deep_learning);
}
}
common::HashValue* deep_learning_overlay_hash = nullptr;
common::Value* deep_learning_overlay_field = config_args->Find(DEEP_LEARNING_OVERLAY_FIELD);
if (deep_learning_overlay_field && deep_learning_overlay_field->GetAsHash(&deep_learning_overlay_hash)) {
auto deep_learning_overlay =
machine_learning::DeepLearningOverlay::MakeDeepLearningOverlay(deep_learning_overlay_hash);
if (deep_learning_overlay) {
econfig->SetDeepLearningOverlay(*deep_learning_overlay);
}
}
#endif
common::HashValue* logo_hash = nullptr;
common::Value* logo_field = config_args->Find(LOGO_FIELD);
if (logo_field && logo_field->GetAsHash(&logo_hash)) {
auto logo = fastotv::Logo::Make(logo_hash);
econfig->SetLogo(logo);
}
common::HashValue* rsvg_logo_hash = nullptr;
common::Value* rsvg_logo_field = config_args->Find(RSVG_LOGO_FIELD);
if (rsvg_logo_field && rsvg_logo_field->GetAsHash(&rsvg_logo_hash)) {
auto logo = fastotv::RSVGLogo::Make(rsvg_logo_hash);
econfig->SetRSVGLogo(logo);
}
common::HashValue* rat_hash = nullptr;
common::Value* rat_field = config_args->Find(ASPECT_RATIO_FIELD);
if (rat_field && rat_field->GetAsHash(&rat_hash)) {
auto rat = fastotv::MakeRational(rat_hash);
econfig->SetAspectRatio(rat);
}
int64_t decl_vm;
common::Value* decl_vm_field = config_args->Find(DECKLINK_VIDEO_MODE_FIELD);
if (decl_vm_field && decl_vm_field->GetAsInteger64(&decl_vm)) {
econfig->SetDecklinkMode(decl_vm);
}
if (stream_type == fastotv::VOD_ENCODE) {
streams::VodEncodeConfig* vconf = new streams::VodEncodeConfig(*econfig);
delete econfig;
econfig = vconf;
bool cleanup_ts;
common::Value* cleanup_ts_field = config_args->Find(CLEANUP_TS_FIELD);
if (cleanup_ts_field && cleanup_ts_field->GetAsBoolean(&cleanup_ts)) {
vconf->SetCleanupTS(cleanup_ts);
}
}
*config = econfig;
return common::Error();
} else if (stream_type == fastotv::TIMESHIFT_RECORDER || stream_type == fastotv::CATCHUP) {
streams::RelayConfig rel(aconf);
std::string video_parser;
common::Value* video_parser_field = config_args->Find(VIDEO_PARSER_FIELD);
if (video_parser_field && video_parser_field->GetAsBasicString(&video_parser)) {
rel.SetVideoParser(video_parser);
}
std::string audio_parser;
common::Value* audio_parser_field = config_args->Find(AUDIO_PARSER_FIELD);
if (audio_parser_field && audio_parser_field->GetAsBasicString(&audio_parser)) {
rel.SetAudioParser(audio_parser);
}
streams::TimeshiftConfig* tconf = new streams::TimeshiftConfig(rel);
int64_t timeshift_chunk_duration;
common::Value* timeshift_chunk_duration_field = config_args->Find(TIMESHIFT_CHUNK_DURATION_FIELD);
if (timeshift_chunk_duration_field && timeshift_chunk_duration_field->GetAsInteger64(&timeshift_chunk_duration)) {
tconf->SetTimeShiftChunkDuration(timeshift_chunk_duration);
}
CHECK(tconf->GetTimeShiftChunkDuration()) << "Avoid division by zero";
*config = tconf;
return common::Error();
}
return common::make_error(common::MemSPrintf("Unhandled stream type: %d", stream_type));
}
Config* make_config_copy(const Config* conf, const link_generator::ILinkGenerator* generator) {
Config* copy = conf->Clone();
if (generator) {
input_t input = copy->GetInput();
for (size_t i = 0; i < input.size(); ++i) {
fastotv::InputUri url;
if (generator->Generate(input[i], &url)) {
input[i] = url;
DEBUG_LOG() << "Generated url: " << url.GetUrl().spec();
}
}
copy->SetInput(input);
}
return copy;
}
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/stream_config.h"
namespace fastocloud {
namespace link_generator {
class ILinkGenerator;
}
namespace stream {
class Config;
common::Error make_config(const StreamConfig& config_args, Config** config) WARN_UNUSED_RESULT;
Config* make_config_copy(const Config* conf, const link_generator::ILinkGenerator* generator) WARN_UNUSED_RESULT;
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,44 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/dumpers/dumpers_factory.h"
#include <string>
#include <common/string_util.h>
#include "stream/dumpers/htmldump.h"
#define HTML_FORMAT "html"
namespace fastocloud {
namespace stream {
namespace dumper {
IDumper* DumpersFactory::CreateDumper(const common::file_system::ascii_file_string_path& path) {
if (!path.IsValid()) {
return nullptr;
}
std::string ext = path.GetExtension();
if (common::EqualsASCII(ext, HTML_FORMAT, false)) {
return new HtmlDump;
}
return new HtmlDump;
}
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,34 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <common/patterns/singleton_pattern.h>
#include "stream/dumpers/idumper.h"
namespace fastocloud {
namespace stream {
namespace dumper {
class DumpersFactory : public common::patterns::LazySingleton<DumpersFactory> {
public:
friend class common::patterns::LazySingleton<DumpersFactory>;
IDumper* CreateDumper(const common::file_system::ascii_file_string_path& path);
};
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,72 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/dumpers/htmldump.h"
#include <gst/gst.h>
#include <fstream>
#include <string>
#include "stream/elements/element.h"
#define JS_LIB "https://github.com/mdaines/viz.js/releases/download/v1.8.2/viz-lite.js"
namespace fastocloud {
namespace stream {
namespace dumper {
bool HtmlDump::Dump(GstBin* pipeline, const common::file_system::ascii_file_string_path& path) {
if (!path.IsValid()) {
return false;
}
if (!pipeline) {
return false;
}
#if !defined(GST_DISABLE_GST_DEBUG)
std::ofstream dumpfile(path.GetPath());
if (!dumpfile.is_open()) {
return false;
}
#if GST_CHECK_VERSION(1, 11, 1)
char* dot_description = gst_debug_bin_to_dot_data(pipeline, GST_DEBUG_GRAPH_SHOW_ALL);
if (!dot_description) {
return false;
}
std::string pipeline_description(dot_description);
dumpfile << "<html><head></head>"
<< "<body>"
<< " <script type=\"text/javascript\" src=\"" JS_LIB "\"></script>"
<< " <script>"
<< " document.body.innerHTML += Viz(String.raw`" << pipeline_description << "`);"
<< " </script>"
<< "</body>"
<< "</html>";
g_free(dot_description);
return true;
#else
return false;
#endif
#else
return false;
#endif
}
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,30 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/dumpers/idumper.h"
namespace fastocloud {
namespace stream {
namespace dumper {
class HtmlDump : public IDumper {
public:
bool Dump(GstBin* pipeline, const common::file_system::ascii_file_string_path& path) override;
};
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,25 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/dumpers/idumper.h"
namespace fastocloud {
namespace stream {
namespace dumper {
IDumper::~IDumper() {}
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <common/file_system/path.h>
typedef struct _GstBin GstBin;
namespace fastocloud {
namespace stream {
namespace dumper {
class IDumper {
public:
virtual bool Dump(GstBin* pipeline, const common::file_system::ascii_file_string_path& path) = 0;
virtual ~IDumper();
};
} // namespace dumper
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,49 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/audio/audio.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace audio {
void ElementVolume::SetVolume(gdouble volume) {
SetProperty("volume", volume);
}
void ElementRGVolume::SetPreAmp(gdouble volume) {
SetProperty("pre-amp", volume);
}
void ElementSpectrum::SetBands(guint bands) {
SetProperty("bands", bands);
}
void ElementSpectrum::SetTheshold(gint threshold) {
SetProperty("threshold", threshold);
}
void ElementSpectrum::SetPostMessage(gboolean pm) {
SetProperty("post-messages", pm);
}
void ElementSpectrum::SetMessagePhase(gboolean mp) {
SetProperty("message-phase", mp);
}
} // namespace audio
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,90 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace audio {
class ElementAudioConvert : public ElementEx<ELEMENT_AUDIO_CONVERT> {
public:
typedef ElementEx<ELEMENT_AUDIO_CONVERT> base_class;
using base_class::base_class;
};
class ElementAudioResample : public ElementEx<ELEMENT_AUDIO_RESAMPLE> {
public:
typedef ElementEx<ELEMENT_AUDIO_RESAMPLE> base_class;
using base_class::base_class;
};
class ElementVolume : public ElementEx<ELEMENT_VOLUME> {
public:
typedef ElementEx<ELEMENT_VOLUME> base_class;
using base_class::base_class;
void SetVolume(gdouble volume = 1); // 0 - 10 Default: 1
};
class ElementRGVolume : public ElementEx<ELEMENT_RG_VOLUME> {
public:
typedef ElementEx<ELEMENT_RG_VOLUME> base_class;
using base_class::base_class;
void SetPreAmp(gdouble volume = 0); // -60 - 60 Default: 0
};
class ElementAudioMixer : public ElementEx<ELEMENT_AUDIO_MIXER> {
public:
typedef ElementEx<ELEMENT_AUDIO_MIXER> base_class;
using base_class::base_class;
};
class ElementIterleave : public ElementEx<ELEMENT_INTERLEAVE> {
public:
typedef ElementEx<ELEMENT_INTERLEAVE> base_class;
using base_class::base_class;
};
class ElementDeinterleave : public ElementEx<ELEMENT_DEINTERLEAVE> {
public:
typedef ElementEx<ELEMENT_DEINTERLEAVE> base_class;
using base_class::base_class;
};
class ElementSpectrum : public ElementEx<ELEMENT_SPECTRUM> {
public:
typedef ElementEx<ELEMENT_SPECTRUM> base_class;
using base_class::base_class;
void SetBands(guint bands = 128); // 2 - 1073741824 Default: 128
void SetTheshold(gint threshold = -60); // -2147483648 - 0 Default: -60
void SetPostMessage(gboolean pm = true); // Default: true
void SetMessagePhase(gboolean mp = false); // Defaut: false
};
class ElementLevel : public ElementEx<ELEMENT_LEVEL> {
public:
typedef ElementEx<ELEMENT_LEVEL> base_class;
using base_class::base_class;
};
} // namespace audio
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,46 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/depay/audio.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {
ElementRtpAACDePay* make_aac_depay(element_id_t pay_id) {
ElementRtpAACDePay* aac_pay = make_audio_depay<ElementRtpAACDePay>(pay_id);
return aac_pay;
}
ElementRtpAC3DePay* make_ac3_depay(element_id_t pay_id) {
ElementRtpAC3DePay* aac_pay = make_audio_depay<ElementRtpAC3DePay>(pay_id);
return aac_pay;
}
Element* make_audio_depay(const std::string& pay, const std::string& name) {
if (pay == ElementRtpAACDePay::GetPluginName()) {
return new ElementRtpAACDePay(name);
} else if (pay == ElementRtpAC3DePay::GetPluginName()) {
return new ElementRtpAC3DePay(name);
}
NOTREACHED();
return nullptr;
}
} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,56 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
#include "stream/stypes.h"
#include "stream/elements/depay/depay.h" // for ElementRtpPay
#include "stream/elements/element.h" // for Element (ptr only), SupportedElements:...
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {
class ElementRtpAACDePay : public ElementRtpDePay<ELEMENT_RTP_AAC_DEPAY> {
public:
typedef ElementRtpDePay<ELEMENT_RTP_AAC_DEPAY> base_class;
using base_class::base_class;
};
class ElementRtpAC3DePay : public ElementRtpDePay<ELEMENT_RTP_AC3_DEPAY> {
public:
typedef ElementRtpDePay<ELEMENT_RTP_AC3_DEPAY> base_class;
using base_class::base_class;
};
template <typename T>
T* make_audio_depay(element_id_t pay_id) {
return make_element<T>(common::MemSPrintf(AUDIO_DEPAY_NAME_1U, pay_id));
}
ElementRtpAACDePay* make_aac_depay(element_id_t pay_id);
ElementRtpAC3DePay* make_ac3_depay(element_id_t pay_id);
Element* make_audio_depay(const std::string& pay, const std::string& name);
} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/depay/depay.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,34 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {
template <SupportedElements el>
class ElementRtpDePay : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
};
} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,53 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/depay/video.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {
ElementRtpMPEG2DePay* make_mpeg2_depay(element_id_t pay_id) {
ElementRtpMPEG2DePay* h264_pay = make_video_depay<ElementRtpMPEG2DePay>(pay_id);
return h264_pay;
}
ElementRtpH264DePay* make_h264_depay(element_id_t pay_id) {
ElementRtpH264DePay* h264_pay = make_video_depay<ElementRtpH264DePay>(pay_id);
return h264_pay;
}
ElementRtpH265DePay* make_h265_depay(element_id_t pay_id) {
ElementRtpH265DePay* h265_pay = make_video_depay<ElementRtpH265DePay>(pay_id);
return h265_pay;
}
Element* make_video_depay(const std::string& pay, const std::string& name) {
if (pay == ElementRtpH264DePay::GetPluginName()) {
return new ElementRtpH264DePay(name);
} else if (pay == ElementRtpH265DePay::GetPluginName()) {
return new ElementRtpH265DePay(name);
} else if (pay == ElementRtpMPEG2DePay::GetPluginName()) {
return new ElementRtpMPEG2DePay(name);
}
NOTREACHED();
return nullptr;
}
} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,65 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
// for element_id_t, VIDEO_PAY_NAME_1U
#include "stream/elements/depay/depay.h" // for ElementRtpPay
#include "stream/elements/element.h" // for Element (ptr only), SupportedElements:...
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace depay {
class ElementRtpMPEG2DePay : public ElementRtpDePay<ELEMENT_RTP_MPEG2_DEPAY> {
public:
typedef ElementRtpDePay<ELEMENT_RTP_MPEG2_DEPAY> base_class;
using base_class::base_class;
};
class ElementRtpH264DePay : public ElementRtpDePay<ELEMENT_RTP_H264_DEPAY> {
public:
typedef ElementRtpDePay<ELEMENT_RTP_H264_DEPAY> base_class;
using base_class::base_class;
};
class ElementRtpH265DePay : public ElementRtpDePay<ELEMENT_RTP_H265_DEPAY> {
public:
typedef ElementRtpDePay<ELEMENT_RTP_H265_DEPAY> base_class;
using base_class::base_class;
};
template <typename T>
T* make_video_depay(element_id_t pay_id) {
return make_element<T>(common::MemSPrintf(VIDEO_DEPAY_NAME_1U, pay_id));
}
ElementRtpMPEG2DePay* make_mpeg2_depay(element_id_t pay_id);
ElementRtpH264DePay* make_h264_depay(element_id_t pay_id);
ElementRtpH265DePay* make_h265_depay(element_id_t pay_id);
Element* make_video_depay(const std::string& pay, const std::string& name);
} // namespace depay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,588 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/element.h"
#include <common/sprintf.h>
#include <gst/gst.h>
#include <gst/gstpipeline.h>
#include "stream/gstreamer_utils.h" // for make_element_safe
#include "base/gst_constants.h" // for AAC_PARSE, AC3_PARSE, ALSA_SRC
#include "stream/pad/pad.h"
#include "stream/stypes.h"
#define DECLARE_ELEMENT_TRAITS_SPECIALIZATION(x) \
template <> \
const char* ElementsTraits<ELEMENT_##x>::name() { \
return x; \
}
namespace fastocloud {
namespace stream {
namespace elements {
std::string Element::GetPluginName() const {
return plugin_name_;
}
std::string Element::GetName() const {
return name_;
}
bool Element::IsValid() const {
return element_ != nullptr;
}
GstElement* Element::GetGstElement() const {
return element_;
}
std::unique_ptr<pad::Pad> Element::StaticPad(const gchar* name) const {
GstPad* pad = gst_element_get_static_pad(element_, name);
if (pad) {
return std::make_unique<pad::Pad>(pad);
}
DNOTREACHED();
return std::unique_ptr<pad::Pad>();
}
std::unique_ptr<pad::Pad> Element::RequestPad(const gchar* name) const {
#if GST_CHECK_VERSION(1, 19, 0)
GstPad* pad = gst_element_request_pad_simple(element_, name);
#else
GstPad* pad = gst_element_get_request_pad(element_, name);
#endif
if (pad) {
return std::make_unique<pad::Pad>(pad);
}
DNOTREACHED();
return std::unique_ptr<pad::Pad>();
}
void Element::ReleaseRequestedPad(pad::Pad* pad) {
if (!pad) {
DNOTREACHED();
return;
}
gst_element_release_request_pad(GetGstElement(), pad->GetGstPad());
}
std::unique_ptr<pad::Pad> Element::LinkStaticAndStaticPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) {
auto src_pad = src->StaticPad(src_pad_name);
if (!src_pad) {
WARNING_LOG() << "Can't get static pad: " << src_pad_name << ", for: " << src->GetName();
return std::unique_ptr<pad::Pad>();
}
auto sink_pad = sink->StaticPad(sink_pad_name);
if (!sink_pad) {
WARNING_LOG() << "Can't get static pad: " << sink_pad_name << ", for: " << sink->GetName();
return std::unique_ptr<pad::Pad>();
}
if (LinkPads(src_pad->GetGstPad(), sink_pad->GetGstPad())) {
return sink_pad;
}
return std::unique_ptr<pad::Pad>();
}
std::unique_ptr<pad::Pad> Element::LinkStaticAndRequestPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) {
auto src_pad = src->StaticPad(src_pad_name);
if (!src_pad) {
WARNING_LOG() << "Can't get static pad: " << src_pad_name << ", for: " << src->GetName();
return std::unique_ptr<pad::Pad>();
}
auto sink_pad = sink->RequestPad(sink_pad_name);
if (!sink_pad) {
WARNING_LOG() << "Can't get requested pad: " << sink_pad_name << ", for: " << sink->GetName();
return std::unique_ptr<pad::Pad>();
}
if (LinkPads(src_pad->GetGstPad(), sink_pad->GetGstPad())) {
return sink_pad;
}
return std::unique_ptr<pad::Pad>();
}
std::unique_ptr<pad::Pad> Element::LinkRequestAndStaticPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) {
auto src_pad = src->RequestPad(src_pad_name);
if (!src_pad) {
WARNING_LOG() << "Can't get requested pad: " << src_pad_name << ", for: " << src->GetName();
return std::unique_ptr<pad::Pad>();
}
auto sink_pad = sink->StaticPad(sink_pad_name);
if (!sink_pad) {
WARNING_LOG() << "Can't get static pad: " << sink_pad_name << ", for: " << sink->GetName();
return std::unique_ptr<pad::Pad>();
}
if (LinkPads(src_pad->GetGstPad(), sink_pad->GetGstPad())) {
return sink_pad;
}
return std::unique_ptr<pad::Pad>();
}
bool Element::LinkPads(GstPad* src_pad, GstPad* sink_pad) {
GstPadLinkReturn ret = gst_pad_link(src_pad, sink_pad);
bool result = GST_PAD_LINK_SUCCESSFUL(ret);
if (!result) {
WARNING_LOG() << "LinkPads failed: " << ret;
}
return result;
}
bool Element::LinkElementPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) {
gboolean result = gst_element_link_pads(src->GetGstElement(), src_pad_name, sink->GetGstElement(), sink_pad_name);
if (!result) {
WARNING_LOG() << "LinkElementPads failed: " << result;
}
return result;
}
void Element::UnLinkElementPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) {
gst_element_unlink_pads(src->GetGstElement(), src_pad_name, sink->GetGstElement(), sink_pad_name);
}
Element::Element(const std::string& plugin_name, const std::string& name)
: Element(plugin_name, name, make_element_safe(plugin_name, name)) {
element_id_t elem_id;
if (!GetElementId(name, &elem_id)) {
WARNING_LOG() << "Not template plugin '" << plugin_name << "' named: " << name;
}
}
Element::Element(const std::string& plugin_name, const std::string& name, GstElement* const element)
: name_(name), plugin_name_(plugin_name), element_(element) {}
Element::~Element() {
for (size_t i = 0; i < signals_.size(); ++i) {
UnRegisterCallback(signals_[i]);
}
signals_.clear();
}
gboolean Element::RegisterCallback(const char* signal_name, GCallback cb, gpointer user_data) {
gulong id = g_signal_connect(element_, signal_name, cb, user_data);
if (id == 0) {
return FALSE;
}
signals_.push_back(id);
return TRUE;
}
gboolean Element::RegisterPadAddedCallback(pad_added_callback_t cb, gpointer user_data) {
return RegisterCallback("pad-added", G_CALLBACK(cb), user_data);
}
gboolean Element::RegisterPadRemovedCallback(pad_removed_callback_t cb, gpointer user_data) {
return RegisterCallback("pad-removed", G_CALLBACK(cb), user_data);
}
gboolean Element::RegisterNoMorePadsCallback(no_more_pads_callback_t cb, gpointer user_data) {
return RegisterCallback("no-more-pads", G_CALLBACK(cb), user_data);
}
void Element::UnRegisterCallback(gulong signal_id) {
g_signal_handler_disconnect(element_, signal_id);
}
void Element::SetProperty(const char* property, bool val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gfloat val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gdouble val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gint8 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, guint8 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gint16 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, guint16 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gint val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, guint val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, gint64 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, guint64 val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, const char* val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetProperty(const char* property, const std::string& val) {
SetProperty(property, val.c_str());
}
void Element::SetProperty(const char* property, void* val) {
g_object_set(element_, property, val, nullptr);
}
void Element::SetFractionProperty(const char* property, gint num, gint den) {
g_object_set(element_, property, num, den, nullptr);
}
GValue Element::GetProperty(const char* property, GType type) const {
GValue value = G_VALUE_INIT;
g_value_init(&value, type);
g_object_get_property(G_OBJECT(element_), property, &value);
return value;
}
std::string Element::GetStringProperty(const char* property) const {
GValue gvalue = GetProperty(property, G_TYPE_STRING);
return gvalue_cast<const char*>(&gvalue);
}
std::string Element::GetElementName(GstElement* element) {
if (!element) {
return std::string();
}
gchar* name = gst_element_get_name(element);
if (!name) {
return std::string();
}
std::string name_str(name);
g_free(name);
return name_str;
}
std::string Element::GetPluginName(GstElement* element) {
if (!element) {
return std::string();
}
GstElementFactory* factory = gst_element_get_factory(element);
gpointer plug_feature = GST_PLUGIN_FEATURE(factory);
if (!plug_feature) {
return std::string();
}
return gst_plugin_feature_get_name(plug_feature);
}
void ElementDecodebin::SetUseBuffering(bool use_buffering) {
SetProperty("use-buffering", use_buffering);
}
void ElementDecodebin::SetMaxSizeBuffers(guint val) {
SetProperty("max-size-buffers", val);
}
void ElementDecodebin::SetMaxSizeTime(guint val) {
SetProperty("max-size-time", val);
}
void ElementDecodebin::SetMaxSizeBytes(guint64 val) {
SetProperty("max-size-bytes", val);
}
void ElementDecodebin::SetEmpty() {
SetMaxSizeBuffers(0);
SetMaxSizeTime(0);
SetMaxSizeBytes(0);
}
gboolean ElementDecodebin::RegisterAutoplugContinue(autoplug_continue_callback_t cb, gpointer user_data) {
return RegisterCallback("autoplug-continue", G_CALLBACK(cb), user_data);
}
gboolean ElementDecodebin::RegisterAutoplugSelect(autoplug_select_callback_t cb, gpointer user_data) {
return RegisterCallback("autoplug-select", G_CALLBACK(cb), user_data);
}
gboolean ElementDecodebin::RegisterAutoplugSort(autoplug_sort_callback_t cb, gpointer user_data) {
return RegisterCallback("autoplug-sort", G_CALLBACK(cb), user_data);
}
void ElementQueue::SetMaxSizeBuffers(guint val) {
SetProperty("max-size-buffers", val);
}
void ElementQueue::SetMaxSizeTime(guint val) {
SetProperty("max-size-time", val);
}
void ElementQueue::SetMaxSizeBytes(guint64 val) {
SetProperty("max-size-bytes", val);
}
void ElementQueue::SetEmpty() {
SetMaxSizeBuffers(0);
SetMaxSizeTime(0);
SetMaxSizeBytes(0);
}
void ElementCapsFilter::SetCaps(GstCaps* caps) {
SetProperty("caps", caps);
}
void ElementQueue2::SetMaxSizeBuffers(guint val) {
SetProperty("max-size-buffers", val);
}
void ElementQueue2::SetMaxSizeTime(guint64 val) {
SetProperty("max-size-time", val);
}
void ElementQueue2::SetMaxSizeBytes(guint val) {
SetProperty("max-size-bytes", val);
}
void ElementQueue2::SetUseBuffering(bool use_buffering) {
SetProperty("use-buffering", use_buffering);
}
void ElementAvdecH264::SetMaxThreads(gint threads) {
SetProperty("max-threads", threads);
}
void ElementAvdecH264::SetSkipFrame(gint skip_frame) {
SetProperty("skip-frame", skip_frame);
}
void ElementAvdecH264::SetOutputCorrupt(gboolean output_corrupt) {
SetProperty("output-corrupt", output_corrupt);
}
void ElementVaapiPostProc::SetDinterlaceMode(gint deinterlace_method) {
SetProperty("deinterlace-method", deinterlace_method);
}
void ElementVaapiPostProc::SetFormat(gint format) {
SetProperty("format", format);
}
void ElementVaapiPostProc::SetWidth(guint width) {
SetProperty("width", width);
}
void ElementVaapiPostProc::SetHeight(guint height) {
SetProperty("height", height);
}
void ElementVaapiPostProc::SetForceAspectRatio(bool ratio) {
SetProperty("force-aspect-ratio", ratio);
}
void ElementVaapiPostProc::SetScaleMethod(guint met) {
SetProperty("scale-method", met);
}
void ElementVaapiPostProc::SetDeinerlaceMethod(guint met) {
SetProperty("deinterlace-method", met);
}
void ElementVaapiPostProc::SetDenoise(gfloat denoise) {
SetProperty("denoise", denoise);
}
void ElementVaapiPostProc::SetSkinToneEnhancement(bool val) {
SetProperty("skin-tone-enhancement", val);
}
void ElementMFXVpp::SetForceAspectRatio(bool ratio) {
SetProperty("force-aspect-ratio", ratio);
}
void ElementMFXVpp::SetWidth(gint width) {
SetProperty("width", width);
}
void ElementMFXVpp::SetHeight(gint height) {
SetProperty("height", height);
}
void ElementMFXVpp::SetFrameRate(const common::media::Rational& framerate) {
SetFractionProperty("framerate", framerate.num, framerate.den);
}
void ElementMFXVpp::SetDinterlaceMode(int mode) {
SetProperty("deinterlace-mode", mode);
}
void ElementMFXH264Decode::SetLiveMode(bool mode) {
SetProperty("live-mode", mode);
}
void ElementTsDemux::SetParsePrivateSections(gboolean parse_private_sections) {
SetProperty("parse-private-sections", parse_private_sections);
}
void ElementTsDemux::SetProgramNumber(gint number) {
SetProperty("program-number", number);
}
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DECODEBIN)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(FAKE_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TEST_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_TEST_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_TEST_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DISPLAY_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_SCREEN_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_SCREEN_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(QUEUE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(QUEUE2)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(H264_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(H265_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MPEG_VIDEO_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AAC_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AC3_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MPEG_AUDIO_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RAW_AUDIO_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TEE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(FLV_MUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MP4_MUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(QT_MUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MPEGTS_MUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(FILE_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MULTIFILE_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_MUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_MPEG2_PAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_H264_PAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_H265_PAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_AAC_PAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_AC3_PAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_MPEG2_DEPAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_H264_DEPAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_H265_DEPAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_AAC_DEPAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTP_AC3_DEPAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(V4L2_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SPLIT_MUX_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(ALSA_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MULTIFILE_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(APP_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(FILE_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(IMAGE_FREEZE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(CAPS_FILTER)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_CONVERT)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RG_VOLUME)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VOLUME)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(FAAC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VOAAC_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_RESAMPLE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(LAME_MP3_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_CONVERT)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DEINTERLACE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(ASPECT_RATIO)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AV_DEINTERLACE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(UDP_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TCP_SERVER_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTMP_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(HLS_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(KVS_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SOUP_HTTP_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DVB_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_SCALE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_RATE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(NV_H264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(NV_H265_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MSDK_H264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(X264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(X265_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MPEG2_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(EAVC_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(OPEN_H264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(UDP_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TCP_SERVER_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTMP_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RTSP_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VAAPI_H264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VAAPI_MPEG2_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MFX_H264_ENC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(GDK_PIXBUF_OVERLAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(RSVG_OVERLAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_BOX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_MIXER)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_MIXER)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(INTERLEAVE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DEINTERLEAVE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(CAIRO_OVERLAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TEXT_OVERLAY)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_CROP)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SPECTRUM)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(LEVEL)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(HLS_DEMUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VIDEO_DECK_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUDIO_DECK_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(INTERLACE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AUTO_VIDEO_CONVERT)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TS_PARSE)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AVDEC_H264)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TS_DEMUX)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AVDEC_AC3)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(AVDEC_AC3_FIXED)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SOUP_HTTP_CLIENT_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VAAPI_DECODEBIN)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(VAAPI_POST_PROC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MFX_VPP)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(MFX_H264_DEC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SRT_SRC)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(SRT_SINK)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TINY_YOLOV2)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(TINY_YOLOV3)
DECLARE_ELEMENT_TRAITS_SPECIALIZATION(DETECTION_OVERLAY)
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,460 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <memory>
#include <string> // for string
#include <vector>
#include <gst/gstbin.h>
#include <gst/gstobject.h>
#include <common/macros.h>
#include <common/media/types.h>
enum GstAutoplugSelectResult { GST_AUTOPLUG_SELECT_TRY, GST_AUTOPLUG_SELECT_EXPOSE, GST_AUTOPLUG_SELECT_SKIP };
namespace fastocloud {
namespace stream {
namespace pad {
class Pad;
}
namespace elements {
enum SupportedElements {
ELEMENT_DECODEBIN,
ELEMENT_FAKE_SINK,
ELEMENT_TEST_SINK,
ELEMENT_VIDEO_TEST_SRC,
ELEMENT_AUDIO_TEST_SRC,
ELEMENT_DISPLAY_SRC,
ELEMENT_VIDEO_SCREEN_SINK,
ELEMENT_AUDIO_SCREEN_SINK,
ELEMENT_QUEUE,
ELEMENT_QUEUE2,
ELEMENT_H264_PARSE,
ELEMENT_H265_PARSE,
ELEMENT_MPEG_VIDEO_PARSE,
ELEMENT_AAC_PARSE,
ELEMENT_AC3_PARSE,
ELEMENT_MPEG_AUDIO_PARSE,
ELEMENT_RAW_AUDIO_PARSE,
ELEMENT_TEE,
ELEMENT_FLV_MUX,
ELEMENT_MP4_MUX,
ELEMENT_QT_MUX,
ELEMENT_MPEGTS_MUX,
ELEMENT_FILE_SINK,
ELEMENT_RTP_MUX,
ELEMENT_RTP_MPEG2_PAY,
ELEMENT_RTP_H264_PAY,
ELEMENT_RTP_H265_PAY,
ELEMENT_RTP_AAC_PAY,
ELEMENT_RTP_AC3_PAY,
ELEMENT_RTP_MPEG2_DEPAY,
ELEMENT_RTP_H264_DEPAY,
ELEMENT_RTP_H265_DEPAY,
ELEMENT_RTP_AAC_DEPAY,
ELEMENT_RTP_AC3_DEPAY,
ELEMENT_V4L2_SRC,
ELEMENT_SPLIT_MUX_SINK,
ELEMENT_ALSA_SRC,
ELEMENT_MULTIFILE_SRC,
ELEMENT_APP_SRC,
ELEMENT_FILE_SRC,
ELEMENT_IMAGE_FREEZE,
ELEMENT_CAPS_FILTER,
ELEMENT_AUDIO_CONVERT,
ELEMENT_RG_VOLUME,
ELEMENT_VOLUME,
ELEMENT_FAAC,
ELEMENT_VOAAC_ENC,
ELEMENT_AUDIO_RESAMPLE,
ELEMENT_LAME_MP3_ENC,
ELEMENT_VIDEO_CONVERT,
ELEMENT_ASPECT_RATIO,
ELEMENT_DEINTERLACE,
ELEMENT_AV_DEINTERLACE,
ELEMENT_UDP_SINK,
ELEMENT_TCP_SERVER_SINK,
ELEMENT_RTMP_SINK,
ELEMENT_HLS_SINK,
ELEMENT_MULTIFILE_SINK,
ELEMENT_KVS_SINK,
ELEMENT_SOUP_HTTP_SRC,
ELEMENT_DVB_SRC,
ELEMENT_VIDEO_SCALE,
ELEMENT_VIDEO_RATE,
ELEMENT_NV_H264_ENC,
ELEMENT_NV_H265_ENC,
ELEMENT_MSDK_H264_ENC,
ELEMENT_X264_ENC,
ELEMENT_X265_ENC,
ELEMENT_MPEG2_ENC,
ELEMENT_EAVC_ENC,
ELEMENT_OPEN_H264_ENC,
ELEMENT_UDP_SRC,
ELEMENT_TCP_SERVER_SRC,
ELEMENT_RTMP_SRC,
ELEMENT_RTSP_SRC,
ELEMENT_VAAPI_H264_ENC,
ELEMENT_VAAPI_MPEG2_ENC,
ELEMENT_MFX_H264_ENC,
ELEMENT_GDK_PIXBUF_OVERLAY,
ELEMENT_RSVG_OVERLAY,
ELEMENT_VIDEO_BOX,
ELEMENT_VIDEO_MIXER,
ELEMENT_AUDIO_MIXER,
ELEMENT_INTERLEAVE,
ELEMENT_DEINTERLEAVE,
ELEMENT_CAIRO_OVERLAY,
ELEMENT_TEXT_OVERLAY,
ELEMENT_VIDEO_CROP,
ELEMENT_SPECTRUM,
ELEMENT_LEVEL,
ELEMENT_HLS_DEMUX,
ELEMENT_VIDEO_DECK_SINK,
ELEMENT_AUDIO_DECK_SINK,
ELEMENT_INTERLACE,
ELEMENT_AUTO_VIDEO_CONVERT,
ELEMENT_TS_PARSE,
ELEMENT_AVDEC_H264,
ELEMENT_TS_DEMUX,
ELEMENT_AVDEC_AC3,
ELEMENT_AVDEC_AC3_FIXED,
ELEMENT_SOUP_HTTP_CLIENT_SINK,
ELEMENT_VAAPI_DECODEBIN,
ELEMENT_VAAPI_POST_PROC,
ELEMENT_MFX_VPP,
ELEMENT_MFX_H264_DEC,
ELEMENT_SRT_SRC,
ELEMENT_SRT_SINK,
ELEMENT_TINY_YOLOV2,
ELEMENT_TINY_YOLOV3,
ELEMENT_DETECTION_OVERLAY,
ELEMENTS_COUNT
};
template <SupportedElements el>
struct ElementsTraits {
enum { value = el };
static const char* name();
};
// wrapper for GstElement
class Element {
public:
typedef void (*pad_added_callback_t)(GstElement* self, GstPad* new_pad, gpointer user_data);
typedef void (*pad_removed_callback_t)(GstElement* self, GstPad* old_pad, gpointer user_data);
typedef void (*no_more_pads_callback_t)(GstElement* self, gpointer user_data);
std::string GetPluginName() const; // gst plugin name
std::string GetName() const;
bool IsValid() const;
GstElement* GetGstElement() const;
std::unique_ptr<pad::Pad> StaticPad(const gchar* name) const WARN_UNUSED_RESULT; // allocate pad::Pad
std::unique_ptr<pad::Pad> RequestPad(const gchar* name) const WARN_UNUSED_RESULT; // allocate pad::Pad
void ReleaseRequestedPad(pad::Pad* pad);
static std::unique_ptr<pad::Pad> LinkStaticAndStaticPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name)
WARN_UNUSED_RESULT; // allocate pad::Pad, static -> static
static std::unique_ptr<pad::Pad> LinkStaticAndRequestPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name)
WARN_UNUSED_RESULT; // allocate pad::Pad, static -> request
static std::unique_ptr<pad::Pad> LinkRequestAndStaticPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name)
WARN_UNUSED_RESULT; // allocate pad::Pad, request -> static
static bool LinkPads(GstPad* src, GstPad* sink) WARN_UNUSED_RESULT;
static bool LinkElementPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name) WARN_UNUSED_RESULT; // allocate pad::Pad
static void UnLinkElementPads(elements::Element* src,
elements::Element* sink,
const char* src_pad_name,
const char* sink_pad_name);
virtual ~Element();
void SetProperty(const char* property, bool val);
void SetProperty(const char* property, gfloat val);
void SetProperty(const char* property, gdouble val);
void SetProperty(const char* property, gint8 val);
void SetProperty(const char* property, guint8 val);
void SetProperty(const char* property, gint16 val);
void SetProperty(const char* property, guint16 val);
void SetProperty(const char* property, gint val);
void SetProperty(const char* property, guint val);
void SetProperty(const char* property, gint64 val);
void SetProperty(const char* property, guint64 val);
void SetProperty(const char* property, const char* val);
void SetProperty(const char* property, const std::string& val);
void SetProperty(const char* property, void* val);
void SetFractionProperty(const char* property, gint num, gint den);
GValue GetProperty(const char* property, GType type) const;
std::string GetStringProperty(const char* property) const;
static std::string GetElementName(GstElement* element);
static std::string GetPluginName(GstElement* element);
gboolean RegisterPadAddedCallback(pad_added_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
gboolean RegisterPadRemovedCallback(pad_removed_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
gboolean RegisterNoMorePadsCallback(no_more_pads_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
protected:
Element(const std::string& plugin_name,
const std::string& name); // allocate element
Element(const std::string& plugin_name,
const std::string& name,
GstElement* const element); // take poiner of element
gboolean RegisterCallback(const char* signal_name, GCallback cb, gpointer user_data) WARN_UNUSED_RESULT;
private:
void UnRegisterCallback(gulong signal_id);
const std::string name_;
const std::string plugin_name_;
GstElement* const element_;
std::vector<gulong> signals_;
};
template <SupportedElements el>
class ElementEx : public Element {
public:
typedef ElementsTraits<el> traits_t;
typedef Element base_class;
explicit ElementEx(const std::string& name) : Element(GetPluginName(), name) {} // allocate element
ElementEx(const std::string& name, GstElement* const element)
: Element(GetPluginName(), name, element) {} // take poiner of element, only wrap
static std::string GetPluginName() { return traits_t::name(); }
};
template <SupportedElements el>
class ElementBinEx : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
typedef void (*element_added_callback_t)(GstBin* bin, GstElement* element, gpointer user_data);
typedef void (*element_removed_callback_t)(GstBin* bin, GstElement* element, gpointer user_data);
typedef void (*element_deep_added_callback_t)(GstBin* bin, GstBin* sub_bin, GstElement* element, gpointer user_data);
typedef void (*element_deep_removed_callback_t)(GstBin* bin,
GstBin* sub_bin,
GstElement* element,
gpointer user_data);
GstElement* GetElementByName(const char* name) {
return gst_bin_get_by_name(GST_BIN(base_class::GetGstElement()), name);
}
gboolean RegisterElementAdded(element_added_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT {
return base_class::RegisterCallback("element-added", G_CALLBACK(cb), user_data);
}
gboolean RegisterElementRemoved(element_removed_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT {
return base_class::RegisterCallback("element-removed", G_CALLBACK(cb), user_data);
}
gboolean RegisterDeepElementAdded(element_deep_added_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT {
return base_class::RegisterCallback("deep-element-added", G_CALLBACK(cb), user_data);
}
gboolean RegisterDeepElementRemoved(element_deep_removed_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT {
return base_class::RegisterCallback("deep-element-removed", G_CALLBACK(cb), user_data);
}
};
// decoders elements
class ElementDecodebin : public ElementBinEx<ELEMENT_DECODEBIN> {
public:
typedef ElementBinEx<ELEMENT_DECODEBIN> base_class;
using base_class::base_class;
typedef gboolean (*autoplug_continue_callback_t)(GstElement* elem, GstPad* pad, GstCaps* caps, gpointer user_data);
typedef GValueArray* (*autoplug_sort_callback_t)(GstElement* bin,
GstPad* pad,
GstCaps* caps,
GValueArray* factories,
gpointer user_data);
typedef GstAutoplugSelectResult (*autoplug_select_callback_t)(GstElement* bin,
GstPad* pad,
GstCaps* caps,
GstElementFactory* factory,
gpointer user_data);
void SetUseBuffering(bool use_buffering = false); // Default: false
void SetMaxSizeBuffers(guint val = 200); // 0 - 4294967295 Default: 200
void SetMaxSizeTime(guint val = 10485760); // 0 - 4294967295 Default: 10485760
void SetMaxSizeBytes(guint64 val = 1000000000); // 0 - 18446744073709551615 Default: 1000000000
void SetEmpty();
gboolean RegisterAutoplugContinue(autoplug_continue_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
gboolean RegisterAutoplugSelect(autoplug_select_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
gboolean RegisterAutoplugSort(autoplug_sort_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
};
class ElementVaapiDecodebin : public ElementBinEx<ELEMENT_VAAPI_DECODEBIN> {
public:
typedef ElementBinEx<ELEMENT_VAAPI_DECODEBIN> base_class;
using base_class::base_class;
};
class ElementVaapiPostProc : public ElementBinEx<ELEMENT_VAAPI_POST_PROC> {
public:
typedef ElementBinEx<ELEMENT_VAAPI_POST_PROC> base_class;
using base_class::base_class;
void SetDinterlaceMode(gint deinterlace_method = 0); // Default value: Auto Detection (0),
// Allowed values: Auto Detection (0),
// Force Deinterlace (1),
// Never Deinterlace (2)
void SetFormat(gint format = 1); // Default value: Encoded (1),
void SetWidth(guint width = 0); // Range: 0 - 2147483647 Default: 0
void SetHeight(guint height = 0); // Range: 0 - 2147483647 Default: 0
void SetForceAspectRatio(bool ratio = true); // Default: true
void SetScaleMethod(guint met = 0); // Range: 1 - 2 Default: 0
void SetDeinerlaceMethod(guint met = 1); // Range: 1 - 4 Default: 1, "bob"
void SetDenoise(gfloat denoise = 0); // Range: [0,1] Default: 0"
void SetSkinToneEnhancement(bool val = false); // Default: false
};
class ElementMFXVpp : public ElementEx<ELEMENT_MFX_VPP> {
public:
typedef ElementEx<ELEMENT_MFX_VPP> base_class;
using base_class::base_class;
void SetForceAspectRatio(bool ratio = true); // Default: true
void SetWidth(gint width = 0); // Range: 0 - 2147483647 Default: 0
void SetHeight(gint height = 0); // Range: 0 - 2147483647 Default: 0
void SetFrameRate(const common::media::Rational& framerate); // Range: 0 - 2147483647 Default: 0
void SetDinterlaceMode(int mode);
};
class ElementMFXH264Decode : public ElementEx<ELEMENT_MFX_H264_DEC> {
public:
typedef ElementEx<ELEMENT_MFX_H264_DEC> base_class;
using base_class::base_class;
void SetLiveMode(bool mode = false); // Default: false
};
class ElementAvdecH264 : public ElementEx<ELEMENT_AVDEC_H264> {
public:
typedef ElementEx<ELEMENT_AVDEC_H264> base_class;
using base_class::base_class;
void SetMaxThreads(gint threads = 0); // Default value: 0 (auto), Allowed
// values: [0, 2147483647]
void SetSkipFrame(gint skip_frame = 0); // Default vaule: Skip Nothing (0)
// Allowed values: Skip Nothing (0),
// Skip B-Frames (1),
// Skip IDCT-Dequantization
// (2) Skip everything (5)
void SetOutputCorrupt(gboolean output_corrupt = true); // Default value: true
};
class ElementAvdecAc3 : public ElementEx<ELEMENT_AVDEC_AC3> {
public:
typedef ElementEx<ELEMENT_AVDEC_AC3> base_class;
using base_class::base_class;
};
class ElementAvdecAc3Fixed : public ElementEx<ELEMENT_AVDEC_AC3_FIXED> {
public:
typedef ElementEx<ELEMENT_AVDEC_AC3_FIXED> base_class;
using base_class::base_class;
};
// demuxer elements
class ElementHlsDemux : public ElementBinEx<ELEMENT_HLS_DEMUX> {
public:
typedef ElementBinEx<ELEMENT_HLS_DEMUX> base_class;
using base_class::base_class;
};
class ElementTsDemux : public ElementBinEx<ELEMENT_TS_DEMUX> {
public:
typedef ElementBinEx<ELEMENT_TS_DEMUX> base_class;
using base_class::base_class;
void SetParsePrivateSections(gboolean parse_private_sections = true); // Default value: true
void SetProgramNumber(gint number); // -1 - 2147483647 Default: -1
};
// common elements
class ElementQueue : public ElementEx<ELEMENT_QUEUE> {
public:
typedef ElementEx<ELEMENT_QUEUE> base_class;
using base_class::base_class;
void SetMaxSizeBuffers(guint val = 200); // 0 - 4294967295 Default: 200
void SetMaxSizeTime(guint val = 10485760); // 0 - 4294967295 Default: 10485760
void SetMaxSizeBytes(guint64 val = 1000000000); // 0 - 18446744073709551615 Default: 1000000000
void SetEmpty();
};
class ElementQueue2 : public ElementEx<ELEMENT_QUEUE2> {
public:
typedef ElementEx<ELEMENT_QUEUE2> base_class;
using base_class::base_class;
void SetMaxSizeBuffers(guint val = 100); // 0 - 4294967295 Default: 100
void SetMaxSizeTime(guint64 val = 2000000000); // 0 - 18446744073709551615 Default: 2000000000
void SetMaxSizeBytes(guint val = 2097152); // 0 - 4294967295 Default: 2097152
void SetUseBuffering(bool use_buffering = false); // true - false: false
};
class ElementTee : public ElementEx<ELEMENT_TEE> {
public:
typedef ElementEx<ELEMENT_TEE> base_class;
using base_class::base_class;
};
class ElementCapsFilter : public ElementEx<ELEMENT_CAPS_FILTER> {
public:
typedef ElementEx<ELEMENT_CAPS_FILTER> base_class;
using base_class::base_class;
void SetCaps(GstCaps* caps);
};
template <typename T>
T* make_element(const std::string& name) {
T* element = new T(name);
return element;
}
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,136 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/encoders/audio.h"
#include <string> // for string
#include <vector>
#include <gst/gstcaps.h>
#include <gst/gstelementfactory.h>
#include "base/constants.h" // for AUDIO_CODEC, DEFAULT_VOLUME, UDB_...
#include "base/gst_constants.h" // for VOAAC_ENC
#include "stream/elements/audio/audio.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace encoders {
void ElementFAAC::SetRateControl(guint brtype) {
SetProperty("rate-control", brtype);
}
void ElementMP3Enc::SetTarget(guint target) {
SetProperty("target", target);
}
ElementFAAC* make_aac_encoder(element_id_t encoder_id) {
return make_audio_encoder<ElementFAAC>(encoder_id);
}
ElementVoaacEnc* make_voaac_encoder(element_id_t encoder_id) {
return make_audio_encoder<ElementVoaacEnc>(encoder_id);
}
ElementFAAC* make_mp3_encoder(element_id_t encoder_id) {
return make_audio_encoder<ElementFAAC>(encoder_id);
}
Element* make_audio_encoder(const std::string& codec, const std::string& name, bit_rate_t audiorate) {
if (codec == ElementFAAC::GetPluginName()) {
ElementFAAC* aac = new ElementFAAC(name);
if (audiorate) {
aac->SetRateControl(2);
aac->SetBitRate(*audiorate);
}
return aac;
} else if (codec == ElementVoaacEnc::GetPluginName()) {
ElementVoaacEnc* aac = new ElementVoaacEnc(name);
if (audiorate) {
aac->SetBitRate(*audiorate);
}
return aac;
} else if (codec == ElementMP3Enc::GetPluginName()) {
ElementMP3Enc* mp3 = new ElementMP3Enc(name);
if (audiorate) {
mp3->SetTarget(1);
mp3->SetBitRate(*audiorate);
}
return mp3;
}
NOTREACHED() << "Please register new audio encoder type: " << codec;
return nullptr;
}
Element* make_audio_encoder(const std::string& codec, const std::string& name) {
if (codec == ElementFAAC::GetPluginName()) {
ElementFAAC* aac = new ElementFAAC(name);
return aac;
} else if (codec == ElementVoaacEnc::GetPluginName()) {
ElementVoaacEnc* aac = new ElementVoaacEnc(name);
return aac;
} else if (codec == ElementMP3Enc::GetPluginName()) {
ElementMP3Enc* mp3 = new ElementMP3Enc(name);
return mp3;
}
NOTREACHED() << "Please register new audio encoder type: " << codec;
return nullptr;
}
elements_line_t build_audio_converters(volume_t volume,
audio_channels_count_t achannels,
ILinker* linker,
element_id_t audio_convert_id) {
elements::audio::ElementAudioConvert* audio_convert =
new elements::audio::ElementAudioConvert(common::MemSPrintf(AUDIO_CONVERT_NAME_1U, audio_convert_id));
elements::Element* first = audio_convert;
elements::Element* last = audio_convert;
linker->ElementAdd(audio_convert);
if (achannels) {
elements::ElementCapsFilter* caps =
new elements::ElementCapsFilter(common::MemSPrintf(AUDIO_CONVERT_CAPS_FILTER_NAME_1U, audio_convert_id));
GstCaps* cap_convert = gst_caps_new_simple("audio/x-raw", "channels", G_TYPE_INT, *achannels, nullptr);
caps->SetCaps(cap_convert);
gst_caps_unref(cap_convert);
linker->ElementAdd(caps);
linker->ElementLink(audio_convert, caps);
last = caps;
}
if (volume) {
audio::ElementVolume* vol = new audio::ElementVolume(common::MemSPrintf(VOLUME_NAME_1U, audio_convert_id));
vol->SetVolume(*volume);
linker->ElementAdd(vol);
linker->ElementLink(last, vol);
return {first, vol};
}
return {first, last};
}
bool IsAACEncoder(const std::string& encoder) {
return encoder == ElementFAAC::GetPluginName() || encoder == ElementVoaacEnc::GetPluginName();
}
} // namespace encoders
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,91 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string> // for string
#include <common/sprintf.h>
#include "base/types.h"
#include "stream/gst_types.h"
#include "stream/ilinker.h" // for ILinker (ptr only), elements_line_t
#include "stream/stypes.h"
// for element_id_t, AUDIO_CODEC_NAME_1U
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace encoders {
template <SupportedElements el>
class ElementAudioEncoder : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
void SetBitRate(gint bitrate) { ElementEx<el>::SetProperty("bitrate", bitrate); }
};
class ElementFAAC : public ElementAudioEncoder<ELEMENT_FAAC> {
public:
typedef ElementAudioEncoder<ELEMENT_FAAC> base_class;
using base_class::base_class;
void SetRateControl(guint brtype = 1); // Default value: VBR (1)
// Allowed values: VBR (1), ABR (2)
};
class ElementVoaacEnc : public ElementAudioEncoder<ELEMENT_VOAAC_ENC> {
public:
typedef ElementAudioEncoder<ELEMENT_VOAAC_ENC> base_class;
using base_class::base_class;
};
class ElementMP3Enc : public ElementAudioEncoder<ELEMENT_LAME_MP3_ENC> {
public:
typedef ElementAudioEncoder<ELEMENT_LAME_MP3_ENC> base_class;
using base_class::base_class;
void SetTarget(guint target = 0); // Default: 0, "quality"
// (0): quality - Quality
// (1): bitrate - Bitrate
};
template <typename T>
T* make_audio_encoder(element_id_t encoder_id) {
return make_element<T>(common::MemSPrintf(AUDIO_CODEC_NAME_1U, encoder_id));
}
ElementFAAC* make_aac_encoder(element_id_t encoder_id);
ElementVoaacEnc* make_voaac_encoder(element_id_t encoder_id);
ElementFAAC* make_mp3_encoder(element_id_t encoder_id);
Element* make_audio_encoder(const std::string& codec, const std::string& name, bit_rate_t audiorate);
Element* make_audio_encoder(const std::string& codec, const std::string& name);
elements_line_t build_audio_converters(volume_t volume,
audio_channels_count_t achannels,
ILinker* linker,
element_id_t audio_convert_id);
bool IsAACEncoder(const std::string& encoder);
} // namespace encoders
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,215 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/encoders/video.h"
#include <gst/gstvalue.h>
#include <string>
#include "base/gst_constants.h"
#include "stream/elements/video/video.h"
#define QUEUE_MAX_SIZE_BYTES 1024 * 1024 * 10
#define VIDEO_SCALE_POST_NAME_1U "videoscale_post_%lu"
// https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-deinterlace.html
namespace fastocloud {
namespace stream {
namespace elements {
namespace encoders {
void ElementMFXH264Enc::SetIDRInterval(guint idr) {
SetProperty("idr-interval", idr);
}
Element* build_video_scale(int width, int height, ILinker* linker, Element* link_to, element_id_t video_scale_id) {
// CPU scale
auto scale = new video::ElementVideoScale(common::MemSPrintf(VIDEO_SCALE_NAME_1U, video_scale_id));
linker->ElementAdd(scale);
ElementCapsFilter* capsfilter =
new ElementCapsFilter(common::MemSPrintf(VIDEO_SCALE_CAPS_FILTER_NAME_1U, video_scale_id));
linker->ElementAdd(capsfilter);
GstCaps* cap_width_height =
gst_caps_new_simple("video/x-raw", "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, nullptr);
capsfilter->SetCaps(cap_width_height);
gst_caps_unref(cap_width_height);
linker->ElementLink(link_to, scale);
linker->ElementLink(scale, capsfilter);
return capsfilter;
}
Element* build_video_framerate(const common::media::Rational& framerate,
ILinker* linker,
Element* link_to,
element_id_t video_framerate_id) {
video::ElementVideoRate* videorate =
new video::ElementVideoRate(common::MemSPrintf(VIDEO_RATE_NAME_1U, video_framerate_id));
ElementCapsFilter* capsfilter =
new ElementCapsFilter(common::MemSPrintf(VIDEO_RATE_CAPS_FILTER_NAME_1U, video_framerate_id));
linker->ElementAdd(videorate);
linker->ElementAdd(capsfilter);
GstCaps* cap_framerate =
gst_caps_new_simple("video/x-raw", "framerate", GST_TYPE_FRACTION, framerate.num, framerate.den, nullptr);
capsfilter->SetCaps(cap_framerate);
gst_caps_unref(cap_framerate);
linker->ElementLink(link_to, videorate);
linker->ElementLink(videorate, capsfilter);
return capsfilter;
}
ElementX264Enc* make_h264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementX264Enc>(encoder_id);
}
ElementX265Enc* make_h265_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementX265Enc>(encoder_id);
}
ElementMPEG2Enc* make_mpeg2_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementMPEG2Enc>(encoder_id);
}
ElementEAVCEnc* make_eavc_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementEAVCEnc>(encoder_id);
}
ElementOpenH264Enc* make_openh264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementOpenH264Enc>(encoder_id);
}
ElementVAAPIH264Enc* make_vaapi_h264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementVAAPIH264Enc>(encoder_id);
}
ElementVAAPIMpeg2Enc* make_vaapi_mpeg2_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementVAAPIMpeg2Enc>(encoder_id);
}
ElementMFXH264Enc* make_mfx_h264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementMFXH264Enc>(encoder_id);
}
ElementNvH264Enc* make_nv_h264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementNvH264Enc>(encoder_id);
}
ElementNvH265Enc* make_nv_h265_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementNvH265Enc>(encoder_id);
}
ElementMsdkH264Enc* make_msdk_h264_encoder(element_id_t encoder_id) {
return make_video_encoder<ElementMsdkH264Enc>(encoder_id);
}
Element* make_video_encoder(const std::string& codec, const std::string& name) {
if (codec == ElementX264Enc::GetPluginName()) {
return new ElementX264Enc(name);
} else if (codec == ElementX265Enc::GetPluginName()) {
ElementX265Enc* x265 = new ElementX265Enc(name);
return x265;
} else if (codec == ElementMPEG2Enc::GetPluginName()) {
return new ElementMPEG2Enc(name);
} else if (codec == ElementVAAPIH264Enc::GetPluginName()) {
return new ElementVAAPIH264Enc(name);
} else if (codec == ElementVAAPIMpeg2Enc::GetPluginName()) {
return new ElementVAAPIMpeg2Enc(name);
} else if (codec == ElementMFXH264Enc::GetPluginName()) {
ElementMFXH264Enc* mfx = new ElementMFXH264Enc(name);
return mfx;
} else if (codec == ElementOpenH264Enc::GetPluginName()) {
return new ElementOpenH264Enc(name);
} else if (codec == ElementEAVCEnc::GetPluginName()) {
return new ElementEAVCEnc(name);
} else if (codec == ElementNvH264Enc::GetPluginName()) {
return new ElementNvH264Enc(name);
} else if (codec == ElementNvH265Enc::GetPluginName()) {
return new ElementNvH265Enc(name);
} else if (codec == ElementMsdkH264Enc::GetPluginName()) {
return new ElementMsdkH264Enc(name);
}
NOTREACHED() << "Please register new video encoder type: " << codec;
return nullptr;
}
elements_line_t build_video_convert(deinterlace_t deinterlace, ILinker* linker, element_id_t video_convert_id) {
video::ElementVideoConvert* video_convert =
new video::ElementVideoConvert(common::MemSPrintf(VIDEO_CONVERT_NAME_1U, video_convert_id));
linker->ElementAdd(video_convert);
Element* first = video_convert;
Element* last = video_convert;
if (deinterlace && *deinterlace) {
std::string deinterlace_str = AV_DEINTERLACE;
Element* deinter =
video::make_video_deinterlace(deinterlace_str, common::MemSPrintf(DEINTERLACE_NAME_1U, video_convert_id));
linker->ElementAdd(deinter);
linker->ElementLink(last, deinter);
last = deinter;
}
return {first, last};
}
Element* build_video_encoder(const std::string& codec, bit_rate_t video_bitrate, element_id_t encoder_id) {
Element* codec_element = make_video_encoder(codec, common::MemSPrintf(VIDEO_CODEC_NAME_1U, encoder_id));
if (video_bitrate) {
int bitrate = *video_bitrate;
if (codec_element->GetPluginName() == ElementEAVCEnc::GetPluginName()) {
codec_element->SetProperty("bitrate-avg", bitrate);
} else {
if (codec_element->GetPluginName() == ElementOpenH264Enc::GetPluginName()) {
// bits per second
} else if (codec_element->GetPluginName() == ElementNvH264Enc::GetPluginName()) {
bitrate /= 1024;
codec_element->SetProperty("rc-mode", 2); // constant
} else if (codec_element->GetPluginName() == ElementNvH265Enc::GetPluginName()) {
bitrate /= 1024;
codec_element->SetProperty("rc-mode", 1); // constant
} else if (codec_element->GetPluginName() == ElementX264Enc::GetPluginName()) {
bitrate /= 1024;
} else if (codec_element->GetPluginName() == ElementX265Enc::GetPluginName()) {
bitrate /= 1024;
} else if (codec_element->GetPluginName() == ElementVAAPIH264Enc::GetPluginName()) {
codec_element->SetProperty("rate-control", 2); // constant
} else if (codec_element->GetPluginName() == ElementMFXH264Enc::GetPluginName()) {
codec_element->SetProperty("rate-control", 1); // constant
}
codec_element->SetProperty("bitrate", bitrate);
}
}
return codec_element;
}
bool IsH264Encoder(const std::string& encoder) {
return encoder == ElementX264Enc::GetPluginName() || encoder == ElementVAAPIH264Enc::GetPluginName() ||
encoder == ElementOpenH264Enc::GetPluginName() || encoder == ElementNvH264Enc::GetPluginName() ||
encoder == ElementMFXH264Enc::GetPluginName();
}
} // namespace encoders
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,134 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
#include "stream/gst_types.h"
#include "stream/ilinker.h" // for ILinker (ptr only), elements_line_t
#include "stream/stypes.h"
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace encoders {
class ElementMsdkH264Enc : public ElementEx<ELEMENT_MSDK_H264_ENC> {
public:
typedef ElementEx<ELEMENT_MSDK_H264_ENC> base_class;
using base_class::base_class;
};
class ElementNvH264Enc : public ElementEx<ELEMENT_NV_H264_ENC> {
public:
typedef ElementEx<ELEMENT_NV_H264_ENC> base_class;
using base_class::base_class;
};
class ElementNvH265Enc : public ElementEx<ELEMENT_NV_H265_ENC> {
public:
typedef ElementEx<ELEMENT_NV_H265_ENC> base_class;
using base_class::base_class;
};
class ElementX264Enc : public ElementEx<ELEMENT_X264_ENC> {
public:
typedef ElementEx<ELEMENT_X264_ENC> base_class;
using base_class::base_class;
};
class ElementX265Enc : public ElementEx<ELEMENT_X265_ENC> {
public:
typedef ElementEx<ELEMENT_X265_ENC> base_class;
using base_class::base_class;
};
class ElementMPEG2Enc : public ElementEx<ELEMENT_MPEG2_ENC> {
public:
typedef ElementEx<ELEMENT_MPEG2_ENC> base_class;
using base_class::base_class;
};
class ElementEAVCEnc : public ElementEx<ELEMENT_EAVC_ENC> {
public:
typedef ElementEx<ELEMENT_EAVC_ENC> base_class;
using base_class::base_class;
};
class ElementOpenH264Enc : public ElementEx<ELEMENT_OPEN_H264_ENC> {
public:
typedef ElementEx<ELEMENT_OPEN_H264_ENC> base_class;
using base_class::base_class;
};
class ElementVAAPIH264Enc : public ElementEx<ELEMENT_VAAPI_H264_ENC> {
public:
typedef ElementEx<ELEMENT_VAAPI_H264_ENC> base_class;
using base_class::base_class;
};
class ElementVAAPIMpeg2Enc : public ElementEx<ELEMENT_VAAPI_MPEG2_ENC> {
public:
typedef ElementEx<ELEMENT_VAAPI_MPEG2_ENC> base_class;
using base_class::base_class;
};
class ElementMFXH264Enc : public ElementEx<ELEMENT_MFX_H264_ENC> {
public:
typedef ElementEx<ELEMENT_MFX_H264_ENC> base_class;
using base_class::base_class;
void SetIDRInterval(guint idr = 0); // Range: 0 - 2147483647 Default: 0
};
Element* build_video_scale(int width, int height, ILinker* linker, Element* link_to, element_id_t video_scale_id);
Element* build_video_framerate(const common::media::Rational& framerate,
ILinker* linker,
Element* link_to,
element_id_t video_framerate_id); // framerate = num/den
template <typename T>
T* make_video_encoder(element_id_t encoder_id) {
return make_element<T>(common::MemSPrintf(VIDEO_CODEC_NAME_1U, encoder_id));
}
ElementX264Enc* make_h264_encoder(element_id_t encoder_id);
ElementX265Enc* make_h265_encoder(element_id_t encoder_id);
ElementMPEG2Enc* make_mpeg2_encoder(element_id_t encoder_id);
ElementEAVCEnc* make_eavc_encoder(element_id_t encoder_id);
ElementOpenH264Enc* make_openh264_encoder(element_id_t encoder_id);
ElementVAAPIH264Enc* make_vaapi_h264_encoder(element_id_t encoder_id);
ElementVAAPIMpeg2Enc* make_vaapi_mpeg2_encoder(element_id_t encoder_id);
ElementMFXH264Enc* make_mfx_h264_encoder(element_id_t encoder_id);
ElementNvH264Enc* make_nv_h264_encoder(element_id_t encoder_id);
ElementNvH265Enc* make_nv_h265_encoder(element_id_t encoder_id);
ElementMsdkH264Enc* make_msdk_h264_encoder(element_id_t encoder_id);
Element* make_video_encoder(const std::string& codec, const std::string& name);
elements_line_t build_video_convert(deinterlace_t deinterlace, ILinker* linker, element_id_t video_convert_id);
Element* build_video_encoder(const std::string& codec, bit_rate_t video_bitrate, element_id_t encoder_id);
bool IsH264Encoder(const std::string& encoder);
} // namespace encoders
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,29 @@
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/machine_learning/detectionoverlay.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
void ElementDetectionOverlay::SetLabels(const std::string& labels) {
return SetProperty("labels", labels);
}
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,37 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
class ElementDetectionOverlay : public ElementEx<ELEMENT_DETECTION_OVERLAY> {
public:
typedef ElementEx<ELEMENT_DETECTION_OVERLAY> base_class;
using base_class::base_class;
void SetLabels(const std::string& labels);
};
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/machine_learning/tinyyolov2.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,43 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/machine_learning/video_ml_filter.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
class ElementTinyYolov2 : public ElementVideoMLFilter {
public:
enum MatrixSize { width = 416, height = 416 };
typedef ElementsTraits<ELEMENT_TINY_YOLOV2> traits_t;
typedef ElementVideoMLFilter base_class;
explicit ElementTinyYolov2(const std::string& name) : base_class(GetPluginName(), name) {} // allocate element
ElementTinyYolov2(const std::string& name, GstElement* const element)
: base_class(GetPluginName(), name, element) {} // take poiner of element, only wrap
static std::string GetPluginName() { return traits_t::name(); }
};
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/machine_learning/tinyyolov3.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,43 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/machine_learning/video_ml_filter.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
class ElementTinyYolov3 : public ElementVideoMLFilter {
public:
enum MatrixSize { width = 416, height = 416 };
typedef ElementsTraits<ELEMENT_TINY_YOLOV3> traits_t;
typedef ElementVideoMLFilter base_class;
explicit ElementTinyYolov3(const std::string& name) : base_class(GetPluginName(), name) {} // allocate element
ElementTinyYolov3(const std::string& name, GstElement* const element)
: base_class(GetPluginName(), name, element) {} // take poiner of element, only wrap
static std::string GetPluginName() { return traits_t::name(); }
};
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/machine_learning/video_ml_filter.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
void ElementVideoMLFilter::SetBackend(GstBackend* backend) {
SetProperty("backend", backend);
}
gboolean ElementVideoMLFilter::RegisterNewPredictionCallback(new_prediction_callback_t cb, gpointer user_data) {
return RegisterCallback("new-prediction", G_CALLBACK(cb), user_data);
}
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,46 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <utility>
#include <vector>
#include <common/sprintf.h>
#include "stream/elements/element.h"
typedef struct _GstBackend GstBackend;
namespace fastocloud {
namespace stream {
namespace elements {
namespace machine_learning {
class ElementVideoMLFilter : public Element {
public:
typedef Element base_class;
typedef void (*new_prediction_callback_t)(GstElement* elem, gpointer meta, gpointer user_data);
using base_class::base_class;
void SetBackend(GstBackend* backend);
gboolean RegisterNewPredictionCallback(new_prediction_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
};
} // namespace machine_learning
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,60 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/muxer/muxer.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace muxer {
ElementFLVMux* make_flvmux(bool streamable, element_id_t muxer_id) {
ElementFLVMux* flvmux = make_muxer<ElementFLVMux>(muxer_id);
flvmux->SetStreamable(streamable);
return flvmux;
}
ElementMPEGTSMux* make_mpegtsmux(element_id_t muxer_id) {
return make_muxer<ElementMPEGTSMux>(muxer_id);
}
ElementRTPMux* make_rtpmux(element_id_t muxer_id) {
return make_muxer<ElementRTPMux>(muxer_id);
}
Element* make_muxer(const common::uri::GURL& url, element_id_t muxer_id) {
if (url.SchemeIsRtmp()) {
return make_flvmux(true, muxer_id);
} else if (url.SchemeIsUdp()) {
return make_rtpmux(muxer_id);
} else if (url.SchemeIsTcp()) {
return make_mpegtsmux(muxer_id);
} else if (url.SchemeIsHTTPOrHTTPS()) {
return make_mpegtsmux(muxer_id);
} else if (url.SchemeIsSrt()) {
return make_mpegtsmux(muxer_id);
}
NOTREACHED() << "Unknown output url: " << url.spec();
return nullptr;
}
void ElementFLVMux::SetStreamable(bool streamable) {
SetProperty("streamable", streamable);
}
} // namespace muxer
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,57 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <common/sprintf.h>
#include "stream/elements/element.h"
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace muxer {
class ElementMPEGTSMux : public ElementEx<ELEMENT_MPEGTS_MUX> {
public:
typedef ElementEx<ELEMENT_MPEGTS_MUX> base_class;
using base_class::base_class;
};
typedef ElementEx<ELEMENT_RTP_MUX> ElementRTPMux;
class ElementFLVMux : public ElementEx<ELEMENT_FLV_MUX> {
public:
typedef ElementEx<ELEMENT_FLV_MUX> base_class;
using base_class::base_class;
void SetStreamable(bool streamable = false); // Default: false
};
template <typename T>
T* make_muxer(element_id_t muxer_id) {
return make_element<T>(common::MemSPrintf(MUXER_NAME_1U, muxer_id));
}
ElementFLVMux* make_flvmux(bool streamable, element_id_t muxer_id);
ElementRTPMux* make_rtpmux(element_id_t muxer_id);
ElementMPEGTSMux* make_mpegtsmux(element_id_t muxer_id);
Element* make_muxer(const common::uri::GURL& url, element_id_t muxer_id);
} // namespace muxer
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,67 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/parser/audio.h"
#include <string>
#include <common/sprintf.h>
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {
namespace {
template <typename T>
T* make_audio_parser(element_id_t parser_id) {
return make_element<T>(common::MemSPrintf(AUDIO_PARSER_NAME_1U, parser_id));
}
} // namespace
ElementAACParse* make_aac_parser(element_id_t parser_id) {
return make_audio_parser<ElementAACParse>(parser_id);
}
ElementMPEGAudioParse* make_mpeg_parser(element_id_t parser_id) {
return make_audio_parser<ElementMPEGAudioParse>(parser_id);
}
ElementAC3Parse* make_ac3_parser(element_id_t parser_id) {
return make_audio_parser<ElementAC3Parse>(parser_id);
}
ElementRawAudioParse* make_raw_parser(element_id_t parser_id) {
return make_audio_parser<ElementRawAudioParse>(parser_id);
}
Element* make_audio_parser(const std::string& parser, const std::string& name) {
if (parser == ElementAACParse::GetPluginName()) {
return new ElementAACParse(name);
} else if (parser == ElementAC3Parse::GetPluginName()) {
return new ElementAC3Parse(name);
} else if (parser == ElementMPEGAudioParse::GetPluginName()) {
return new ElementMPEGAudioParse(name);
} else if (parser == ElementRawAudioParse::GetPluginName()) {
return new ElementRawAudioParse(name);
}
NOTREACHED() << "Please register new audio parser type: " << parser;
return nullptr;
}
} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,62 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/stypes.h"
#include "stream/elements/parser/parser.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {
class ElementAACParse : public ElementBaseParse<ELEMENT_AAC_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_AAC_PARSE> base_class;
using base_class::base_class;
};
class ElementAC3Parse : public ElementBaseParse<ELEMENT_AC3_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_AC3_PARSE> base_class;
using base_class::base_class;
};
class ElementMPEGAudioParse : public ElementBaseParse<ELEMENT_MPEG_AUDIO_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_MPEG_AUDIO_PARSE> base_class;
using base_class::base_class;
};
class ElementRawAudioParse : public ElementBaseParse<ELEMENT_RAW_AUDIO_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_RAW_AUDIO_PARSE> base_class;
using base_class::base_class;
};
ElementAACParse* make_aac_parser(element_id_t parser_id);
ElementAC3Parse* make_ac3_parser(element_id_t parser_id);
ElementMPEGAudioParse* make_mpeg_parser(element_id_t parser_id);
ElementRawAudioParse* make_raw_parser(element_id_t parser_id);
Element* make_audio_parser(const std::string& parser, const std::string& name);
} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/parser/parser.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,34 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {
template <SupportedElements el>
class ElementBaseParse : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
};
} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,79 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/parser/video.h"
#include <string>
#include <common/sprintf.h>
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {
namespace {
template <typename T>
T* make_video_parser(element_id_t parser_id) {
return make_element<T>(common::MemSPrintf(VIDEO_PARSER_NAME_1U, parser_id));
}
} // namespace
void ElementH264Parse::SetConfigInterval(gint interval) {
SetProperty("config-interval", interval);
}
void ElementH264Parse::SetDisablePassthrough(gboolean pass) {
SetProperty("disable-passthrough", pass);
}
void ElementH265Parse::SetConfigInterval(gint interval) {
SetProperty("config-interval", interval);
}
ElementMpegParse* make_mpeg2_parser(element_id_t parser_id) {
return make_video_parser<ElementMpegParse>(parser_id);
}
ElementTsParse* make_ts_parser(element_id_t parser_id) {
return make_video_parser<ElementTsParse>(parser_id);
}
ElementH264Parse* make_h264_parser(element_id_t parser_id) {
return make_video_parser<ElementH264Parse>(parser_id);
}
ElementH265Parse* make_h265_parser(element_id_t parser_id) {
return make_video_parser<ElementH265Parse>(parser_id);
}
Element* make_video_parser(const std::string& parser, const std::string& name) {
if (parser == ElementH264Parse::GetPluginName()) {
return new ElementH264Parse(name);
} else if (parser == ElementH265Parse::GetPluginName()) {
return new ElementH265Parse(name);
} else if (parser == ElementMpegParse::GetPluginName()) {
return new ElementMpegParse(name);
} else if (parser == ElementTsParse::GetPluginName()) {
return new ElementTsParse(name);
}
NOTREACHED() << "Please register new video parser type: " << parser;
return nullptr;
}
} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,67 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/stypes.h"
#include "stream/elements/parser/parser.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace parser {
class ElementH264Parse : public ElementBaseParse<ELEMENT_H264_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_H264_PARSE> base_class;
using base_class::base_class;
void SetConfigInterval(gint interval = 0); // Range: -1 - 3600 Default: 0
void SetDisablePassthrough(gboolean pass);
};
class ElementH265Parse : public ElementBaseParse<ELEMENT_H265_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_H265_PARSE> base_class;
using base_class::base_class;
void SetConfigInterval(gint interval = 0); // Range: -1 - 3600 Default: 0
};
class ElementMpegParse : public ElementBaseParse<ELEMENT_MPEG_VIDEO_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_MPEG_VIDEO_PARSE> base_class;
using base_class::base_class;
};
class ElementTsParse : public ElementBaseParse<ELEMENT_TS_PARSE> {
public:
typedef ElementBaseParse<ELEMENT_TS_PARSE> base_class;
using base_class::base_class;
};
ElementMpegParse* make_mpeg2_parser(element_id_t parser_id);
ElementTsParse* make_ts_parser(element_id_t parser_id);
ElementH264Parse* make_h264_parser(element_id_t parser_id);
ElementH265Parse* make_h265_parser(element_id_t parser_id);
Element* make_video_parser(const std::string& parser, const std::string& name);
} // namespace parser
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,48 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/pay/audio.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {
ElementRtpAACPay* make_aac_pay(guint pt, element_id_t pay_id) {
ElementRtpAACPay* aac_pay = make_audio_pay<ElementRtpAACPay>(pay_id);
aac_pay->SetPt(pt);
return aac_pay;
}
ElementRtpAC3Pay* make_ac3_pay(guint pt, element_id_t pay_id) {
ElementRtpAC3Pay* aac_pay = make_audio_pay<ElementRtpAC3Pay>(pay_id);
aac_pay->SetPt(pt);
return aac_pay;
}
Element* make_audio_pay(const std::string& pay, const std::string& name) {
if (pay == ElementRtpAACPay::GetPluginName()) {
return new ElementRtpAACPay(name);
} else if (pay == ElementRtpAC3Pay::GetPluginName()) {
return new ElementRtpAC3Pay(name);
}
NOTREACHED();
return nullptr;
}
} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,56 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
#include "stream/stypes.h"
#include "stream/elements/element.h" // for Element (ptr only), SupportedElements:...
#include "stream/elements/pay/pay.h" // for ElementRtpPay
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {
class ElementRtpAACPay : public ElementRtpPay<ELEMENT_RTP_AAC_PAY> {
public:
typedef ElementRtpPay<ELEMENT_RTP_AAC_PAY> base_class;
using base_class::base_class;
};
class ElementRtpAC3Pay : public ElementRtpPay<ELEMENT_RTP_AC3_PAY> {
public:
typedef ElementRtpPay<ELEMENT_RTP_AC3_PAY> base_class;
using base_class::base_class;
};
template <typename T>
T* make_audio_pay(element_id_t pay_id) {
return make_element<T>(common::MemSPrintf(AUDIO_PAY_NAME_1U, pay_id));
}
ElementRtpAACPay* make_aac_pay(guint pt, element_id_t pay_id);
ElementRtpAC3Pay* make_ac3_pay(guint pt, element_id_t pay_id);
Element* make_audio_pay(const std::string& pay, const std::string& name);
} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/pay/pay.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,36 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {
template <SupportedElements el>
class ElementRtpPay : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
void SetPt(guint pt) { ElementEx<el>::SetProperty("pt", pt); }
};
} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,56 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/pay/video.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {
ElementRtpMPEG2Pay* make_mpeg2_pay(guint pt, element_id_t pay_id) {
ElementRtpMPEG2Pay* h264_pay = make_video_pay<ElementRtpMPEG2Pay>(pay_id);
h264_pay->SetPt(pt);
return h264_pay;
}
ElementRtpH264Pay* make_h264_pay(guint pt, element_id_t pay_id) {
ElementRtpH264Pay* h264_pay = make_video_pay<ElementRtpH264Pay>(pay_id);
h264_pay->SetPt(pt);
return h264_pay;
}
ElementRtpH265Pay* make_h265_pay(guint pt, element_id_t pay_id) {
ElementRtpH265Pay* h265_pay = make_video_pay<ElementRtpH265Pay>(pay_id);
h265_pay->SetPt(pt);
return h265_pay;
}
Element* make_video_pay(const std::string& pay, const std::string& name) {
if (pay == ElementRtpH264Pay::GetPluginName()) {
return new ElementRtpH264Pay(name);
} else if (pay == ElementRtpH265Pay::GetPluginName()) {
return new ElementRtpH265Pay(name);
} else if (pay == ElementRtpMPEG2Pay::GetPluginName()) {
return new ElementRtpMPEG2Pay(name);
}
NOTREACHED();
return nullptr;
}
} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,65 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
// for element_id_t, VIDEO_PAY_NAME_1U
#include "stream/elements/element.h" // for Element (ptr only), SupportedElements:...
#include "stream/elements/pay/pay.h" // for ElementRtpPay
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace pay {
class ElementRtpMPEG2Pay : public ElementRtpPay<ELEMENT_RTP_MPEG2_PAY> {
public:
typedef ElementRtpPay<ELEMENT_RTP_MPEG2_PAY> base_class;
using base_class::base_class;
};
class ElementRtpH264Pay : public ElementRtpPay<ELEMENT_RTP_H264_PAY> {
public:
typedef ElementRtpPay<ELEMENT_RTP_H264_PAY> base_class;
using base_class::base_class;
};
class ElementRtpH265Pay : public ElementRtpPay<ELEMENT_RTP_H265_PAY> {
public:
typedef ElementRtpPay<ELEMENT_RTP_H265_PAY> base_class;
using base_class::base_class;
};
template <typename T>
T* make_video_pay(element_id_t pay_id) {
return make_element<T>(common::MemSPrintf(VIDEO_PAY_NAME_1U, pay_id));
}
ElementRtpMPEG2Pay* make_mpeg2_pay(guint pt, element_id_t pay_id);
ElementRtpH264Pay* make_h264_pay(guint pt, element_id_t pay_id);
ElementRtpH265Pay* make_h265_pay(guint pt, element_id_t pay_id);
Element* make_video_pay(const std::string& pay, const std::string& name);
} // namespace pay
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,76 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/build_output.h"
#include <string>
#include "stream/elements/sink/file.h"
#include "stream/elements/sink/http.h" // for build_http_sink, HlsOutput
#include "stream/elements/sink/rtmp.h" // for build_rtmp_sink
#include "stream/elements/sink/srt.h"
#include "stream/elements/sink/tcp.h"
#include "stream/elements/sink/udp.h" // for build_udp_sink
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
Element* build_output(const fastotv::OutputUri& output, element_id_t sink_id, bool is_vod, bool is_cod) {
common::uri::GURL uri = output.GetUrl();
if (uri.SchemeIsUdp()) {
common::net::HostAndPort host(uri.host(), uri.EffectiveIntPort());
ElementUDPSink* udp_sink = elements::sink::make_udp_sink(host, sink_id);
return udp_sink;
} else if (uri.SchemeIsTcp()) {
common::net::HostAndPort host(uri.host(), uri.EffectiveIntPort());
ElementTCPServerSink* tcp_sink = elements::sink::make_tcp_server_sink(host, sink_id);
return tcp_sink;
} else if (uri.SchemeIsRtmp()) {
ElementRtmpSink* rtmp_sink = elements::sink::make_rtmp_sink(sink_id, uri.spec());
return rtmp_sink;
} else if (uri.SchemeIsHTTPOrHTTPS()) {
const auto http_root = output.GetHttpRoot();
elements::sink::HlsOutput hout;
common::Error err = is_vod ? MakeVodHlsOutput(uri, http_root, &hout) : MakeHlsOutput(uri, http_root, &hout);
if (err) {
NOTREACHED() << err->GetDescription();
return nullptr;
}
ElementHLSSink* http_sink =
elements::sink::make_http_sink(sink_id, hout, is_cod ? CODS_TS_DURATION : HTTP_TS_DURATION);
return http_sink;
} else if (uri.SchemeIsSrt()) {
int srt_mode = fastotv::OutputUri::CALLER;
auto mode = output.GetSrtMode();
if (mode) {
srt_mode = *mode;
}
ElementSrtSink* srt_sink = elements::sink::make_srt_sink(uri.spec(), srt_mode, sink_id);
return srt_sink;
} else if (uri.SchemeIsFile()) {
ElementFileSink* file_sink = elements::sink::make_file_sink(uri.path(), sink_id);
return file_sink;
}
NOTREACHED() << "Unknown output url: " << uri.spec();
return nullptr;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <fastotv/types/output_uri.h>
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
class Element;
namespace sink {
Element* build_output(const fastotv::OutputUri& output, element_id_t sink_id, bool is_vod, bool is_cod);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/fake.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
ElementFakeSink* make_fake_sink(element_id_t sink_id) {
ElementFakeSink* fake_sink = make_sink<ElementFakeSink>(sink_id);
fake_sink->SetSync(true);
return fake_sink;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h" // for SupportedElements::ELEMENT_FAKE_SINK
#include "stream/elements/sink/sink.h" // for ElementBaseSink
#include "stream/stypes.h"
// for element_id_
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementFakeSink : public ElementBaseSink<ELEMENT_FAKE_SINK> {
public:
typedef ElementBaseSink<ELEMENT_FAKE_SINK> base_class;
using base_class::base_class;
};
ElementFakeSink* make_fake_sink(element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,35 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/file.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
ElementFileSink* make_file_sink(const std::string& path, element_id_t sink_id) {
ElementFileSink* file_out = make_sink<ElementFileSink>(sink_id);
file_out->SetLocation(path);
return file_out;
}
void ElementFileSink::SetLocation(const std::string& location) {
SetProperty("location", location);
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sink/sink.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementFileSink : public ElementBaseSink<ELEMENT_FILE_SINK> {
public:
typedef ElementBaseSink<ELEMENT_FILE_SINK> base_class;
using base_class::base_class;
void SetLocation(const std::string& location);
};
ElementFileSink* make_file_sink(const std::string& path, element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,138 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/http.h"
#include <string>
#include <common/time.h>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
common::Error MakeHlsOutput(const common::uri::GURL& uri,
const common::Optional<common::file_system::ascii_directory_string_path>& http_root,
HlsOutput* out) {
if (!out) {
return common::make_error_inval();
}
if (!http_root) {
return common::make_error("Invalid http_root");
}
const std::string filename = uri.ExtractFileName();
if (filename.empty()) {
return common::make_error("Empty playlist name, please create urls like http://localhost/master.m3u8");
}
const common::file_system::ascii_directory_string_path dir(http_root->GetPath());
fastotv::timestamp_t t = common::time::current_utc_mstime();
const auto ts = dir.MakeFileStringPath(GenHttpTsTemplate(t));
const auto location = dir.MakeFileStringPath(filename);
elements::sink::HlsOutput hout;
hout.location = ts->GetPath();
hout.play_locataion = location->GetPath();
hout.playlist_root = location->GetDirectory();
hout.paylist_length = 5;
hout.max_files = 10;
*out = hout;
return common::Error();
}
common::Error MakeVodHlsOutput(const common::uri::GURL& uri,
const common::Optional<common::file_system::ascii_directory_string_path>& http_root,
HlsOutput* out) {
if (!out) {
return common::make_error_inval();
}
if (!http_root) {
return common::make_error("Invalid http_root");
}
const std::string filename = uri.ExtractFileName();
if (filename.empty()) {
return common::make_error("Empty playlist name, please create urls like http://localhost/master.m3u8");
}
const common::file_system::ascii_directory_string_path dir(http_root->GetPath());
const auto ts = dir.MakeFileStringPath(GenVodHttpTsTemplate());
const auto location = dir.MakeFileStringPath(filename);
elements::sink::HlsOutput hout;
hout.location = ts->GetPath();
hout.play_locataion = location->GetPath();
hout.playlist_root = location->GetDirectory();
hout.paylist_length = 0;
hout.max_files = 0;
*out = hout;
return common::Error();
}
void ElementHLSSink::SetLocation(const std::string& location) {
SetProperty("location", location);
}
std::string ElementHLSSink::GetLocation() const {
return GetStringProperty("location");
}
void ElementHLSSink::SetPlayLocation(const std::string& play_location) {
SetProperty("playlist-location", play_location);
}
void ElementHLSSink::SetTargetDuration(guint duration) {
SetProperty("target-duration", duration);
}
void ElementHLSSink::SetPlayListRoot(const std::string& play_root) {
SetProperty("playlist-root", play_root);
}
void ElementHLSSink::SetPlaylistLenght(guint duration) {
SetProperty("playlist-length", duration);
}
void ElementHLSSink::SetMaxFiles(guint max_files) {
SetProperty("max-files", max_files);
}
void ElementSoupHttpSink::SetLocation(const std::string& location) {
SetProperty("location", location);
}
ElementSoupHttpSink* make_http_soup_sink(element_id_t sink_id, const std::string& location) {
ElementSoupHttpSink* hls_out = make_sink<ElementSoupHttpSink>(sink_id);
hls_out->SetLocation(location);
return hls_out;
}
ElementHLSSink* make_http_sink(element_id_t sink_id, const HlsOutput& output, guint ts_duration) {
ElementHLSSink* hls_out = make_sink<ElementHLSSink>(sink_id);
hls_out->SetLocation(output.location);
hls_out->SetPlayLocation(output.play_locataion);
hls_out->SetTargetDuration(ts_duration);
hls_out->SetPlaylistLenght(output.paylist_length);
hls_out->SetMaxFiles(output.max_files);
return hls_out;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,76 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/file_system/file_system.h>
#include <common/file_system/path.h>
#include <common/uri/gurl.h>
#include "stream/elements/element.h" // for ElementEx, SupportedElements::ELEMENT_...
#include "stream/elements/sink/sink.h"
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
struct HlsOutput {
std::string location;
std::string play_locataion;
std::string playlist_root;
uint32_t paylist_length;
uint32_t max_files;
};
common::Error MakeHlsOutput(const common::uri::GURL& uri,
const common::Optional<common::file_system::ascii_directory_string_path>& http_root,
HlsOutput* out);
common::Error MakeVodHlsOutput(const common::uri::GURL& uri,
const common::Optional<common::file_system::ascii_directory_string_path>& http_root,
HlsOutput* out);
class ElementHLSSink : public ElementBinEx<ELEMENT_HLS_SINK> {
public:
typedef ElementBinEx<ELEMENT_HLS_SINK> base_class;
using base_class::base_class;
void SetLocation(const std::string& location = "segment%05d.ts"); // String; Default: "segment%05d.ts"
std::string GetLocation() const;
void SetPlayLocation(const std::string& play_location = "playlist.m3u8"); // String; Default: "playlist.m3u8"
void SetTargetDuration(guint duration = 15); // Range: 0 - 4294967295 Default: 15
void SetPlayListRoot(const std::string& play_root); // String, Default: null
void SetPlaylistLenght(guint duration = 5); // Range: 0 - 4294967295 Default: 5
void SetMaxFiles(guint max_files = 10); // Range: 0 - 4294967295 Default: 10
};
class ElementSoupHttpSink : public ElementEx<ELEMENT_SOUP_HTTP_CLIENT_SINK> {
public:
typedef ElementEx<ELEMENT_SOUP_HTTP_CLIENT_SINK> base_class;
using base_class::base_class;
void SetLocation(const std::string& location); // String; Default: null
};
ElementSoupHttpSink* make_http_soup_sink(element_id_t sink_id, const std::string& location);
ElementHLSSink* make_http_sink(element_id_t sink_id, const HlsOutput& output, guint ts_duration);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,37 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/rtmp.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
void ElementRtmpSink::SetLocation(const std::string& location) {
SetProperty("location", location);
}
ElementRtmpSink* make_rtmp_sink(element_id_t sink_id, const std::string& output) {
ElementRtmpSink* rtmp_out = make_sink<ElementRtmpSink>(sink_id);
rtmp_out->SetLocation(output);
return rtmp_out;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,43 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// for element_id_t
#include <string>
#include "stream/elements/element.h" // for SupportedElements::ELEMENT_RTMP_SINK
#include "stream/elements/sink/sink.h" // for ElementBaseSink
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementRtmpSink : public ElementBaseSink<ELEMENT_RTMP_SINK> {
public:
typedef ElementBaseSink<ELEMENT_RTMP_SINK> base_class;
using base_class::base_class;
void SetLocation(const std::string& location);
};
ElementRtmpSink* make_rtmp_sink(element_id_t sink_id, const std::string& output);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,69 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/screen.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
void ElementVideoDeckSink::SetMode(decklink_video_mode_t mode) {
SetProperty("mode", mode);
}
ElementVideoScreenSink* make_video_screen_sink(element_id_t sink_id) {
ElementVideoScreenSink* video_sink = make_video_sink<ElementVideoScreenSink>(sink_id);
return video_sink;
}
ElementAudioScreenSink* make_audio_screen_sink(element_id_t sink_id) {
ElementAudioScreenSink* audio_sink = make_audio_sink<ElementAudioScreenSink>(sink_id);
return audio_sink;
}
ElementVideoDeckSink* make_video_deck_sink(element_id_t sink_id) {
ElementVideoDeckSink* video_sink = make_video_sink<ElementVideoDeckSink>(sink_id);
return video_sink;
}
ElementAudioDeckSink* make_audio_deck_sink(element_id_t sink_id) {
ElementAudioDeckSink* audio_sink = make_audio_sink<ElementAudioDeckSink>(sink_id);
return audio_sink;
}
Element* make_video_device_sink(SinkDeviceType dev, element_id_t sink_id) {
if (dev == SCREEN_OUTPUT) {
return make_video_screen_sink(sink_id);
} else if (dev == DECKLINK_OUTPUT) {
return make_video_deck_sink(sink_id);
}
return nullptr;
}
Element* make_audio_device_sink(SinkDeviceType dev, element_id_t sink_id) {
if (dev == SCREEN_OUTPUT) {
return make_audio_screen_sink(sink_id);
} else if (dev == DECKLINK_OUTPUT) {
return make_audio_deck_sink(sink_id);
}
return nullptr;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,53 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// for element_id_t, device_output_t, deckl...
#include "stream/elements/element.h" // for Element (ptr only), SupportedElement...
#include "stream/elements/sink/sink.h" // for ElementBaseSink
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
typedef ElementBaseSink<ELEMENT_VIDEO_SCREEN_SINK> ElementVideoScreenSink;
typedef ElementBaseSink<ELEMENT_AUDIO_SCREEN_SINK> ElementAudioScreenSink;
ElementVideoScreenSink* make_video_screen_sink(element_id_t sink_id);
ElementAudioScreenSink* make_audio_screen_sink(element_id_t sink_id);
class ElementVideoDeckSink : public ElementBaseSink<ELEMENT_VIDEO_DECK_SINK> {
public:
typedef ElementBaseSink<ELEMENT_VIDEO_DECK_SINK> base_class;
using base_class::base_class;
void SetMode(decklink_video_mode_t mode = 1); // 0 - 30 Default: 1, "ntsc"
};
typedef ElementBaseSink<ELEMENT_AUDIO_DECK_SINK> ElementAudioDeckSink;
ElementVideoDeckSink* make_video_deck_sink(element_id_t sink_id);
ElementAudioDeckSink* make_audio_deck_sink(element_id_t sink_id);
Element* make_video_device_sink(SinkDeviceType dev, element_id_t sink_id);
Element* make_audio_device_sink(SinkDeviceType dev, element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,52 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/sink.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
gboolean ElementSplitMuxSink::RegisterFormatLocationCallback(format_location_callback_t cb, gpointer user_data) {
return RegisterCallback("format-location", G_CALLBACK(cb), user_data);
}
#if GST_CHECK_VERSION(1, 11, 1)
gboolean ElementSplitMuxSink::RegisterFormatLocationFullCallback(format_location_full_callback_t cb,
gpointer user_data) {
return RegisterCallback("format-location-full", G_CALLBACK(cb), user_data);
}
#endif
void ElementSplitMuxSink::SetSink(Element* sink) {
SetProperty("sink", sink->GetGstElement());
}
void ElementSplitMuxSink::SetMuxer(Element* muxer) {
SetProperty("muxer", muxer->GetGstElement());
}
void ElementSplitMuxSink::SetMaxSizeTime(guint64 val) {
SetProperty("max-size-time", val);
}
void ElementSplitMuxSink::SetSendKeyFrameRequest(gboolean send) {
SetProperty("send-keyframe-requests", send);
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,91 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib.h>
#include <gst/gstversion.h>
#include <common/sprintf.h>
#include "stream/elements/element.h"
#include "stream/stypes.h"
#if GST_CHECK_VERSION(1, 11, 1)
typedef struct _GstSample GstSample;
#endif
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementMultiFileSink : public ElementEx<ELEMENT_MULTIFILE_SINK> {
public:
typedef ElementEx<ELEMENT_MULTIFILE_SINK> base_class;
using base_class::base_class;
};
class ElementSplitMuxSink : public ElementEx<ELEMENT_SPLIT_MUX_SINK> {
public:
typedef ElementEx<ELEMENT_SPLIT_MUX_SINK> base_class;
typedef gchararray (*format_location_callback_t)(GstElement* splitmux, guint fragment_id, gpointer user_data);
#if GST_CHECK_VERSION(1, 11, 1)
typedef gchararray (*format_location_full_callback_t)(GstElement* splitmux,
guint fragment_id,
GstSample* sample,
gpointer user_data);
#endif
using base_class::base_class;
gboolean RegisterFormatLocationCallback(format_location_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
#if GST_CHECK_VERSION(1, 11, 1)
gboolean RegisterFormatLocationFullCallback(format_location_full_callback_t cb,
gpointer user_data) WARN_UNUSED_RESULT;
#endif
void SetSink(Element* sink);
void SetMuxer(Element* muxer);
void SetMaxSizeTime(guint64 val = 0); // 0 - 18446744073709551615 Default: 0
void SetSendKeyFrameRequest(gboolean send); // Default: false
};
template <SupportedElements el>
class ElementBaseSink : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
void SetSync(bool sync) { ElementEx<el>::SetProperty("sync", sync); }
};
template <typename T>
T* make_video_sink(element_id_t parser_id) {
return make_element<T>(common::MemSPrintf(VIDEO_SINK_NAME_1U, parser_id));
}
template <typename T>
T* make_audio_sink(element_id_t parser_id) {
return make_element<T>(common::MemSPrintf(AUDIO_SINK_NAME_1U, parser_id));
}
template <typename T>
T* make_sink(element_id_t parser_id) {
return make_element<T>(common::MemSPrintf(SINK_NAME_1U, parser_id));
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/srt.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
void ElementSrtSink::SetUri(const std::string& uri) {
SetProperty("uri", uri);
}
void ElementSrtSink::SetMode(int mode) {
SetProperty("mode", mode);
}
ElementSrtSink* make_srt_sink(const std::string& uri, int mode, element_id_t sink_id) {
ElementSrtSink* sink = make_sink<ElementSrtSink>(sink_id);
sink->SetMode(mode);
sink->SetUri(uri);
return sink;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,50 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
// for element_id_t
#include "stream/elements/element.h"
#include "stream/elements/sink/sink.h"
#include "stream/stypes.h"
namespace common {
struct HostAndPort;
}
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementSrtSink : public ElementBaseSink<ELEMENT_SRT_SINK> {
public:
typedef ElementBaseSink<ELEMENT_SRT_SINK> base_class;
using base_class::base_class;
void SetUri(const std::string& uri = "srt://127.0.0.1:7001"); // String. Default: "srt://127.0.0.1:7001"
void SetMode(int mode = 1);
};
ElementSrtSink* make_srt_sink(const std::string& uri, int mode, element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/tcp.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
void ElementTCPServerSink::SetHost(const std::string& host) {
SetProperty("host", host);
}
void ElementTCPServerSink::SetPort(uint16_t port) {
SetProperty("port", port);
}
ElementTCPServerSink* make_tcp_server_sink(const common::net::HostAndPort& host, element_id_t sink_id) {
ElementTCPServerSink* tcp_out = make_sink<ElementTCPServerSink>(sink_id);
tcp_out->SetHost(host.GetHost());
tcp_out->SetPort(host.GetPort());
return tcp_out;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,50 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
// for element_id_t
#include "stream/elements/element.h"
#include "stream/elements/sink/sink.h"
#include "stream/stypes.h"
namespace common {
struct HostAndPort;
}
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementTCPServerSink : public ElementBaseSink<ELEMENT_TCP_SERVER_SINK> {
public:
typedef ElementBaseSink<ELEMENT_TCP_SERVER_SINK> base_class;
using base_class::base_class;
void SetHost(const std::string& host = "localhost"); // String; Default: "localhost"
void SetPort(uint16_t port = 5004); // 0 - 65535; Default: 5004
};
ElementTCPServerSink* make_tcp_server_sink(const common::net::HostAndPort& host, element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/test.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
ElementTestSink* make_test_sink(element_id_t sink_id) {
ElementTestSink* test_sink = make_sink<ElementTestSink>(sink_id);
test_sink->SetSync(true);
return test_sink;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/element.h" // for SupportedElements::ELEMENT_FAKE_SINK
#include "stream/elements/sink/sink.h" // for ElementBaseSink
#include "stream/stypes.h"
// for element_id_
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementTestSink : public ElementBaseSink<ELEMENT_TEST_SINK> {
public:
typedef ElementBaseSink<ELEMENT_TEST_SINK> base_class;
using base_class::base_class;
};
ElementTestSink* make_test_sink(element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sink/udp.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
void ElementUDPSink::SetHost(const std::string& host) {
SetProperty("host", host);
}
void ElementUDPSink::SetPort(uint16_t port) {
SetProperty("port", port);
}
ElementUDPSink* make_udp_sink(const common::net::HostAndPort& host, element_id_t sink_id) {
ElementUDPSink* udp_out = make_sink<ElementUDPSink>(sink_id);
udp_out->SetHost(host.GetHost());
udp_out->SetPort(host.GetPort());
return udp_out;
}
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,50 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
// for element_id_t
#include "stream/elements/element.h" // for SupportedElements::ELEMENT_UDP_SINK
#include "stream/elements/sink/sink.h" // for ElementBaseSink
#include "stream/stypes.h"
namespace common {
struct HostAndPort;
}
namespace fastocloud {
namespace stream {
namespace elements {
namespace sink {
class ElementUDPSink : public ElementBaseSink<ELEMENT_UDP_SINK> {
public:
typedef ElementBaseSink<ELEMENT_UDP_SINK> base_class;
using base_class::base_class;
void SetHost(const std::string& host = "localhost"); // String; Default: "localhost"
void SetPort(uint16_t port = 5004); // 0 - 65535; Default: 5004
};
ElementUDPSink* make_udp_sink(const common::net::HostAndPort& host, element_id_t sink_id);
} // namespace sink
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,37 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/alsasrc.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementAlsaSrc::SetDevice(const std::string& device) {
SetProperty("device", device);
}
ElementAlsaSrc* make_alsa_src(const std::string& device, element_id_t input_id) {
ElementAlsaSrc* alsa = make_sources<ElementAlsaSrc>(input_id);
alsa->SetDevice(device);
return alsa;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementAlsaSrc : public ElementPushSrc<ELEMENT_ALSA_SRC> {
public:
typedef ElementPushSrc<ELEMENT_ALSA_SRC> base_class;
using base_class::base_class;
void SetDevice(const std::string& device = "default"); // Default value: "default"
};
ElementAlsaSrc* make_alsa_src(const std::string& device, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,47 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/appsrc.h"
#include <gst/app/gstappsrc.h> // for GST_APP_SRC
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
gboolean ElementAppSrc::RegisterNeedDataCallback(need_data_callback_t cb, gpointer user_data) {
return RegisterCallback("need-data", G_CALLBACK(cb), user_data);
}
void ElementAppSrc::SetIsLive(bool live) {
SetProperty("is-live", live);
}
GstFlowReturn ElementAppSrc::PushBuffer(GstBuffer* buffer) {
return gst_app_src_push_buffer(GST_APP_SRC(GetGstElement()), buffer);
}
void ElementAppSrc::SendEOS() {
gst_app_src_end_of_stream(GST_APP_SRC(GetGstElement())); // send eos
}
ElementAppSrc* make_app_src(element_id_t input_id) {
return make_sources<ElementAppSrc>(input_id);
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementAppSrc : public ElementBaseSrc<ELEMENT_APP_SRC> {
public:
typedef ElementBaseSrc<ELEMENT_APP_SRC> base_class;
typedef void (*need_data_callback_t)(GstElement* pipeline, guint size, gpointer user_data);
using base_class::base_class;
gboolean RegisterNeedDataCallback(need_data_callback_t cb, gpointer user_data) WARN_UNUSED_RESULT;
void SetIsLive(bool live = false); // Defaut: false
GstFlowReturn PushBuffer(GstBuffer* buffer);
void SendEOS();
};
ElementAppSrc* make_app_src(element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,115 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/build_input.h"
#include <string>
#include <common/convert2string.h>
#include <common/string_split.h>
#include "stream/elements/sources/dvbsrc.h"
#include "stream/elements/sources/filesrc.h"
#include "stream/elements/sources/httpsrc.h"
#include "stream/elements/sources/rtmpsrc.h"
#include "stream/elements/sources/srtsrc.h"
#include "stream/elements/sources/tcpsrc.h"
#include "stream/elements/sources/udpsrc.h"
namespace {
const char kFFmpegUA[] = "Lavf/58.27.103";
const char kVLC[] = "VLC/3.0.1 LibVLC/3.0.1";
const char kWinkUA[] = "WINK";
const char kChromeUA[] = "Chrome/60.0.3112.113 Safari/537.36";
const char kMozillaUA[] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)";
const char kSafariUA[] = "AppleWebKit/537.36 (KHTML, like Gecko)";
} // namespace
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
Element* make_src(const fastotv::InputUri& uri, element_id_t input_id, gint timeout_secs) {
common::uri::GURL url = uri.GetUrl();
if (url.SchemeIsFile()) {
return make_file_src(url.path(), input_id);
} else if (url.SchemeIsHTTPOrHTTPS()) {
common::Optional<std::string> agent;
const auto ua = uri.GetUserAgent();
if (ua) {
fastotv::InputUri::UserAgent uagent = *ua;
if (uagent == fastotv::InputUri::VLC) {
agent = std::string(kVLC);
} else if (uagent == fastotv::InputUri::FFMPEG) {
agent = std::string(kFFmpegUA);
} else if (uagent == fastotv::InputUri::WINK) {
agent = std::string(kWinkUA);
} else if (uagent == fastotv::InputUri::CHROME) {
agent = std::string(kChromeUA);
} else if (uagent == fastotv::InputUri::MOZILLA) {
agent = std::string(kMozillaUA);
} else if (uagent == fastotv::InputUri::SAFARI) {
agent = std::string(kSafariUA);
}
}
return make_http_src(url.spec(), agent, uri.GetHttpProxyUrl(), timeout_secs, input_id);
} else if (url.SchemeIsUdp()) {
// udp://localhost:8080
common::net::HostAndPort host(url.host(), url.EffectiveIntPort());
return make_udp_src(host, uri.GetMulticastIface(), input_id);
} else if (url.SchemeIsRtmp()) {
return make_rtmp_src(url.spec(), timeout_secs, input_id);
} else if (url.SchemeIsTcp()) {
// tcp://localhost:8080
common::net::HostAndPort host(url.host(), url.EffectiveIntPort());
return make_tcp_server_src(host, input_id);
} else if (url.SchemeIsSrt()) {
return make_srt_src(url.spec(), input_id);
} else if (url.SchemeIs("dvb")) {
// dvb://?modulation=3&trans-mode=1&frequency=514000000
auto src = make_dvb_src(input_id);
const auto spl = common::SplitString(url.query(), "&", common::TRIM_WHITESPACE, common::SPLIT_WANT_ALL);
for (const std::string& line : spl) {
size_t delem = line.find_first_of('=');
if (delem == std::string::npos) {
continue;
}
std::string key = line.substr(0, delem);
std::string value = line.substr(delem + 1);
gint lmodulation, ltrans;
guint lfrequency;
if (key == MODULATION_PROPERTY && common::ConvertFromString(value, &lmodulation)) {
src->SetModulation(lmodulation);
} else if (key == TRANS_MODE_PROPERTY && common::ConvertFromString(value, &ltrans)) {
src->SetTransMode(ltrans);
} else if (key == FREQUENCY_PROPERTY && common::ConvertFromString(value, &lfrequency)) {
src->SetFrequency(lfrequency);
} else if (key == POLARITY_PROPERTY) {
src->SetPolarity(value);
}
}
return src;
}
NOTREACHED() << "Unknown input url: " << url.spec();
return nullptr;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "stream/stypes.h"
#include "stream/elements/element.h"
#include <fastotv/types/input_uri.h>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
Element* make_src(const fastotv::InputUri& uri, element_id_t input_id, gint timeout_secs);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,47 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/dvbsrc.h"
#include <vector>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementDvbSrc::SetModulation(gint modulation) {
SetProperty(MODULATION_PROPERTY, modulation);
}
void ElementDvbSrc::SetTransMode(gint trans) {
SetProperty(TRANS_MODE_PROPERTY, trans);
}
void ElementDvbSrc::SetFrequency(guint frequency) {
SetProperty(FREQUENCY_PROPERTY, frequency);
}
void ElementDvbSrc::SetPolarity(const std::string& polarity) {
SetProperty(POLARITY_PROPERTY, polarity);
}
ElementDvbSrc* make_dvb_src(element_id_t input_id) {
return make_sources<ElementDvbSrc>(input_id);
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,50 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <vector>
#include "stream/elements/sources/sources.h" // for ElementLocation
#define MODULATION_PROPERTY "modulation"
#define TRANS_MODE_PROPERTY "trans-mode"
#define FREQUENCY_PROPERTY "frequency"
#define POLARITY_PROPERTY "polarity"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementDvbSrc : public ElementPushSrc<ELEMENT_DVB_SRC> {
public:
typedef ElementPushSrc<ELEMENT_DVB_SRC> base_class;
using base_class::base_class;
static const gint MODULATION_DEFAULT = 1;
static const gint TRANS_MODE_DEFAULT = 1;
void SetModulation(gint modulation = MODULATION_DEFAULT); // 0 - 13 Default: 1
void SetTransMode(gint trans = TRANS_MODE_DEFAULT); // 0 - 8 Default: 1
void SetFrequency(guint frequency = 0); // 0 - 4294967295 Default: 0
void SetPolarity(const std::string& polarity = "h"); // [vhHV] (eg. V for Vertical
};
ElementDvbSrc* make_dvb_src(element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,35 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/filesrc.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementFileSrc::SetLocation(const std::string& location) {
SetProperty("location", location);
}
ElementFileSrc* make_file_src(const std::string& location, element_id_t input_id) {
ElementFileSrc* file_src = make_sources<ElementFileSrc>(input_id);
file_src->SetLocation(location);
return file_src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h" // for ElementLocation
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementFileSrc : public ElementBaseSrc<ELEMENT_FILE_SRC> {
public:
typedef ElementBaseSrc<ELEMENT_FILE_SRC> base_class;
using base_class::base_class;
void SetLocation(const std::string& location);
};
ElementFileSrc* make_file_src(const std::string& location, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,91 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/httpsrc.h"
#include <vector>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementSoupHTTPSrc::SetIsLive(bool live) {
SetProperty("is-live", live);
}
void ElementSoupHTTPSrc::SetTimeOut(gint secs) {
SetProperty("timeout", secs);
}
void ElementSoupHTTPSrc::SetUserAgent(const std::string& agent) {
SetProperty("user-agent", agent);
}
void ElementSoupHTTPSrc::SetProxy(const common::uri::GURL& url) {
SetProperty("proxy", url.spec());
}
void ElementSoupHTTPSrc::SetProxyID(const std::string& id) {
SetProperty("proxy-id", id);
}
void ElementSoupHTTPSrc::SetProxyPW(const std::string& pw) {
SetProperty("proxy-pw", pw);
}
void ElementSoupHTTPSrc::SetAutomaticRedirect(bool redirect) {
SetProperty("automatic-redirect", redirect);
}
void ElementSoupHTTPSrc::SetCookies(const std::vector<std::string>& cookies) {
size_t number_of_row = cookies.size();
const char** gcookies = (const char**)malloc(sizeof(char*) * number_of_row + 1);
for (size_t i = 0; i < number_of_row; ++i) {
gcookies[i] = cookies[i].c_str();
}
gcookies[number_of_row] = NULL;
SetProperty("cookies", gcookies);
free(gcookies);
}
ElementSoupHTTPSrc* make_http_src(const std::string& location,
const common::Optional<std::string>& user_agent,
common::Optional<common::uri::GURL> proxy,
gint timeout_secs,
element_id_t input_id) {
ElementSoupHTTPSrc* http_src = make_sources<ElementSoupHTTPSrc>(input_id);
http_src->SetLocation(location);
http_src->SetTimeOut(timeout_secs);
http_src->SetIsLive(true);
if (user_agent) {
http_src->SetUserAgent(*user_agent);
}
if (proxy) {
http_src->SetProxy(*proxy);
http_src->SetAutomaticRedirect(false);
if (proxy->has_username()) {
http_src->SetProxyID(proxy->username());
}
if (proxy->has_password()) {
http_src->SetProxyPW(proxy->password());
}
}
return http_src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,53 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <vector>
#include "stream/elements/sources/sources.h" // for ElementLocation
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementSoupHTTPSrc : public ElementLocation<ELEMENT_SOUP_HTTP_SRC> {
public:
typedef ElementLocation<ELEMENT_SOUP_HTTP_SRC> base_class;
using base_class::base_class;
void SetIsLive(bool live = false); // Defaut: false
void SetTimeOut(gint secs = 15); // 0 - 3600 Default: 15
void SetUserAgent(const std::string& agent);
void SetProxy(const common::uri::GURL& url);
void SetProxyID(const std::string& id);
void SetProxyPW(const std::string& pw);
void SetAutomaticRedirect(bool redirect);
void SetCookies(const std::vector<std::string>& cookies);
};
ElementSoupHTTPSrc* make_http_src(const std::string& location,
const common::Optional<std::string>& user_agent,
common::Optional<common::uri::GURL> proxy,
gint timeout_secs,
element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,41 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/multifilesrc.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementMultiFileSrc::SetIndex(int index) {
SetProperty("index", index);
}
void ElementMultiFileSrc::SetLoop(bool loop) {
SetProperty("loop", loop);
}
ElementMultiFileSrc* make_multifile_src(const MultiFileSrcInfo& info, element_id_t input_id) {
ElementMultiFileSrc* multifile_src = make_sources<ElementMultiFileSrc>(input_id);
multifile_src->SetLocation(info.location);
multifile_src->SetIndex(info.index);
multifile_src->SetLoop(info.loop);
return multifile_src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,46 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h" // for ElementLocation
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
struct MultiFileSrcInfo {
std::string location;
int index;
bool loop;
};
class ElementMultiFileSrc : public ElementLocation<ELEMENT_MULTIFILE_SRC> {
public:
typedef ElementLocation<ELEMENT_MULTIFILE_SRC> base_class;
using base_class::base_class;
void SetIndex(int index = 0); // Range: 0 - 2147483647 Default: 0
void SetLoop(bool loop = false); // Default: false
};
ElementMultiFileSrc* make_multifile_src(const MultiFileSrcInfo& info, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,38 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/rtmpsrc.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementRTMPSrc::SetTimeOut(gint secs) {
SetProperty("timeout", secs);
}
ElementRTMPSrc* make_rtmp_src(const std::string& location, gint timeout_secs, element_id_t input_id) {
ElementRTMPSrc* rtmp_src = make_sources<ElementRTMPSrc>(input_id);
rtmp_src->SetLocation(location);
rtmp_src->SetTimeOut(timeout_secs);
return rtmp_src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h" // for ElementLocation
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementRTMPSrc : public ElementLocation<ELEMENT_RTMP_SRC> {
public:
typedef ElementLocation<ELEMENT_RTMP_SRC> base_class;
using base_class::base_class;
void SetTimeOut(gint secs = 120); // 0 - 2147483647 Default: 120
};
ElementRTMPSrc* make_rtmp_src(const std::string& location, gint timeout_secs, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,45 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/rtspsrc.h"
#include <string>
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementRTSPSrc::SetLocation(const std::string& location) {
SetProperty("location", location);
}
std::string ElementRTSPSrc::GetLocation() const {
return GetStringProperty("location");
}
void ElementRTSPSrc::SetLatency(gint latency) {
SetProperty("latency", latency);
}
ElementRTSPSrc* make_rtsp_src(const std::string& location, element_id_t input_id) {
ElementRTSPSrc* rtsp_src = make_sources<ElementRTSPSrc>(input_id);
rtsp_src->SetLocation(location);
return rtsp_src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h" // for ElementLocation
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementRTSPSrc : public ElementBinEx<ELEMENT_RTSP_SRC> {
public:
typedef ElementBinEx<ELEMENT_RTSP_SRC> base_class;
using base_class::base_class;
void SetLocation(const std::string& location); // String; Default: null
std::string GetLocation() const;
void SetLatency(gint latency);
};
ElementRTSPSrc* make_rtsp_src(const std::string& location, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,23 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {}
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,65 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/sprintf.h>
#include "stream/elements/element.h" // for ElementEx, SupportedElements, Supporte...
#include "stream/stypes.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
template <SupportedElements el>
class ElementBaseSrc : public ElementEx<el> {
public:
typedef ElementEx<el> base_class;
using base_class::base_class;
};
template <SupportedElements el>
class ElementPushSrc : public ElementBaseSrc<el> {
public:
typedef ElementBaseSrc<el> base_class;
using base_class::base_class;
};
typedef ElementPushSrc<ELEMENT_VIDEO_TEST_SRC> ElementVideoTestSrc;
typedef ElementPushSrc<ELEMENT_AUDIO_TEST_SRC> ElementAudioTestSrc;
typedef ElementPushSrc<ELEMENT_DISPLAY_SRC> ElementDisplayTestSrc;
template <SupportedElements el>
class ElementLocation : public ElementPushSrc<el> {
public:
typedef ElementPushSrc<el> base_class;
using base_class::base_class;
void SetLocation(const std::string& location) { base_class::SetProperty("location", location); }
};
template <typename T>
T* make_sources(element_id_t source_id) {
return make_element<T>(common::MemSPrintf(SRC_NAME_1U, source_id));
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,35 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/srtsrc.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementSRTSrc::SetUri(const std::string& uri) {
SetProperty("uri", uri);
}
ElementSRTSrc* make_srt_src(const std::string& uri, element_id_t input_id) {
ElementSRTSrc* src = make_sources<ElementSRTSrc>(input_id);
src->SetUri(uri);
return src;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,41 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementSRTSrc : public ElementPushSrc<ELEMENT_SRT_SRC> {
public:
typedef ElementPushSrc<ELEMENT_SRT_SRC> base_class;
using base_class::base_class;
void SetUri(const std::string& uri = "srt://127.0.0.1:7001"); // String. Default: "srt://127.0.0.1:7001"
};
ElementSRTSrc* make_srt_src(const std::string& uri, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,40 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/tcpsrc.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementTCPSrc::SetHost(const std::string& host) {
SetProperty("host", host);
}
void ElementTCPSrc::SetPort(uint16_t port) {
SetProperty("port", port);
}
ElementTCPSrc* make_tcp_server_src(const common::net::HostAndPort& location, element_id_t input_id) {
ElementTCPSrc* tcpsrc = make_sources<ElementTCPSrc>(input_id);
tcpsrc->SetHost(location.GetHost());
tcpsrc->SetPort(location.GetPort());
return tcpsrc;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,42 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementTCPSrc : public ElementPushSrc<ELEMENT_TCP_SERVER_SRC> {
public:
typedef ElementPushSrc<ELEMENT_TCP_SERVER_SRC> base_class;
using base_class::base_class;
void SetHost(const std::string& host = "localhost"); // String. Default: "localhost"
void SetPort(uint16_t port);
};
ElementTCPSrc* make_tcp_server_src(const common::net::HostAndPort& location, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,53 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/udpsrc.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementUDPSrc::SetUri(const std::string& uri) {
SetProperty("uri", uri);
}
void ElementUDPSrc::SetAddress(const std::string& host) {
SetProperty("address", host);
}
void ElementUDPSrc::SetPort(uint16_t port) {
SetProperty("port", port);
}
void ElementUDPSrc::SetMulticastIface(const std::string& iface) {
SetProperty("multicast-iface", iface);
}
ElementUDPSrc* make_udp_src(const common::net::HostAndPort& host,
common::Optional<std::string> iface,
element_id_t input_id) {
ElementUDPSrc* udpsrc = make_sources<ElementUDPSrc>(input_id);
udpsrc->SetAddress(host.GetHost());
udpsrc->SetPort(host.GetPort());
if (iface) {
udpsrc->SetMulticastIface(*iface);
}
return udpsrc;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,46 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <common/net/types.h>
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementUDPSrc : public ElementPushSrc<ELEMENT_UDP_SRC> {
public:
typedef ElementPushSrc<ELEMENT_UDP_SRC> base_class;
using base_class::base_class;
void SetAddress(const std::string& host);
void SetPort(uint16_t port);
void SetUri(const std::string& uri = "udp://0.0.0.0:5004"); // String. Default: "udp://0.0.0.0:5004"
void SetMulticastIface(const std::string& iface); // multicast-iface=10.100.200.10
};
ElementUDPSrc* make_udp_src(const common::net::HostAndPort& host,
common::Optional<std::string> iface,
element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,35 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/sources/v4l2src.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
void ElementV4L2Src::SetDevice(const std::string& device) {
SetProperty("device", device);
}
ElementV4L2Src* make_v4l2_src(const std::string& device, element_id_t input_id) {
ElementV4L2Src* v4l2sr = make_sources<ElementV4L2Src>(input_id);
v4l2sr->SetDevice(device);
return v4l2sr;
}
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,39 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include "stream/elements/sources/sources.h"
namespace fastocloud {
namespace stream {
namespace elements {
namespace sources {
class ElementV4L2Src : public ElementPushSrc<ELEMENT_V4L2_SRC> {
public:
typedef ElementPushSrc<ELEMENT_V4L2_SRC> base_class;
using base_class::base_class;
void SetDevice(const std::string& device = "/dev/video0"); // Default value: "/dev/video0"
};
ElementV4L2Src* make_v4l2_src(const std::string& device, element_id_t input_id);
} // namespace sources
} // namespace elements
} // namespace stream
} // namespace fastocloud

View file

@ -0,0 +1,98 @@
/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stream/elements/video/video.h"
#define DEINTERLACE_METHOD 5
// https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good-plugins/html/gst-plugins-good-plugins-deinterlace.html
namespace fastocloud {
namespace stream {
namespace elements {
namespace video {
void ElementGDKPixBufOverlay::SetOffsetX(gint x) {
SetProperty("offset-x", x);
}
void ElementGDKPixBufOverlay::SetOffsetY(gint y) {
SetProperty("offset-y", y);
}
void ElementGDKPixBufOverlay::SetLocation(const std::string& location) {
SetProperty("location", location);
}
void ElementGDKPixBufOverlay::SetAlpha(alpha_t alpha) {
SetProperty("alpha", alpha);
}
void ElementGDKPixBufOverlay::SetOverlayHeight(gint height) {
SetProperty("overlay-height", height);
}
void ElementGDKPixBufOverlay::SetOverlayWidth(gint width) {
SetProperty("overlay-width", width);
}
void ElementRSVGOverlay::SetX(gint x) {
SetProperty("x", x);
}
void ElementRSVGOverlay::SetY(gint y) {
SetProperty("y", y);
}
void ElementRSVGOverlay::SetLocation(const std::string& location) {
SetProperty("location", location);
}
void ElementRSVGOverlay::SetHeight(gint height) {
SetProperty("height", height);
}
void ElementRSVGOverlay::SetWidth(gint width) {
SetProperty("width", width);
}
void ElementDeinterlace::SetMethod(int method) {
SetProperty("method", method);
}
void ElementAspectRatio::SetAspectRatio(const common::media::Rational& rat) {
SetFractionProperty("aspect-ratio", rat.num, rat.den);
}
Element* make_video_deinterlace(const std::string& deinterlace, const std::string& name) {
if (deinterlace == ElementAvDeinterlace::GetPluginName()) {
return new ElementAvDeinterlace(name);
} else if (deinterlace == ElementDeinterlace::GetPluginName()) {
ElementDeinterlace* deint = new ElementDeinterlace(name);
deint->SetMethod(DEINTERLACE_METHOD);
return deint;
}
NOTREACHED() << "make_video_deinterlace: " << deinterlace;
return nullptr;
}
gboolean ElementCairoOverlay::RegisterDrawCallback(draw_callback_t cb, gpointer user_data) {
return RegisterCallback("draw", G_CALLBACK(cb), user_data);
}
} // namespace video
} // namespace elements
} // namespace stream
} // namespace fastocloud

Some files were not shown because too many files have changed in this diff Show more