[vlc-devel] [PATCH 1/2] demux: adaptive: add a method to check whether playlist can pause or not
Zhao Zhili
quinkblack at foxmail.com
Wed Apr 18 15:57:22 CEST 2018
Ping for review.
> On 13 Apr 2018, at 11:30 AM, Zhao Zhili <quinkblack at foxmail.com> wrote:
>
> HLS PLAYLIST-TYPE event stream can pause, even though it's live stream.
> ---
> modules/demux/adaptive/PlaylistManager.cpp | 4 +++-
> modules/demux/adaptive/PlaylistManager.h | 1 +
> modules/demux/adaptive/playlist/AbstractPlaylist.cpp | 5 +++++
> modules/demux/adaptive/playlist/AbstractPlaylist.hpp | 1 +
> 4 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
> index 81000a6..45d0263 100644
> --- a/modules/demux/adaptive/PlaylistManager.cpp
> +++ b/modules/demux/adaptive/PlaylistManager.cpp
> @@ -74,6 +74,7 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
> vlc_cond_init(&waitcond);
> vlc_mutex_init(&cached.lock);
> cached.b_live = false;
> + cached.b_canpause = true;
> cached.i_length = 0;
> cached.f_position = 0.0;
> cached.i_time = VLC_TS_INVALID;
> @@ -542,7 +543,7 @@ int PlaylistManager::doControl(int i_query, va_list args)
> case DEMUX_SET_PAUSE_STATE:
> {
> vlc_mutex_locker locker(&cached.lock);
> - return cached.b_live ? VLC_EGENERIC : VLC_SUCCESS;
> + return cached.b_canpause ? VLC_SUCCESS : VLC_EGENERIC;
> }
>
> case DEMUX_GET_TIME:
> @@ -730,6 +731,7 @@ void PlaylistManager::updateControlsContentType()
> cached.b_live = false;
> cached.i_length = getDuration();
> }
> + cached.b_canpause = playlist->canPause();
> }
>
> AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::LogicType type, AbstractConnectionManager *conn)
> diff --git a/modules/demux/adaptive/PlaylistManager.h b/modules/demux/adaptive/PlaylistManager.h
> index 27f2f57..454182d 100644
> --- a/modules/demux/adaptive/PlaylistManager.h
> +++ b/modules/demux/adaptive/PlaylistManager.h
> @@ -121,6 +121,7 @@ namespace adaptive
> struct
> {
> bool b_live;
> + bool b_canpause;
> mtime_t i_length;
> mtime_t i_time;
> double f_position;
> diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
> index c89527a..6dc3240 100644
> --- a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
> +++ b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
> @@ -54,6 +54,11 @@ AbstractPlaylist::~AbstractPlaylist()
> delete(this->periods.at(i));
> }
>
> +bool AbstractPlaylist::canPause() const
> +{
> + return !isLive();
> +}
> +
> const std::vector<BasePeriod *>& AbstractPlaylist::getPeriods()
> {
> return periods;
> diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.hpp b/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
> index 51cf19e..9a620fb 100644
> --- a/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
> +++ b/modules/demux/adaptive/playlist/AbstractPlaylist.hpp
> @@ -41,6 +41,7 @@ namespace adaptive
> virtual ~AbstractPlaylist();
>
> virtual bool isLive() const = 0;
> + virtual bool canPause() const;
> void setType(const std::string &);
> void setMinBuffering( mtime_t );
> mtime_t getMinBuffering() const;
> --
> 2.9.5
>
More information about the vlc-devel
mailing list