Bug 1358662 - Store VPXDecoder codec as an enum. r=jya
Use the enum we already have here instead of converting
to an int when we pass it around, giving us better
type checking.
MozReview-Commit-ID: Gj4xmtQnzw2
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -17,32 +17,32 @@
#undef LOG
#define LOG(arg, ...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, ("VPXDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
namespace mozilla {
using namespace gfx;
using namespace layers;
-static int MimeTypeToCodec(const nsACString& aMimeType)
+static VPXDecoder::Codec MimeTypeToCodec(const nsACString& aMimeType)
{
if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) {
return VPXDecoder::Codec::VP8;
} else if (aMimeType.EqualsLiteral("video/webm; codecs=vp9")) {
return VPXDecoder::Codec::VP9;
} else if (aMimeType.EqualsLiteral("video/vp9")) {
return VPXDecoder::Codec::VP9;
}
- return -1;
+ return VPXDecoder::Codec::Unknown;
}
static nsresult
InitContext(vpx_codec_ctx_t* aCtx,
const VideoInfo& aInfo,
- const int aCodec)
+ const VPXDecoder::Codec aCodec)
{
int decode_threads = 2;
vpx_codec_iface_t* dx = nullptr;
if (aCodec == VPXDecoder::Codec::VP8) {
dx = vpx_codec_vp8_dx();
}
else if (aCodec == VPXDecoder::Codec::VP9) {
--- a/dom/media/platforms/agnostic/VPXDecoder.h
+++ b/dom/media/platforms/agnostic/VPXDecoder.h
@@ -29,17 +29,18 @@ public:
const char* GetDescriptionName() const override
{
return "libvpx video decoder";
}
enum Codec: uint8_t
{
VP8 = 1 << 0,
- VP9 = 1 << 1
+ VP9 = 1 << 1,
+ Unknown = 1 << 7,
};
// Return true if aMimeType is a one of the strings used by our demuxers to
// identify VPX of the specified type. Does not parse general content type
// strings, i.e. white space matters.
static bool IsVPX(const nsACString& aMimeType, uint8_t aCodecMask=VP8|VP9);
static bool IsVP8(const nsACString& aMimeType);
static bool IsVP9(const nsACString& aMimeType);
@@ -55,14 +56,14 @@ private:
// VPx decoder state
vpx_codec_ctx_t mVPX;
// VPx alpha decoder state
vpx_codec_ctx_t mVPXAlpha;
const VideoInfo& mInfo;
- const int mCodec;
+ const Codec mCodec;
};
} // namespace mozilla
#endif