forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsoundsourcemediafoundation.h
More file actions
135 lines (117 loc) · 3.97 KB
/
Copy pathsoundsourcemediafoundation.h
File metadata and controls
135 lines (117 loc) · 3.97 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* \file soundsourcemediafoundation.h
* \class SoundSourceMediaFoundation
* \brief Decodes MPEG4/AAC audio using the SourceReader interface of the
* Media Foundation framework included in Windows 7.
* \author Bill Good <bkgood at gmail dot com>
* \author Albert Santoni <alberts at mixxx dot org>
* \date Jan 10, 2011
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SOUNDSOURCEMEDIAFOUNDATION_H
#define SOUNDSOURCEMEDIAFOUNDATION_H
#include <QFile>
#include <QString>
#include "util/defs.h"
#include "defs_version.h"
#include "soundsource.h"
#ifdef Q_OS_WIN
#define MY_EXPORT __declspec(dllexport)
#else
#define MY_EXPORT
#endif
class IMFSourceReader;
class IMFMediaType;
class IMFMediaSource;
class SoundSourceMediaFoundation : public Mixxx::SoundSource {
public:
explicit SoundSourceMediaFoundation(QString filename);
~SoundSourceMediaFoundation();
Result open();
long seek(long filepos);
unsigned read(unsigned long size, const SAMPLE *buffer);
inline long unsigned length();
Result parseHeader();
QImage parseCoverArt();
static QList<QString> supportedFileExtensions();
static QList<QString> supportedMimeTypes();
private:
bool configureAudioStream();
bool readProperties();
void copyFrames(qint16 *dest, size_t *destFrames, const qint16 *src,
size_t srcFrames);
static inline qreal secondsFromMF(qint64 mf);
static inline qint64 mfFromSeconds(qreal sec);
static inline qint64 frameFromMF(qint64 mf);
static inline qint64 mfFromFrame(qint64 frame);
IMFSourceReader *m_pReader;
IMFMediaType *m_pAudioType;
wchar_t *m_wcFilename;
int m_nextFrame;
qint16 *m_leftoverBuffer;
size_t m_leftoverBufferSize;
size_t m_leftoverBufferLength;
int m_leftoverBufferPosition;
qint64 m_mfDuration;
long m_iCurrentPosition;
bool m_dead;
bool m_seeking;
};
extern "C" MY_EXPORT const char* getMixxxVersion()
{
return VERSION;
}
extern "C" MY_EXPORT int getSoundSourceAPIVersion()
{
return MIXXX_SOUNDSOURCE_API_VERSION;
}
extern "C" MY_EXPORT Mixxx::SoundSource* getSoundSource(QString filename)
{
return new SoundSourceMediaFoundation(filename);
}
extern "C" MY_EXPORT char** supportedFileExtensions()
{
QList<QString> exts = SoundSourceMediaFoundation::supportedFileExtensions();
//Convert to C string array.
char** c_exts = (char**)malloc((exts.count() + 1) * sizeof(char*));
for (int i = 0; i < exts.count(); i++)
{
QByteArray qba = exts[i].toUtf8();
c_exts[i] = strdup(qba.constData());
qDebug() << c_exts[i];
}
c_exts[exts.count()] = NULL; //NULL terminate the list
return c_exts;
}
extern "C" MY_EXPORT char** supportedMimeTypes()
{
QList<QString> mimes = SoundSourceMediaFoundation::supportedMimeTypes();
//Convert to C string array.
char** c_mime = (char**)malloc((mimes.count() + 1) * sizeof(char*));
for (int i = 0; i < mimes.count(); i++)
{
QByteArray qba = mimes[i].toUtf8();
c_mime[i] = strdup(qba.constData());
qDebug() << c_mime[i];
}
c_mime[mimes.count()] = NULL; //NULL terminate the list
return c_mime;
}
extern "C" MY_EXPORT void freeFileExtensions(char **exts)
{
for (int i(0); exts[i]; ++i) free(exts[i]);
free(exts);
}
extern "C" MY_EXPORT void freeMimeTypes(char **mimes)
{
for (int i(0); mimes[i]; ++i) free(mimes[i]);
free(mimes);
}
#endif // ifndef SOUNDSOURCEMEDIAFOUNDATION_H