From 00f4f7871730e43a9ee0cc0c12fff8fe3e5b1071 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 7 May 2015 23:08:52 +0200 Subject: [PATCH] Give a name to video streams for logging purposes --- apps/openmw/mwgui/videowidget.cpp | 2 +- extern/osg-ffmpeg-videoplayer/videoplayer.cpp | 4 ++-- extern/osg-ffmpeg-videoplayer/videoplayer.hpp | 3 ++- extern/osg-ffmpeg-videoplayer/videostate.cpp | 8 +++----- extern/osg-ffmpeg-videoplayer/videostate.hpp | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/videowidget.cpp b/apps/openmw/mwgui/videowidget.cpp index 13fabfeed..2c9b1c97e 100644 --- a/apps/openmw/mwgui/videowidget.cpp +++ b/apps/openmw/mwgui/videowidget.cpp @@ -30,7 +30,7 @@ void VideoWidget::playVideo(const std::string &video) { mPlayer->setAudioFactory(new MWSound::MovieAudioFactory()); - mPlayer->playVideo(mVFS->get(video)); + mPlayer->playVideo(mVFS->get(video), video); osg::ref_ptr texture = mPlayer->getVideoTexture(); if (!texture) diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp index 1336e45a3..9bd4a2df3 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp @@ -25,7 +25,7 @@ void VideoPlayer::setAudioFactory(MovieAudioFactory *factory) mAudioFactory.reset(factory); } -void VideoPlayer::playVideo(boost::shared_ptr inputstream) +void VideoPlayer::playVideo(boost::shared_ptr inputstream, const std::string& name) { if(mState) close(); @@ -33,7 +33,7 @@ void VideoPlayer::playVideo(boost::shared_ptr inputstream) try { mState = new VideoState; mState->setAudioFactory(mAudioFactory.get()); - mState->init(inputstream); + mState->init(inputstream, name); // wait until we have the first picture while (mState->video_st && !mState->mTexture.get()) diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.hpp b/extern/osg-ffmpeg-videoplayer/videoplayer.hpp index 261246f39..b886257e7 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.hpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.hpp @@ -41,7 +41,8 @@ namespace Video /// Play the given video. If a video is already playing, the old video is closed first. /// @note The video will be unpaused by default. Use the pause() and play() methods to control pausing. - void playVideo (boost::shared_ptr inputstream); + /// @param name A name for the video stream - only used for logging purposes. + void playVideo (boost::shared_ptr inputstream, const std::string& name); /// Get the current playback time position in the video, in seconds double getCurrentTime(); diff --git a/extern/osg-ffmpeg-videoplayer/videostate.cpp b/extern/osg-ffmpeg-videoplayer/videostate.cpp index 72fc82f86..4dd618858 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.cpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.cpp @@ -602,7 +602,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) return 0; } -void VideoState::init(boost::shared_ptr inputstream) +void VideoState::init(boost::shared_ptr inputstream, const std::string &name) { int video_index = -1; int audio_index = -1; @@ -622,8 +622,6 @@ void VideoState::init(boost::shared_ptr inputstream) if(this->format_ctx) this->format_ctx->pb = ioCtx; - std::string videoName; - // Open video file /// /// format_ctx->pb->buffer must be freed by hand, @@ -631,7 +629,7 @@ void VideoState::init(boost::shared_ptr inputstream) /// /// https://trac.ffmpeg.org/ticket/1357 /// - if(!this->format_ctx || avformat_open_input(&this->format_ctx, videoName.c_str(), NULL, NULL)) + if(!this->format_ctx || avformat_open_input(&this->format_ctx, name.c_str(), NULL, NULL)) { if (this->format_ctx != NULL) { @@ -655,7 +653,7 @@ void VideoState::init(boost::shared_ptr inputstream) throw std::runtime_error("Failed to retrieve stream information"); // Dump information about file onto standard error - av_dump_format(this->format_ctx, 0, videoName.c_str(), 0); + av_dump_format(this->format_ctx, 0, name.c_str(), 0); for(i = 0;i < this->format_ctx->nb_streams;i++) { diff --git a/extern/osg-ffmpeg-videoplayer/videostate.hpp b/extern/osg-ffmpeg-videoplayer/videostate.hpp index 40925e014..4a4f2fc6b 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.hpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.hpp @@ -84,7 +84,7 @@ struct VideoState { void setAudioFactory(MovieAudioFactory* factory); - void init(boost::shared_ptr inputstream); + void init(boost::shared_ptr inputstream, const std::string& name); void deinit(); void setPaused(bool isPaused);