[vlc-devel] [vlc-commits] demux: hls: add keystore (fix #18259)

Rémi Denis-Courmont remi at remlab.net
Wed Apr 26 19:07:22 CEST 2017


Le keskiviikkona 26. huhtikuuta 2017, 16.39.40 EEST Francois Cartegnie a 
écrit :
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 26
> 18:38:24 2017 +0200| [2de6e358177a1b805090283ab1ed21d3ae686829] |
> committer: Francois Cartegnie
> 
> demux: hls: add keystore (fix #18259)
> 
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2de6e358177a1b80509
> > 0283ab1ed21d3ae686829
> ---
> 
>  modules/demux/hls/playlist/M3U8.cpp   | 33
> +++++++++++++++++++++++++++++++++ modules/demux/hls/playlist/M3U8.hpp   | 
> 5 +++++
>  modules/demux/hls/playlist/Parser.cpp | 15 +++------------
>  3 files changed, 41 insertions(+), 12 deletions(-)
> 
> diff --git a/modules/demux/hls/playlist/M3U8.cpp
> b/modules/demux/hls/playlist/M3U8.cpp index 648414122e..1d2ec2b5ac 100644
> --- a/modules/demux/hls/playlist/M3U8.cpp
> +++ b/modules/demux/hls/playlist/M3U8.cpp
> @@ -25,9 +25,11 @@
>  #include "Representation.hpp"
>  #include "../adaptive/playlist/BasePeriod.h"
>  #include "../adaptive/playlist/BaseAdaptationSet.h"
> +#include "../adaptive/tools/Retrieve.hpp"
> 
>  #include <vlc_common.h>
>  #include <vlc_stream.h>
> +#include <vlc_block.h>
> 
>  using namespace hls::playlist;
> 
> @@ -35,11 +37,42 @@ M3U8::M3U8 (vlc_object_t *p_object) :
>      AbstractPlaylist(p_object)
>  {
>      minUpdatePeriod.Set( 5 * CLOCK_FREQ );
> +    vlc_mutex_init(&keystore_lock);
>  }
> 
>  M3U8::~M3U8()
>  {
> +    vlc_mutex_destroy(&keystore_lock);
> +}
> +
> +std::vector<std::uint8_t> M3U8::getEncryptionKey(const std::string &uri)
> +{
> +    std::vector<std::uint8_t> key;
> +
> +    vlc_mutex_lock( &keystore_lock );
> +    std::map<std::string, std::vector<std::uint8_t>>::iterator it =
> keystore.find(uri); +    if(it == keystore.end())
> +    {
> +        /* Pretty bad inside the lock */

You don´t say... Why do you not fetch the key outside the lock, and check for 
accidental race duplicates afterwards?


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list