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
.mUrl
);
54 WriteParam(aWriter
, aParam
.mArtwork
);
57 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
58 if (!ReadParam(aReader
, &(aResult
->mTitle
)) ||
59 !ReadParam(aReader
, &(aResult
->mArtist
)) ||
60 !ReadParam(aReader
, &(aResult
->mAlbum
)) ||
61 !ReadParam(aReader
, &(aResult
->mUrl
)) ||
62 !ReadParam(aReader
, &(aResult
->mArtwork
))) {
70 struct ParamTraits
<mozilla::dom::PositionState
> {
71 typedef mozilla::dom::PositionState paramType
;
73 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
74 WriteParam(aWriter
, aParam
.mDuration
);
75 WriteParam(aWriter
, aParam
.mPlaybackRate
);
76 WriteParam(aWriter
, aParam
.mLastReportedPlaybackPosition
);
77 WriteParam(aWriter
, aParam
.mPositionUpdatedTime
);
80 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
81 if (!ReadParam(aReader
, &(aResult
->mDuration
)) ||
82 !ReadParam(aReader
, &(aResult
->mPlaybackRate
)) ||
83 !ReadParam(aReader
, &(aResult
->mLastReportedPlaybackPosition
)) ||
84 !ReadParam(aReader
, &(aResult
->mPositionUpdatedTime
))) {
92 struct ParamTraits
<mozilla::dom::MediaSessionPlaybackState
>
93 : public mozilla::dom::WebIDLEnumSerializer
<
94 mozilla::dom::MediaSessionPlaybackState
> {};
97 struct ParamTraits
<mozilla::dom::MediaSessionAction
>
98 : public mozilla::dom::WebIDLEnumSerializer
<
99 mozilla::dom::MediaSessionAction
> {};
103 #endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_