1.10
video.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_VIDEO_H
7#define EGT_VIDEO_H
8
14#include <egt/detail/meta.h>
15#include <egt/signal.h>
16#include <egt/window.h>
17
18namespace egt
19{
20inline namespace v1
21{
22namespace detail
23{
26bool audio_device();
28WindowHint check_windowhint(WindowHint& hint);
29class GstDecoderImpl;
30class GstAppSinkImpl;
31}
32
44class EGT_API VideoWindow : public Window
45{
46protected:
48 /*
49 * Must be declared before SignalW members to match the order of members
50 * in the constructor initialization lists.
51 */
52 std::unique_ptr<detail::GstDecoderImpl> m_video_impl;
53
54public:
55
62
65
68
83 explicit VideoWindow(const Rect& rect = {},
84 PixelFormat format = PixelFormat::xrgb8888,
85 WindowHint hint = WindowHint::overlay);
86
98 VideoWindow(const Rect& rect,
99 const std::string& uri,
100 PixelFormat format = PixelFormat::xrgb8888,
101 WindowHint hint = WindowHint::overlay);
102
109 : VideoWindow(props, false)
110 {
111 }
112
113protected:
114
115 VideoWindow(Serializer::Properties& props, bool is_derived);
116
117public:
118
119 VideoWindow(const VideoWindow&) = delete;
122 VideoWindow& operator=(VideoWindow&&) noexcept;
123
124 void do_draw() override
125 {
126 // video windows don't draw
127 }
128
129 void draw(Painter& painter, const Rect& rect) override;
130
137 bool media(const std::string& uri);
138
144 EGT_NODISCARD std::string media() const
145 {
146 return m_uri;
147 }
148
154 bool play();
155
161 bool pause();
162
168 EGT_NODISCARD bool playing() const;
169
175 EGT_NODISCARD int64_t position() const;
176
182 EGT_NODISCARD int64_t duration() const;
183
190 bool volume(int volume);
191
196 EGT_NODISCARD int volume() const;
197
207 bool seek(int64_t pos);
208
215 void loopback(bool enable);
216
222 EGT_NODISCARD bool loopback() const;
223
224 using Window::scale;
225 void scale(float hscale, float vscale) override;
226
227 using Window::resize;
228 void resize(const Size& s) override;
229
236 EGT_NODISCARD bool has_audio() const;
237
238 void gst_custom_pipeline(const std::string& pipeline_desc);
239
240 void serialize(Serializer& serializer) const override;
241
242 ~VideoWindow() noexcept override;
243
244protected:
246 std::string m_uri;
247
248 friend class detail::GstDecoderImpl;
249 friend class detail::GstAppSinkImpl;
250
251private:
252
253 void deserialize(Serializer::Properties& props);
254};
255
256}
257
258}
259
260#endif
Drawing interface for 2D graphics.
Definition painter.h:45
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Definition signal.h:184
A VideoWindow is a widget to decode video and render it to a screen.
Definition video.h:45
EGT_NODISCARD bool playing() const
Check is video in play state.
SignalW on_state_changed
Invoked when the state of the player changes.
Definition video.h:70
bool play()
Play the video.
EGT_NODISCARD bool has_audio() const
check for audio is supported.
EGT_NODISCARD int64_t duration() const
Get the total duration of the video.
VideoWindow(Serializer::Properties &props)
Construct a video window.
Definition video.h:108
bool volume(int volume)
Adjust volume of the video being played.
VideoWindow(const Rect &rect={}, PixelFormat format=PixelFormat::xrgb8888, WindowHint hint=WindowHint::overlay)
Create a video window to decode video and render it to a screen.
bool pause()
Pause the video.
EGT_NODISCARD int volume() const
Get the volume value for the video being played.
EGT_NODISCARD bool loopback() const
Get loop-back state.
~VideoWindow() noexcept override
VideoWindow(const Rect &rect, const std::string &uri, PixelFormat format=PixelFormat::xrgb8888, WindowHint hint=WindowHint::overlay)
Create a video window to decode video and render it to a screen.
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
SignalW< const std::string & > on_error
Invoked when an error occurs.
Definition video.h:64
SignalW< int64_t > on_position_changed
Event signal.
Definition video.h:61
EGT_NODISCARD int64_t position() const
Get the current position of the video being played.
void gst_custom_pipeline(const std::string &pipeline_desc)
bool seek(int64_t pos)
Seek to a position.
SignalW on_eos
Invoked on end of stream.
Definition video.h:67
VideoWindow(Serializer::Properties &props, bool is_derived)
EGT_NODISCARD std::string media() const
get the media file used of video playback.
Definition video.h:144
void resize(const Size &s) override
Resize the widget.
VideoWindow(const VideoWindow &)=delete
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
VideoWindow & operator=(const VideoWindow &)=delete
VideoWindow(VideoWindow &&) noexcept
void loopback(bool enable)
Enable/disable continues loop-back mode of the video being played.
void scale(float hscale, float vscale) override
Set the scale of the widget.
bool media(const std::string &uri)
Initialize gstreamer pipeline for specified media file.
A Window is a Widget that handles drawing to a Screen.
Definition window.h:47
WindowHint
Hint used for configuring Window backends.
Definition widgetflags.h:683
PixelFormat
Supported pixel formats.
Definition types.h:94
EGT framework namespace.
Definition animation.h:24