Skip to content

Commit

Permalink
Fix remote screenshots during TV playback
Browse files Browse the repository at this point in the history
Got home from work and tried while playback was running.  Seems there are two
separate event paths (makes sense) depending on whether or not the player is
running.

Tweaked the playback case as well to match the non-playback.  All is now
working for the remote screenshots on my setup.
  • Loading branch information
Beirdo committed Jun 11, 2011
1 parent 28f0fdb commit 6be90d3
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 28 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -3875,10 +3875,10 @@ bool MythPlayer::IsEmbedding(void)
return false;
}

bool MythPlayer::GetScreenShot(int width, int height)
bool MythPlayer::GetScreenShot(int width, int height, QString filename)
{
if (videoOutput)
return videoOutput->GetScreenShot(width, height);
return videoOutput->GetScreenShot(width, height, filename);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -189,7 +189,7 @@ class MTV_PUBLIC MythPlayer
bool UsingNullVideo(void) const { return using_null_videoout; }
bool HasTVChainNext(void) const;
bool CanSupportDoubleRate(void);
bool GetScreenShot(int width = 0, int height = 0);
bool GetScreenShot(int width = 0, int height = 0, QString filename = "");

// Non-const gets
VideoOutput *getVideoOutput(void) { return videoOutput; }
Expand Down
20 changes: 15 additions & 5 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -8138,15 +8138,25 @@ void TV::customEvent(QEvent *e)
if (message == ACTION_SCREENSHOT)
{
PlayerContext *mctx = GetPlayerWriteLock(0, __FILE__, __LINE__);
bool extra = me->ExtraDataCount() == 2;
int width = extra ? me->ExtraData(0).toInt() : 0;
int height = extra ? me->ExtraData(1).toInt() : 0;
if (mctx && mctx->player && mctx->player->GetScreenShot(width, height))
int width = 0;
int height = 0;
QString filename;

if (me->ExtraDataCount() >= 2)
{
width = me->ExtraData(0).toInt();
height = me->ExtraData(1).toInt();

if (me->ExtraDataCount() == 3)
filename = me->ExtraData(2);
}
if (mctx && mctx->player &&
mctx->player->GetScreenShot(width, height, filename))
{
}
else
{
GetMythMainWindow()->ScreenShot(width, height);
GetMythMainWindow()->ScreenShot(width, height, filename);
}
ReturnPlayerLock(mctx);
}
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videoout_vdpau.cpp
Expand Up @@ -1258,9 +1258,9 @@ void VideoOutputVDPAU::ParseOptions(void)
}
}

bool VideoOutputVDPAU::GetScreenShot(int width, int height)
bool VideoOutputVDPAU::GetScreenShot(int width, int height, QString filename)
{
if (m_render)
return m_render->GetScreenShot(width, height);
return m_render->GetScreenShot(width, height, filename);
return false;
}
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/videoout_vdpau.h
Expand Up @@ -62,7 +62,8 @@ class VideoOutputVDPAU : public VideoOutput
virtual bool hasHWAcceleration(void) const
{ return codec_is_vdpau(video_codec_id); }
virtual MythPainter* GetOSDPainter(void) { return (MythPainter*)m_osd_painter; }
virtual bool GetScreenShot(int width = 0, int height = 0);
virtual bool GetScreenShot(int width = 0, int height = 0,
QString filename = "");

virtual bool CanVisualise(AudioPlayer *audio, MythRender *render)
{ return VideoOutput::CanVisualise(audio, m_render); }
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/videooutbase.h
Expand Up @@ -238,7 +238,8 @@ class VideoOutput

virtual QString GetOSDRenderer(void) const;
virtual MythPainter *GetOSDPainter(void) { return (MythPainter*)osd_painter; }
virtual bool GetScreenShot(int width = 0, int height = 0) { return false; }
virtual bool GetScreenShot(int width = 0, int height = 0,
QString filename = "") { return false; }

QString GetFilters(void) const;
/// \brief translates caption/dvd button rectangle into 'screen' space
Expand Down
20 changes: 8 additions & 12 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -2236,23 +2236,19 @@ void MythMainWindow::customEvent(QEvent *ce)
}
else if (message.startsWith(ACTION_SCREENSHOT))
{
int width = 0;
int height = 0;
QString filename;

if (me->ExtraDataCount() >= 2)
{
int width = me->ExtraData(0).toInt();
int height = me->ExtraData(1).toInt();
width = me->ExtraData(0).toInt();
height = me->ExtraData(1).toInt();

if (me->ExtraDataCount() == 3)
{
QString filename = me->ExtraData(2);
ScreenShot(width, height, filename);
}
else
ScreenShot(width, height);
}
else
{
ScreenShot();
filename = me->ExtraData(2);
}
ScreenShot(width, height, filename);
}
}
else if ((MythEvent::Type)(ce->type()) == MythEvent::MythUserMessage)
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythui/mythrender_vdpau.cpp
Expand Up @@ -475,7 +475,7 @@ void MythRenderVDPAU::MoveResizeWin(QRect &rect)
m_display->MoveResizeWin(m_window, rect);
}

bool MythRenderVDPAU::GetScreenShot(int width, int height)
bool MythRenderVDPAU::GetScreenShot(int width, int height, QString filename)
{
LOCK_RENDER
CHECK_STATUS(false)
Expand Down Expand Up @@ -516,8 +516,9 @@ bool MythRenderVDPAU::GetScreenShot(int width, int height)
if (height <= 0)
height = img.height();

img = img.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
success = window->SaveScreenShot(img);
img = img.scaled(width, height, Qt::KeepAspectRatio,
Qt::SmoothTransformation);
success = window->SaveScreenShot(img, filename);
}
delete [] buffer;
return success;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythrender_vdpau.h
Expand Up @@ -73,7 +73,7 @@ class MUI_PUBLIC MythRenderVDPAU : public MythRender
void DrawDisplayRect(const QRect &rect, bool use_colorkey = false);
void MoveResizeWin(QRect &rect);
void CheckOutputSurfaces(void);
bool GetScreenShot(int width = 0, int height = 0);
bool GetScreenShot(int width = 0, int height = 0, QString filename = "");

uint CreateOutputSurface(const QSize &size,
VdpRGBAFormat fmt = VDP_RGBA_FORMAT_B8G8R8A8,
Expand Down

0 comments on commit 6be90d3

Please sign in to comment.