Skip to content

Commit 3b32e21

Browse files
author
Clement Champetier
committed
properties: used FileProperties instead of FormatContext to instanciate stream properties
With the FileProperties class, we have access to several conveniant methods.
1 parent ced6585 commit 3b32e21

11 files changed

+28
-23
lines changed

src/AvTranscoder/properties/AttachementProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace avtranscoder
99
class AvExport AttachementProperties : public StreamProperties
1010
{
1111
public:
12-
AttachementProperties(const FormatContext& formatContext, const size_t index)
13-
: StreamProperties(formatContext, index)
12+
AttachementProperties(const FileProperties& fileProperties, const size_t index)
13+
: StreamProperties(fileProperties, index)
1414
{
1515
}
1616
};

src/AvTranscoder/properties/AudioProperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extern "C" {
1515
namespace avtranscoder
1616
{
1717

18-
AudioProperties::AudioProperties(const FormatContext& formatContext, const size_t index)
19-
: StreamProperties(formatContext, index)
18+
AudioProperties::AudioProperties(const FileProperties& fileProperties, const size_t index)
19+
: StreamProperties(fileProperties, index)
2020
{
2121
}
2222

src/AvTranscoder/properties/AudioProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace avtranscoder
1111
class AvExport AudioProperties : public StreamProperties
1212
{
1313
public:
14-
AudioProperties(const FormatContext& formatContext, const size_t index);
14+
AudioProperties(const FileProperties& fileProperties, const size_t index);
1515

1616
std::string getSampleFormatName() const;
1717
std::string getSampleFormatLongName() const;

src/AvTranscoder/properties/DataProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace avtranscoder
99
class AvExport DataProperties : public StreamProperties
1010
{
1111
public:
12-
DataProperties(const FormatContext& formatContext, const size_t index)
13-
: StreamProperties(formatContext, index)
12+
DataProperties(const FileProperties& fileProperties, const size_t index)
13+
: StreamProperties(fileProperties, index)
1414
{
1515
}
1616

src/AvTranscoder/properties/FileProperties.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,37 @@ void FileProperties::extractStreamProperties(IProgress& progress, const EAnalyse
4444
{
4545
case AVMEDIA_TYPE_VIDEO:
4646
{
47-
VideoProperties properties(*_formatContext, streamIndex, progress, level);
47+
VideoProperties properties(*this, streamIndex, progress, level);
4848
_videoStreams.push_back(properties);
4949
break;
5050
}
5151
case AVMEDIA_TYPE_AUDIO:
5252
{
53-
AudioProperties properties(*_formatContext, streamIndex);
53+
AudioProperties properties(*this, streamIndex);
5454
_audioStreams.push_back(properties);
5555
break;
5656
}
5757
case AVMEDIA_TYPE_DATA:
5858
{
59-
DataProperties properties(*_formatContext, streamIndex);
59+
DataProperties properties(*this, streamIndex);
6060
_dataStreams.push_back(properties);
6161
break;
6262
}
6363
case AVMEDIA_TYPE_SUBTITLE:
6464
{
65-
SubtitleProperties properties(*_formatContext, streamIndex);
65+
SubtitleProperties properties(*this, streamIndex);
6666
_subtitleStreams.push_back(properties);
6767
break;
6868
}
6969
case AVMEDIA_TYPE_ATTACHMENT:
7070
{
71-
AttachementProperties properties(*_formatContext, streamIndex);
71+
AttachementProperties properties(*this, streamIndex);
7272
_attachementStreams.push_back(properties);
7373
break;
7474
}
7575
case AVMEDIA_TYPE_UNKNOWN:
7676
{
77-
UnknownProperties properties(*_formatContext, streamIndex);
77+
UnknownProperties properties(*this, streamIndex);
7878
_unknownStreams.push_back(properties);
7979
break;
8080
}

src/AvTranscoder/properties/StreamProperties.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
#include <AvTranscoder/properties/util.hpp>
44
#include <AvTranscoder/properties/JsonWriter.hpp>
5+
#include <AvTranscoder/properties/FileProperties.hpp>
56

67
#include <stdexcept>
78

89
namespace avtranscoder
910
{
1011

11-
StreamProperties::StreamProperties(const FormatContext& formatContext, const size_t index)
12-
: _formatContext(&formatContext.getAVFormatContext())
12+
StreamProperties::StreamProperties(const FileProperties& fileProperties, const size_t index)
13+
: _fileProperties(&fileProperties)
14+
, _formatContext(&fileProperties.getAVFormatContext())
1315
, _codecContext(NULL)
1416
, _codec(NULL)
1517
, _streamIndex(index)

src/AvTranscoder/properties/StreamProperties.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
namespace avtranscoder
1010
{
1111

12+
class FileProperties;
13+
1214
/// Virtual based class of properties for all types of stream
1315
class AvExport StreamProperties
1416
{
1517
public:
16-
StreamProperties(const FormatContext& formatContext, const size_t index);
18+
StreamProperties(const FileProperties& fileProperties, const size_t index);
1719
virtual ~StreamProperties() = 0;
1820

1921
size_t getStreamIndex() const { return _streamIndex; }
@@ -65,6 +67,7 @@ class AvExport StreamProperties
6567
#endif
6668

6769
protected:
70+
const FileProperties* _fileProperties; ///< Has link (no ownership)
6871
const AVFormatContext* _formatContext; ///< Has link (no ownership)
6972
AVCodecContext* _codecContext; ///< Has link (no ownership)
7073
AVCodec* _codec; ///< Has link (no ownership)

src/AvTranscoder/properties/SubtitleProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace avtranscoder
99
class AvExport SubtitleProperties : public StreamProperties
1010
{
1111
public:
12-
SubtitleProperties(const FormatContext& formatContext, const size_t index)
13-
: StreamProperties(formatContext, index)
12+
SubtitleProperties(const FileProperties& fileProperties, const size_t index)
13+
: StreamProperties(fileProperties, index)
1414
{
1515
}
1616
};

src/AvTranscoder/properties/UnknownProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace avtranscoder
99
class AvExport UnknownProperties : public StreamProperties
1010
{
1111
public:
12-
UnknownProperties(const FormatContext& formatContext, const size_t index)
13-
: StreamProperties(formatContext, index)
12+
UnknownProperties(const FileProperties& fileProperties, const size_t index)
13+
: StreamProperties(fileProperties, index)
1414
{
1515
}
1616
};

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ extern "C" {
1717
namespace avtranscoder
1818
{
1919

20-
VideoProperties::VideoProperties(const FormatContext& formatContext, const size_t index, IProgress& progress,
20+
VideoProperties::VideoProperties(const FileProperties& fileProperties, const size_t index, IProgress& progress,
2121
const EAnalyseLevel level)
22-
: StreamProperties(formatContext, index)
22+
: StreamProperties(fileProperties, index)
2323
, _levelAnalysis(level)
2424
, _pixelProperties()
2525
, _isInterlaced(false)

src/AvTranscoder/properties/VideoProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace avtranscoder
2121
class AvExport VideoProperties : public StreamProperties
2222
{
2323
public:
24-
VideoProperties(const FormatContext& formatContext, const size_t index, IProgress& progress,
24+
VideoProperties(const FileProperties& fileProperties, const size_t index, IProgress& progress,
2525
const EAnalyseLevel level = eAnalyseLevelFirstGop);
2626

2727
std::string getProfileName() const;

0 commit comments

Comments
 (0)