Skip to content

Commit

Permalink
Migrate gz-common logging calls
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <methylDragon@gmail.com>
  • Loading branch information
methylDragon committed May 20, 2022
1 parent cf4cb81 commit abfe3e8
Show file tree
Hide file tree
Showing 51 changed files with 340 additions and 340 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@

## Gazebo Common 3.2.0 (2019-08-07)

1. Allow ignLogInit to use an absolute path. Added a timeToIso that converts a given time to an ISO string. Some console timestamps were using `IGN_SYSTEM_TIME_NS()` and others `gz::common::systemTimeISO()`. Switched all to use `gz::common::systemTimeISO()`.
1. Allow gzLogInit to use an absolute path. Added a timeToIso that converts a given time to an ISO string. Some console timestamps were using `IGN_SYSTEM_TIME_NS()` and others `gz::common::systemTimeISO()`. Switched all to use `gz::common::systemTimeISO()`.
* [BitBucket pull request 203](https://osrf-migration.github.io/ignition-gh-pages/#!/gazebosim/gz-common/pull-requests/203)

1. Port ColladaLoader fix: use default value of 1 for stride parameter when unset.
Expand Down
2 changes: 1 addition & 1 deletion av/include/gz/common/HWEncoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace gz::common
/// \param[in] _encoderContext Context of the encoder for which hardware
/// acceleration should be set up.
/// \note If the configuration fails, the codec will be left configured for
/// software encoding and an error will be written to ignerr describing what
/// software encoding and an error will be written to gzerr describing what
/// failed.
public: void ConfigHWAccel(AVCodecContext* _encoderContext);

Expand Down
26 changes: 13 additions & 13 deletions av/src/AudioDecoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ bool AudioDecoder::Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize)

if (this->dataPtr->codec == nullptr)
{
ignerr << "Set an audio file before decoding.\n";
gzerr << "Set an audio file before decoding.\n";
return false;
}

if (_outBufferSize == nullptr)
{
ignerr << "outBufferSize is null!!\n";
gzerr << "outBufferSize is null!!\n";
return false;
}

Expand All @@ -102,14 +102,14 @@ bool AudioDecoder::Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize)

if (!(decodedFrame = common::AVFrameAlloc()))
{
ignerr << "Audio decoder out of memory\n";
gzerr << "Audio decoder out of memory\n";
result = false;
}

packet = av_packet_alloc();
if (!packet)
{
ignerr << "Failed to allocate AVPacket" << std::endl;
gzerr << "Failed to allocate AVPacket" << std::endl;
return false;
}

Expand All @@ -125,7 +125,7 @@ bool AudioDecoder::Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize)
int ret = avcodec_send_packet(this->dataPtr->codecCtx, packet);
if (ret < 0)
{
ignerr << "Error submitting the packet to the decoder" << std::endl;
gzerr << "Error submitting the packet to the decoder" << std::endl;
return false;
}

Expand All @@ -140,7 +140,7 @@ bool AudioDecoder::Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize)
}
else if (ret < 0)
{
ignerr << "Error during decoding" << std::endl;
gzerr << "Error during decoding" << std::endl;
return false;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)
if (avformat_open_input(&this->dataPtr->formatCtx,
_filename.c_str(), nullptr, nullptr) < 0)
{
ignerr << "Unable to open audio file[" << _filename << "]\n";
gzerr << "Unable to open audio file[" << _filename << "]\n";
this->dataPtr->formatCtx = nullptr;
return false;
}
Expand All @@ -250,7 +250,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)
// Retrieve some information
if (avformat_find_stream_info(this->dataPtr->formatCtx, nullptr) < 0)
{
ignerr << "Unable to find stream info.\n";
gzerr << "Unable to find stream info.\n";
avformat_close_input(&this->dataPtr->formatCtx);
this->dataPtr->formatCtx = nullptr;

Expand Down Expand Up @@ -286,7 +286,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)

if (this->dataPtr->audioStream == -1)
{
ignerr << "Couldn't find audio stream.\n";
gzerr << "Couldn't find audio stream.\n";
avformat_close_input(&this->dataPtr->formatCtx);
this->dataPtr->formatCtx = nullptr;

Expand All @@ -312,13 +312,13 @@ bool AudioDecoder::SetFile(const std::string &_filename)
this->dataPtr->audioStream]->codecpar->codec_id);
if (!this->dataPtr->codec)
{
ignerr << "Failed to find the codec" << std::endl;
gzerr << "Failed to find the codec" << std::endl;
return false;
}
this->dataPtr->codecCtx = avcodec_alloc_context3(this->dataPtr->codec);
if (!this->dataPtr->codecCtx)
{
ignerr << "Failed to allocate the codec context" << std::endl;
gzerr << "Failed to allocate the codec context" << std::endl;
return false;
}
// Copy all relevant parameters from codepar to codecCtx
Expand All @@ -331,7 +331,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)

