chore: 修正缩进

This commit is contained in:
KkemChen 2024-06-19 11:25:18 +08:00
parent 9fadcd275a
commit 7cab102bba
3 changed files with 472 additions and 475 deletions

View File

@ -18,8 +18,8 @@
// ITU-R BT.709
#define RGB_TO_Y(R, G, B) (((47 * (R) + 157 * (G) + 16 * (B) + 128) >> 8) + 16)
#define RGB_TO_U(R, G, B) (((-26 * (R)-87 * (G) + 112 * (B) + 128) >> 8) + 128)
#define RGB_TO_V(R, G, B) (((112 * (R)-102 * (G)-10 * (B) + 128) >> 8) + 128)
#define RGB_TO_U(R, G, B) (((-26 * (R) - 87 * (G) + 112 * (B) + 128) >> 8) + 128)
#define RGB_TO_V(R, G, B) (((112 * (R) - 102 * (G) - 10 * (B) + 128) >> 8) + 128)
INSTANCE_IMP(VideoStackManager)
@ -80,7 +80,7 @@ void Channel::copyData(const mediakit::FFmpegFrame::Ptr& buf, const Param::Ptr&
memcpy(buf->get()->data[0] + buf->get()->linesize[0] * (i + p->posY) + p->posX,
_tmp->get()->data[0] + _tmp->get()->linesize[0] * i, _tmp->get()->width);
}
//确保height为奇数时也能正确的复制到最后一行uv数据
// 确保height为奇数时也能正确的复制到最后一行uv数据
for (int i = 0; i < (p->height + 1) / 2; i++) {
// U平面
memcpy(buf->get()->data[1] + buf->get()->linesize[1] * (i + p->posY / 2) +
@ -95,7 +95,7 @@ void Channel::copyData(const mediakit::FFmpegFrame::Ptr& buf, const Param::Ptr&
break;
}
case AV_PIX_FMT_NV12: {
//TODO: 待实现
// TODO: 待实现
break;
}
@ -110,7 +110,7 @@ void StackPlayer::addChannel(const std::weak_ptr<Channel>& chn) {
void StackPlayer::play() {
auto url = _url;
//创建拉流 解码对象
// 创建拉流 解码对象
_player = std::make_shared<mediakit::MediaPlayer>();
std::weak_ptr<mediakit::MediaPlayer> weakPlayer = _player;
@ -138,10 +138,10 @@ void StackPlayer::play() {
auto videoTrack = std::dynamic_pointer_cast<mediakit::VideoTrack>(
strongPlayer->getTrack(mediakit::TrackVideo, false));
//auto audioTrack = std::dynamic_pointer_cast<mediakit::AudioTrack>(strongPlayer->getTrack(mediakit::TrackAudio, false));
// auto audioTrack = std::dynamic_pointer_cast<mediakit::AudioTrack>(strongPlayer->getTrack(mediakit::TrackAudio, false));
if (videoTrack) {
//TODO:添加使用显卡还是cpu解码的判断逻辑
// TODO:添加使用显卡还是cpu解码的判断逻辑
auto decoder = std::make_shared<mediakit::FFmpegDecoder>(
videoTrack, 0, std::vector<std::string>{"h264", "hevc"});
@ -193,18 +193,15 @@ void StackPlayer::onDisconnect() {
void StackPlayer::rePlay(const std::string& url) {
_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();
_timer = std::make_shared<toolkit::Timer>(
delay / 1000.0f,
[weakSelf, url]() {
_timer = std::make_shared<toolkit::Timer>(delay / 1000.0f, [weakSelf, url]() {
auto self = weakSelf.lock();
if (!self) {}
WarnL << "replay [" << self->_failedCount << "]:" << url;
self->_player->play(url);
return false;
},
nullptr);
}, nullptr);
}
VideoStack::VideoStack(const std::string& id, int width, int height, AVPixelFormat pixfmt,
@ -230,7 +227,7 @@ VideoStack::VideoStack(const std::string& id, int width, int height, AVPixelForm
info.iBitRate = _bitRate;
_dev->initVideo(info);
//dev->initAudio(); //TODO:音频
// dev->initAudio(); //TODO:音频
_dev->addTrackCompleted();
_isExit = false;
@ -279,7 +276,7 @@ void VideoStack::start() {
}
void VideoStack::initBgColor() {
//填充底色
// 填充底色
auto R = 20;
auto G = 20;
auto B = 20;
@ -399,13 +396,13 @@ Params VideoStackManager::parseParams(const Json::Value& json, std::string& id,
id = getJsonValue<std::string>(json, "id");
width = getJsonValue<int>(json, "width");
height = getJsonValue<int>(json, "height");
int rows = getJsonValue<int>(json, "row");//行数
int cols = getJsonValue<int>(json, "col");//列数
int rows = getJsonValue<int>(json, "row");// 行数
int cols = getJsonValue<int>(json, "col");// 列数
float gapv = json["gapv"].asFloat();//垂直间距
float gaph = json["gaph"].asFloat();//水平间距
float gapv = json["gapv"].asFloat();// 垂直间距
float gaph = json["gaph"].asFloat();// 水平间距
//单个间距
// 单个间距
int gaphPix = static_cast<int>(round(width * gaph));
int gapvPix = static_cast<int>(round(height * gapv));
@ -430,7 +427,7 @@ Params VideoStackManager::parseParams(const Json::Value& json, std::string& id,
}
}
//判断是否需要合并格子 (焦点屏)
// 判断是否需要合并格子 (焦点屏)
if (json.isMember("span") && json["span"].isArray() && json["span"].size() > 0) {
for (const auto& subArray : json["span"]) {
if (!subArray.isArray() || subArray.size() != 2) {

View File

@ -98,7 +98,7 @@ private:
std::string _url;
mediakit::MediaPlayer::Ptr _player;
//用于断线重连
// 用于断线重连
toolkit::Timer::Ptr _timer;
int _failedCount = 0;
@ -145,13 +145,13 @@ private:
class VideoStackManager {
public:
//创建拼接流
// 创建拼接流
int startVideoStack(const Json::Value& json);
//停止拼接流
// 停止拼接流
int stopVideoStack(const std::string& id);
//可以在不断流的情况下,修改拼接流的配置(实现切换拼接屏内容)
// 可以在不断流的情况下,修改拼接流的配置(实现切换拼接屏内容)
int resetVideoStack(const Json::Value& json);
public:

View File

@ -1956,7 +1956,7 @@ void installWebApi() {
ret = VideoStackManager::Instance().startVideoStack(allArgs.args);
val["code"] = ret;
val["msg"] = ret ? "failed" : "success";
} catch (const std::exception& e) {
} catch (const std::exception &e) {
val["code"] = -1;
val["msg"] = e.what();
}
@ -1970,7 +1970,7 @@ void installWebApi() {
auto ret = VideoStackManager::Instance().resetVideoStack(allArgs.args);
val["code"] = ret;
val["msg"] = ret ? "failed" : "success";
} catch (const std::exception& e) {
} catch (const std::exception &e) {
val["code"] = -1;
val["msg"] = e.what();
}