AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AudioReader.cpp
Go to the documentation of this file.
1 #include "AudioReader.hpp"
2 
3 #include <AvTranscoder/util.hpp>
9 
10 namespace avtranscoder
11 {
12 
13 AudioReader::AudioReader(const std::string& filename, const size_t streamIndex, const int channelIndex)
14  : IReader(filename, streamIndex, channelIndex)
15  , _audioStreamProperties(NULL)
16  , _outputSampleRate(0)
17  , _outputNbChannels(0)
18  , _outputSampleFormat(AV_SAMPLE_FMT_S16)
19 {
20  init();
21 }
22 
23 AudioReader::AudioReader(InputFile& inputFile, const size_t streamIndex, const int channelIndex)
24  : IReader(inputFile, streamIndex, channelIndex)
25  , _audioStreamProperties(NULL)
26  , _outputSampleRate(0)
27  , _outputNbChannels(0)
28  , _outputSampleFormat(AV_SAMPLE_FMT_S16)
29 {
30  init();
31 }
32 
34 {
35  // analyse InputFile
37  _inputFile->analyse(p);
41 
42  // setup decoder
46 
47  // generator
49 
50  // create transform
51  _transform = new AudioTransform();
52 
53  // create src frame
55  AudioFrame* srcFrame = static_cast<AudioFrame*>(_srcFrame);
56  // create dst frame
57  _outputSampleRate = srcFrame->getSampleRate();
58  _outputNbChannels = (_channelIndex == -1) ? srcFrame->getNbChannels() : 1;
60 }
61 
63 {
64  delete _decoder;
65  delete _generator;
66  delete _srcFrame;
67  delete _dstFrame;
68  delete _transform;
69 }
70 
71 void AudioReader::updateOutput(const size_t sampleRate, const size_t nbChannels, const std::string& sampleFormat)
72 {
73  _outputSampleRate = sampleRate;
74  _outputNbChannels = nbChannels;
75  _outputSampleFormat = getAVSampleFormat(sampleFormat);
76  // update dst frame
77  delete _dstFrame;
79 }
80 }
IDecoder * _generator
Definition: IReader.hpp:70
AudioCodec & getAudioCodec()
Definition: InputStream.cpp:87
IDecoder * _decoder
Definition: IReader.hpp:69
void analyse(IProgress &progress, const EAnalyseLevel level=eAnalyseLevelFirstGop)
Run the analyse on the file after a setup. call this function before getProperties().
Definition: InputFile.cpp:51
Based class to read a stream.
Definition: IReader.hpp:18
AVSampleFormat _outputSampleFormat
Definition: AudioReader.hpp:50
const avtranscoder::StreamProperties & getStreamPropertiesWithIndex(const size_t streamIndex) const
AudioReader(const std::string &filename, const size_t streamIndex=0, const int channelIndex=-1)
Definition: AudioReader.cpp:13
virtual void setupDecoder(const ProfileLoader::Profile &profile=ProfileLoader::Profile())
Setup the decoder.
Definition: IDecoder.hpp:21
void activateStream(const size_t streamIndex, const bool activate=true)
Activate the indicated stream.
Definition: InputFile.cpp:108
const FileProperties & getProperties() const
Return media properties on the current InputFile.
Definition: InputFile.hpp:71
const AudioProperties * _audioStreamProperties
Properties of the source audio stream read (no ownership, has link)
Definition: AudioReader.hpp:44
AudioFrameDesc getAudioFrameDesc() const
Definition: AudioCodec.cpp:24
InputFile * _inputFile
Definition: IReader.hpp:67
Description to create an audio frame. This corresponds to the number of samples, which corresponds to...
Definition: AudioFrame.hpp:14
This class describes decoded audio data.
Definition: AudioFrame.hpp:36
ITransform * _transform
Definition: IReader.hpp:76
void updateOutput(const size_t sampleRate, const size_t nbChannels, const std::string &sampleFormat)
Update sample rate, number of channels and sample format of the output.
Definition: AudioReader.cpp:71
const StreamProperties * _streamProperties
Definition: IReader.hpp:68
InputStream & getStream(size_t index)
Get stream type: video, audio, subtitle, etc.
Definition: InputFile.cpp:113
AVSampleFormat getAVSampleFormat(const std::string &sampleFormat)
Get the corresponding AVSampleFormat from the sample format name.
Definition: util.cpp:95
IDecoder * _currentDecoder
Link to _inputDecoder or _generator.
Definition: IReader.hpp:71
Implementation of IProgress, to manage cases when we need an IProgress but don't care of a progress b...
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy