[vpx] Store VPXDecoder codec as an enum

Use the enum we already have here instead of converting to an int when we pass it around, giving us better type checking.
This commit is contained in:
trav90 2018-10-08 21:10:31 -05:00 • committed by Roy Tam
commit 0c88f36323
2 changed files with 5 additions and 4 deletions

View file

@ -22,7 +22,7 @@ namespace mozilla {
using namespace gfx; using namespace gfx;
using namespace layers; using namespace layers;
static int MimeTypeToCodec(const nsACString& aMimeType) static VPXDecoder::Codec MimeTypeToCodec(const nsACString& aMimeType)
{ {
if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) { if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) {
return VPXDecoder::Codec::VP8; return VPXDecoder::Codec::VP8;
@ -31,7 +31,7 @@ static int MimeTypeToCodec(const nsACString& aMimeType)
} else if (aMimeType.EqualsLiteral("video/vp9")) { } else if (aMimeType.EqualsLiteral("video/vp9")) {
return VPXDecoder::Codec::VP9; return VPXDecoder::Codec::VP9;
} }
return -1; return VPXDecoder::Codec::Unknown;
} }
VPXDecoder::VPXDecoder(const CreateDecoderParams& aParams) VPXDecoder::VPXDecoder(const CreateDecoderParams& aParams)

View file

@ -36,7 +36,8 @@ public:
enum Codec: uint8_t { enum Codec: uint8_t {
VP8 = 1 << 0, 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 // Return true if aMimeType is a one of the strings used by our demuxers to
@ -61,7 +62,7 @@ private:
const VideoInfo& mInfo; const VideoInfo& mInfo;
const int mCodec; const Codec mCodec;
}; };
} // namespace mozilla } // namespace mozilla