Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
YangLei
libvlcpp
Commits
6fe9a537
Commit
6fe9a537
authored
Oct 18, 2018
by
Hugo Beauzée-Luyssen
Browse files
Add Media thumbnail support
parent
05c72b1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
vlcpp/EventManager.hpp
View file @
6fe9a537
...
...
@@ -371,6 +371,34 @@ class MediaEventManager : public EventManager
(
*
callback
)(
media
!=
nullptr
?
std
::
make_shared
<
Media
>
(
media
,
true
)
:
nullptr
);
});
}
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
/**
* \brief onThumbnailGenerated is invoked upon success & failure of a thumbnail generation
* \param A std::function<void(const Picture*)> (or an equivalent Callable type)
* The provided picture will be null if the thumbnail generation failed.
* In case of success, the thumbnail is only valid for the duration
* of the callback, but can be safely copied if needed.
*/
template
<
typename
Func
>
RegisteredEvent
onThumbnailGenerated
(
Func
&&
f
)
{
EXPECT_SIGNATURE
(
void
(
const
Picture
*
));
return
handle
(
libvlc_MediaThumbnailGenerated
,
std
::
forward
<
Func
>
(
f
),
[](
const
libvlc_event_t
*
e
,
void
*
data
)
{
auto
callback
=
static_cast
<
DecayPtr
<
Func
>>
(
data
);
auto
pic
=
e
->
u
.
media_thumbnail_generated
.
p_thumbnail
;
if
(
pic
!=
nullptr
)
{
Picture
p
{
pic
};
(
*
callback
)(
&
p
);
}
else
(
*
callback
)(
nullptr
);
});
}
#endif
};
/**
...
...
vlcpp/Media.hpp
View file @
6fe9a537
...
...
@@ -743,6 +743,48 @@ public:
return
res
;
}
#endif
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
using
ThumbnailRequest
=
libvlc_media_thumbnail_request_t
;
enum
class
ThumbnailSeekSpeed
{
Precise
=
libvlc_media_thumbnail_seek_precise
,
Fast
=
libvlc_media_thumbnail_seek_fast
,
};
ThumbnailRequest
*
thumbnailRequestByTime
(
libvlc_time_t
time
,
ThumbnailSeekSpeed
speed
,
uint32_t
width
,
uint32_t
height
,
Picture
::
Type
type
,
libvlc_time_t
timeout
)
{
return
libvlc_media_thumbnail_request_by_time
(
*
this
,
time
,
static_cast
<
libvlc_thumbnailer_seek_speed
>
(
speed
),
width
,
height
,
static_cast
<
libvlc_picture_type_t
>
(
type
),
timeout
);
}
ThumbnailRequest
*
thumbnailRequestByPos
(
float
pos
,
ThumbnailSeekSpeed
speed
,
uint32_t
width
,
uint32_t
height
,
Picture
::
Type
type
,
libvlc_time_t
timeout
)
{
return
libvlc_media_thumbnail_request_by_pos
(
*
this
,
pos
,
static_cast
<
libvlc_thumbnailer_seek_speed
>
(
speed
),
width
,
height
,
static_cast
<
libvlc_picture_type_t
>
(
type
),
timeout
);
}
/**
* @brief thumbnailCancel cancels a thumbnailing request
* @param request An opaque thumbnail request object.
*
* Cancelling the request will still cause onThumbnailGenerated callback
* to be invoked, with nullptr as the picture instance.
* If the request is cancelled after its completion, the behavior is undefined.
*/
void
thumbnailCancel
(
ThumbnailRequest
*
request
)
{
libvlc_media_thumbnail_cancel
(
request
);
}
#endif
private:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment