first commit
This commit is contained in:
85
project/fm_viewer/fav/AudioEncoder.cpp
Normal file
85
project/fm_viewer/fav/AudioEncoder.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
QtAV: Multimedia framework based on Qt and FFmpeg
|
||||
Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV (from 2015)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
******************************************************************************/
|
||||
|
||||
#include "AudioEncoder.h"
|
||||
#if !(REMOVE_AV_ENCODER)
|
||||
#include "AVEncoder_p.h"
|
||||
#include "factory.h"
|
||||
#include "Logger.h"
|
||||
|
||||
namespace FAV {
|
||||
FACTORY_DEFINE(AudioEncoder)
|
||||
|
||||
void AudioEncoder_RegisterAll()
|
||||
{
|
||||
static bool called = false;
|
||||
if (called)
|
||||
return;
|
||||
called = true;
|
||||
// factory.h does not check whether an id is registered
|
||||
if (AudioEncoder::id("FFmpeg")) //registered on load
|
||||
return;
|
||||
extern bool RegisterAudioEncoderFFmpeg_Man();
|
||||
RegisterAudioEncoderFFmpeg_Man();
|
||||
}
|
||||
|
||||
QStringList AudioEncoder::supportedCodecs()
|
||||
{
|
||||
static QStringList codecs;
|
||||
if (!codecs.isEmpty())
|
||||
return codecs;
|
||||
avcodec_register_all();
|
||||
AVCodec* c = NULL;
|
||||
while ((c=av_codec_next(c))) {
|
||||
if (!av_codec_is_encoder(c) || c->type != AVMEDIA_TYPE_AUDIO)
|
||||
continue;
|
||||
codecs.append(QString::fromLatin1(c->name));
|
||||
}
|
||||
return codecs;
|
||||
}
|
||||
|
||||
AudioEncoder::AudioEncoder(AudioEncoderPrivate &d):
|
||||
AVEncoder(d)
|
||||
{
|
||||
}
|
||||
|
||||
QString AudioEncoder::name() const
|
||||
{
|
||||
return QLatin1String(AudioEncoder::name(id()));
|
||||
}
|
||||
|
||||
void AudioEncoder::setAudioFormat(const AudioFormat& format)
|
||||
{
|
||||
DPTR_D(AudioEncoder);
|
||||
if (d.format == format)
|
||||
return;
|
||||
d.format = format;
|
||||
d.format_used = format;
|
||||
Q_EMIT audioFormatChanged();
|
||||
}
|
||||
|
||||
const AudioFormat& AudioEncoder::audioFormat() const
|
||||
{
|
||||
return d_func().format_used;
|
||||
}
|
||||
|
||||
} //namespace FAV
|
||||
#endif //#if !(REMOVE_AV_ENCODER)
|
||||
Reference in New Issue
Block a user