Skip to content

Commit 7339f50

Browse files
author
Clement Champetier
committed
stat: add AudioStat class
1 parent a16929b commit 7339f50

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

src/AvTranscoder/stat/AudioStat.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef _AV_TRANSCODER_AUDIOSTAT_HPP
2+
#define _AV_TRANSCODER_AUDIOSTAT_HPP
3+
4+
#include <AvTranscoder/common.hpp>
5+
6+
namespace avtranscoder
7+
{
8+
9+
/**
10+
* @brief Statistics related to an audio stream.
11+
*/
12+
class AvExport AudioStat
13+
{
14+
public:
15+
AudioStat( const double duration, const size_t nbPackets )
16+
: _duration( duration )
17+
, _nbPackets( nbPackets )
18+
{}
19+
20+
public:
21+
double _duration;
22+
size_t _nbPackets;
23+
};
24+
25+
}
26+
27+
#endif

src/AvTranscoder/stat/ProcessStat.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ void ProcessStat::addVideoStat( const size_t streamIndex, const VideoStat& video
1010
_videoStats.insert( std::make_pair( streamIndex, videoStat ) );
1111
}
1212

13+
void ProcessStat::addAudioStat( const size_t streamIndex, const AudioStat& audioStat )
14+
{
15+
_audioStats.insert( std::make_pair( streamIndex, audioStat ) );
16+
}
17+
1318
}

src/AvTranscoder/stat/ProcessStat.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <AvTranscoder/common.hpp>
55
#include <AvTranscoder/stat/VideoStat.hpp>
6+
#include <AvTranscoder/stat/AudioStat.hpp>
67

78
#include <map>
89

@@ -21,11 +22,14 @@ class AvExport ProcessStat
2122
{}
2223

2324
void addVideoStat( const size_t streamIndex, const VideoStat& videoStat );
25+
void addAudioStat( const size_t streamIndex, const AudioStat& audioStat );
2426

2527
VideoStat& getVideoStat( const size_t streamIndex ) { return _videoStats.at(streamIndex); }
28+
AudioStat& getAudioStat( const size_t streamIndex ) { return _audioStats.at(streamIndex); }
2629

2730
private:
2831
std::map<size_t, VideoStat> _videoStats; ///< Key: streamIndex, Value: statistic video results
32+
std::map<size_t, AudioStat> _audioStats; ///< Key: streamIndex, Value: statistic audio results
2933
};
3034

3135
}

src/AvTranscoder/stream/OutputStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AvExport OutputStream : public IOutputStream
1515

1616
size_t getStreamIndex() const { return _streamIndex; }
1717
double getStreamDuration() const;
18-
size_t getNbFrames() const;
18+
size_t getNbFrames() const; ///< If audio stream, returns number of packets
1919

2020
IOutputStream::EWrappingStatus wrap( const CodedData& data );
2121

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ void Transcoder::fillProcessStat( ProcessStat& processStat )
537537
processStat.addVideoStat( streamIndex, videoStat );
538538
break;
539539
}
540+
case AVMEDIA_TYPE_AUDIO:
541+
{
542+
AudioStat audioStat( stream.getStreamDuration(), stream.getNbFrames() );
543+
processStat.addAudioStat( streamIndex, audioStat );
544+
break;
545+
}
540546
default:
541547
break;
542548
}

0 commit comments

Comments
 (0)
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