Unverified Commit df4003fd authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

add UUID in LOG() in decoder (#3080)

* add UUID in LOG() in decoder

* Fix lint

* More lint
parent 9fc6522d
......@@ -149,7 +149,8 @@ bool Decoder::enableLogLevel(int level) const {
}
void Decoder::logCallback(int level, const std::string& message) {
LOG(INFO) << "Msg, level: " << level << ", msg: " << message;
LOG(INFO) << "Msg, uuid=" << params_.loggingUuid << " level=" << level
<< " msg=" << message;
}
/* static */
......@@ -221,8 +222,9 @@ bool Decoder::init(
cleanUp();
if ((params.uri.empty() || in) && (!params.uri.empty() || !in)) {
LOG(ERROR) << "Either external URI gets provided"
<< " or explicit input callback";
LOG(ERROR)
<< "uuid=" << params_.loggingUuid
<< " either external URI gets provided or explicit input callback";
return false;
}
......@@ -230,7 +232,8 @@ bool Decoder::init(
params_ = params;
if (!(inputCtx_ = avformat_alloc_context())) {
LOG(ERROR) << "Cannot allocate format context";
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " cannot allocate format context";
return false;
}
......@@ -243,7 +246,8 @@ bool Decoder::init(
params_.timeoutMs,
params_.maxSeekableBytes,
params_.isImage ? &type : nullptr)) < 0) {
LOG(ERROR) << "can't initiate seekable buffer";
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " can't initiate seekable buffer";
cleanUp();
return false;
}
......@@ -271,7 +275,8 @@ bool Decoder::init(
uint8_t* avioCtxBuffer =
(uint8_t*)av_malloc(avioCtxBufferSize + kIoPaddingSize);
if (!avioCtxBuffer) {
LOG(ERROR) << "av_malloc cannot allocate " << avioCtxBufferSize
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " av_malloc cannot allocate " << avioCtxBufferSize
<< " bytes";
cleanUp();
return false;
......@@ -285,7 +290,8 @@ bool Decoder::init(
&Decoder::readFunction,
nullptr,
result == 1 ? &Decoder::seekFunction : nullptr))) {
LOG(ERROR) << "avio_alloc_context failed";
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " avio_alloc_context failed";
av_free(avioCtxBuffer);
cleanUp();
return false;
......@@ -323,7 +329,8 @@ bool Decoder::init(
guard = std::make_unique<std::thread>([&f, this]() {
auto timeout = std::chrono::milliseconds(params_.timeoutMs);
if (std::future_status::timeout == f.wait_for(timeout)) {
LOG(ERROR) << "Cannot open stream within " << params_.timeoutMs
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " cannot open stream within " << params_.timeoutMs
<< " ms";
interrupted_ = true;
}
......@@ -346,7 +353,8 @@ bool Decoder::init(
}
if (result < 0 || interrupted_) {
LOG(ERROR) << "avformat_open_input failed, error: "
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " avformat_open_input failed, error="
<< Util::generateErrorDesc(result);
cleanUp();
return false;
......@@ -355,14 +363,15 @@ bool Decoder::init(
result = avformat_find_stream_info(inputCtx_, nullptr);
if (result < 0) {
LOG(ERROR) << "avformat_find_stream_info failed, error: "
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " avformat_find_stream_info failed, error="
<< Util::generateErrorDesc(result);
cleanUp();
return false;
}
if (!openStreams(metadata)) {
LOG(ERROR) << "Cannot activate streams";
LOG(ERROR) << "uuid=" << params_.loggingUuid << " cannot activate streams";
cleanUp();
return false;
}
......@@ -418,7 +427,8 @@ bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
params_.loggingUuid);
CHECK(stream);
if (stream->openCodec(metadata) < 0) {
LOG(ERROR) << "Cannot open codec " << i;
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " open codec failed, stream_idx=" << i;
return false;
}
streams_.emplace(i, std::move(stream));
......@@ -518,13 +528,15 @@ int Decoder::getFrame(size_t workingTimeInMs) {
bool hasMsg = false;
// packet either got consumed completely or not at all
if ((result = processPacket(stream, &avPacket, &gotFrame, &hasMsg)) < 0) {
LOG(ERROR) << "processPacket failed with code: " << result;
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " processPacket failed with code=" << result;
break;
}
if (!gotFrame && params_.maxProcessNoBytes != 0 &&
++numConsecutiveNoBytes > params_.maxProcessNoBytes) {
LOG(ERROR) << "Exceeding max amount of consecutive no bytes";
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " exceeding max amount of consecutive no bytes";
break;
}
if (result > 0) {
......@@ -538,7 +550,8 @@ int Decoder::getFrame(size_t workingTimeInMs) {
if (result < 0) {
if (params_.maxPackageErrors != 0 && // check errors
++decodingErrors >= params_.maxPackageErrors) { // reached the limit
LOG(ERROR) << "Exceeding max amount of consecutive package errors";
LOG(ERROR) << "uuid=" << params_.loggingUuid
<< " exceeding max amount of consecutive package errors";
break;
}
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment