Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming server MVP #8

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Streaming server MVP #8

wants to merge 9 commits into from

Conversation

hjbaa
Copy link
Collaborator

@hjbaa hjbaa commented May 16, 2023

No description provided.

@hjbaa hjbaa changed the base branch from dev to main May 16, 2023 15:46
Copy link

@a-badin a-badin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если я правильно понял, получилось сделать только получение информации о потоках видео/аудио. Оцениваю на 15


set(CMAKE_CXX_STANDARD 17)

find_package(Boost 1.82.0 REQUIRED COMPONENTS filesystem)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

используйте лучше std::filesystem если оно подходит по ваши нужды

include_directories(boost_test ${Boost_INCLUDE_DIRS})
find_package(Threads REQUIRED)

set(FFMPEG_LIBRARIES "/usr/lib/x86_64-linux-gnu/libavcodec.so;/usr/lib/x86_64-linux-gnu/libavformat.so;/usr/lib/x86_64-linux-gnu/libavutil.so;/usr/lib/x86_64-linux-gnu/libswscale.so")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это можно делать через PkgConfig

find_package(PkgConfig REQUIRED) 
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
target_link_libraries(server PUBLIC
        PkgConfig::AVCODEC)


set(FFMPEG_LIBRARIES "/usr/lib/x86_64-linux-gnu/libavcodec.so;/usr/lib/x86_64-linux-gnu/libavformat.so;/usr/lib/x86_64-linux-gnu/libavutil.so;/usr/lib/x86_64-linux-gnu/libswscale.so")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-pthread добавит Threads


# Set include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/VideoStream/include)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target


# Add source files
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_CURRENT_SOURCE_DIR можно не писать, относительные пути работают от CMAKE_CURRENT_SOURCE_DIR


class AudioEncoder : IEncoder {
public:
AudioEncoder() = delete;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удаляется сам, когда вы объявляете любой конструктор

class IEncoder {
public:
virtual ~IEncoder() = default;
virtual std::vector<uint8_t> encode(const uint8_t* data) = 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а как понять размер data


class VideoStream {
public:
const std::string DEFAULT_CODEC = "H264";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем держать это в классе - оно потребляет память. Вынесите в константу в CPP файл

}

void VideoStream::open(const std::string& filename) {
_video_encoder = std::make_shared<VideoEncoder>(1920, 1080, 30, 10000000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше принимать IEncoder или IVideoEncoder как параметр, тогда это будет Dependency Injection, код будет меньше связан

bool findStreamInfo();

std::string file_path_;
AVFormatContext* format_context_ = nullptr;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше сделать под такие данные C++ RAII обертки, чтобы правильно из создавать и уничтожать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants