Skip to content

Commit

Permalink
Merge branch 'video_logging' into 'master'
Browse files Browse the repository at this point in the history
Migrate videoplayer to OSG logging system

See merge request OpenMW/openmw!4408
  • Loading branch information
Assumeru committed Oct 19, 2024
2 parents bac0018 + 1933403 commit 001d390
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion extern/osg-ffmpeg-videoplayer/videoplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <iostream>

#include <osg/Notify>
#include <osg/Texture2D>

#include "audiofactory.hpp"
Expand Down Expand Up @@ -45,7 +46,7 @@ void VideoPlayer::playVideo(std::unique_ptr<std::istream>&& inputstream, const s
}
}
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();
}
}
Expand Down
16 changes: 8 additions & 8 deletions extern/osg-ffmpeg-videoplayer/videostate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ int VideoPicture::set_dimensions(int w, int h) {
std::unique_ptr<AVFrame, VideoPicture::AVFrameDeleter> 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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -442,7 +442,7 @@ class VideoThread
}
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;
}
})
{
Expand Down Expand Up @@ -567,9 +567,9 @@ class ParseThread
{
// 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
Expand Down Expand Up @@ -635,7 +635,7 @@ class ParseThread
}
}
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 001d390

Please sign in to comment.