-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathsoundsource.h
50 lines (39 loc) · 1.27 KB
/
soundsource.h
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
#pragma once
#include <QFileInfo>
#include "sources/audiosource.h"
#include "sources/metadatasourcetaglib.h"
namespace mixxx {
// Base class for sound sources with a default implementation (Taglib)
// for reading/writing metadata.
class SoundSource
: public AudioSource,
public MetadataSourceTagLib {
public:
/// Determine the type from an URL.
///
/// Only local file URLs are supported.
static QString getTypeFromUrl(const QUrl& url);
/// Determine the type from a (local) file.
static QString getTypeFromFile(const QFileInfo& fileInfo);
/// The type of the source.
///
/// The type equals the preferred suffix of the content's MIME type.
QString getType() const {
return m_type;
}
protected:
// If no type is provided the file extension of the file referred
// by the URL will be used as the type of the SoundSource.
explicit SoundSource(const QUrl& url)
: SoundSource(url, getTypeFromUrl(url)) {
}
SoundSource(const QUrl& url, const QString& type);
private:
QString m_type;
};
typedef std::shared_ptr<SoundSource> SoundSourcePointer;
template<typename T>
SoundSourcePointer newSoundSourceFromUrl(const QUrl& url) {
return std::make_shared<T>(url);
}
} // namespace mixxx