blob: 628c343796f1544a6f2e51e94c16cd52399e0dc1 [file] [log] [blame]
agsantosc9181b42020-11-26 12:03:04 -05001/**
2 * Copyright (C) 2020 Savoir-faire Linux Inc.
3 *
4 * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#pragma once
22
23extern "C" {
24#include <libavutil/frame.h>
25}
26#include <observer.h>
27
28#include <frameFilter.h>
29
30namespace jami {
31
32class FilterAudioSubscriber : public Observer<AVFrame*>
33{
34public:
35 FilterAudioSubscriber(const std::string& dataPath, const std::string& irFile);
36 ~FilterAudioSubscriber();
37
38 virtual void update(jami::Observable<AVFrame*>*, AVFrame* const&) override;
39 virtual void attached(jami::Observable<AVFrame*>*) override;
40 virtual void detached(jami::Observable<AVFrame*>*) override;
41
42 void detach();
43
44 void setIRFile(const std::string& irFile);
45
46private:
47 // Observer pattern
48 Observable<AVFrame*>* observable_ = nullptr;
49
50 // Data
51 std::string path_;
52 FrameFilter reverbFilter_;
53 AVFormatContext* pFormatCtx_;
54 int audioStream_ = -1;
55
56 // Status variables of the processing
57 bool firstRun {true};
58
59 void setFilterDescription(const int pSampleRate, const int pSamples);
60 void setIRAVFrame();
61 AudioFormat getIRAVFrameInfos();
62 std::string irFile_{};
63 std::string filterDescription_{};
64};
65} // namespace jami