From 967f2549af522dc7bbca7208035119677ac9e6d0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Jul 2021 23:24:28 +0200 Subject: matrix: detect ogg vorbis files as audio files for upload --- include/FileAnalyzer.hpp | 1 + src/FileAnalyzer.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/FileAnalyzer.hpp b/include/FileAnalyzer.hpp index 51a7aa8..aedd520 100644 --- a/include/FileAnalyzer.hpp +++ b/include/FileAnalyzer.hpp @@ -22,6 +22,7 @@ namespace QuickMedia { AUDIO_MIDI, AUDIO_WAVE, AUDIO_FLAC, + AUDIO_VORBIS, AUDIO_OPUS, IMAGE_JPEG, IMAGE_PNG, diff --git a/src/FileAnalyzer.cpp b/src/FileAnalyzer.cpp index f44ecbf..bd44da7 100644 --- a/src/FileAnalyzer.cpp +++ b/src/FileAnalyzer.cpp @@ -21,7 +21,7 @@ namespace QuickMedia { // What about audio ogg files that are not opus? // TODO: Test all of these - static const std::array magic_numbers = { + static const std::array magic_numbers = { MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'A', 'V', 'I', ' '}, 12, ContentType::VIDEO_AVI }, MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'i', 's', 'o', 'm'}, 12, ContentType::VIDEO_MP4 }, MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'}, 12, ContentType::VIDEO_MP4 }, @@ -42,6 +42,7 @@ namespace QuickMedia { MagicNumber{ {'M', 'T', 'h', 'd', -1, -1, -1, -1}, 8, ContentType::AUDIO_MIDI }, MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'W', 'A', 'V', 'E'}, 12, ContentType::AUDIO_WAVE }, MagicNumber{ {'f', 'L', 'a', 'C'}, 4, ContentType::AUDIO_FLAC }, + MagicNumber{ {'O', 'g', 'g', 'S', 0x00, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ,-1, -1, -1, -1, -1, -1, -1, -1, 'v', 'o', 'r', 'b', 'i', 's'}, 30, ContentType::AUDIO_VORBIS }, MagicNumber{ {'O', 'g', 'g', 'S', 0x00, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ,-1, -1, -1, -1, -1, -1, -1, 'O', 'p', 'u', 's', 'H', 'e', 'a', 'd'}, 36, ContentType::AUDIO_OPUS }, MagicNumber{ {0xFF, 0xD8, 0xFF}, 3, ContentType::IMAGE_JPEG }, MagicNumber{ {0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A}, 8, ContentType::IMAGE_PNG }, @@ -77,6 +78,7 @@ namespace QuickMedia { case ContentType::AUDIO_MIDI: return "audio/midi"; case ContentType::AUDIO_WAVE: return "audio/wave"; case ContentType::AUDIO_FLAC: return "audio/wave"; + case ContentType::AUDIO_VORBIS: return "audio/ogg"; case ContentType::AUDIO_OPUS: return "audio/ogg"; case ContentType::IMAGE_JPEG: return "image/jpeg"; case ContentType::IMAGE_PNG: return "image/png"; -- cgit v1.2.3