#pragma once
#include "MediaSessionIdentifier.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
struct NowPlayingInfo {
String title;
String sourceApplicationIdentifier;
double duration { 0 };
double currentTime { 0 };
bool supportsSeeking { false };
MediaSessionIdentifier uniqueIdentifier;
bool isPlaying { false };
bool allowsNowPlayingControlsVisibility { false };
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<NowPlayingInfo> decode(Decoder&);
};
template<class Encoder> inline void NowPlayingInfo::encode(Encoder& encoder) const
{
encoder << title << sourceApplicationIdentifier << duration << currentTime << supportsSeeking << uniqueIdentifier << isPlaying << allowsNowPlayingControlsVisibility;
}
template<class Decoder> inline Optional<NowPlayingInfo> NowPlayingInfo::decode(Decoder& decoder)
{
String title;
if (!decoder.decode(title))
return { };
String sourceApplicationIdentifier;
if (!decoder.decode(sourceApplicationIdentifier))
return { };
double duration;
if (!decoder.decode(duration))
return { };
double currentTime;
if (!decoder.decode(currentTime))
return { };
bool supportsSeeking;
if (!decoder.decode(supportsSeeking))
return { };
MediaSessionIdentifier uniqueIdentifier;
if (!decoder.decode(uniqueIdentifier))
return { };
bool isPlaying;
if (!decoder.decode(isPlaying))
return { };
bool allowsNowPlayingControlsVisibility;
if (!decoder.decode(allowsNowPlayingControlsVisibility))
return { };
return NowPlayingInfo { WTFMove(title), WTFMove(sourceApplicationIdentifier), duration, currentTime, supportsSeeking, uniqueIdentifier, isPlaying, allowsNowPlayingControlsVisibility };
}
}