Paul Adenot 2022-02-16 13:36:54 +00:00
Родитель 2b8f3b9ba5
Коммит 792cfa9cb9
5 изменённых файлов: 5 добавлений и 55 удалений

Просмотреть файл

@ -145,43 +145,6 @@ MediaExtendedMIMEType::MediaExtendedMIMEType(const MediaMIMEType& aType)
MediaExtendedMIMEType::MediaExtendedMIMEType(MediaMIMEType&& aType)
: mOriginalString(aType.AsString()), mMIMEType(std::move(aType)) {}
/* static */
Maybe<double> MediaExtendedMIMEType::ComputeFractionalString(
const nsAString& aFrac) {
nsAutoString frac(aFrac);
nsresult error;
double result = frac.ToDouble(&error);
if (NS_SUCCEEDED(error)) {
if (result <= 0) {
return Nothing();
}
return Some(result);
}
int32_t slashPos = frac.Find(u"/"_ns);
if (slashPos == kNotFound) {
return Nothing();
}
nsAutoString firstPart(Substring(frac, 0, slashPos - 1));
double first = firstPart.ToDouble(&error);
if (NS_FAILED(error)) {
return Nothing();
}
nsAutoString secondPart(Substring(frac, slashPos + 1));
double second = secondPart.ToDouble(&error);
if (NS_FAILED(error) || second == 0) {
return Nothing();
}
result = first / second;
if (result <= 0) {
return Nothing();
}
return Some(result);
}
Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(const nsAString& aType) {
nsContentTypeParser parser(aType);
nsAutoString mime;
@ -230,15 +193,13 @@ Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(
rv = parser.GetParameter("codecs", codecs);
bool haveCodecs = NS_SUCCEEDED(rv);
auto framerate =
MediaExtendedMIMEType::ComputeFractionalString(aConfig.mFramerate);
if (!framerate) {
if (!IsFinite(aConfig.mFramerate) || aConfig.mFramerate <= 0.0) {
return Nothing();
}
return Some(MediaExtendedMIMEType(
NS_ConvertUTF16toUTF8(aConfig.mContentType), mime8, haveCodecs, codecs,
aConfig.mWidth, aConfig.mHeight, framerate.ref(), aConfig.mBitrate));
aConfig.mWidth, aConfig.mHeight, aConfig.mFramerate, aConfig.mBitrate));
}
Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(

Просмотреть файл

@ -172,10 +172,6 @@ class MediaExtendedMIMEType {
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
// aFrac is either a floating-point number or a fraction made of two
// floating-point numbers.
static Maybe<double> ComputeFractionalString(const nsAString& aFrac);
private:
friend Maybe<MediaExtendedMIMEType> MakeMediaExtendedMIMEType(
const nsAString& aType);

Просмотреть файл

@ -63,11 +63,10 @@ static nsCString VideoConfigurationToStr(const VideoConfiguration* aConfig) {
auto str = nsPrintfCString(
"[contentType:%s width:%d height:%d bitrate:%" PRIu64
" framerate:%s hasAlphaChannel:%s hdrMetadataType:%s colorGamut:%s "
" framerate:%lf hasAlphaChannel:%s hdrMetadataType:%s colorGamut:%s "
"transferFunction:%s scalabilityMode:%s]",
NS_ConvertUTF16toUTF8(aConfig->mContentType).get(), aConfig->mWidth,
aConfig->mHeight, aConfig->mBitrate,
NS_ConvertUTF16toUTF8(aConfig->mFramerate).get(),
aConfig->mHeight, aConfig->mBitrate, aConfig->mFramerate,
aConfig->mHasAlphaChannel.WasPassed()
? aConfig->mHasAlphaChannel.Value() ? "true" : "false"
: "?",

Просмотреть файл

@ -37,7 +37,7 @@ dictionary VideoConfiguration {
required unsigned long width;
required unsigned long height;
required unsigned long long bitrate;
required DOMString framerate;
required double framerate;
boolean hasAlphaChannel;
HdrMetadataType hdrMetadataType;
ColorGamut colorGamut;

Просмотреть файл

@ -8,9 +8,6 @@
[Test that decodingInfo rejects if the video configuration contentType has more than one parameter]
expected: FAIL
[Test that decodingInfo() rejects framerate in the form of x/y]
expected: FAIL
[Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects]
expected: FAIL
@ -37,9 +34,6 @@
[Test that decodingInfo rejects if the video configuration contentType has more than one parameter]
expected: FAIL
[Test that decodingInfo() rejects framerate in the form of x/y]
expected: FAIL
[Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects]
expected: FAIL