2024-07-26 17:34:36 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "avplayer.h"
|
|
|
|
#include "avplayer_data_streamer.h"
|
|
|
|
#include "avplayer_state.h"
|
|
|
|
|
|
|
|
#include "core/libraries/kernel/thread_management.h"
|
|
|
|
|
2024-08-14 20:30:44 +02:00
|
|
|
#include <mutex>
|
|
|
|
|
2024-07-26 17:34:36 +02:00
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Libraries::AvPlayer {
|
|
|
|
|
|
|
|
class AvPlayer {
|
|
|
|
public:
|
2024-08-14 20:30:44 +02:00
|
|
|
AvPlayer(const SceAvPlayerInitData& data);
|
2024-07-26 17:34:36 +02:00
|
|
|
|
|
|
|
s32 PostInit(const SceAvPlayerPostInitData& data);
|
|
|
|
s32 AddSource(std::string_view filename);
|
|
|
|
s32 GetStreamCount();
|
|
|
|
s32 GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info);
|
2024-08-12 18:01:02 +02:00
|
|
|
s32 EnableStream(u32 stream_index);
|
2024-07-26 17:34:36 +02:00
|
|
|
s32 Start();
|
|
|
|
bool GetAudioData(SceAvPlayerFrameInfo& audio_info);
|
|
|
|
bool GetVideoData(SceAvPlayerFrameInfo& video_info);
|
|
|
|
bool GetVideoData(SceAvPlayerFrameInfoEx& video_info);
|
|
|
|
bool IsActive();
|
|
|
|
u64 CurrentTime();
|
|
|
|
s32 Stop();
|
2024-08-15 20:59:59 +02:00
|
|
|
bool SetLooping(bool is_looping);
|
2024-07-26 17:34:36 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
using ScePthreadMutex = Kernel::ScePthreadMutex;
|
|
|
|
|
2024-08-14 20:30:44 +02:00
|
|
|
// Memory Replacement
|
|
|
|
static void* PS4_SYSV_ABI Allocate(void* handle, u32 alignment, u32 size);
|
|
|
|
static void PS4_SYSV_ABI Deallocate(void* handle, void* memory);
|
|
|
|
static void* PS4_SYSV_ABI AllocateTexture(void* handle, u32 alignment, u32 size);
|
|
|
|
static void PS4_SYSV_ABI DeallocateTexture(void* handle, void* memory);
|
|
|
|
|
|
|
|
// File Replacement
|
|
|
|
static int PS4_SYSV_ABI OpenFile(void* handle, const char* filename);
|
|
|
|
static int PS4_SYSV_ABI CloseFile(void* handle);
|
|
|
|
static int PS4_SYSV_ABI ReadOffsetFile(void* handle, u8* buffer, u64 position, u32 length);
|
|
|
|
static u64 PS4_SYSV_ABI SizeFile(void* handle);
|
|
|
|
|
|
|
|
SceAvPlayerInitData StubInitData(const SceAvPlayerInitData& data);
|
|
|
|
|
2024-07-26 17:34:36 +02:00
|
|
|
SceAvPlayerInitData m_init_data{};
|
|
|
|
SceAvPlayerInitData m_init_data_original{};
|
|
|
|
SceAvPlayerPostInitData m_post_init_data{};
|
2024-08-14 20:30:44 +02:00
|
|
|
std::mutex m_file_io_mutex{};
|
2024-07-26 17:34:36 +02:00
|
|
|
|
|
|
|
std::atomic_bool m_has_source{};
|
2024-08-14 20:30:44 +02:00
|
|
|
std::unique_ptr<AvPlayerState> m_state{};
|
2024-07-26 17:34:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Libraries::AvPlayer
|