@@ -149,7 +149,8 @@ bool Decoder::enableLogLevel(int level) const {
149
149
}
150
150
151
151
void Decoder::logCallback (int level, const std::string& message) {
152
- LOG (INFO) << " Msg, level: " << level << " , msg: " << message;
152
+ LOG (INFO) << " Msg, uuid=" << params_.loggingUuid << " level=" << level
153
+ << " msg=" << message;
153
154
}
154
155
155
156
/* static */
@@ -221,16 +222,18 @@ bool Decoder::init(
221
222
cleanUp ();
222
223
223
224
if ((params.uri .empty () || in) && (!params.uri .empty () || !in)) {
224
- LOG (ERROR) << " Either external URI gets provided"
225
- << " or explicit input callback" ;
225
+ LOG (ERROR)
226
+ << " uuid=" << params_.loggingUuid
227
+ << " either external URI gets provided or explicit input callback" ;
226
228
return false ;
227
229
}
228
230
229
231
// set callback and params
230
232
params_ = params;
231
233
232
234
if (!(inputCtx_ = avformat_alloc_context ())) {
233
- LOG (ERROR) << " Cannot allocate format context" ;
235
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
236
+ << " cannot allocate format context" ;
234
237
return false ;
235
238
}
236
239
@@ -243,7 +246,8 @@ bool Decoder::init(
243
246
params_.timeoutMs ,
244
247
params_.maxSeekableBytes ,
245
248
params_.isImage ? &type : nullptr )) < 0 ) {
246
- LOG (ERROR) << " can't initiate seekable buffer" ;
249
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
250
+ << " can't initiate seekable buffer" ;
247
251
cleanUp ();
248
252
return false ;
249
253
}
@@ -271,7 +275,8 @@ bool Decoder::init(
271
275
uint8_t * avioCtxBuffer =
272
276
(uint8_t *)av_malloc (avioCtxBufferSize + kIoPaddingSize );
273
277
if (!avioCtxBuffer) {
274
- LOG (ERROR) << " av_malloc cannot allocate " << avioCtxBufferSize
278
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
279
+ << " av_malloc cannot allocate " << avioCtxBufferSize
275
280
<< " bytes" ;
276
281
cleanUp ();
277
282
return false ;
@@ -285,7 +290,8 @@ bool Decoder::init(
285
290
&Decoder::readFunction,
286
291
nullptr ,
287
292
result == 1 ? &Decoder::seekFunction : nullptr ))) {
288
- LOG (ERROR) << " avio_alloc_context failed" ;
293
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
294
+ << " avio_alloc_context failed" ;
289
295
av_free (avioCtxBuffer);
290
296
cleanUp ();
291
297
return false ;
@@ -323,7 +329,8 @@ bool Decoder::init(
323
329
guard = std::make_unique<std::thread>([&f, this ]() {
324
330
auto timeout = std::chrono::milliseconds (params_.timeoutMs );
325
331
if (std::future_status::timeout == f.wait_for (timeout)) {
326
- LOG (ERROR) << " Cannot open stream within " << params_.timeoutMs
332
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
333
+ << " cannot open stream within " << params_.timeoutMs
327
334
<< " ms" ;
328
335
interrupted_ = true ;
329
336
}
@@ -346,7 +353,8 @@ bool Decoder::init(
346
353
}
347
354
348
355
if (result < 0 || interrupted_) {
349
- LOG (ERROR) << " avformat_open_input failed, error: "
356
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
357
+ << " avformat_open_input failed, error="
350
358
<< Util::generateErrorDesc (result);
351
359
cleanUp ();
352
360
return false ;
@@ -355,14 +363,15 @@ bool Decoder::init(
355
363
result = avformat_find_stream_info (inputCtx_, nullptr );
356
364
357
365
if (result < 0 ) {
358
- LOG (ERROR) << " avformat_find_stream_info failed, error: "
366
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
367
+ << " avformat_find_stream_info failed, error="
359
368
<< Util::generateErrorDesc (result);
360
369
cleanUp ();
361
370
return false ;
362
371
}
363
372
364
373
if (!openStreams (metadata)) {
365
- LOG (ERROR) << " Cannot activate streams" ;
374
+ LOG (ERROR) << " uuid= " << params_. loggingUuid << " cannot activate streams" ;
366
375
cleanUp ();
367
376
return false ;
368
377
}
@@ -418,7 +427,8 @@ bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
418
427
params_.loggingUuid );
419
428
CHECK (stream);
420
429
if (stream->openCodec (metadata) < 0 ) {
421
- LOG (ERROR) << " Cannot open codec " << i;
430
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
431
+ << " open codec failed, stream_idx=" << i;
422
432
return false ;
423
433
}
424
434
streams_.emplace (i, std::move (stream));
@@ -518,13 +528,15 @@ int Decoder::getFrame(size_t workingTimeInMs) {
518
528
bool hasMsg = false ;
519
529
// packet either got consumed completely or not at all
520
530
if ((result = processPacket (stream, &avPacket, &gotFrame, &hasMsg)) < 0 ) {
521
- LOG (ERROR) << " processPacket failed with code: " << result;
531
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
532
+ << " processPacket failed with code=" << result;
522
533
break ;
523
534
}
524
535
525
536
if (!gotFrame && params_.maxProcessNoBytes != 0 &&
526
537
++numConsecutiveNoBytes > params_.maxProcessNoBytes ) {
527
- LOG (ERROR) << " Exceeding max amount of consecutive no bytes" ;
538
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
539
+ << " exceeding max amount of consecutive no bytes" ;
528
540
break ;
529
541
}
530
542
if (result > 0 ) {
@@ -538,7 +550,8 @@ int Decoder::getFrame(size_t workingTimeInMs) {
538
550
if (result < 0 ) {
539
551
if (params_.maxPackageErrors != 0 && // check errors
540
552
++decodingErrors >= params_.maxPackageErrors ) { // reached the limit
541
- LOG (ERROR) << " Exceeding max amount of consecutive package errors" ;
553
+ LOG (ERROR) << " uuid=" << params_.loggingUuid
554
+ << " exceeding max amount of consecutive package errors" ;
542
555
break ;
543
556
}
544
557
} else {
0 commit comments