14 changes: 6 additions & 8 deletions mythtv/libs/libmythtv/videoout_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ VideoOutputOpenGL::VideoOutputOpenGL()
: VideoOutput(),
gl_context_lock(QMutex::Recursive), gl_context(NULL),
gl_videochain(NULL), gl_pipchain_active(NULL),
gl_parent_win(0), gl_embed_win(0),
gl_painter(NULL), gl_created_painter(false)
gl_parent_win(0), gl_painter(NULL), gl_created_painter(false)
{
memset(&av_pause_frame, 0, sizeof(av_pause_frame));
av_pause_frame.buf = NULL;
Expand Down Expand Up @@ -111,19 +110,18 @@ void VideoOutputOpenGL::TearDown(void)

bool VideoOutputOpenGL::Init(int width, int height, float aspect,
WId winid, int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid)
MythCodecID codec_id)
{
QMutexLocker locker(&gl_context_lock);

bool success = true;
// FIXME Mac OS X overlay does not work with preview
window.SetAllowPreviewEPG(true);
gl_parent_win = winid;
gl_embed_win = embedid;

VideoOutput::Init(width, height, aspect,
winid, winx, winy, winw, winh,
codec_id, embedid);
codec_id);

SetProfile();

Expand Down Expand Up @@ -183,7 +181,7 @@ bool VideoOutputOpenGL::InputChanged(const QSize &input_size,
QRect disp = window.GetDisplayVisibleRect();
if (Init(input_size.width(), input_size.height(),
aspect, gl_parent_win, disp.left(), disp.top(),
disp.width(), disp.height(), av_codec_id, gl_embed_win))
disp.width(), disp.height(), av_codec_id))
{
BestDeint();
return true;
Expand Down Expand Up @@ -739,10 +737,10 @@ void VideoOutputOpenGL::MoveResizeWindow(QRect new_rect)
gl_context->MoveResizeWindow(new_rect);
}

void VideoOutputOpenGL::EmbedInWidget(int x, int y, int w, int h)
void VideoOutputOpenGL::EmbedInWidget(const QRect &rect)
{
if (!window.IsEmbedding())
VideoOutput::EmbedInWidget(x,y,w,h);
VideoOutput::EmbedInWidget(rect);

MoveResize();
}
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/videoout_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VideoOutputOpenGL : public VideoOutput

virtual bool Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid = 0);
MythCodecID codec_id);
virtual void SetProfile(void);
virtual void TearDown(void);

Expand All @@ -36,7 +36,7 @@ class VideoOutputOpenGL : public VideoOutput
void InitPictureAttributes(void);
static QStringList GetAllowedRenderers(MythCodecID myth_codec_id,
const QSize &video_dim);
void EmbedInWidget(int x, int y, int w, int h);
void EmbedInWidget(const QRect &rect);
void StopEmbedding(void);
virtual bool SetDeinterlacingEnabled(bool);
virtual bool SetupDeinterlace(bool i, const QString& ovrf="");
Expand Down Expand Up @@ -70,7 +70,6 @@ class VideoOutputOpenGL : public VideoOutput
QMap<MythPlayer*,bool> gl_pip_ready;
OpenGLVideo *gl_pipchain_active;
WId gl_parent_win;
WId gl_embed_win;
VideoFrame av_pause_frame;

MythOpenGLPainter *gl_painter;
Expand Down
30 changes: 14 additions & 16 deletions mythtv/libs/libmythtv/videoout_quartz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,20 +1229,19 @@ bool VideoOutputQuartz::InputChanged(const QSize &input_size,

bool VideoOutputQuartz::Init(int width, int height, float aspect,
WId winid, int winx, int winy,
int winw, int winh, MythCodecID codec_id,
WId embedid)
int winw, int winh, MythCodecID codec_id)
{
VERBOSE(VB_PLAYBACK, LOC +
QString("Init(WxH %1x%2, aspect=%3, winid=%4\n\t\t\t"
"win_bounds(x %5, y%6, WxH %7x%8), WId embedid=%9)")
"win_bounds(x %5, y%6, WxH %7x%8))")
.arg(width).arg(height).arg(aspect).arg(winid)
.arg(winx).arg(winy).arg(winw).arg(winh).arg(embedid));
.arg(winx).arg(winy).arg(winw).arg(winh));

vbuffers.Init(kNumBuffers, true, kNeedFreeFrames,
kPrebufferFramesNormal, kPrebufferFramesSmall,
kKeepPrebuffer);
VideoOutput::Init(width, height, aspect, winid,
winx, winy, winw, winh, codec_id, embedid);
winx, winy, winw, winh, codec_id);

