66 lines
2.0 KiB
C
66 lines
2.0 KiB
C
![]() |
// 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"
|
||
|
|
||
|
extern "C" {
|
||
|
#include <libavcodec/avcodec.h>
|
||
|
#include <libavformat/avformat.h>
|
||
|
}
|
||
|
|
||
|
#include <memory>
|
||
|
#include <vector>
|
||
|
|
||
|
namespace Libraries::AvPlayer {
|
||
|
|
||
|
class AvPlayer {
|
||
|
public:
|
||
|
// 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);
|
||
|
|
||
|
AvPlayer();
|
||
|
|
||
|
void Init(const SceAvPlayerInitData& data, const ThreadPriorities& priorities);
|
||
|
|
||
|
s32 PostInit(const SceAvPlayerPostInitData& data);
|
||
|
s32 AddSource(std::string_view filename);
|
||
|
s32 GetStreamCount();
|
||
|
s32 GetStreamInfo(u32 stream_index, SceAvPlayerStreamInfo& info);
|
||
|
s32 EnableStream(u32 stream_id);
|
||
|
s32 Start();
|
||
|
bool GetAudioData(SceAvPlayerFrameInfo& audio_info);
|
||
|
bool GetVideoData(SceAvPlayerFrameInfo& video_info);
|
||
|
bool GetVideoData(SceAvPlayerFrameInfoEx& video_info);
|
||
|
bool IsActive();
|
||
|
u64 CurrentTime();
|
||
|
s32 Stop();
|
||
|
|
||
|
private:
|
||
|
using ScePthreadMutex = Kernel::ScePthreadMutex;
|
||
|
|
||
|
std::unique_ptr<AvPlayerState> m_state{};
|
||
|
SceAvPlayerInitData m_init_data{};
|
||
|
SceAvPlayerInitData m_init_data_original{};
|
||
|
SceAvPlayerPostInitData m_post_init_data{};
|
||
|
PthreadMutex m_file_io_mutex{};
|
||
|
|
||
|
std::atomic_bool m_has_source{};
|
||
|
};
|
||
|
|
||
|
} // namespace Libraries::AvPlayer
|