1 #include <lib/gui/evideo.h>
2 #include <lib/gui/ewidgetdesktop.h>
4 static ePtr<eTimer> fullsizeTimer;
5 static int pendingFullsize;
9 for (int decoder=0; decoder < 1; ++decoder)
11 if (pendingFullsize & (1 << decoder))
13 for (int i=0; i<4; ++i)
15 const char *targets[]={"left", "top", "width", "height"};
17 snprintf(filename, 128, "/proc/stb/vmpeg/%d/dst_%s", decoder, targets[i]);
18 FILE *f = fopen(filename, "w");
21 eDebug("failed to open %s - %m", filename);
24 fprintf(f, "%08x\n", 0);
27 pendingFullsize &= ~(1 << decoder);
32 eVideoWidget::eVideoWidget(eWidget *parent)
33 :eLabel(parent), m_fb_size(720, 576), m_state(0), m_decoder(1)
37 fullsizeTimer = eTimer::create(eApp);
38 fullsizeTimer->timeout.connect(slot(setFullsize));
40 parent->setPositionNotifyChild(1);
41 // setBackgroundColor(gRGB(0xFF000000));
44 int eVideoWidget::event(int event, void *data, void *data2)
48 case evtChangedPosition:
49 case evtParentChangedPosition:
51 updatePosition(!isVisible());
55 updatePosition(!isVisible());
57 case evtParentVisibilityChanged:
58 updatePosition(!isVisible());
61 return eLabel::event(event, data, data2);
64 eVideoWidget::~eVideoWidget()
69 void eVideoWidget::setFBSize(eSize size)
74 void eVideoWidget::updatePosition(int disable)
79 if (disable && !(m_state & 4))
81 // eDebug("was not visible!");
85 if ((m_state & 2) != 2)
87 // eDebug("no size!");
91 // eDebug("position %d %d -> %d %d", position().x(), position().y(), size().width(), size().height());
95 pos = eRect(getAbsolutePosition(), size());
99 // eDebug("abs position %d %d -> %d %d", pos.left(), pos.top(), pos.width(), pos.height());
101 if (!disable && m_state & 8 && pos == m_user_rect)
103 // eDebug("matched");
111 // eDebug("set user rect pos!");
114 // eDebug("m_user_rect %d %d -> %d %d", m_user_rect.left(), m_user_rect.top(), m_user_rect.width(), m_user_rect.height());
116 int left = pos.left() * 720 / m_fb_size.width();
117 int top = pos.top() * 576 / m_fb_size.height();
118 int width = pos.width() * 720 / m_fb_size.width();
119 int height = pos.height() * 576 / m_fb_size.height();
121 int tmp = left - (width * 4) / 100;
122 left = tmp < 0 ? 0 : tmp;
123 tmp = top - (height * 4) / 100;
124 top = tmp < 0 ? 0 : tmp;
125 tmp = (width * 108) / 100;
126 width = left + tmp > 720 ? 720 - left : tmp;
127 tmp = (height * 108) / 100;
128 height = top + tmp > 576 ? 576 - top : tmp;
130 // eDebug("picture recalced %d %d -> %d %d", left, top, width, height);
134 for (int i=0; i<4; ++i)
136 const char *targets[]={"left", "top", "width", "height"};
138 snprintf(filename, 128, "/proc/stb/vmpeg/%d/dst_%s", m_decoder, targets[i]);
139 FILE *f = fopen(filename, "w");
142 eDebug("failed to open %s - %m", filename);
149 case 0: val = left; break;
150 case 1: val = top; break;
151 case 2: val = width; break;
152 case 3: val = height; break;
154 fprintf(f, "%08x\n", val);
156 // eDebug("%s %08x", filename, val);
159 pendingFullsize &= ~(1 << m_decoder);
165 pendingFullsize |= (1 << m_decoder);
166 fullsizeTimer->start(100, true);
171 void eVideoWidget::setDecoder(int decoder)