Migrate videoplayer to OSG logging system

pull/3236/head
Andrei Kortunov 2 months ago
parent bac0018a09
commit 1933403400

@ -2,6 +2,7 @@
#include <iostream> #include <iostream>
#include <osg/Notify>
#include <osg/Texture2D> #include <osg/Texture2D>
#include "audiofactory.hpp" #include "audiofactory.hpp"
@ -45,7 +46,7 @@ void VideoPlayer::playVideo(std::unique_ptr<std::istream>&& inputstream, const s
} }
} }
catch(std::exception& e) { catch(std::exception& e) {
std::cerr<< "Failed to play video: "<<e.what() <<std::endl; OSG_FATAL << "Failed to play video: " << e.what() << std::endl;
close(); close();
} }
} }

@ -205,7 +205,7 @@ int VideoPicture::set_dimensions(int w, int h) {
std::unique_ptr<AVFrame, VideoPicture::AVFrameDeleter> frame{ std::unique_ptr<AVFrame, VideoPicture::AVFrameDeleter> frame{
av_frame_alloc()}; av_frame_alloc()};
if (frame == nullptr) { if (frame == nullptr) {
std::cerr << "av_frame_alloc failed" << std::endl; OSG_FATAL << "av_frame_alloc failed" << std::endl;
return -1; return -1;
} }
@ -215,7 +215,7 @@ int VideoPicture::set_dimensions(int w, int h) {
frame->height = h; frame->height = h;
if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height,
kPixFmt, 1) < 0) { kPixFmt, 1) < 0) {
std::cerr << "av_image_alloc failed" << std::endl; OSG_FATAL << "av_image_alloc failed" << std::endl;
return -1; return -1;
} }
@ -442,7 +442,7 @@ public:
} }
catch(std::exception& e) 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" // In the FFMpeg 4.0 a "filename" field was replaced by "url"
#if LIBAVCODEC_VERSION_INT < 3805796 #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 #else
std::cerr << "Error seeking " << self->format_ctx->url << std::endl; OSG_FATAL << "Error seeking " << self->format_ctx->url << std::endl;
#endif #endif
} }
else else
@ -635,7 +635,7 @@ public:
} }
} }
catch(std::exception& e) { 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; self->mQuit = true;
@ -689,7 +689,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
if (!mAudioFactory) 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); avcodec_free_context(&this->audio_ctx);
this->audio_st = nullptr; this->audio_st = nullptr;
return -1; return -1;
@ -698,7 +698,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
mAudioDecoder = mAudioFactory->createDecoder(this); mAudioDecoder = mAudioFactory->createDecoder(this);
if (!mAudioDecoder) 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); avcodec_free_context(&this->audio_ctx);
this->audio_st = nullptr; this->audio_st = nullptr;
return -1; return -1;

Loading…
Cancel
Save