2017-01-25 15:00:56 +00:00
|
|
|
#ifndef _VIDEOVLCCOMPONENT_H_
|
|
|
|
#define _VIDEOVLCCOMPONENT_H_
|
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
#include GLHEADER
|
|
|
|
|
|
|
|
#include "VideoComponent.h"
|
|
|
|
#include <vlc/vlc.h>
|
2017-06-01 20:08:44 +00:00
|
|
|
#include <vlc/libvlc_media.h>
|
2017-01-25 15:00:56 +00:00
|
|
|
#include "resources/TextureResource.h"
|
|
|
|
|
|
|
|
struct VideoContext {
|
|
|
|
SDL_Surface* surface;
|
|
|
|
SDL_mutex* mutex;
|
|
|
|
bool valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VideoVlcComponent : public VideoComponent
|
|
|
|
{
|
|
|
|
// Structure that groups together the configuration of the video component
|
|
|
|
struct Configuration
|
|
|
|
{
|
|
|
|
unsigned startDelay;
|
|
|
|
bool showSnapshotNoVideo;
|
|
|
|
bool showSnapshotDelay;
|
|
|
|
std::string defaultVideoPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2017-06-01 20:08:44 +00:00
|
|
|
static void setupVLC(std::string subtitles);
|
2017-01-25 15:00:56 +00:00
|
|
|
|
2017-06-01 20:08:44 +00:00
|
|
|
VideoVlcComponent(Window* window, std::string subtitles);
|
2017-01-25 15:00:56 +00:00
|
|
|
virtual ~VideoVlcComponent();
|
|
|
|
|
|
|
|
void render(const Eigen::Affine3f& parentTrans) override;
|
|
|
|
|
2017-03-25 17:02:28 +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.
|
|
|
|
// Can be set before or after a video is loaded.
|
|
|
|
// setMaxSize() and setResize() are mutually exclusive.
|
|
|
|
void setResize(float width, float height);
|
|
|
|
|
|
|
|
// Resize the video to be as large as possible but fit within a box of this size.
|
|
|
|
// 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);
|
|
|
|
|
2017-01-25 15:00:56 +00:00
|
|
|
private:
|
2017-03-25 17:02:28 +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();
|
2017-01-25 15:00:56 +00:00
|
|
|
// Start the video Immediately
|
|
|
|
virtual void startVideo();
|
|
|
|
// Stop the video
|
|
|
|
virtual void stopVideo();
|
|
|
|
// Handle looping the video. Must be called periodically
|
|
|
|
virtual void handleLooping();
|
|
|
|
|
|
|
|
void setupContext();
|
|
|
|
void freeContext();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static libvlc_instance_t* mVLC;
|
|
|
|
libvlc_media_t* mMedia;
|
|
|
|
libvlc_media_player_t* mMediaPlayer;
|
|
|
|
VideoContext mContext;
|
|
|
|
std::shared_ptr<TextureResource> mTexture;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|