diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/media/mediasession/MediaSessionIPCUtils.h | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/mediasession/MediaSessionIPCUtils.h')
-rw-r--r-- | dom/media/mediasession/MediaSessionIPCUtils.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dom/media/mediasession/MediaSessionIPCUtils.h b/dom/media/mediasession/MediaSessionIPCUtils.h new file mode 100644 index 0000000000..c44f4b4553 --- /dev/null +++ b/dom/media/mediasession/MediaSessionIPCUtils.h @@ -0,0 +1,102 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_ +#define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_ + +#include "ipc/EnumSerializer.h" +#include "MediaMetadata.h" +#include "mozilla/dom/MediaSession.h" +#include "mozilla/dom/MediaSessionBinding.h" +#include "mozilla/Maybe.h" + +namespace mozilla { +namespace dom { + +typedef Maybe<MediaMetadataBase> MaybeMediaMetadataBase; + +} // namespace dom +} // namespace mozilla + +namespace IPC { + +template <> +struct ParamTraits<mozilla::dom::MediaImage> { + typedef mozilla::dom::MediaImage paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mSizes); + WriteParam(aWriter, aParam.mSrc); + WriteParam(aWriter, aParam.mType); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mSizes)) || + !ReadParam(aReader, &(aResult->mSrc)) || + !ReadParam(aReader, &(aResult->mType))) { + return false; + } + return true; + } +}; + +template <> +struct ParamTraits<mozilla::dom::MediaMetadataBase> { + typedef mozilla::dom::MediaMetadataBase paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mTitle); + WriteParam(aWriter, aParam.mArtist); + WriteParam(aWriter, aParam.mAlbum); + WriteParam(aWriter, aParam.mArtwork); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mTitle)) || + !ReadParam(aReader, &(aResult->mArtist)) || + !ReadParam(aReader, &(aResult->mAlbum)) || + !ReadParam(aReader, &(aResult->mArtwork))) { + return false; + } + return true; + } +}; + +template <> +struct ParamTraits<mozilla::dom::PositionState> { + typedef mozilla::dom::PositionState paramType; + + static void Write(MessageWriter* aWriter, const paramType& aParam) { + WriteParam(aWriter, aParam.mDuration); + WriteParam(aWriter, aParam.mPlaybackRate); + WriteParam(aWriter, aParam.mLastReportedPlaybackPosition); + } + + static bool Read(MessageReader* aReader, paramType* aResult) { + if (!ReadParam(aReader, &(aResult->mDuration)) || + !ReadParam(aReader, &(aResult->mPlaybackRate)) || + !ReadParam(aReader, &(aResult->mLastReportedPlaybackPosition))) { + return false; + } + return true; + } +}; + +template <> +struct ParamTraits<mozilla::dom::MediaSessionPlaybackState> + : public ContiguousEnumSerializer< + mozilla::dom::MediaSessionPlaybackState, + mozilla::dom::MediaSessionPlaybackState::None, + mozilla::dom::MediaSessionPlaybackState::EndGuard_> {}; + +template <> +struct ParamTraits<mozilla::dom::MediaSessionAction> + : public ContiguousEnumSerializer< + mozilla::dom::MediaSessionAction, + mozilla::dom::MediaSessionAction::Play, + mozilla::dom::MediaSessionAction::EndGuard_> {}; + +} // namespace IPC + +#endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_ |