Skip to content

Commit 2525317

Browse files
author
Clement Champetier
committed
FormatContext: added const to local variables of methods
1 parent 2a81f06 commit 2525317

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/AvTranscoder/file/FormatContext.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ FormatContext::~FormatContext()
5353

5454
void FormatContext::findStreamInfo(AVDictionary** options)
5555
{
56-
int err = avformat_find_stream_info(_avFormatContext, options);
56+
const int err = avformat_find_stream_info(_avFormatContext, options);
5757
if(err < 0)
5858
{
5959
throw std::ios_base::failure("Unable to find stream informations: " + getDescriptionFromErrorCode(err));
@@ -65,7 +65,7 @@ void FormatContext::openRessource(const std::string& url, int flags)
6565
if((_avFormatContext->flags & AVFMT_NOFILE) == AVFMT_NOFILE)
6666
return;
6767

68-
int err = avio_open2(&_avFormatContext->pb, url.c_str(), flags, NULL, NULL);
68+
const int err = avio_open2(&_avFormatContext->pb, url.c_str(), flags, NULL, NULL);
6969
if(err < 0)
7070
{
7171
throw std::ios_base::failure("Error when opening output format: " + getDescriptionFromErrorCode(err));
@@ -77,7 +77,7 @@ void FormatContext::closeRessource()
7777
if((_avFormatContext->flags & AVFMT_NOFILE) == AVFMT_NOFILE)
7878
return;
7979

80-
int err = avio_close(_avFormatContext->pb);
80+
const int err = avio_close(_avFormatContext->pb);
8181
if(err < 0)
8282
{
8383
throw std::ios_base::failure("Error when close output format: " + getDescriptionFromErrorCode(err));
@@ -86,7 +86,7 @@ void FormatContext::closeRessource()
8686

8787
void FormatContext::writeHeader(AVDictionary** options)
8888
{
89-
int ret = avformat_write_header(_avFormatContext, options);
89+
const int ret = avformat_write_header(_avFormatContext, options);
9090
if(ret != 0)
9191
{
9292
throw std::runtime_error("Could not write header: " + getDescriptionFromErrorCode(ret));
@@ -115,7 +115,7 @@ void FormatContext::writeFrame(AVPacket& packet, bool interleaved)
115115

116116
void FormatContext::writeTrailer()
117117
{
118-
int ret = av_write_trailer(_avFormatContext);
118+
const int ret = av_write_trailer(_avFormatContext);
119119
if(ret != 0)
120120
{
121121
throw std::runtime_error("Could not write trailer: " + getDescriptionFromErrorCode(ret));
@@ -124,7 +124,7 @@ void FormatContext::writeTrailer()
124124

125125
void FormatContext::addMetaData(const std::string& key, const std::string& value)
126126
{
127-
int ret = av_dict_set(&_avFormatContext->metadata, key.c_str(), value.c_str(), 0);
127+
const int ret = av_dict_set(&_avFormatContext->metadata, key.c_str(), value.c_str(), 0);
128128
if(ret < 0)
129129
{
130130
LOG_ERROR(getDescriptionFromErrorCode(ret))
@@ -144,8 +144,8 @@ AVStream& FormatContext::addAVStream(const AVCodec& avCodec)
144144

145145
bool FormatContext::seek(const uint64_t position, const int flag)
146146
{
147-
LOG_INFO("Seek in '" << _avFormatContext->filename << "' at " << position << " (in AV_TIME_BASE units)")
148-
int err = av_seek_frame(_avFormatContext, -1, position, flag);
147+
LOG_INFO("Seek in '" << _avFormatContext->filename << "' at " << position << " with flag '"<< flag << "'")
148+
const int err = av_seek_frame(_avFormatContext, -1, position, flag);
149149
if(err < 0)
150150
{
151151
LOG_ERROR("Error when seek at " << position << " (in AV_TIME_BASE units) in file")

0 commit comments

Comments
 (0)