const QSize video_dim = window.GetVideoDim();
data->srcWidth = video_dim.width();
Expand Down Expand Up @@ -1554,29 +1553,28 @@ void VideoOutputQuartz::DeleteQuartzBuffers()
vbuffers.DeleteBuffers();
}

void VideoOutputQuartz::EmbedInWidget(int x, int y, int w, int h)
void VideoOutputQuartz::EmbedInWidget(const QRect &rect)
{
VERBOSE(VB_PLAYBACK, (LOC + "EmbedInWidget(x=%1, y=%2, w=%3, h=%4)")
.arg(x).arg(y).arg(w).arg(h));
VERBOSE(VB_PLAYBACK, LOC + QString("EmbedInWidget(x=%1, y=%2, w=%3, h=%4)")
.arg(rect.left()).arg(rect.top())
.arg(rect.width()).arg(rect.height()));

if (window.IsEmbedding())
return;

VideoOutput::EmbedInWidget(x, y, w, h);
VideoOutput::EmbedInWidget(rect);
// Base class has now calculated Aspect/Fill,
// so copy for precision sizing of new widget:
QRect newArea = window.GetDisplayVideoRect();

x = newArea.left(), y = newArea.top(),
w = newArea.width(), h = newArea.height();

VERBOSE(VB_PLAYBACK, (LOC + "EmbedInWidget() - now x=%1, y=%2, w=%3, h=%4")
.arg(x).arg(y).arg(w).arg(h));
VERBOSE(VB_PLAYBACK, LOC + QString("now - EmbedInWidget(x=%1, y=%2, w=%3, h=%4)")
.arg(newArea.left()).arg(newArea.top())
.arg(newArea.width()).arg(newArea.height()));

data->pixelLock.lock();

// create embedded widget
data->embeddedView = new VoqvEmbedded(data, x, y, w, h);
data->embeddedView = new VoqvEmbedded(data, newArea.left(), newArea.top(),
newArea.width(), newArea.height());
if (data->embeddedView)
{
data->embeddedView->Init();
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videoout_quartz.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VideoOutputQuartz : public VideoOutput

bool Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid = 0);
MythCodecID codec_id);

void ProcessFrame(VideoFrame *frame, OSD *osd,
FilterChain *filterList,
Expand All @@ -35,7 +35,7 @@ class VideoOutputQuartz : public VideoOutput
void Zoom(ZoomDirection direction);
void ToggleAdjustFill(AdjustFillMode adjustFill);

void EmbedInWidget(int x, int y, int w, int h);
void EmbedInWidget(const QRect &rect);
void StopEmbedding(void);

void MoveResizeWindow(QRect new_rect) {;}
Expand Down
12 changes: 5 additions & 7 deletions mythtv/libs/libmythtv/videoout_vdpau.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,19 @@ void VideoOutputVDPAU::TearDown(void)

bool VideoOutputVDPAU::Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid)
MythCodecID codec_id)
{
// Attempt to free up as much video memory as possible
// only works when using the VDPAU painter for the UI
MythPainter *painter = GetMythPainter();
if (painter)
painter->FreeResources();

(void) embedid;
m_win = winid;
QMutexLocker locker(&m_lock);
window.SetNeedRepaint(true);
bool ok = VideoOutput::Init(width, height, aspect,
winid, winx, winy, winw, winh,
codec_id, embedid);
winid, winx, winy, winw, winh,codec_id);
if (db_vdisp_profile)
db_vdisp_profile->SetVideoRenderer("vdpau");

Expand Down Expand Up @@ -717,7 +715,7 @@ bool VideoOutputVDPAU::InputChanged(const QSize &input_size,
QRect disp = window.GetDisplayVisibleRect();
if (Init(input_size.width(), input_size.height(),
aspect, m_win, disp.left(), disp.top(),
disp.width(), disp.height(), av_codec_id, 0))
disp.width(), disp.height(), av_codec_id))
{
BestDeint();
return true;
Expand All @@ -743,12 +741,12 @@ void VideoOutputVDPAU::VideoAspectRatioChanged(float aspect)
VideoOutput::VideoAspectRatioChanged(aspect);
}

void VideoOutputVDPAU::EmbedInWidget(int x, int y,int w, int h)
void VideoOutputVDPAU::EmbedInWidget(const QRect &rect)
{
QMutexLocker locker(&m_lock);
if (!window.IsEmbedding())
{
VideoOutput::EmbedInWidget(x, y, w, h);
VideoOutput::EmbedInWidget(rect);
MoveResize();
window.SetDisplayVisibleRect(window.GetTmpDisplayVisibleRect());
}
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videoout_vdpau.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class VideoOutputVDPAU : public VideoOutput
~VideoOutputVDPAU();
bool Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid = 0);
MythCodecID codec_id);
bool SetDeinterlacingEnabled(bool interlaced);
bool SetupDeinterlace(bool interlaced, const QString& ovrf="");
bool ApproveDeintFilter(const QString& filtername) const;
Expand All @@ -43,7 +43,7 @@ class VideoOutputVDPAU : public VideoOutput
bool &aspect_only);
void Zoom(ZoomDirection direction);
void VideoAspectRatioChanged(float aspect);
void EmbedInWidget(int x, int y, int w, int h);
void EmbedInWidget(const QRect &rect);
void StopEmbedding(void);
void MoveResizeWindow(QRect new_rect);
void DrawUnusedRects(bool sync = true);
Expand Down
12 changes: 4 additions & 8 deletions mythtv/libs/libmythtv/videoout_xv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ bool VideoOutputXv::InitSetupBuffers(void)
bool VideoOutputXv::Init(
int width, int height, float aspect,
WId winid, int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid)
MythCodecID codec_id)
{
window.SetNeedRepaint(true);

Expand Down Expand Up @@ -909,15 +909,11 @@ bool VideoOutputXv::Init(
// Basic setup
VideoOutput::Init(width, height, aspect,
winid, winx, winy, winw, winh,
codec_id, embedid);
codec_id);

// Set resolution/measurements (check XRandR, Xinerama, config settings)
InitDisplayMeasurements(width, height, true);

// Set embedding window id
if (embedid > 0)
XJ_curwin = XJ_win = embedid;

if (!InitSetupBuffers())
return false;

Expand Down Expand Up @@ -1317,12 +1313,12 @@ void VideoOutputXv::DeleteBuffers(VOSType subtype, bool delete_pause_frame)
XJ_non_xv_image = NULL;
}

void VideoOutputXv::EmbedInWidget(int x, int y, int w, int h)
void VideoOutputXv::EmbedInWidget(const QRect &rect)
{
QMutexLocker locker(&global_lock);

if (!window.IsEmbedding())
VideoOutput::EmbedInWidget(x, y, w, h);
VideoOutput::EmbedInWidget(rect);
MoveResize();
}

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videoout_xv.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class VideoOutputXv : public VideoOutput

bool Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid = 0);
MythCodecID codec_id);

