1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef ipc_MediaControlIPC_h
8 #define ipc_MediaControlIPC_h
9 
10 #include "ipc/EnumSerializer.h"
11 
12 #include "mozilla/dom/MediaControllerBinding.h"
13 #include "mozilla/dom/MediaControlKeySource.h"
14 #include "mozilla/dom/MediaPlaybackStatus.h"
15 
16 namespace IPC {
17 template <>
18 struct ParamTraits<mozilla::dom::MediaControlKey>
19     : public ContiguousEnumSerializerInclusive<
20           mozilla::dom::MediaControlKey, mozilla::dom::MediaControlKey::Focus,
21           mozilla::dom::MediaControlKey::Stop> {};
22 
23 template <>
24 struct ParamTraits<mozilla::dom::MediaPlaybackState>
25     : public ContiguousEnumSerializerInclusive<
26           mozilla::dom::MediaPlaybackState,
27           mozilla::dom::MediaPlaybackState::eStarted,
28           mozilla::dom::MediaPlaybackState::eStopped> {};
29 
30 template <>
31 struct ParamTraits<mozilla::dom::MediaAudibleState>
32     : public ContiguousEnumSerializerInclusive<
33           mozilla::dom::MediaAudibleState,
34           mozilla::dom::MediaAudibleState::eInaudible,
35           mozilla::dom::MediaAudibleState::eAudible> {};
36 
37 template <>
38 struct ParamTraits<mozilla::dom::SeekDetails> {
39   typedef mozilla::dom::SeekDetails paramType;
40 
41   static void Write(MessageWriter* aWriter, const paramType& aParam) {
42     WriteParam(aWriter, aParam.mSeekTime);
43     WriteParam(aWriter, aParam.mFastSeek);
44   }
45 
46   static bool Read(MessageReader* aReader, paramType* aResult) {
47     if (!ReadParam(aReader, &aResult->mSeekTime) ||
48         !ReadParam(aReader, &aResult->mFastSeek)) {
49       return false;
50     }
51     return true;
52   }
53 };
54 
55 template <>
56 struct ParamTraits<mozilla::dom::MediaControlAction> {
57   typedef mozilla::dom::MediaControlAction paramType;
58 
59   static void Write(MessageWriter* aWriter, const paramType& aParam) {
60     WriteParam(aWriter, aParam.mKey);
61     WriteParam(aWriter, aParam.mDetails);
62   }
63 
64   static bool Read(MessageReader* aReader, paramType* aResult) {
65     if (!ReadParam(aReader, &aResult->mKey) ||
66         !ReadParam(aReader, &aResult->mDetails)) {
67       return false;
68     }
69     return true;
70   }
71 };
72 
73 }  // namespace IPC
74 
75 #endif  // mozilla_MediaControlIPC_hh
76