2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-28 16:39:18 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-28 16:39:18 +00:00
|
|
|
// VideoVlcComponent.h
|
|
|
|
//
|
|
|
|
// Video playing using libVLC.
|
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_VIDEO_VLC_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_VIDEO_VLC_COMPONENT_H
|
2017-01-25 15:00:56 +00:00
|
|
|
|
|
|
|
#include "VideoComponent.h"
|
2020-06-28 16:39:18 +00:00
|
|
|
|
2020-05-15 16:35:30 +00:00
|
|
|
#include <vlc/vlc.h>
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
struct SDL_mutex;
|
|
|
|
struct SDL_Surface;
|
|
|
|
struct libvlc_instance_t;
|
|
|
|
struct libvlc_media_t;
|
|
|
|
struct libvlc_media_player_t;
|
2017-01-25 15:00:56 +00:00
|
|
|
|
|
|
|
struct VideoContext {
|
2020-06-28 16:39:18 +00:00
|
|
|
SDL_Surface* surface;
|
|
|
|
SDL_mutex* mutex;
|
|
|
|
bool valid;
|
2017-01-25 15:00:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class VideoVlcComponent : public VideoComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-10-17 14:06:01 +00:00
|
|
|
VideoVlcComponent(Window* window);
|
2020-06-28 16:39:18 +00:00
|
|
|
virtual ~VideoVlcComponent();
|
2017-01-25 15:00:56 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Resize the video to fit this size. If one axis is zero, scale that axis to maintain
|
|
|
|
// aspect ratio. If both are non-zero, potentially break the aspect ratio. If both are
|
|
|
|
// zero, no resizing. This can be set before or after a video is loaded.
|
|
|
|
// setMaxSize() and setResize() are mutually exclusive.
|
|
|
|
void setResize(float width, float height) override;
|
2017-03-25 17:02:28 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Resize the video to be as large as possible but fit within a box of this size.
|
|
|
|
// This can be set before or after a video is loaded.
|
|
|
|
// Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive.
|
|
|
|
void setMaxSize(float width, float height) override;
|
2017-03-25 17:02:28 +00:00
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
private:
|
2020-11-17 16:20:25 +00:00
|
|
|
static void setupVLC();
|
|
|
|
void setupContext();
|
|
|
|
void freeContext();
|
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Calculates the correct mSize from our resizing information (set by setResize/setMaxSize).
|
|
|
|
// Used internally whenever the resizing parameters or texture change.
|
|
|
|
void resize();
|
2020-07-18 11:21:44 +00:00
|
|
|
|
2020-11-17 16:20:25 +00:00
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
|
|
|
void calculateBlackRectangle();
|
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
// Start the video immediately.
|
|
|
|
virtual void startVideo() override;
|
|
|
|
// Stop the video.
|
|
|
|
virtual void stopVideo() override;
|
2020-07-18 11:21:44 +00:00
|
|
|
// Pause the video when a game has been launched.
|
|
|
|
virtual void pauseVideo() override;
|
2020-06-28 16:39:18 +00:00
|
|
|
// Handle looping the video. Must be called periodically.
|
|
|
|
virtual void handleLooping() override;
|
2017-01-25 15:00:56 +00:00
|
|
|
|
2020-06-28 16:39:18 +00:00
|
|
|
static void VlcMediaParseCallback(const libvlc_event_t *event, void *user_data) {};
|
2020-05-15 16:35:30 +00:00
|
|
|
|
2020-12-22 22:27:23 +00:00
|
|
|
static VideoVlcComponent* sInstance;
|
2020-06-28 16:39:18 +00:00
|
|
|
static libvlc_instance_t* mVLC;
|
|
|
|
libvlc_media_t* mMedia;
|
|
|
|
libvlc_media_player_t* mMediaPlayer;
|
|
|
|
VideoContext mContext;
|
|
|
|
std::shared_ptr<TextureResource> mTexture;
|
2020-11-16 22:34:08 +00:00
|
|
|
std::vector<float> mVideoRectangleCoords;
|
2017-01-25 15:00:56 +00:00
|
|
|
};
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_CORE_COMPONENTS_VIDEO_VLC_COMPONENT_H
|