bool SetDeinterlacingEnabled(bool);
bool SetupDeinterlace(bool interlaced, const QString& ovrf="");
Expand All @@ -61,7 +61,7 @@ class VideoOutputXv : public VideoOutput
bool &aspect_only);
void Zoom(ZoomDirection direction);
void VideoAspectRatioChanged(float aspect);
void EmbedInWidget(int x, int y, int w, int h);
void EmbedInWidget(const QRect &rect);
void StopEmbedding(void);
void MoveResizeWindow(QRect new_rect);
void DrawUnusedRects(bool sync = true);
Expand Down
20 changes: 7 additions & 13 deletions mythtv/libs/libmythtv/videooutbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ VideoOutput *VideoOutput::Create(
PIPState pipState,
const QSize &video_dim, float video_aspect,
WId win_id, const QRect &display_rect,
float video_prate, WId embed_id)
float video_prate)
{
(void) codec_priv;

Expand Down Expand Up @@ -200,8 +200,7 @@ VideoOutput *VideoOutput::Create(
if (vo->Init(
video_dim.width(), video_dim.height(), video_aspect,
win_id, display_rect.x(), display_rect.y(),
display_rect.width(), display_rect.height(),
codec_id, embed_id))
display_rect.width(), display_rect.height(), codec_id))
{
return vo;
}
Expand Down Expand Up @@ -379,10 +378,9 @@ VideoOutput::~VideoOutput()
*/
bool VideoOutput::Init(int width, int height, float aspect, WId winid,
int winx, int winy, int winw, int winh,
MythCodecID codec_id, WId embedid)
MythCodecID codec_id)
{
(void)winid;
(void)embedid;

video_codec_id = codec_id;
bool wasembedding = window.IsEmbedding();
Expand Down Expand Up @@ -410,7 +408,7 @@ bool VideoOutput::Init(int width, int height, float aspect, WId winid,
if (wasembedding)
{
VERBOSE(VB_PLAYBACK, LOC + "Restoring embedded playback");
EmbedInWidget(oldrect.x(), oldrect.y(), oldrect.width(), oldrect.height());
EmbedInWidget(oldrect);
}

VideoAspectRatioChanged(aspect); // apply aspect ratio and letterbox mode
Expand Down Expand Up @@ -682,21 +680,17 @@ void VideoOutput::ResizeDisplayWindow(const QRect &rect, bool save_visible_rect)

/**
* \brief Tells video output to embed video in an existing window.
* \param x X location where to locate video
* \param y Y location where to locate video
* \param w width of video
* \param h height of video
* \sa StopEmbedding()
*/
void VideoOutput::EmbedInWidget(int x, int y, int w, int h)
void VideoOutput::EmbedInWidget(const QRect &rect)
{
window.EmbedInWidget(QRect(x, y, w, h));
window.EmbedInWidget(rect);
}

/**
* \fn VideoOutput::StopEmbedding(void)
* \brief Tells video output to stop embedding video in an existing window.
* \sa EmbedInWidget(WId, int, int, int, int)
* \sa EmbedInWidget(const QRect&)
*/
void VideoOutput::StopEmbedding(void)
{
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/videooutbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class VideoOutput
PIPState pipState,
const QSize &video_dim, float video_aspect,
WId win_id, const QRect &display_rect,
float video_prate, WId embed_id);
float video_prate);

VideoOutput();
virtual ~VideoOutput();

virtual bool Init(int width, int height, float aspect,
WId winid, int winx, int winy, int winw,
int winh, MythCodecID codec_id, WId embedid = 0);
int winh, MythCodecID codec_id);
virtual void InitOSD(OSD *osd);
virtual void SetVideoFrameRate(float);
virtual bool IsPreferredRenderer(QSize video_size);
Expand Down Expand Up @@ -89,7 +89,7 @@ class VideoOutput
virtual void VideoAspectRatioChanged(float aspect);

virtual void ResizeDisplayWindow(const QRect&, bool);
virtual void EmbedInWidget(int x, int y, int w, int h);
virtual void EmbedInWidget(const QRect &rect);
virtual void StopEmbedding(void);
virtual void ResizeForGui(void);
virtual void ResizeForVideo(uint width = 0, uint height = 0);
Expand Down
3 changes: 3 additions & 0 deletions mythtv/libs/libmythtv/videooutwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ VideoOutWindow::VideoOutWindow() :
display_video_rect(0, 0, 0, 0),
display_visible_rect(0, 0, 0, 0),
tmp_display_visible_rect(0, 0, 0, 0),
embedding_rect(QRect()),

// Various state variables
embedding(false), needrepaint(false),
Expand Down Expand Up @@ -675,6 +676,7 @@ void VideoOutWindow::EmbedInWidget(const QRect &new_video_rect)
if (!allowpreviewepg && pip_state == kPIPOff)
return;

embedding_rect = new_video_rect;
bool save_visible_rect = !embedding;

embedding = true;
Expand All @@ -690,6 +692,7 @@ void VideoOutWindow::EmbedInWidget(const QRect &new_video_rect)
*/
void VideoOutWindow::StopEmbedding(void)
{
embedding_rect = QRect();
display_visible_rect = tmp_display_visible_rect;

MoveResize();
Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmythtv/videooutwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ class VideoOutWindow
PIPState GetPIPState(void) const { return pip_state; }
float GetOverridenVideoAspect(void) const { return overriden_video_aspect;}
QRect GetDisplayVisibleRect(void) const { return display_visible_rect; }
QRect GetScreenGeometry(void) const { return screen_geom; }
QRect GetScreenGeometry(void) const { return screen_geom; }
QRect GetVideoRect(void) const { return video_rect; }
QRect GetDisplayVideoRect(void) const { return display_video_rect; }
bool UsingXinerama(void) const { return using_xinerama; }
QRect GetEmbeddingRect(void) const { return embedding_rect; }
bool UsingXinerama(void) const { return using_xinerama; }
bool UsingGuiSize(void) const { return db_use_gui_size; }

/// \brief Returns current aspect override mode
Expand Down Expand Up @@ -157,6 +158,8 @@ class VideoOutWindow
/// Used to save the display_visible_rect for
/// restoration after video embedding ends.
QRect tmp_display_visible_rect;
/// Embedded video rectangle
QRect embedding_rect;

/// State variables
bool embedding;
Expand Down