2016-09-21 12:24:43 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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 mozilla_dom_media_MediaIPCUtils_h
|
|
|
|
#define mozilla_dom_media_MediaIPCUtils_h
|
|
|
|
|
2020-10-21 02:26:27 +03:00
|
|
|
#include "DecoderDoctorDiagnostics.h"
|
2019-02-23 12:21:41 +03:00
|
|
|
#include "PlatformDecoderModule.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
#include "ipc/EnumSerializer.h"
|
2020-10-21 02:26:27 +03:00
|
|
|
#include "mozilla/EnumSet.h"
|
2016-09-21 12:24:43 +03:00
|
|
|
#include "mozilla/GfxMessageUtils.h"
|
2019-02-23 12:21:41 +03:00
|
|
|
#include "mozilla/gfx/Rect.h"
|
2016-09-21 12:24:43 +03:00
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::VideoInfo> {
|
|
|
|
typedef mozilla::VideoInfo paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
// TrackInfo
|
|
|
|
WriteParam(aMsg, aParam.mMimeType);
|
|
|
|
|
|
|
|
// VideoInfo
|
|
|
|
WriteParam(aMsg, aParam.mDisplay);
|
|
|
|
WriteParam(aMsg, aParam.mStereoMode);
|
|
|
|
WriteParam(aMsg, aParam.mImage);
|
2020-12-14 11:16:23 +03:00
|
|
|
WriteParam(aMsg, aParam.mImageRect);
|
2019-04-11 15:36:00 +03:00
|
|
|
WriteParam(aMsg, *aParam.mCodecSpecificConfig);
|
|
|
|
WriteParam(aMsg, *aParam.mExtraData);
|
|
|
|
WriteParam(aMsg, aParam.mRotation);
|
|
|
|
WriteParam(aMsg, aParam.mColorDepth);
|
|
|
|
WriteParam(aMsg, aParam.mColorSpace);
|
2019-07-26 11:45:22 +03:00
|
|
|
WriteParam(aMsg, aParam.mColorRange);
|
2019-04-11 15:36:00 +03:00
|
|
|
WriteParam(aMsg, aParam.HasAlpha());
|
2016-09-21 12:24:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
2017-08-29 05:00:33 +03:00
|
|
|
mozilla::gfx::IntRect imageRect;
|
2019-04-11 15:36:00 +03:00
|
|
|
bool alphaPresent;
|
2016-09-21 12:24:43 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &aResult->mMimeType) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mDisplay) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mStereoMode) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mImage) &&
|
2020-12-14 11:16:23 +03:00
|
|
|
ReadParam(aMsg, aIter, &aResult->mImageRect) &&
|
2019-04-11 15:36:00 +03:00
|
|
|
ReadParam(aMsg, aIter, aResult->mCodecSpecificConfig.get()) &&
|
|
|
|
ReadParam(aMsg, aIter, aResult->mExtraData.get()) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mRotation) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mColorDepth) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mColorSpace) &&
|
2019-07-26 11:45:22 +03:00
|
|
|
ReadParam(aMsg, aIter, &aResult->mColorRange) &&
|
2019-04-11 15:36:00 +03:00
|
|
|
ReadParam(aMsg, aIter, &alphaPresent)) {
|
|
|
|
aResult->SetAlpha(alphaPresent);
|
2016-09-21 12:24:43 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2018-11-19 16:25:37 +03:00
|
|
|
}
|
2016-09-21 12:24:43 +03:00
|
|
|
};
|
2018-11-14 21:06:11 +03:00
|
|
|
|
2019-02-14 22:08:21 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::TrackInfo::TrackType>
|
|
|
|
: public ContiguousEnumSerializerInclusive<
|
|
|
|
mozilla::TrackInfo::TrackType,
|
|
|
|
mozilla::TrackInfo::TrackType::kUndefinedTrack,
|
|
|
|
mozilla::TrackInfo::TrackType::kTextTrack> {};
|
|
|
|
|
2019-04-11 15:36:00 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::VideoInfo::Rotation>
|
|
|
|
: public ContiguousEnumSerializerInclusive<
|
|
|
|
mozilla::VideoInfo::Rotation, mozilla::VideoInfo::Rotation::kDegree_0,
|
|
|
|
mozilla::VideoInfo::Rotation::kDegree_270> {};
|
|
|
|
|
2019-02-14 22:08:21 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::MediaByteBuffer>
|
|
|
|
: public ParamTraits<nsTArray<uint8_t>> {
|
|
|
|
typedef mozilla::MediaByteBuffer paramType;
|
|
|
|
};
|
|
|
|
|
2018-11-14 21:06:11 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::AudioInfo> {
|
|
|
|
typedef mozilla::AudioInfo paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
// TrackInfo
|
|
|
|
WriteParam(aMsg, aParam.mMimeType);
|
|
|
|
|
|
|
|
// AudioInfo
|
|
|
|
WriteParam(aMsg, aParam.mRate);
|
|
|
|
WriteParam(aMsg, aParam.mChannels);
|
|
|
|
WriteParam(aMsg, aParam.mChannelMap);
|
|
|
|
WriteParam(aMsg, aParam.mBitDepth);
|
|
|
|
WriteParam(aMsg, aParam.mProfile);
|
|
|
|
WriteParam(aMsg, aParam.mExtendedProfile);
|
2019-02-14 22:08:21 +03:00
|
|
|
WriteParam(aMsg, *aParam.mCodecSpecificConfig);
|
2018-11-14 21:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
if (ReadParam(aMsg, aIter, &aResult->mMimeType) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mRate) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mChannels) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mChannelMap) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mBitDepth) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mProfile) &&
|
2019-02-14 22:08:21 +03:00
|
|
|
ReadParam(aMsg, aIter, &aResult->mExtendedProfile) &&
|
|
|
|
ReadParam(aMsg, aIter, aResult->mCodecSpecificConfig.get())) {
|
2018-11-14 21:06:11 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2018-11-19 16:25:37 +03:00
|
|
|
}
|
2018-11-14 21:06:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::MediaDataDecoder::ConversionRequired>
|
|
|
|
: public ContiguousEnumSerializerInclusive<
|
|
|
|
mozilla::MediaDataDecoder::ConversionRequired,
|
|
|
|
mozilla::MediaDataDecoder::ConversionRequired(0),
|
|
|
|
mozilla::MediaDataDecoder::ConversionRequired(
|
|
|
|
mozilla::MediaDataDecoder::ConversionRequired::kNeedAnnexB)> {};
|
|
|
|
|
2019-02-23 12:21:41 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::media::TimeUnit> {
|
|
|
|
typedef mozilla::media::TimeUnit paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.IsValid());
|
|
|
|
WriteParam(aMsg, aParam.IsValid() ? aParam.ToMicroseconds() : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
bool valid;
|
|
|
|
int64_t value;
|
|
|
|
if (ReadParam(aMsg, aIter, &valid) && ReadParam(aMsg, aIter, &value)) {
|
|
|
|
if (!valid) {
|
|
|
|
*aResult = mozilla::media::TimeUnit::Invalid();
|
|
|
|
} else {
|
|
|
|
*aResult = mozilla::media::TimeUnit::FromMicroseconds(value);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::media::TimeInterval> {
|
|
|
|
typedef mozilla::media::TimeInterval paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.mStart);
|
|
|
|
WriteParam(aMsg, aParam.mEnd);
|
|
|
|
WriteParam(aMsg, aParam.mFuzz);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
if (ReadParam(aMsg, aIter, &aResult->mStart) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mEnd) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mFuzz)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-26 17:51:56 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::MediaResult> {
|
|
|
|
typedef mozilla::MediaResult paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.Code());
|
|
|
|
WriteParam(aMsg, aParam.Message());
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
nsresult result;
|
|
|
|
nsCString message;
|
2020-12-04 03:59:04 +03:00
|
|
|
if (ReadParam(aMsg, aIter, &result) && ReadParam(aMsg, aIter, &message)) {
|
2019-09-26 17:51:56 +03:00
|
|
|
*aResult = paramType(result, std::move(message));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-10-21 02:26:27 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::DecoderDoctorDiagnostics> {
|
|
|
|
typedef mozilla::DecoderDoctorDiagnostics paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
WriteParam(aMsg, aParam.mDiagnosticsType);
|
|
|
|
WriteParam(aMsg, aParam.mFormat);
|
|
|
|
WriteParam(aMsg, aParam.mFlags);
|
|
|
|
WriteParam(aMsg, aParam.mEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
if (ReadParam(aMsg, aIter, &aResult->mDiagnosticsType) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mFormat) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mFlags) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mEvent)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::DecoderDoctorDiagnostics::DiagnosticsType>
|
|
|
|
: public ContiguousEnumSerializerInclusive<
|
|
|
|
mozilla::DecoderDoctorDiagnostics::DiagnosticsType,
|
|
|
|
mozilla::DecoderDoctorDiagnostics::DiagnosticsType::eUnsaved,
|
|
|
|
mozilla::DecoderDoctorDiagnostics::DiagnosticsType::eDecodeWarning> {
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::DecoderDoctorEvent> {
|
|
|
|
typedef mozilla::DecoderDoctorEvent paramType;
|
|
|
|
|
|
|
|
static void Write(Message* aMsg, const paramType& aParam) {
|
|
|
|
int domain = aParam.mDomain;
|
|
|
|
WriteParam(aMsg, domain);
|
|
|
|
WriteParam(aMsg, aParam.mResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
paramType* aResult) {
|
|
|
|
int domain = 0;
|
|
|
|
if (ReadParam(aMsg, aIter, &domain) &&
|
|
|
|
ReadParam(aMsg, aIter, &aResult->mResult)) {
|
|
|
|
aResult->mDomain = paramType::Domain(domain);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-21 12:24:43 +03:00
|
|
|
} // namespace IPC
|
|
|
|
|
|
|
|
#endif // mozilla_dom_media_MediaIPCUtils_h
|