1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
6 #define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
8 #include "ipc/EnumSerializer.h"
9 #include "mozilla/dom/BindingIPCUtils.h"
10 #include "MediaMetadata.h"
11 #include "mozilla/dom/MediaSession.h"
12 #include "mozilla/dom/MediaSessionBinding.h"
13 #include "mozilla/Maybe.h"
18 typedef Maybe
<MediaMetadataBase
> MaybeMediaMetadataBase
;
21 } // namespace mozilla
26 struct ParamTraits
<mozilla::dom::MediaImage
> {
27 typedef mozilla::dom::MediaImage paramType
;
29 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
30 WriteParam(aWriter
, aParam
.mSizes
);
31 WriteParam(aWriter
, aParam
.mSrc
);
32 WriteParam(aWriter
, aParam
.mType
);
35 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
36 if (!ReadParam(aReader
, &(aResult
->mSizes
)) ||
37 !ReadParam(aReader
, &(aResult
->mSrc
)) ||
38 !ReadParam(aReader
, &(aResult
->mType
))) {
46 struct ParamTraits
<mozilla::dom::MediaMetadataBase
> {
47 typedef mozilla::dom::MediaMetadataBase paramType
;
49 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
50 WriteParam(aWriter
, aParam
.mTitle
);
51 WriteParam(aWriter
, aParam
.mArtist
);
52 WriteParam(aWriter
, aParam
.mAlbum
);
53 WriteParam(aWriter
, aParam
.mArtwork
);
56 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
57 if (!ReadParam(aReader
, &(aResult
->mTitle
)) ||
58 !ReadParam(aReader
, &(aResult
->mArtist
)) ||
59 !ReadParam(aReader
, &(aResult
->mAlbum
)) ||
60 !ReadParam(aReader
, &(aResult
->mArtwork
))) {
68 struct ParamTraits
<mozilla::dom::PositionState
> {
69 typedef mozilla::dom::PositionState paramType
;
71 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
72 WriteParam(aWriter
, aParam
.mDuration
);
73 WriteParam(aWriter
, aParam
.mPlaybackRate
);
74 WriteParam(aWriter
, aParam
.mLastReportedPlaybackPosition
);
75 WriteParam(aWriter
, aParam
.mPositionUpdatedTime
);
78 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
79 if (!ReadParam(aReader
, &(aResult
->mDuration
)) ||
80 !ReadParam(aReader
, &(aResult
->mPlaybackRate
)) ||
81 !ReadParam(aReader
, &(aResult
->mLastReportedPlaybackPosition
)) ||
82 !ReadParam(aReader
, &(aResult
->mPositionUpdatedTime
))) {
90 struct ParamTraits
<mozilla::dom::MediaSessionPlaybackState
>
91 : public mozilla::dom::WebIDLEnumSerializer
<
92 mozilla::dom::MediaSessionPlaybackState
> {};
95 struct ParamTraits
<mozilla::dom::MediaSessionAction
>
96 : public mozilla::dom::WebIDLEnumSerializer
<
97 mozilla::dom::MediaSessionAction
> {};
101 #endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_