Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / dom / media / mediasession / MediaSessionIPCUtils.h
blob8a3f2cf16a6d8093b02037abbf69f2ed48a1fe04
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"
15 namespace mozilla {
16 namespace dom {
18 typedef Maybe<MediaMetadataBase> MaybeMediaMetadataBase;
20 } // namespace dom
21 } // namespace mozilla
23 namespace IPC {
25 template <>
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))) {
39 return false;
41 return true;
45 template <>
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))) {
63 return false;
65 return true;
69 template <>
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))) {
85 return false;
87 return true;
91 template <>
92 struct ParamTraits<mozilla::dom::MediaSessionPlaybackState>
93 : public mozilla::dom::WebIDLEnumSerializer<
94 mozilla::dom::MediaSessionPlaybackState> {};
96 template <>
97 struct ParamTraits<mozilla::dom::MediaSessionAction>
98 : public mozilla::dom::WebIDLEnumSerializer<
99 mozilla::dom::MediaSessionAction> {};
101 } // namespace IPC
103 #endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_