This commit is contained in:
2026-03-03 08:13:16 +03:00
commit 85685e7e17
19 changed files with 2887 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
#include "../include/eclipt-linux/EcliptLinux.h"
#include "../../../libEcliptPlayer/include/eclipt/EcliptPlayer.h"
#include "../../../libEcliptPlayer/include/eclipt/Frame.h"
#include "../../../libEcliptPlayer/include/eclipt/Config.h"
#include <chrono>
#include <cstring>
namespace eclipt {
namespace platform {
namespace linux {
LinuxPlayer::LinuxPlayer() = default;
LinuxPlayer::~LinuxPlayer() {
shutdown();
}
bool LinuxPlayer::initialize(const LinuxDisplayConfig& display, const LinuxAudioConfig& audio) {
display_config_ = display;
audio_config_ = audio;
core_player_ = std::make_unique<eclipt::EcliptPlayer>();
core_player_->setVideoCallback([this](VideoFrame&& frame) {
onVideoFrame(std::move(frame));
});
core_player_->setAudioCallback([this](AudioFrame&& frame) {
onAudioFrame(std::move(frame));
});
initialized_ = true;
return true;
}
void LinuxPlayer::shutdown() {
running_ = false;
if (render_thread_.joinable()) {
render_cv_.notify_all();
render_thread_.join();
}
if (core_player_) {
core_player_->close();
}
initialized_ = false;
}
bool LinuxPlayer::open(const std::string& url) {
if (!core_player_) return false;
return core_player_->open(url);
}
void LinuxPlayer::close() {
if (core_player_) {
core_player_->close();
}
}
bool LinuxPlayer::play() {
if (!core_player_) return false;
running_ = true;
render_thread_ = std::thread([this]() { renderLoop(); });
return core_player_->play();
}
bool LinuxPlayer::pause() {
if (!core_player_) return false;
return core_player_->pause();
}
bool LinuxPlayer::stop() {
running_ = false;
if (core_player_) {
core_player_->stop();
}
return true;
}
bool LinuxPlayer::seek(int64_t position_ms) {
if (!core_player_) return false;
return core_player_->seek(position_ms, eclipt::SeekDirection::Absolute);
}
int LinuxPlayer::getState() const {
if (!core_player_) return 0;
return static_cast<int>(core_player_->getState());
}
void LinuxPlayer::setVolume(float volume) {
if (core_player_) {
core_player_->setVolume(volume);
}
}
float LinuxPlayer::getVolume() const {
if (!core_player_) return 0.0f;
return core_player_->getVolume();
}
void LinuxPlayer::render() {
if (!running_) return;
VideoFrame frame;
{
std::lock_guard<std::mutex> lock(frame_mutex_);
if (!frame_queue_.empty()) {
frame = std::move(frame_queue_.front());
frame_queue_.erase(frame_queue_.begin());
}
}
if (frame.isValid()) {
// Render frame using the configured display backend
}
}
void LinuxPlayer::setEventCallback(EventCallback callback) {
event_callback_ = std::move(callback);
}
void LinuxPlayer::onVideoFrame(VideoFrame&& frame) {
std::lock_guard<std::mutex> lock(frame_mutex_);
if (frame_queue_.size() < 3) {
frame_queue_.push_back(std::move(frame));
frame_cv_.notify_one();
}
}
void LinuxPlayer::onAudioFrame(AudioFrame&& frame) {
// Handle audio frame
}
void LinuxPlayer::renderLoop() {
while (running_) {
render();
std::this_thread::sleep_for(std::chrono::milliseconds(16));
}
}
}
}
}

View File

@@ -0,0 +1,44 @@
#include "eclipt-linux/EcliptLinux.h"
#include <iostream>
using namespace eclipt::platform::linux;
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
return 1;
}
LinuxDisplayConfig display;
display.title = "Eclipt IPTV Player";
display.window_width = 1280;
display.window_height = 720;
LinuxAudioConfig audio;
LinuxPlayer player;
if (!player.initialize(display, audio)) {
std::cerr << "Failed to initialize player" << std::endl;
return 1;
}
if (!player.open(argv[1])) {
std::cerr << "Failed to open: " << argv[1] << std::endl;
return 1;
}
if (!player.play()) {
std::cerr << "Failed to start playback" << std::endl;
return 1;
}
std::cout << "Playing: " << argv[1] << std::endl;
std::cout << "Press Enter to stop..." << std::endl;
std::cin.get();
player.stop();
player.shutdown();
return 0;
}