MediaRecorderPrivateOptions.h [plain text]
#pragma once
#include <wtf/Forward.h>
#if ENABLE(MEDIA_STREAM)
namespace WebCore {
struct MediaRecorderPrivateOptions {
String mimeType;
Optional<unsigned> audioBitsPerSecond;
Optional<unsigned> videoBitsPerSecond;
Optional<unsigned> bitsPerSecond;
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<MediaRecorderPrivateOptions> decode(Decoder&);
};
template<class Encoder>
inline void MediaRecorderPrivateOptions::encode(Encoder& encoder) const
{
encoder << mimeType;
encoder << audioBitsPerSecond;
encoder << videoBitsPerSecond;
encoder << bitsPerSecond;
}
template<class Decoder>
inline Optional<MediaRecorderPrivateOptions> MediaRecorderPrivateOptions::decode(Decoder& decoder)
{
String mimeType;
if (!decoder.decode(mimeType))
return WTF::nullopt;
Optional<Optional<unsigned>> audioBitsPerSecond;
decoder >> audioBitsPerSecond;
if (!audioBitsPerSecond)
return WTF::nullopt;
Optional<Optional<unsigned>> videoBitsPerSecond;
decoder >> videoBitsPerSecond;
if (!videoBitsPerSecond)
return WTF::nullopt;
Optional<Optional<unsigned>> bitsPerSecond;
decoder >> bitsPerSecond;
if (!bitsPerSecond)
return WTF::nullopt;
return MediaRecorderPrivateOptions { WTFMove(mimeType), *audioBitsPerSecond, *videoBitsPerSecond, *bitsPerSecond };
}
}
#endif // ENABLE(MEDIA_STREAM)