if (this->dataPtr->codec == nullptr)
{
ignerr << "Couldn't find codec for audio stream.\n";
gzerr << "Couldn't find codec for audio stream.\n";
avformat_close_input(&this->dataPtr->formatCtx);
this->dataPtr->formatCtx = nullptr;

Expand All @@ -350,7 +350,7 @@ bool AudioDecoder::SetFile(const std::string &_filename)
if (avcodec_open2(this->dataPtr->codecCtx,
this->dataPtr->codec, nullptr) < 0)
{
ignerr << "Couldn't open audio codec.\n";
gzerr << "Couldn't open audio codec.\n";
avformat_close_input(&this->dataPtr->formatCtx);
this->dataPtr->formatCtx = nullptr;

Expand Down
36 changes: 18 additions & 18 deletions av/src/HWEncoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool ProbeDevice(const std::string& _deviceName,
else
{
if (_warnIfNotFile)
ignwarn << "Device " << _deviceName << " can't be used with "
gzwarn << "Device " << _deviceName << " can't be used with "
<< HWEncoderTypeParser.Str(_encoderType) <<" (aren't write "
<< "permissions for the device missing?)" << std::endl;
return false;
Expand All @@ -159,14 +159,14 @@ bool ProbeDevice(const std::string& _deviceName,

if (ret < 0)
{
ignerr << "Could not initialize " << deviceStr << " for "
gzerr << "Could not initialize " << deviceStr << " for "
<< HWEncoderTypeParser.Str(_encoderType) << ", skipping.\n";
return false;
}

av_buffer_unref(&tmpHwDevice);

ignmsg << "Initialized " << HWEncoderTypeParser.Str(_encoderType)
gzmsg << "Initialized " << HWEncoderTypeParser.Str(_encoderType)
<< " on " << deviceStr << std::endl;

return true;
Expand Down Expand Up @@ -211,7 +211,7 @@ AVCodec* HWEncoder::FindEncoder(AVCodecID _codecId)
// if we only search for software encoders, happily return the first one
if (this->dataPtr->initHwEncoders == HWEncoderType::NONE)
{
ignmsg << "Compatible SW encoder: " << codec->name << std::endl;
gzmsg << "Compatible SW encoder: " << codec->name << std::endl;
foundEncoder = const_cast<AVCodec*>(codec);
break;
}
Expand All @@ -221,11 +221,11 @@ AVCodec* HWEncoder::FindEncoder(AVCodecID _codecId)
}
else
{
ignmsg << "Found known HW encoder: " << codec->name << std::endl;
gzmsg << "Found known HW encoder: " << codec->name << std::endl;

if (!this->dataPtr->initHwEncoders[hwEncoderType])
{
ignmsg << "Encoder " << codec->name << " is not allowed, skipping.\n";
gzmsg << "Encoder " << codec->name << " is not allowed, skipping.\n";
continue;
}

Expand Down Expand Up @@ -375,7 +375,7 @@ AVCodec* HWEncoder::FindEncoder(AVCodecID _codecId)
{
// This is an encoder that is compiled into libavcodec, but we do
// not (yet) support it.
ignmsg << "Encoder " << codec->name << " is not yet supported.\n";
gzmsg << "Encoder " << codec->name << " is not yet supported.\n";
break;
}
}
Expand All @@ -386,7 +386,7 @@ AVCodec* HWEncoder::FindEncoder(AVCodecID _codecId)
if (foundEncoder == nullptr &&
this->dataPtr->initHwEncoders != HWEncoderType::NONE)
{
ignwarn << "No hardware-accelerated encoder found, falling back to "
gzwarn << "No hardware-accelerated encoder found, falling back to "
"software encoders" << std::endl;
this->dataPtr->initHwEncoders = HWEncoderType::NONE;
return this->FindEncoder(_codecId);
Expand Down Expand Up @@ -456,7 +456,7 @@ void HWEncoder::ConfigHWAccel(AVCodecContext* _encoderContext)

if (ret < 0)
{
ignerr << "Could not initialize HW encoding device using "
gzerr << "Could not initialize HW encoding device using "
<< HWEncoderTypeParser.Str(this->dataPtr->hwEncoderType) << ". "
<< av_err2str_cpp(ret)
<< ". Video encoding will use a software encoder instead.\n";
Expand All @@ -468,12 +468,12 @@ void HWEncoder::ConfigHWAccel(AVCodecContext* _encoderContext)
ret = av_opt_set(_encoderContext->priv_data, "rc", "vbr",
AV_OPT_SEARCH_CHILDREN);
if (ret == AVERROR_OPTION_NOT_FOUND)
ignerr << "Codec " << _encoderContext->codec->name << " does not "
gzerr << "Codec " << _encoderContext->codec->name << " does not "
<< "support option 'rc' which is required for setting bitrate "
<< "of the encoded video. The video will have some default "
<< "bitrate.\n";
else if (ret == AVERROR(EINVAL))
ignerr << "Codec " << _encoderContext->codec->name << " does not "
gzerr << "Codec " << _encoderContext->codec->name << " does not "
<< "support 'vbr' mode for option 'rc' which is required for "
<< "setting bitrate of the encoded video. The video will have "
<< "some default bitrate.\n";
Expand Down Expand Up @@ -502,7 +502,7 @@ void HWEncoder::ConfigHWAccel(AVCodecContext* _encoderContext)
this->dataPtr->hwDeviceName.c_str(), nullptr, 0);
if (ret < 0)
{
ignerr << "Could not initialize HW encoding device using "
gzerr << "Could not initialize HW encoding device using "
<< HWEncoderTypeParser.Str(this->dataPtr->hwEncoderType) << ". "
<< av_err2str_cpp(ret)
<< ". Video encoding will use a software encoder instead.\n";
Expand Down Expand Up @@ -546,7 +546,7 @@ void HWEncoder::ConfigHWAccel(AVCodecContext* _encoderContext)

if (ret < 0)
{
ignerr << "Could not initialize HW encoding device using "
gzerr << "Could not initialize HW encoding device using "
<< HWEncoderTypeParser.Str(this->dataPtr->hwEncoderType) << ". "
<< av_err2str_cpp(ret)
<< ". Video encoding will use a software encoder instead.\n";
Expand Down Expand Up @@ -601,7 +601,7 @@ bool HWEncoder::Implementation::ConfigHWSurface(AVCodecContext* _encoderContext)
auto* hw_frames_ref = av_hwframe_ctx_alloc(this->hwDevice); // lavu 55.6.0
if (hw_frames_ref == nullptr)
{
ignerr << "Could not allocate hardware surface for format "
gzerr << "Could not allocate hardware surface for format "
<< av_get_pix_fmt_name(_encoderContext->pix_fmt) // lavu 51.3.0
<< " and HW encoder " << HWEncoderTypeParser.Str(this->hwEncoderType)
<< ". Encoder will use a software surface.\n";
Expand All @@ -619,7 +619,7 @@ bool HWEncoder::Implementation::ConfigHWSurface(AVCodecContext* _encoderContext)
if (ret < 0)
{
av_buffer_unref(&hw_frames_ref);
ignerr << "Could not initialize hardware surface for format "
gzerr << "Could not initialize hardware surface for format "
<< av_get_pix_fmt_name(_encoderContext->pix_fmt) // lavu 51.3.0
<< " and HW encoder "
<< HWEncoderTypeParser.Str(this->hwEncoderType)
Expand All @@ -637,7 +637,7 @@ bool HWEncoder::Implementation::ConfigHWSurface(AVCodecContext* _encoderContext)
{
av_buffer_unref(&_encoderContext->hw_frames_ctx);

ignerr << "Could not allocate frame for format "
gzerr << "Could not allocate frame for format "
<< av_get_pix_fmt_name(_encoderContext->pix_fmt) // lavu 51.3.0
<< " and HW encoder " << HWEncoderTypeParser.Str(this->hwEncoderType)
<< ". Encoder will use a software surface.\n";
Expand All @@ -651,15 +651,15 @@ bool HWEncoder::Implementation::ConfigHWSurface(AVCodecContext* _encoderContext)
av_frame_free(&this->avOutHwFrame); // lavc 55.45.101
av_buffer_unref(&_encoderContext->hw_frames_ctx);

ignerr << "Could not initialize hardware frame for format "
gzerr << "Could not initialize hardware frame for format "
<< av_get_pix_fmt_name(_encoderContext->pix_fmt) // lavu 51.3.0
<< " and HW encoder " << HWEncoderTypeParser.Str(this->hwEncoderType)
<< ". Encoder will use a software surface. The reason is: "
<< av_err2str_cpp(ret) << std::endl;
return false;
}

ignmsg << "Using HW surface for the encoder." << std::endl;
gzmsg << "Using HW surface for the encoder." << std::endl;
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions av/src/Util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void logCallback(void *_ptr, int _level, const char *_fmt, va_list _args)
case AV_LOG_PANIC:
case AV_LOG_FATAL:
case AV_LOG_ERROR:
ignerr << msg << std::endl;
gzerr << msg << std::endl;
break;
case AV_LOG_WARNING:
ignwarn << msg << std::endl;
gzwarn << msg << std::endl;
break;
default:
ignmsg << msg << std::endl;
gzmsg << msg << std::endl;
break;
}
}
Expand Down
22 changes: 11 additions & 11 deletions av/src/Video.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ bool Video::Load(const std::string &_filename)
if (avformat_open_input(&this->dataPtr->formatCtx, _filename.c_str(),
nullptr, nullptr) < 0)
{
ignerr << "Unable to read video file[" << _filename << "]\n";
gzerr << "Unable to read video file[" << _filename << "]\n";
return false;
}

// Retrieve stream information
if (avformat_find_stream_info(this->dataPtr->formatCtx, nullptr) < 0)
{
ignerr << "Couldn't find stream information\n";
gzerr << "Couldn't find stream information\n";
return false;
}

Expand All @@ -137,7 +137,7 @@ bool Video::Load(const std::string &_filename)

if (this->dataPtr->videoStream == -1)
{
ignerr << "Unable to find a video stream\n";
gzerr << "Unable to find a video stream\n";
return false;
}

Expand All @@ -150,7 +150,7 @@ bool Video::Load(const std::string &_filename)
#endif
if (codec == nullptr)
{
ignerr << "Codec not found\n";
gzerr << "Codec not found\n";
return false;
}

Expand All @@ -161,15 +161,15 @@ bool Video::Load(const std::string &_filename)
this->dataPtr->codecCtx = avcodec_alloc_context3(codec);
if (!this->dataPtr->codecCtx)
{
ignerr << "Failed to allocate the codec context" << std::endl;
gzerr << "Failed to allocate the codec context" << std::endl;
return false;
}

// Copy codec parameters from input stream to output codec context
if (avcodec_parameters_to_context(this->dataPtr->codecCtx,
stream->codecpar) < 0)
{
ignerr << "Failed to copy codec parameters to decoder context"
gzerr << "Failed to copy codec parameters to decoder context"
<< std::endl;
return false;
}
Expand All @@ -192,7 +192,7 @@ bool Video::Load(const std::string &_filename)
// Open codec
if (avcodec_open2(this->dataPtr->codecCtx, codec, nullptr) < 0)
{
ignerr << "Could not open codec\n";
gzerr << "Could not open codec\n";
return false;
}

Expand All @@ -207,7 +207,7 @@ bool Video::Load(const std::string &_filename)

if (this->dataPtr->swsCtx == nullptr)
{
ignerr << "Error while calling sws_getContext\n";
gzerr << "Error while calling sws_getContext\n";
return false;
}

Expand Down Expand Up @@ -254,7 +254,7 @@ bool Video::NextFrame(unsigned char **_buffer)
packet = av_packet_alloc();
if (!packet)
{
ignerr << "Failed to allocate AVPacket" << std::endl;
gzerr << "Failed to allocate AVPacket" << std::endl;
return false;
}

Expand All @@ -277,7 +277,7 @@ bool Video::NextFrame(unsigned char **_buffer)
}
else
{
ignerr << "Error reading packet: " << av_err2str_cpp(ret)
gzerr << "Error reading packet: " << av_err2str_cpp(ret)
<< ". Stopped reading the file." << std::endl;
return false;
}
Expand All @@ -303,7 +303,7 @@ bool Video::NextFrame(unsigned char **_buffer)
}
else if (ret < 0)
{
ignerr << "Error while processing packet data: "
gzerr << "Error while processing packet data: "
<< av_err2str_cpp(ret) << std::endl;
// continue processing data
}
Expand Down
Loading

0 comments on commit abfe3e8

Please sign in to comment.