зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1725190 - Incorrect file extension when downloading CR3 files. r=jolin
Differential Revision: https://phabricator.services.mozilla.com/D127291
This commit is contained in:
Родитель
b70b5914dd
Коммит
97efb10d2e
|
@ -8530,6 +8530,11 @@
|
|||
#endif
|
||||
mirror: always
|
||||
|
||||
- name: media.mp4.sniff_iso_brand
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Error/warning handling, Decoder Doctor.
|
||||
#
|
||||
# Set to true to force demux/decode warnings to be treated as errors.
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mp3sniff.h"
|
||||
#include "nestegg/nestegg.h"
|
||||
#include "nsHttpChannel.h"
|
||||
|
@ -61,27 +63,44 @@ nsMediaSnifferEntry nsMediaSniffer::sSnifferEntries[] = {
|
|||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF\xFF\xFF\xFF", "#EXTM3U",
|
||||
APPLICATION_MPEGURL)};
|
||||
|
||||
using PatternLabel = mozilla::Telemetry::LABELS_MEDIA_SNIFFER_MP4_BRAND_PATTERN;
|
||||
|
||||
struct nsMediaSnifferFtypEntry : nsMediaSnifferEntry {
|
||||
nsMediaSnifferFtypEntry(nsMediaSnifferEntry aBase, const PatternLabel aLabel)
|
||||
: nsMediaSnifferEntry(aBase), mLabel(aLabel) {}
|
||||
PatternLabel mLabel;
|
||||
};
|
||||
|
||||
// For a complete list of file types, see http://www.ftyps.com/index.html
|
||||
nsMediaSnifferEntry sFtypEntries[] = {
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF", "mp4", VIDEO_MP4), // Could be mp41 or mp42.
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF", "avc",
|
||||
VIDEO_MP4), // Could be avc1, avc2, ...
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "3gp4",
|
||||
VIDEO_MP4), // 3gp4 is based on MP4
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF", "3gp",
|
||||
VIDEO_3GPP), // Could be 3gp5, ...
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4V ", VIDEO_MP4),
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4A ", AUDIO_MP4),
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4P ", AUDIO_MP4),
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "qt ", VIDEO_QUICKTIME),
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF", "iso", VIDEO_MP4), // Could be isom or iso2.
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "mmp4", VIDEO_MP4),
|
||||
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "avif", IMAGE_AVIF),
|
||||
nsMediaSnifferFtypEntry sFtypEntries[] = {
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF", "mp4", VIDEO_MP4),
|
||||
PatternLabel::ftyp_mp4}, // Could be mp41 or mp42.
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF", "avc", VIDEO_MP4),
|
||||
PatternLabel::ftyp_avc}, // Could be avc1, avc2, ...
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "3gp4", VIDEO_MP4),
|
||||
PatternLabel::ftyp_3gp4}, // 3gp4 is based on MP4
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF", "3gp", VIDEO_3GPP),
|
||||
PatternLabel::ftyp_3gp}, // Could be 3gp5, ...
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4V ", VIDEO_MP4),
|
||||
PatternLabel::ftyp_M4V},
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4A ", AUDIO_MP4),
|
||||
PatternLabel::ftyp_M4A},
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "M4P ", AUDIO_MP4),
|
||||
PatternLabel::ftyp_M4P},
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "qt ", VIDEO_QUICKTIME),
|
||||
PatternLabel::ftyp_qt},
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF", "iso", VIDEO_MP4),
|
||||
PatternLabel::ftyp_iso}, // Could be isom or iso2.
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "mmp4", VIDEO_MP4),
|
||||
PatternLabel::ftyp_mmp4},
|
||||
{PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "avif", IMAGE_AVIF),
|
||||
PatternLabel::ftyp_avif},
|
||||
};
|
||||
|
||||
static bool MatchesBrands(const uint8_t aData[4], nsACString& aSniffedType) {
|
||||
for (size_t i = 0; i < mozilla::ArrayLength(sFtypEntries); ++i) {
|
||||
const auto& currentEntry = sFtypEntries[i];
|
||||
|
||||
bool matched = true;
|
||||
MOZ_ASSERT(currentEntry.mLength <= 4,
|
||||
"Pattern is too large to match brand strings.");
|
||||
|
@ -92,7 +111,17 @@ static bool MatchesBrands(const uint8_t aData[4], nsACString& aSniffedType) {
|
|||
}
|
||||
}
|
||||
if (matched) {
|
||||
// If we eventually remove the "iso" pattern entry per bug 1725190,
|
||||
// this block should be removed and the bug1725190.cr3 test in
|
||||
// test_mediasniffer_ext.js will need to be updated
|
||||
if (!mozilla::StaticPrefs::media_mp4_sniff_iso_brand() &&
|
||||
currentEntry.mLabel == PatternLabel::ftyp_iso) {
|
||||
matched = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
aSniffedType.AssignASCII(currentEntry.mContentType);
|
||||
AccumulateCategorical(currentEntry.mLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ const tests = [
|
|||
// An MP3 bytestream in a RIFF container, truncated to 512 bytes.
|
||||
{ path: "data/mp3-in-riff.wav", expected: "audio/mpeg" },
|
||||
// The sniffing-relevant portion of a Canon raw image
|
||||
{ path: "data/bug1725190.cr3", expected: "application/octet-stream" },
|
||||
{ path: "data/bug1725190.cr3", expected: "video/mp4" },
|
||||
];
|
||||
|
||||
// A basic listener that reads checks the if we sniffed properly.
|
||||
|
|
|
@ -10589,6 +10589,29 @@
|
|||
"description": "The operating system audio backend",
|
||||
"bug_numbers": [1671714, 1679745]
|
||||
},
|
||||
"MEDIA_SNIFFER_MP4_BRAND_PATTERN": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"products": ["firefox", "geckoview_streaming"],
|
||||
"alert_emails": ["jolin@mozilla.com", "jbauman@mozilla.com"],
|
||||
"expires_in_version": "never",
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"kind": "categorical",
|
||||
"labels": [
|
||||
"ftyp_mp4",
|
||||
"ftyp_avc",
|
||||
"ftyp_3gp4",
|
||||
"ftyp_3gp",
|
||||
"ftyp_M4V",
|
||||
"ftyp_M4A",
|
||||
"ftyp_M4P",
|
||||
"ftyp_qt",
|
||||
"ftyp_iso",
|
||||
"ftyp_mmp4",
|
||||
"ftyp_avif"
|
||||
],
|
||||
"description": "ISOBMFF brand pattern used to identify MP4 in media sniffer",
|
||||
"bug_numbers": [1725190]
|
||||
},
|
||||
"WEBRTC_DTLS_CIPHER": {
|
||||
"record_in_processes": ["content", "socket"],
|
||||
"products": ["firefox"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче