aboutsummaryrefslogtreecommitdiff
path: root/include/FileAnalyzer.hpp
blob: 92bd0428a58f5c3dcfe2fe9a913e49cf95a7f187 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include <stddef.h>
#include <optional>
#include <string>

namespace QuickMedia {
    struct Dimensions {
        int width;
        int height;
    };

    enum class ContentType {
        UNKNOWN,
        VIDEO_AVI,
        VIDEO_MP4,
        VIDEO_WEBM,
        AUDIO_BASIC,
        AUDIO_AIFF,
        AUDIO_MPEG,
        AUDIO_MIDI,
        AUDIO_WAVE,
        AUDIO_FLAC,
        AUDIO_OPUS,
        IMAGE_JPEG,
        IMAGE_PNG,
        IMAGE_GIF,
        IMAGE_BMP,
        IMAGE_WEBP
    };

    bool is_content_type_video(ContentType content_type);
    bool is_content_type_audio(ContentType content_type);
    bool is_content_type_image(ContentType content_type);
    const char* content_type_to_string(ContentType content_type);

    bool video_get_first_frame(const char *filepath, const char *destination_path, int width, int height);
    
    class FileAnalyzer {
    public:
        FileAnalyzer();
        bool load_file(const char *filepath);
        ContentType get_content_type() const;
        size_t get_file_size() const;
        std::optional<Dimensions> get_dimensions() const;
        std::optional<double> get_duration_seconds() const;
    private:
        FileAnalyzer(FileAnalyzer&) = delete;
        FileAnalyzer& operator=(FileAnalyzer&) = delete;
    private:
        ContentType content_type;
        size_t file_size;
        std::optional<Dimensions> dimensions;
        std::optional<double> duration_seconds;
        bool loaded;
    };
}