]> git.sesse.net Git - kdenlive/blob - testingArea/audioInfo.cpp
Calculating correlation to synchronize audio tracks
[kdenlive] / testingArea / audioInfo.cpp
1 /***************************************************************************
2  *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10
11 #include "audioInfo.h"
12
13 #include "audioStreamInfo.h"
14 #include <iostream>
15 #include <cstdlib>
16
17 AudioInfo::AudioInfo(Mlt::Producer *producer)
18 {
19     // Since we already receive an MLT producer, we do not need to initialize MLT:
20     // Mlt::Factory::init(NULL);
21
22     // Get the number of streams and add the information of each of them if it is an audio stream.
23     int streams = atoi(producer->get("meta.media.nb_streams"));
24     for (int i = 0; i < streams; i++) {
25         std::string propertyName = QString("meta.media.%1.stream.type").arg(i).toStdString();
26
27         if (strcmp("audio", producer->get(propertyName.c_str())) == 0) {
28             m_list << new AudioStreamInfo(producer, i);
29         }
30
31     }
32 }
33
34 AudioInfo::~AudioInfo()
35 {
36     foreach (AudioStreamInfo *info, m_list) {
37         delete info;
38     }
39 }
40
41 int AudioInfo::size() const
42 {
43     return m_list.size();
44 }
45
46 AudioStreamInfo const* AudioInfo::info(int pos) const
47 {
48     Q_ASSERT(pos >= 0);
49     Q_ASSERT(pos <= m_list.size());
50
51     return m_list.at(pos);
52 }
53
54 void AudioInfo::dumpInfo() const
55 {
56     foreach (AudioStreamInfo *info, m_list) {
57         info->dumpInfo();
58     }
59 }