build: When FFmpeg and x264 are not enabled, VideoStack is not compiled
This commit is contained in:
parent
4ec31dbfd7
commit
f0e3cb300d
|
|
@ -1,3 +1,4 @@
|
||||||
|
#if defined(ENABLE_X264) && defined(ENABLE_FFMPEG)
|
||||||
#include "VideoStack.h"
|
#include "VideoStack.h"
|
||||||
#include "Codec/Transcode.h"
|
#include "Codec/Transcode.h"
|
||||||
#include "Common/Device.h"
|
#include "Common/Device.h"
|
||||||
|
|
@ -168,7 +169,7 @@ void StackPlayer::play()
|
||||||
if (videoTrack) {
|
if (videoTrack) {
|
||||||
//TODO:添加使用显卡还是cpu解码的判断逻辑
|
//TODO:添加使用显卡还是cpu解码的判断逻辑
|
||||||
//auto decoder = std::make_shared<FFmpegDecoder>(videoTrack, 1, std::vector<std::string>{ "hevc_cuvid", "h264_cuvid"});
|
//auto decoder = std::make_shared<FFmpegDecoder>(videoTrack, 1, std::vector<std::string>{ "hevc_cuvid", "h264_cuvid"});
|
||||||
auto decoder = std::make_shared<mediakit::FFmpegDecoder>(videoTrack, 0, std::vector<std::string>{ "h264", "hevc" });
|
auto decoder = std::make_shared<mediakit::FFmpegDecoder>(videoTrack, 0, std::vector<std::string> { "h264", "hevc" });
|
||||||
|
|
||||||
decoder->setOnDecode([weakSelf](const mediakit::FFmpegFrame::Ptr& frame) mutable {
|
decoder->setOnDecode([weakSelf](const mediakit::FFmpegFrame::Ptr& frame) mutable {
|
||||||
auto self = weakSelf.lock();
|
auto self = weakSelf.lock();
|
||||||
|
|
@ -231,14 +232,15 @@ void StackPlayer::rePlay(const std::string& url)
|
||||||
_failedCount++;
|
_failedCount++;
|
||||||
auto delay = MAX(2 * 1000, MIN(_failedCount * 3 * 1000, 60 * 1000)); //步进延迟 重试间隔
|
auto delay = MAX(2 * 1000, MIN(_failedCount * 3 * 1000, 60 * 1000)); //步进延迟 重试间隔
|
||||||
std::weak_ptr<StackPlayer> weakSelf = shared_from_this();
|
std::weak_ptr<StackPlayer> weakSelf = shared_from_this();
|
||||||
_timer = std::make_shared<toolkit::Timer>(delay / 1000.0f, [weakSelf, url]() {
|
_timer = std::make_shared<toolkit::Timer>(
|
||||||
auto self = weakSelf.lock();
|
delay / 1000.0f, [weakSelf, url]() {
|
||||||
if (!self) {
|
auto self = weakSelf.lock();
|
||||||
}
|
if (!self) {
|
||||||
WarnL << "replay [" << self->_failedCount << "]:" << url;
|
}
|
||||||
self->_player->play(url);
|
WarnL << "replay [" << self->_failedCount << "]:" << url;
|
||||||
return false;
|
self->_player->play(url);
|
||||||
},
|
return false;
|
||||||
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,7 +261,7 @@ VideoStack::VideoStack(const std::string& id, int width, int height, AVPixelForm
|
||||||
|
|
||||||
av_frame_get_buffer(_buffer->get(), 32);
|
av_frame_get_buffer(_buffer->get(), 32);
|
||||||
|
|
||||||
_dev = std::make_shared<mediakit::DevChannel>(mediakit::MediaTuple{ DEFAULT_VHOST, "live", _id });
|
_dev = std::make_shared<mediakit::DevChannel>(mediakit::MediaTuple { DEFAULT_VHOST, "live", _id });
|
||||||
|
|
||||||
mediakit::VideoInfo info;
|
mediakit::VideoInfo info;
|
||||||
info.codecId = mediakit::CodecH264;
|
info.codecId = mediakit::CodecH264;
|
||||||
|
|
@ -585,3 +587,4 @@ StackPlayer::Ptr VideoStackManager::createPlayer(const std::string& id)
|
||||||
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#if defined(ENABLE_X264) && defined(ENABLE_FFMPEG)
|
||||||
#include "Codec/Transcode.h"
|
#include "Codec/Transcode.h"
|
||||||
#include "Common/Device.h"
|
#include "Common/Device.h"
|
||||||
#include "Player/MediaPlayer.h"
|
#include "Player/MediaPlayer.h"
|
||||||
|
|
@ -39,7 +40,7 @@ struct Param {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
AVPixelFormat pixfmt = AV_PIX_FMT_YUV420P;
|
AVPixelFormat pixfmt = AV_PIX_FMT_YUV420P;
|
||||||
std::string id{};
|
std::string id {};
|
||||||
|
|
||||||
// runtime
|
// runtime
|
||||||
std::weak_ptr<Channel> weak_chn;
|
std::weak_ptr<Channel> weak_chn;
|
||||||
|
|
@ -203,3 +204,4 @@ class VideoStackManager {
|
||||||
|
|
||||||
std::unordered_map<std::string, RefWrapper<StackPlayer::Ptr>::Ptr> _playerMap;
|
std::unordered_map<std::string, RefWrapper<StackPlayer::Ptr>::Ptr> _playerMap;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue