From 19334034009ec0bb87263cab188d252c22fb9525 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 18 Oct 2024 10:20:22 +0400 Subject: [PATCH] Migrate videoplayer to OSG logging system --- extern/osg-ffmpeg-videoplayer/videoplayer.cpp | 3 ++- extern/osg-ffmpeg-videoplayer/videostate.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp index e101bd4870..bc1668971b 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp @@ -2,6 +2,7 @@ #include +#include #include #include "audiofactory.hpp" @@ -45,7 +46,7 @@ void VideoPlayer::playVideo(std::unique_ptr&& inputstream, const s } } catch(std::exception& e) { - std::cerr<< "Failed to play video: "< frame{ av_frame_alloc()}; if (frame == nullptr) { - std::cerr << "av_frame_alloc failed" << std::endl; + OSG_FATAL << "av_frame_alloc failed" << std::endl; return -1; } @@ -215,7 +215,7 @@ int VideoPicture::set_dimensions(int w, int h) { frame->height = h; if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, kPixFmt, 1) < 0) { - std::cerr << "av_image_alloc failed" << std::endl; + OSG_FATAL << "av_image_alloc failed" << std::endl; return -1; } @@ -442,7 +442,7 @@ public: } catch(std::exception& e) { - std::cerr << "An error occurred playing the video: " << e.what () << std::endl; + OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl; } }) { @@ -567,9 +567,9 @@ public: { // In the FFMpeg 4.0 a "filename" field was replaced by "url" #if LIBAVCODEC_VERSION_INT < 3805796 - std::cerr << "Error seeking " << self->format_ctx->filename << std::endl; + OSG_FATAL << "Error seeking " << self->format_ctx->filename << std::endl; #else - std::cerr << "Error seeking " << self->format_ctx->url << std::endl; + OSG_FATAL << "Error seeking " << self->format_ctx->url << std::endl; #endif } else @@ -635,7 +635,7 @@ public: } } catch(std::exception& e) { - std::cerr << "An error occurred playing the video: " << e.what () << std::endl; + OSG_FATAL << "An error occurred playing the video: " << e.what() << std::endl; } self->mQuit = true; @@ -689,7 +689,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) if (!mAudioFactory) { - std::cerr << "No audio factory registered, can not play audio stream" << std::endl; + OSG_FATAL << "No audio factory registered, can not play audio stream" << std::endl; avcodec_free_context(&this->audio_ctx); this->audio_st = nullptr; return -1; @@ -698,7 +698,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) mAudioDecoder = mAudioFactory->createDecoder(this); if (!mAudioDecoder) { - std::cerr << "Failed to create audio decoder, can not play audio stream" << std::endl; + OSG_FATAL << "Failed to create audio decoder, can not play audio stream" << std::endl; avcodec_free_context(&this->audio_ctx); this->audio_st = nullptr; return -1;