]> git.sesse.net Git - kdenlive/blob - src/lib/audio/audioStreamInfo.cpp
QString::toStdString() replaced by QString::toLocal8Bit() as KDE4
[kdenlive] / src / lib / audio / audioStreamInfo.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 "audioStreamInfo.h"
12
13 #include <QString>
14 #include <iostream>
15 #include <cstdlib>
16
17 AudioStreamInfo::AudioStreamInfo(Mlt::Producer *producer, int audioStreamIndex) :
18     m_audioStreamIndex(audioStreamIndex)
19 {
20
21     QByteArray key;
22
23     key = QString("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toLocal8Bit();
24     m_samplingFormat = QString(producer->get(key.data()));
25
26     key = QString("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toLocal8Bit();
27     m_samplingRate = atoi(producer->get(key.data()));
28
29     key = QString("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toLocal8Bit();
30     m_bitRate = atoi(producer->get(key.data()));
31
32     key = QString("meta.media.%1.codec.channels").arg(audioStreamIndex).toLocal8Bit();
33     m_channels = atoi(producer->get(key.data()));
34
35     key = QString("meta.media.%1.codec.name").arg(audioStreamIndex).toLocal8Bit();
36     m_codecName = QString(producer->get(key.data()));
37
38     key = QString("meta.media.%1.codec.long_name").arg(audioStreamIndex).toLocal8Bit();
39     m_codecLongName = QString(producer->get(key.data()));
40 }
41 AudioStreamInfo::~AudioStreamInfo()
42 {
43 }
44
45 int AudioStreamInfo::streamIndex() const { return m_audioStreamIndex; }
46 int AudioStreamInfo::samplingRate() const { return m_samplingRate; }
47 int AudioStreamInfo::channels() const { return m_channels; }
48 int AudioStreamInfo::bitrate() const { return m_bitRate; }
49 const QString& AudioStreamInfo::codecName(bool longName) const
50 {
51     if (longName) {
52         return m_codecLongName;
53     } else {
54         return m_codecName;
55     }
56 }
57
58 void AudioStreamInfo::dumpInfo() const
59 {
60     std::cout << "Info for audio stream " << m_audioStreamIndex << std::endl
61               << "\tCodec: " << m_codecLongName.toLocal8Bit().data() << " (" << m_codecName.toLocal8Bit().data() << ")" << std::endl
62               << "\tChannels: " << m_channels << std::endl
63               << "\tSampling rate: " << m_samplingRate << std::endl
64               << "\tBit rate: " << m_bitRate << std::endl
65                  ;
66
67 }