-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve the process of handling live danmuku * fix live danmaku * Add buvid into cookie * fix #219 * Reduce nanovg state switching * Optimize method of waiting for danmaku queue * fix gradient and danmaku sever
- Loading branch information
Showing
11 changed files
with
400 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Created by maye174 on 2023/11/13. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "api/live/extract_messages.hpp" | ||
|
||
#include <queue> | ||
|
||
#include "nanovg.h" | ||
#include <borealis.hpp> | ||
#include <borealis/core/singleton.hpp> | ||
|
||
class LiveDanmakuItem { | ||
public: | ||
LiveDanmakuItem(danmaku_t *danmaku); | ||
LiveDanmakuItem(const LiveDanmakuItem &item); | ||
LiveDanmakuItem(LiveDanmakuItem &&item); | ||
~LiveDanmakuItem() { | ||
if (!danmaku) return; | ||
danmaku_t_free(danmaku); | ||
free(danmaku); | ||
} | ||
danmaku_t *danmaku; | ||
float time; | ||
float length = 0; | ||
float speed = 0; | ||
int line = 0; | ||
}; | ||
|
||
class LiveDanmakuCore : public brls::Singleton<LiveDanmakuCore> { | ||
public: | ||
//0-60 | ||
static inline int DANMAKU_FILTER_LEVEL_LIVE = 0; | ||
|
||
std::vector<std::pair<float, float>> scroll_lines; | ||
std::vector<int> center_lines; | ||
|
||
float line_height; | ||
|
||
int danmaku_font = brls::Application::getDefaultFont(); | ||
|
||
std::deque<LiveDanmakuItem> next; | ||
std::mutex next_mutex; | ||
|
||
std::map<int, std::deque<LiveDanmakuItem>> now; | ||
|
||
void reset(); | ||
void add(const std::vector<LiveDanmakuItem> &dan_l); | ||
void draw(NVGcontext *vg, float x, float y, float width, float height, | ||
float alpha); | ||
|
||
bool init_danmaku(NVGcontext *vg, LiveDanmakuItem &i, float width, | ||
int LINES, float SECOND, float time); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.