Clementine Adore Mod
 All Classes Namespaces Files Functions Variables Macros Pages
adorestreamer.h
Go to the documentation of this file.
1 /* This file is part of Clementine.
2  Copyright 2015, Thomas Mielke <thomas.mielke@c3s.cc>
3 
4  Clementine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Clementine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Clementine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef ADORESTREAMER_H
18 #define ADORESTREAMER_H
19 
20 #include "engines/gstengine.h"
21 #include "engines/bufferconsumer.h"
22 
23 #include <QBuffer>
24 #include <QTime>
25 
26 #define MINIMUM_PROBING_DURATION 40
27 
28 
33 class AdoreStreamer : public BufferConsumer
34 {
35 public:
36  AdoreStreamer();
38 
39  void SetEngine(GstEngine* engine);
40  void ConsumeBuffer(GstBuffer* buffer, int pipeline_id);
41  void StartProbing();
42  void StopProbing();
43  inline QString& GetLastFingerprint() { return fingerprint_; }
46  inline void ResetLastFingerprint() { fingerprint_ = ""; }
47 
48 private:
49  void MonoMix(const short *source_buffer, int source_numsamples, int source_numberofchannels, int source_samplingrate, short *target_buffer, int target_buffer_size);
50  void GetFingerprint(QString &fingerprint);
51  QString ChromaPrint(short *data, int size);
52  QString EchoPrint(short *data, int size);
53 
54  GstEngine* engine_;
55  QBuffer buffer_;
56  bool probing_;
59  QString fingerprint_;
62 };
63 
64 #endif // ADORESTREAMER_H
GstEngine * engine_
the GStreamer engine object, necessary to peek into the audio stream
Definition: adorestreamer.h:54
QString fingerprinting_algorithm_
either 'echoprint' or 'chromapint', depending on the #define uncommented in the cpp file...
Definition: adorestreamer.h:60
void GetFingerprint(QString &fingerprint)
Definition: adorestreamer.cpp:144
QBuffer buffer_
fingerprinting buffer to collect audio buffers for some seconds before creating a fingerprint ...
Definition: adorestreamer.h:55
void StartProbing()
tell ConsumeBuffer() to start collecting audio buffers for later fingerprinting
Definition: adorestreamer.cpp:93
int samplerate_
computed in ConsumeBuffer() and stored to determine whether the rate has changed and the audio buffer...
Definition: adorestreamer.h:58
~AdoreStreamer()
Definition: adorestreamer.cpp:41
This class handles the received audio buffers.
Definition: adorestreamer.h:33
void MonoMix(const short *source_buffer, int source_numsamples, int source_numberofchannels, int source_samplingrate, short *target_buffer, int target_buffer_size)
Definition: adorestreamer.cpp:119
QString fingerprinting_algorithm_version_
current version of the fingerprinting algorithm. This is set in the constructor.
Definition: adorestreamer.h:61
void StopProbing()
stops collecting buffers and erases existing audio data from the fingerprinting buffer ...
Definition: adorestreamer.cpp:103
QString & GetFingerprintingAlgorithmVersion()
public read-only access to the private fingerprinting_algorithm_version_ member variable.
Definition: adorestreamer.h:45
QString fingerprint_
ascii (base64) representation of the result created by GetFingerprint().
Definition: adorestreamer.h:59
QTime probing_start_time
used to measure when MINIMUM_PROBING_DURATION has been reached and then create a fingerprint ...
Definition: adorestreamer.h:57
AdoreStreamer()
Definition: adorestreamer.cpp:28
QString & GetFingerprintingAlgorithm()
public read-only access to the private fingerprinting_algorithm_ member variable. ...
Definition: adorestreamer.h:44
void ConsumeBuffer(GstBuffer *buffer, int pipeline_id)
Definition: adorestreamer.cpp:56
QString ChromaPrint(short *data, int size)
Definition: adorestreamer.cpp:172
void ResetLastFingerprint()
erases a previously created fingerprint.
Definition: adorestreamer.h:46
bool probing_
controls the collection.
Definition: adorestreamer.h:56
QString & GetLastFingerprint()
public read-only access to the private fingerprint_ member variable.
Definition: adorestreamer.h:43
void SetEngine(GstEngine *engine)
Pass the GStreamer Engine object to the class and get a BufferConsumer hook.
Definition: adorestreamer.cpp:47
QString EchoPrint(short *data, int size)
Definition: adorestreamer.cpp:204