]> git.sesse.net Git - kdenlive/blob - src/lib/audio/audioInfo.cpp
Use QLatin1String
[kdenlive] / src / lib / audio / 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 <QString>
15 #include <iostream>
16 #include <cstdlib>
17
18 AudioInfo::AudioInfo(Mlt::Producer *producer) :
19     m_producer(NULL)
20 {
21     // Since we already receive an MLT producer, we do not need to initialize MLT:
22     // Mlt::Factory::init(NULL);
23
24     // Get the number of streams and add the information of each of them if it is an audio stream.
25     int streams = producer->get_int("meta.media.nb_streams");
26     for (int i = 0; i < streams; ++i) {
27         QByteArray propertyName = QString::fromLatin1("meta.media.%1.stream.type").arg(i).toLocal8Bit();
28         const char* streamtype = producer->get(propertyName.data());
29         if (streamtype && strcmp("audio", streamtype) == 0) {
30             m_list << new AudioStreamInfo(producer, i);
31         }
32     }
33 }
34
35 AudioInfo::~AudioInfo()
36 {
37     foreach (AudioStreamInfo *info, m_list) {
38         delete info;
39     }
40 }
41
42 int AudioInfo::size() const
43 {
44     return m_list.size();
45 }
46
47 AudioStreamInfo const* AudioInfo::info(int pos) const
48 {
49     Q_ASSERT(pos >= 0);
50     Q_ASSERT(pos <= m_list.size());
51
52     return m_list.at(pos);
53 }
54
55 void AudioInfo::dumpInfo() const
56 {
57     foreach (AudioStreamInfo *info, m_list) {
58         info->dumpInfo();
59     }
60 }