[vlc-commits] [Git][videolan/libvlcpp][master] 5 commits: MediaPlayer: Fix indentation

Hugo Beauzée-Luyssen gitlab at videolan.org
Mon Nov 12 17:12:38 CET 2018


Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / libvlcpp


Commits:
72666e8b by Hugo Beauzée-Luyssen at 2018-10-18T11:41:00Z
MediaPlayer: Fix indentation

- - - - -
f5282cbe by Hugo Beauzée-Luyssen at 2018-10-18T12:14:03Z
Include libvlc_version from common.hpp

- - - - -
cc3276f5 by Hugo Beauzée-Luyssen at 2018-10-18T15:36:46Z
Add libvlc_picture_t support

- - - - -
05c72b1c by Hugo Beauzée-Luyssen at 2018-10-18T15:36:46Z
structures: Remove trailing whitespace

- - - - -
6fe9a537 by Hugo Beauzée-Luyssen at 2018-11-12T15:32:24Z
Add Media thumbnail support

- - - - -


8 changed files:

- Makefile.am
- vlcpp/EventManager.hpp
- vlcpp/Media.hpp
- vlcpp/MediaPlayer.hpp
- + vlcpp/Picture.hpp
- vlcpp/common.hpp
- vlcpp/structures.hpp
- vlcpp/vlc.hpp


Changes:

=====================================
Makefile.am
=====================================
@@ -18,6 +18,7 @@ libvlcpp_HEADERS =          \
 	vlcpp/MediaPlayer.hpp         \
 	vlcpp/Dialog.hpp			  \
 	vlcpp/RendererDiscoverer.hpp  \
+	vlcpp/Picture.hpp			  \
 	vlcpp/structures.hpp          \
 	vlcpp/vlc.hpp                 \
 	$(NULL)


=====================================
vlcpp/EventManager.hpp
=====================================
@@ -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
=====================================
@@ -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:
 


=====================================
vlcpp/MediaPlayer.hpp
=====================================
@@ -107,7 +107,7 @@ public:
     {
     }
 
-/**
+    /**
      * Create an empty VLC MediaPlayer instance.
      *
      * Calling any method on such an instance is undefined.


=====================================
vlcpp/Picture.hpp
=====================================
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Picture.hpp: Picture API
+ *****************************************************************************
+ * Copyright © 2018 libvlcpp authors & VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef LIBVLC_CXX_PICTURE_HPP
+#define LIBVLC_CXX_PICTURE_HPP
+
+#include "common.hpp"
+
+#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
+
+namespace VLC
+{
+
+class Picture : public Internal<libvlc_picture_t>
+{
+public:
+    enum class Type : uint8_t
+    {
+        Argb = libvlc_picture_Argb,
+        Jpg = libvlc_picture_Jpg,
+        Png = libvlc_picture_Png,
+    };
+
+    Picture() = default;
+
+    explicit Picture( Internal::InternalPtr ptr )
+        : Internal( ptr, libvlc_picture_release )
+    {
+        libvlc_picture_retain( ptr );
+    }
+
+    /**
+     * Saves this picture to a file. The image format is the same as the one
+     * returned by \link Picture::type() \endlink
+     *
+     * \param path The path to the generated file
+     * \return true in case of success, false otherwise
+     */
+    bool save( const std::string& path ) const
+    {
+        return libvlc_picture_save( *this, path.c_str() ) == 0;
+    }
+
+    /**
+     * Returns the image internal buffer, including potential padding.
+     * The picture instance owns the returned buffer, which must not be modified
+     * nor freed.
+     *
+     * \param size A pointer to a size_t that will hold the size of the buffer [out] [required]
+     * \return A pointer to the internal buffer.
+     */
+    const uint8_t* buffer( size_t* size ) const
+    {
+        return libvlc_picture_get_buffer( *this, size );
+    }
+
+    /**
+     * Returns the picture type
+     *
+     * \see Picture::Type
+     */
+    Type type() const
+    {
+        return static_cast<Type>( libvlc_picture_type( *this ) );
+    }
+
+    /**
+     * Returns the image stride, ie. the number of bytes per line.
+     * This can only be called on images of type Picture::Type::Argb
+     */
+    uint32_t stride() const
+    {
+        return libvlc_picture_get_stride( *this );
+    }
+
+    /**
+     * Returns the width of the image in pixels
+     */
+    uint32_t width() const
+    {
+        return libvlc_picture_get_width( *this );
+    }
+
+    /**
+     * Returns the height of the image in pixels
+     */
+    uint32_t height() const
+    {
+        return libvlc_picture_get_height( *this );
+    }
+
+    /**
+     * Returns the time at which this picture was generated, in milliseconds
+     */
+    libvlc_time_t time() const
+    {
+        return libvlc_picture_get_time( *this );
+    }
+};
+
+}
+
+#endif
+
+#endif // LIBVLC_CXX_PICTURE_HPP


=====================================
vlcpp/common.hpp
=====================================
@@ -29,6 +29,7 @@ using ssize_t = long int;
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc/libvlc_version.h>
 #include <array>
 #include <cassert>
 #include <memory>


=====================================
vlcpp/structures.hpp
=====================================
@@ -27,7 +27,7 @@
 #include <string>
 
 #include "common.hpp"
-#include <vlc/libvlc_version.h>
+#include "Picture.hpp"
 
 //FIXME:
 //Should we make the constructors private again and implement our own vector allocator?
@@ -693,7 +693,7 @@ public:
     }
 };
 
-class RendererDiscovererDescription 
+class RendererDiscovererDescription
 {
 public:
     explicit RendererDiscovererDescription( const libvlc_rd_description_t* d )


=====================================
vlcpp/vlc.hpp
=====================================
@@ -28,6 +28,7 @@
 #include "Equalizer.hpp"
 #include "MediaListPlayer.hpp"
 #include "MediaDiscoverer.hpp"
+#include "Picture.hpp"
 #include "Media.hpp"
 #include "MediaList.hpp"
 #include "RendererDiscoverer.hpp"



View it on GitLab: https://code.videolan.org/videolan/libvlcpp/compare/d1b6a9019d2b4d6779280f4673401014949353f3...6fe9a537c49d854e19ddb282677c93012d033078

-- 
View it on GitLab: https://code.videolan.org/videolan/libvlcpp/compare/d1b6a9019d2b4d6779280f4673401014949353f3...6fe9a537c49d854e19ddb282677c93012d033078
You're receiving this email because of your account on code.videolan.org.


More information about the vlc-commits mailing list