103 lines
2.5 KiB
C++
103 lines
2.5 KiB
C++
#ifndef ECLIPT_PLAYER_H
|
|
#define ECLIPT_PLAYER_H
|
|
|
|
#include "Config.h"
|
|
#include "Frame.h"
|
|
#include "Playlist.h"
|
|
#include "EPG.h"
|
|
#include "Decoder.h"
|
|
#include <memory>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <condition_variable>
|
|
|
|
namespace eclipt {
|
|
|
|
enum class PlayerState {
|
|
Stopped,
|
|
Opening,
|
|
Buffering,
|
|
Playing,
|
|
Paused,
|
|
Error
|
|
};
|
|
|
|
struct PlayerStats {
|
|
int64_t current_pts = 0;
|
|
int64_t buffer_duration_ms = 0;
|
|
int dropped_frames = 0;
|
|
int decoded_frames = 0;
|
|
double fps = 0.0;
|
|
int network_bitrate = 0;
|
|
bool is_hardware_decoding = false;
|
|
};
|
|
|
|
class IPlatformHooks {
|
|
public:
|
|
virtual ~IPlatformHooks() = default;
|
|
virtual void* createHardwareContext() = 0;
|
|
virtual void destroyHardwareContext(void* ctx) = 0;
|
|
virtual bool uploadToTexture(const VideoFrame& frame, void* texture) = 0;
|
|
virtual bool supportsHardwareDecode(const char* codec) const = 0;
|
|
virtual std::string getPreferredDecoder() const = 0;
|
|
};
|
|
|
|
class EcliptPlayer {
|
|
public:
|
|
EcliptPlayer();
|
|
~EcliptPlayer();
|
|
|
|
void setConfig(const PlayerConfig& config);
|
|
PlayerConfig getConfig() const;
|
|
|
|
void setPlatformHooks(std::unique_ptr<IPlatformHooks> hooks);
|
|
|
|
void setLogCallback(LogCallback callback);
|
|
void setVideoCallback(FrameCallback callback);
|
|
void setAudioCallback(AudioCallback callback);
|
|
|
|
bool open(const std::string& url);
|
|
bool open(const std::string& url, const std::string& mime_type);
|
|
void close();
|
|
|
|
bool play();
|
|
bool pause();
|
|
bool stop();
|
|
|
|
bool seek(int64_t timestamp_ms, SeekDirection dir = SeekDirection::Absolute);
|
|
bool seekToProgram(unsigned int program_id);
|
|
bool seekToChannel(int channel_number);
|
|
|
|
PlayerState getState() const;
|
|
PlayerStats getStats() const;
|
|
|
|
float getVolume() const;
|
|
void setVolume(float volume);
|
|
|
|
bool setAudioTrack(int track_index);
|
|
bool setSubtitleTrack(int track_index);
|
|
|
|
std::vector<StreamInfo> getAudioTracks() const;
|
|
std::vector<StreamInfo> getSubtitleTracks() const;
|
|
|
|
bool isPlaying() const { return getState() == PlayerState::Playing; }
|
|
int64_t getDuration() const;
|
|
int64_t getCurrentPosition() const;
|
|
|
|
VideoFrame interpolate(const VideoFrame& a, const VideoFrame& b);
|
|
VideoFrame getDecodedFrame();
|
|
|
|
void setInterpolationEnabled(bool enabled);
|
|
bool isInterpolationEnabled() const;
|
|
|
|
static const char* getVersion();
|
|
static void setGlobalLogLevel(LogLevel level);
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> pImpl;
|
|
};
|
|
|
|
}
|
|
#endif
|