MythTV  master
mhi.cpp
Go to the documentation of this file.
1 #include "mhi.h"
2 
3 #include <QRegion>
4 #include <QVector>
5 #include <QUrl>
6 #include <QPoint> // for QPoint
7 #include <QRgb> // for QRgb
8 #include <QVariant> // for QVariant
9 #include <QByteArray> // for QByteArray
10 #include <QStringList> // for QStringList
11 #include <QTime> // for QTime
12 #include <QHash> // for QHash
13 
14 #include <algorithm> // for min
15 #include <cmath> // for round, sqrt
16 #include <cstdint> // for uint8_t
17 #include <cstring> // for memcpy, memset
18 #include <deque> // for _Deque_iterator, operator!=
19 
20 #include "libmyth/mythaverror.h"
21 #include "libmyth/mythavframe.h"
22 #include "libmythbase/mthread.h" // for MThread
23 #include "libmythbase/mythcorecontext.h"// for MythCoreContext, etc
24 #include "libmythbase/mythdb.h" // for MythDB
25 #include "libmythbase/mythdbcon.h" // for MSqlQuery
26 #include "libmythbase/mythdirs.h"
27 #include "libmythbase/mythevent.h" // for MythEvent
29 #include "libmythui/mythimage.h"
31 #include "libmythui/mythpainter.h"
32 #include "libmythui/mythrect.h" // for MythRect
33 #include "libmythui/mythuiactions.h" // for ACTION_0, ACTION_1, etc
34 #include "libmythui/mythuiimage.h"
35 
36 #include "dsmcc.h" // for Dsmcc
37 #include "interactivescreen.h"
38 #include "interactivetv.h" // for InteractiveTV
39 #include "mythavutil.h"
40 #include "mythplayerui.h"
41 #include "tv_actions.h" // for ACTION_MENUTEXT, etc
42 
43 extern "C" {
44 #include "libavutil/imgutils.h"
45 }
46 
47 static bool ft_loaded = false;
48 static FT_Library ft_library;
49 
50 static constexpr uint8_t FONT_WIDTHRES { 54 };
51 static constexpr uint8_t FONT_HEIGHTRES { 72 }; // 1 pixel per point
52 static constexpr const char * FONT_TO_USE { "FreeSans.ttf" }; // Tiresias Screenfont.ttf is mandated
53 
54 
55 // LifecycleExtension tuneinfo:
56 const unsigned kTuneQuietly = 1U<<0; // b0 tune quietly
57 const unsigned kTuneKeepApp = 1U<<1; // b1 keep app running
58 const unsigned kTuneCarId = 1U<<2; // b2 carousel id in bits 8..16
59 const unsigned kTuneCarReset = 1U<<3; // b3 get carousel id from gateway info
60 //const unsigned kTuneBcastDisa = 1U<<4; // b4 broadcaster_interrupt disable
61 // b5..7 reserverd
62 // b8..15 carousel id
63 const unsigned kTuneKeepChnl = 1U<<16; // Keep current channel
64 // b17..31 reserved
65 
70 {
71  public:
72  QImage m_image;
73  int m_x {0};
74  int m_y {0};
75  bool m_bUnder {false};
76 };
77 
79  : m_parent(parent), m_dsmcc(new Dsmcc()),
80  m_engine(MHCreateEngine(this))
81 {
82  if (!ft_loaded)
83  {
84  FT_Error error = FT_Init_FreeType(&ft_library);
85  if (!error)
86  ft_loaded = true;
87  }
88 
89  if (ft_loaded)
90  {
91  // TODO: We need bold and italic versions.
92  if (LoadFont(FONT_TO_USE))
93  m_faceLoaded = true;
94  }
95 }
96 
97 // Load the font. Copied, generally, from OSD::LoadFont.
98 bool MHIContext::LoadFont(const QString& name)
99 {
100  QString fullnameA = GetConfDir() + "/" + name;
101  QByteArray fnameA = fullnameA.toLatin1();
102  FT_Error errorA = FT_New_Face(ft_library, fnameA.constData(), 0, &m_face);
103  if (!errorA)
104  return true;
105 
106  QString fullnameB = GetFontsDir() + name;
107  QByteArray fnameB = fullnameB.toLatin1();
108  FT_Error errorB = FT_New_Face(ft_library, fnameB.constData(), 0, &m_face);
109  if (!errorB)
110  return true;
111 
112  QString fullnameC = GetShareDir() + "themes/" + name;
113  QByteArray fnameC = fullnameC.toLatin1();
114  FT_Error errorC = FT_New_Face(ft_library, fnameC.constData(), 0, &m_face);
115  if (!errorC)
116  return true;
117 
118  const QString& fullnameD = name;
119  QByteArray fnameD = fullnameD.toLatin1();
120  FT_Error errorD = FT_New_Face(ft_library, fnameD.constData(), 0, &m_face);
121  if (!errorD)
122  return true;
123 
124  LOG(VB_GENERAL, LOG_ERR, QString("[mhi] Unable to find font: %1").arg(name));
125  return false;
126 }
127 
129 {
130  StopEngine();
131  delete(m_engine);
132  delete(m_dsmcc);
133  if (m_faceLoaded) FT_Done_Face(m_face);
134 
135  ClearDisplay();
136  ClearQueue();
137 }
138 
139 // NB caller must hold m_display_lock
141 {
142  for (auto & it : m_display)
143  delete it;
144  m_display.clear();
145  m_videoDisplayRect = QRect();
146 }
147 
148 // NB caller must hold m_dsmccLock
150 {
151  for (auto & it : m_dsmccQueue)
152  delete it;
153  m_dsmccQueue.clear();
154 }
155 
156 // Ask the engine to stop and block until it has.
158 {
159  if (nullptr == m_engineThread)
160  return;
161 
162  m_stop = true;
163  m_runLock.lock();
164  m_engineWait.wakeAll();
165  m_runLock.unlock();
166 
167  m_engineThread->wait();
168  delete m_engineThread;
169  m_engineThread = nullptr;
170 }
171 
172 
173 // Start or restart the MHEG engine.
174 void MHIContext::Restart(int chanid, int sourceid, bool isLive)
175 {
176  int tuneinfo = m_tuneInfo.isEmpty() ? 0 : m_tuneInfo.takeFirst();
177 
178  LOG(VB_MHEG, LOG_INFO,
179  QString("[mhi] Restart ch=%1 source=%2 live=%3 tuneinfo=0x%4")
180  .arg(chanid).arg(sourceid).arg(isLive).arg(tuneinfo,0,16));
181 
182  if (m_currentSource != sourceid)
183  {
184  m_currentSource = sourceid;
185  QMutexLocker locker(&m_channelMutex);
186  m_channelCache.clear();
187  }
188  m_currentStream = (chanid) ? chanid : -1;
189  if (!(tuneinfo & kTuneKeepChnl))
191 
192  if (tuneinfo & kTuneKeepApp)
193  {
194  // We have tuned to the channel in order to find the streams.
195  // Leave the MHEG engine running but restart the DSMCC carousel.
196  // This is a bit of a mess but it's the only way to be able to
197  // select streams from a different channel.
198  {
199  QMutexLocker locker(&m_dsmccLock);
200  if (tuneinfo & kTuneCarReset)
201  m_dsmcc->Reset();
202  ClearQueue();
203  }
204 
205  if (tuneinfo & (kTuneCarReset|kTuneCarId))
206  {
207  QMutexLocker locker(&m_runLock);
208  m_engine->EngineEvent(10); // NonDestructiveTuneOK
209  }
210  }
211  else
212  {
213  StopEngine();
214 
215  m_audioTag = -1;
216  m_videoTag = -1;
217 
218  {
219  QMutexLocker locker(&m_dsmccLock);
220  m_dsmcc->Reset();
221  ClearQueue();
222  }
223 
224  {
225  QMutexLocker locker(&m_keyLock);
226  m_keyQueue.clear();
227  }
228 
229  m_engine->SetBooting();
230  ClearDisplay();
231  m_updated = true;
232  m_stop = false;
233  m_isLive = isLive;
234  // Don't set the NBI version here. Restart is called
235  // after the PMT is processed.
236  m_engineThread = new MThread("MHEG", this);
238  }
239 }
240 
241 void MHIContext::run(void)
242 {
243  QMutexLocker locker(&m_runLock);
244 
245  while (!m_stop)
246  {
247  std::chrono::milliseconds toWait = 0ms;
248  // Dequeue and process any key presses.
249  int key = 0;
250  do
251  {
254  {
255  QMutexLocker locker2(&m_keyLock);
256  key = m_keyQueue.dequeue();
257  }
258 
259  if (key != 0)
261 
262  // Run the engine and find out how long to pause.
263  toWait = m_engine->RunAll();
264  if (toWait < 0ms)
265  return;
266  } while (key != 0);
267 
268  toWait = (toWait > 1s || toWait <= 0ms) ? 1s : toWait;
269 
270  if (!m_stop && (toWait > 0ms))
271  m_engineWait.wait(locker.mutex(), toWait.count());
272  }
273 }
274 
275 // Dequeue and process any DSMCC packets.
277 {
278  DSMCCPacket *packet = nullptr;
279  do
280  {
281  QMutexLocker locker(&m_dsmccLock);
282  packet = m_dsmccQueue.dequeue();
283  if (packet)
284  {
286  packet->m_data, packet->m_length,
287  packet->m_componentTag, packet->m_carouselId,
288  packet->m_dataBroadcastId);
289 
290  delete packet;
291  }
292  } while (packet);
293 }
294 
296  unsigned char *data, int length, int componentTag,
297  unsigned carouselId, int dataBroadcastId)
298 {
299  auto *dataCopy = (unsigned char*) malloc(length * sizeof(unsigned char));
300 
301  if (dataCopy == nullptr)
302  return;
303 
304  memcpy(dataCopy, data, length*sizeof(unsigned char));
305  {
306  QMutexLocker locker(&m_dsmccLock);
307  m_dsmccQueue.enqueue(new DSMCCPacket(dataCopy, length,
308  componentTag, carouselId,
309  dataBroadcastId));
310  }
311  m_engineWait.wakeAll();
312 }
313 
314 // A NetworkBootInfo sub-descriptor is present in the PMT.
315 void MHIContext::SetNetBootInfo(const unsigned char *data, uint length)
316 {
317  if (length < 2) // A valid descriptor should always have at least 2 bytes.
318  return;
319 
320  LOG(VB_MHEG, LOG_INFO, QString("[mhi] SetNetBootInfo version %1 mode %2 len %3")
321  .arg(data[0]).arg(data[1]).arg(length));
322 
323  QMutexLocker locker(&m_dsmccLock);
324  // The carousel should be reset now as the stream has changed
325  m_dsmcc->Reset();
326  ClearQueue();
327  // Save the data from the descriptor.
328  m_nbiData.resize(0);
329  m_nbiData.reserve(length);
330  m_nbiData.insert(m_nbiData.begin(), data, data+length);
331  // If there is no Network Boot Info or we're setting it
332  // for the first time just update the "last version".
334  m_lastNbiVersion = data[0];
335  else
336  m_engineWait.wakeAll();
337 }
338 
339 // Called only by m_engineThread
341 {
342  QMutexLocker locker(&m_dsmccLock);
343  if (m_nbiData.size() >= 2 && m_nbiData[0] != m_lastNbiVersion)
344  {
345  m_lastNbiVersion = m_nbiData[0]; // Update the saved version
346  switch (m_nbiData[1])
347  {
348  case 1:
349  m_dsmcc->Reset();
350  m_engine->SetBooting();
351  locker.unlock();
352  {QMutexLocker locker2(&m_displayLock);
353  ClearDisplay();
354  m_updated = true;}
355  break;
356  case 2:
357  m_engine->EngineEvent(9); // NetworkBootInfo EngineEvent
358  break;
359  default:
360  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Unknown NetworkBoot type %1")
361  .arg(m_nbiData[1]));
362  break;
363  }
364  }
365 }
366 
367 // Called by the engine to check for the presence of an object in the carousel.
368 bool MHIContext::CheckCarouselObject(const QString& objectPath)
369 {
370  if (objectPath.startsWith("http:") || objectPath.startsWith("https:"))
371  {
372  QByteArray cert;
373 
374  // Verify access to server
375  if (!CheckAccess(objectPath, cert))
376  return false;
377 
378  return m_ic.CheckFile(objectPath, cert);
379  }
380 
381  QStringList path = objectPath.split(QChar('/'), Qt::SkipEmptyParts);
382  QByteArray result; // Unused
383  QMutexLocker locker(&m_dsmccLock);
384  int res = m_dsmcc->GetDSMCCObject(path, result);
385  return res == 0; // It's available now.
386 }
387 
388 bool MHIContext::GetDSMCCObject(const QString &objectPath, QByteArray &result)
389 {
390  QStringList path = objectPath.split(QChar('/'), Qt::SkipEmptyParts);
391  QMutexLocker locker(&m_dsmccLock);
392  int res = m_dsmcc->GetDSMCCObject(path, result);
393  return (res == 0);
394 }
395 
396 bool MHIContext::CheckAccess(const QString &objectPath, QByteArray &cert)
397 {
398  cert.clear();
399 
400  // Verify access to server
401  QByteArray servers;
402  if (!GetDSMCCObject("/auth.servers", servers))
403  {
404  LOG(VB_MHEG, LOG_INFO, QString(
405  "[mhi] CheckAccess(%1) No auth.servers").arg(objectPath) );
406  return false;
407  }
408 
409  QByteArray host = QUrl(objectPath).host().toLocal8Bit();
410  if (!servers.contains(host))
411  {
412  LOG(VB_MHEG, LOG_INFO, QString("[mhi] CheckAccess(%1) Host not known")
413  .arg(objectPath) );
414  LOG(VB_MHEG, LOG_DEBUG, QString("[mhi] Permitted servers: %1")
415  .arg(servers.constData()) );
416 
417  // BUG: https://securegate.iplayer.bbc.co.uk is not listed
418  if (!objectPath.startsWith("https:"))
419  return false;
420  }
421 
422  if (!objectPath.startsWith("https:"))
423  return true;
424 
425  // Use TLS cert from carousel file auth.tls.<x>
426  if (!GetDSMCCObject("/auth.tls.1", cert))
427  return false;
428 
429  // The cert has a 5 byte header: 16b cert_count + 24b cert_len
430  cert = cert.mid(5);
431  return true;
432 }
433 
434 // Called by the engine to request data from the carousel.
435 // Caller must hold m_runLock
436 bool MHIContext::GetCarouselData(const QString& objectPath, QByteArray &result)
437 {
438  QByteArray cert;
439  bool const isIC = objectPath.startsWith("http:") || objectPath.startsWith("https:");
440  if (isIC)
441  {
442  // Verify access to server
443  if (!CheckAccess(objectPath, cert))
444  return false;
445  }
446 
447  // Get the path components. The string will normally begin with "//"
448  // since this is an absolute path but that will be removed by split.
449  QStringList path = objectPath.split(QChar('/'), Qt::SkipEmptyParts);
450  // Since the DSMCC carousel and the MHEG engine are currently on the
451  // same thread this is safe. Otherwise we need to make a deep copy of
452  // the result.
453 
454  bool bReported = false;
455  QElapsedTimer t; t.start();
456  while (!m_stop)
457  {
458  if (isIC)
459  {
460  switch (m_ic.GetFile(objectPath, result, cert))
461  {
463  if (bReported)
464  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Received %1").arg(objectPath));
465  return true;
467  if (bReported)
468  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Not found %1").arg(objectPath));
469  return false;
471  break;
472  }
473  }
474  else
475  {
476  QMutexLocker locker(&m_dsmccLock);
477  int res = m_dsmcc->GetDSMCCObject(path, result);
478  if (res == 0)
479  {
480  if (bReported)
481  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Received %1").arg(objectPath));
482  return true; // Found it
483  }
484  // NB don't exit if -1 (not present) is returned as the object may
485  // arrive later. Exiting can cause the inital app to not be found
486  }
487 
488  if (t.hasExpired(60000)) // TODO get this from carousel info
489  {
490  if (bReported)
491  LOG(VB_MHEG, LOG_INFO, QString("[mhi] timed out %1").arg(objectPath));
492  return false; // Not there.
493  }
494  // Otherwise we block.
495  if (!bReported)
496  {
497  bReported = true;
498  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Waiting for %1").arg(objectPath));
499  }
500  // Process DSMCC packets then block for a while or until we receive
501  // some more packets. We should eventually find out if this item is
502  // present.
504  m_engineWait.wait(&m_runLock, 300);
505  }
506  return false; // Stop has been set. Say the object isn't present.
507 }
508 
509 // Mapping from key name & UserInput register to UserInput EventData
511 {
512  using key_t = QPair< QString, int /*UserInput register*/ >;
513 
514 public:
515  MHKeyLookup();
516 
517  int Find(const QString &name, int reg) const
518  { return m_map.value(key_t(name,reg), 0); }
519 
520 private:
521  void key(const QString &name, int code, int r1,
522  int r2=0, int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int r9=0);
523 
524  QHash<key_t,int /*EventData*/ > m_map;
525 };
526 
527 void MHKeyLookup::key(const QString &name, int code, int r1,
528  int r2, int r3, int r4, int r5, int r6, int r7, int r8, int r9)
529 {
530  if (r1 > 0)
531  m_map.insert(key_t(name,r1), code);
532  if (r2 > 0)
533  m_map.insert(key_t(name,r2), code);
534  if (r3 > 0)
535  m_map.insert(key_t(name,r3), code);
536  if (r4 > 0)
537  m_map.insert(key_t(name,r4), code);
538  if (r5 > 0)
539  m_map.insert(key_t(name,r5), code);
540  if (r6 > 0)
541  m_map.insert(key_t(name,r6), code);
542  if (r7 > 0)
543  m_map.insert(key_t(name,r7), code);
544  if (r8 > 0)
545  m_map.insert(key_t(name,r8), code);
546  if (r9 > 0)
547  m_map.insert(key_t(name,r9), code);
548 }
549 
551 {
552  // Use a modification of the standard key mapping for RC's with a single
553  // stop button which is used for both Esc and TEXTEXIT (Back).
554  // This mapping doesn't pass Esc to the MHEG app in registers 3 or 5 and
555  // hence allows the user to exit playback when the red button icon is shown
556  QStringList keylist = GET_KEY("TV Playback", "TEXTEXIT").split(QChar(','));
557  bool strict = !keylist.contains("Esc", Qt::CaseInsensitive);
558 
559  // This supports the UK and NZ key profile registers.
560  // The UK uses 3, 4 and 5 and NZ 13, 14 and 15. These are
561  // similar but the NZ profile also provides an EPG key.
562  // ETSI ES 202 184 V2.2.1 (2011-03) adds group 6 for ICE.
563  // The BBC use group 7 for ICE
564  key(ACTION_UP, 1, 4,5,6,7,14,15);
565  key(ACTION_DOWN, 2, 4,5,6,7,14,15);
566  key(ACTION_LEFT, 3, 4,5,6,7,14,15);
567  key(ACTION_RIGHT, 4, 4,5,6,7,14,15);
568  key(ACTION_0, 5, 4,6,7,14);
569  key(ACTION_1, 6, 4,6,7,14);
570  key(ACTION_2, 7, 4,6,7,14);
571  key(ACTION_3, 8, 4,6,7,14);
572  key(ACTION_4, 9, 4,6,7,14);
573  key(ACTION_5, 10, 4,6,7,14);
574  key(ACTION_6, 11, 4,6,7,14);
575  key(ACTION_7, 12, 4,6,7,14);
576  key(ACTION_8, 13, 4,6,7,14);
577  key(ACTION_9, 14, 4,6,7,14);
578  key(ACTION_SELECT, 15, 4,5,6,7,14,15);
579  key(ACTION_TEXTEXIT, 16, strict ? 3 : 0,4,strict ? 5 : 0,6,7,13,14,15); // 16= Cancel
580  // 17= help
581  // 18..99 reserved by DAVIC
582  key(ACTION_MENURED, 100, 3,4,5,6,7,13,14,15);
583  key(ACTION_MENUGREEN, 101, 3,4,5,6,7,13,14,15);
584  key(ACTION_MENUYELLOW, 102, 3,4,5,6,7,13,14,15);
585  key(ACTION_MENUBLUE, 103, 3,4,5,6,7,13,14,15);
586  key(ACTION_MENUTEXT, 104, 3,4,5,6,7);
587  key(ACTION_MENUTEXT, 105, 13,14,15); // NB from original Myth code
588  // 105..119 reserved for future spec
589  key(ACTION_STOP, 120, 6,7);
590  key(ACTION_PLAY, 121, 6,7);
591  key(ACTION_PAUSE, 122, 6,7);
592  key(ACTION_JUMPFFWD, 123, 6,7); // 123= Skip Forward
593  key(ACTION_JUMPRWND, 124, 6,7); // 124= Skip Back
594 #if 0 // These conflict with left & right
595  key(ACTION_SEEKFFWD, 125, 6,7); // 125= Fast Forward
596  key(ACTION_SEEKRWND, 126, 6,7); // 126= Rewind
597 #endif
598  key(ACTION_PLAYBACK, 127, 6,7);
599  // 128..256 reserved for future spec
600  // 257..299 vendor specific
601  key(ACTION_MENUEPG, 300, 13,14,15);
602  // 301.. Vendor specific
603 }
604 
605 // Called from tv_play when a key is pressed.
606 // If it is one in the current profile we queue it for the engine
607 // and return true otherwise we return false.
608 bool MHIContext::OfferKey(const QString& key)
609 {
610  static const MHKeyLookup kKeymap;
611  int action = kKeymap.Find(key, m_keyProfile);
612  if (action == 0)
613  return false;
614 
615  LOG(VB_GENERAL, LOG_INFO, QString("[mhi] Adding MHEG key %1:%2:%3")
616  .arg(key).arg(action).arg(m_keyQueue.size()) );
617  { QMutexLocker locker(&m_keyLock);
619  m_engineWait.wakeAll();
620  return true;
621 }
622 
623 // Called from MythPlayer::VideoStart and MythPlayer::ReinitOSD
624 void MHIContext::Reinit(const QRect videoRect, const QRect dispRect, float aspect)
625 {
626  LOG(VB_MHEG, LOG_INFO,
627  QString("[mhi] Reinit video(y:%1 x:%2 w:%3 h:%4) "
628  "vis(y:%5 x:%6 w:%7 h:%8) aspect=%9")
629  .arg(videoRect.y()).arg(videoRect.x())
630  .arg(videoRect.width()).arg(videoRect.height())
631  .arg(dispRect.y()).arg(dispRect.x())
632  .arg(dispRect.width()).arg(dispRect.height()).arg(aspect));
633  m_videoDisplayRect = QRect();
634 
635  // MHEG presumes square pixels
636  enum : std::uint8_t { kNone, kHoriz, kBoth };
637  int mode = gCoreContext->GetNumSetting("MhegAspectCorrection", kNone);
638  auto const aspectd = static_cast<double>(aspect);
639  double const vz = (mode == kBoth) ? std::min(1.15, 1. / sqrt(aspectd)) : 1.;
640  double const hz = (mode > kNone) ? vz * aspectd : 1.;
641 
642  m_displayRect = QRect( int(dispRect.width() * (1 - hz) / 2),
643  int(dispRect.height() * (1 - vz) / 2),
644  int(dispRect.width() * hz), int(dispRect.height() * vz) );
645  m_videoRect = QRect( dispRect.x() + m_displayRect.x(),
646  dispRect.y() + int(dispRect.height() * (1 - hz) / 2),
647  int(dispRect.width() * hz), int(dispRect.height() * hz) );
648 }
649 
651 {
652  LOG(VB_MHEG, LOG_INFO, QString("[mhi] SetInputRegister %1").arg(num));
653  QMutexLocker locker(&m_keyLock);
654  m_keyQueue.clear();
655  m_keyProfile = num;
656 }
657 
659 {
660  // 0= Active, 1= Inactive, 2= Disabled
662 }
663 
664 // Called by the video player to redraw the image.
666  MythPainter *osdPainter)
667 {
668  if (!osdWindow || !osdPainter)
669  return;
670 
671  QMutexLocker locker(&m_displayLock);
672 
673  // In MHEG the video is just another item in the display stack
674  // but when we create the OSD we overlay everything over the video.
675  // We need to cut out anything belowthe video on the display stack
676  // to leave the video area clear.
677  auto it = m_display.begin();
678  for (; it != m_display.end(); ++it)
679  {
680  MHIImageData *data = *it;
681  if (!data->m_bUnder)
682  continue;
683 
684  QRect imageRect(data->m_x, data->m_y,
685  data->m_image.width(), data->m_image.height());
686  if (!m_videoDisplayRect.intersects(imageRect))
687  continue;
688 
689  // Replace this item with a set of cut-outs.
690  it = m_display.erase(it);
691 
692  for (const QRect& rect : QRegion(imageRect)-QRegion(m_videoDisplayRect))
693  {
694  QImage image =
695  data->m_image.copy(rect.x()-data->m_x, rect.y()-data->m_y,
696  rect.width(), rect.height());
697  auto *newData = new MHIImageData;
698  newData->m_image = image;
699  newData->m_x = rect.x();
700  newData->m_y = rect.y();
701  newData->m_bUnder = true;
702  it = m_display.insert(it, newData);
703  ++it;
704  }
705  --it;
706  delete data;
707  }
708 
709  m_updated = false;
710  osdWindow->DeleteAllChildren();
711  // Copy all the display items into the display.
712  it = m_display.begin();
713  for (int count = 0; it != m_display.end(); ++it, count++)
714  {
715  MHIImageData *data = *it;
716  MythImage* image = osdPainter->GetFormatImage();
717  if (!image)
718  continue;
719 
720  image->Assign(data->m_image);
721  auto *uiimage = new MythUIImage(osdWindow, QString("itv%1").arg(count));
722  if (uiimage)
723  {
724  uiimage->SetImage(image);
725  uiimage->SetArea(MythRect(data->m_x, data->m_y,
726  data->m_image.width(), data->m_image.height()));
727  }
728  image->DecrRef();
729  }
730  osdWindow->OptimiseDisplayedArea();
731  // N.B. bypasses OSD class hence no expiry set
732  osdWindow->SetVisible(true);
733 }
734 
735 void MHIContext::GetInitialStreams(int &audioTag, int &videoTag) const
736 {
737  audioTag = m_audioTag;
738  videoTag = m_videoTag;
739 }
740 
741 
742 // An area of the screen/image needs to be redrawn.
743 // Called from the MHEG engine.
744 // We always redraw the whole scene.
745 void MHIContext::RequireRedraw(const QRegion & /*region*/)
746 {
747  m_updated = false;
748  m_displayLock.lock();
749  ClearDisplay();
750  m_displayLock.unlock();
751  // Always redraw the whole screen
753  m_updated = true;
754 }
755 
756 inline int MHIContext::ScaleX(int n, bool roundup) const
757 {
758  return (n * m_displayRect.width() + (roundup ? kStdDisplayWidth - 1 : 0)) / kStdDisplayWidth;
759 }
760 
761 inline int MHIContext::ScaleY(int n, bool roundup) const
762 {
763  return (n * m_displayRect.height() + (roundup ? kStdDisplayHeight - 1 : 0)) / kStdDisplayHeight;
764 }
765 
766 inline QRect MHIContext::Scale(const QRect r) const
767 {
768  return { m_displayRect.topLeft() + QPoint(ScaleX(r.x()), ScaleY(r.y())),
769  QSize(ScaleX(r.width(), true), ScaleY(r.height(), true)) };
770 }
771 
772 inline int MHIContext::ScaleVideoX(int n, bool roundup) const
773 {
774  return (n * m_videoRect.width() + (roundup ? kStdDisplayWidth - 1 : 0)) / kStdDisplayWidth;
775 }
776 
777 inline int MHIContext::ScaleVideoY(int n, bool roundup) const
778 {
779  return (n * m_videoRect.height() + (roundup ? kStdDisplayHeight - 1 : 0)) / kStdDisplayHeight;
780 }
781 
782 inline QRect MHIContext::ScaleVideo(const QRect r) const
783 {
784  return { m_videoRect.topLeft() + QPoint(ScaleVideoX(r.x()), ScaleVideoY(r.y())),
785  QSize(ScaleVideoX(r.width(), true), ScaleVideoY(r.height(), true)) };
786 }
787 
788 void MHIContext::AddToDisplay(const QImage &image, const QRect displayRect, bool bUnder /*=false*/)
789 {
790  const QRect scaledRect = Scale(displayRect);
791 
792  auto *data = new MHIImageData;
793 
794  data->m_image = image.convertToFormat(QImage::Format_ARGB32).scaled(
795  scaledRect.width(), scaledRect.height(),
796  Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
797  data->m_x = scaledRect.x();
798  data->m_y = scaledRect.y();
799  data->m_bUnder = bUnder;
800 
801  QMutexLocker locker(&m_displayLock);
802  if (!bUnder)
803  m_display.push_back(data);
804  else
805  {
806  // Replace any existing items under the video with this
807  auto it = m_display.begin();
808  while (it != m_display.end())
809  {
810  MHIImageData *old = *it;
811  if (!old->m_bUnder)
812  ++it;
813  else
814  {
815  it = m_display.erase(it);
816  delete old;
817  }
818  }
819  m_display.push_front(data);
820  }
821 }
822 
823 inline int Roundup(int n, int r)
824 {
825  // NB assumes 2's complement arithmetic
826  return n + (-n & (r - 1));
827 }
828 
829 // The videoRect gives the size and position to which the video must be scaled.
830 // The displayRect gives the rectangle reserved for the video.
831 // e.g. part of the video may be clipped within the displayRect.
832 void MHIContext::DrawVideo(const QRect &videoRect, const QRect &dispRect)
833 {
834  // tell the video player to resize the video stream
835  if (m_parent->GetPlayer())
836  {
837  QRect vidRect;
838  if (videoRect != QRect(QPoint(0,0),QSize(kStdDisplayWidth,kStdDisplayHeight)))
839  {
840  vidRect = ScaleVideo(videoRect);
841  vidRect.setWidth(Roundup(vidRect.width(), 2));
842  vidRect.setHeight(Roundup(vidRect.height(), 2));
843  }
844  emit m_parent->GetPlayer()->ResizeForInteractiveTV(vidRect);
845  }
846 
847  m_videoDisplayRect = Scale(dispRect);
848 
849  // Mark all existing items in the display stack as under the video
850  QMutexLocker locker(&m_displayLock);
851  for (auto & it : m_display)
852  it->m_bUnder = true;
853 }
854 
855 // Caller must hold m_channelMutex
857 {
858  MSqlQuery query(MSqlQuery::InitCon());
859  query.prepare(
860  "SELECT networkid, serviceid, transportid, chanid "
861  "FROM channel, dtv_multiplex "
862  "WHERE channel.deleted IS NULL "
863  " AND channel.mplexid = dtv_multiplex.mplexid "
864  " AND channel.sourceid = dtv_multiplex.sourceid "
865  " AND channel.sourceid = :SOURCEID ;" );
866  query.bindValue(":SOURCEID", m_currentSource);
867  if (!query.exec())
868  {
869  MythDB::DBError("MHIContext::LoadChannelCache", query);
870  return false;
871  }
872  if (!query.isActive())
873  return false;
874  while (query.next())
875  {
876  int nid = query.value(0).toInt();
877  int sid = query.value(1).toInt();
878  int tid = query.value(2).toInt();
879  int cid = query.value(3).toInt();
880  m_channelCache.insert( Key_t(nid, sid), Val_t(tid, cid) );
881  }
882  return true;
883 }
884 
885 // Tuning. Get the index corresponding to a given channel.
886 // The format of the service is dvb://netID.[transPortID].serviceID
887 // where the IDs are in hex.
888 // or rec://svc/lcn/N where N is the "logical channel number"
889 // i.e. the Freeview channel.
890 // Returns -1 if it cannot find it.
891 int MHIContext::GetChannelIndex(const QString &str)
892 {
893  int nResult = -1;
894 
895  do
896  {
897  if (str.startsWith("dvb://"))
898  {
899  QStringList list = str.mid(6).split('.');
900  if (list.size() != 3)
901  break; // Malformed.
902  // The various fields are expressed in hexadecimal.
903  // Convert them to decimal for the DB.
904  bool ok = false;
905  int netID = list[0].toInt(&ok, 16);
906  if (!ok)
907  break;
908  int transportID = !list[1].isEmpty() ? list[1].toInt(&ok, 16) : -1;
909  if (!ok)
910  break;
911  int serviceID = list[2].toInt(&ok, 16);
912  if (!ok)
913  break;
914 
915  QMutexLocker locker(&m_channelMutex);
916  if (m_channelCache.isEmpty())
918 
919  ChannelCache_t::const_iterator it = m_channelCache.constFind(
920  Key_t(netID,serviceID) );
921  if (it == m_channelCache.constEnd())
922  break;
923  if (transportID < 0)
924  nResult = Cid(it);
925  else
926  {
927  do
928  {
929  if (Tid(it) == transportID)
930  {
931  nResult = Cid(it);
932  break;
933  }
934  }
935  while (++it != m_channelCache.constEnd());
936  }
937  }
938  else if (str.startsWith("rec://svc/lcn/"))
939  {
940  // I haven't seen this yet so this is untested.
941  bool ok = false;
942  int channelNo = str.mid(14).toInt(&ok); // Decimal integer
943  if (!ok)
944  break;
945  MSqlQuery query(MSqlQuery::InitCon());
946  query.prepare("SELECT chanid "
947  "FROM channel "
948  "WHERE deleted IS NULL AND "
949  " channum = :CHAN AND "
950  " channel.sourceid = :SOURCEID");
951  query.bindValue(":CHAN", channelNo);
952  query.bindValue(":SOURCEID", m_currentSource);
953  if (query.exec() && query.isActive() && query.next())
954  nResult = query.value(0).toInt();
955  }
956  else if (str == "rec://svc/cur")
957  {
959  }
960  else if (str == "rec://svc/def")
961  {
962  nResult = m_currentChannel;
963  }
964  else
965  {
966  LOG(VB_GENERAL, LOG_WARNING,
967  QString("[mhi] GetChannelIndex -- Unrecognized URL %1")
968  .arg(str));
969  }
970  }
971  while (false);
972 
973  LOG(VB_MHEG, LOG_INFO, QString("[mhi] GetChannelIndex %1 => %2")
974  .arg(str).arg(nResult));
975  return nResult;
976 
977 }
978 
979 // Get netId etc from the channel index. This is the inverse of GetChannelIndex.
980 bool MHIContext::GetServiceInfo(int channelId, int &netId, int &origNetId,
981  int &transportId, int &serviceId)
982 {
983  QMutexLocker locker(&m_channelMutex);
984  if (m_channelCache.isEmpty())
986 
987  for (auto it = m_channelCache.cbegin(); it != m_channelCache.cend(); ++it)
988  {
989  if (Cid(it) == channelId)
990  {
991  transportId = Tid(it);
992  netId = Nid(it);
993  origNetId = netId; // We don't have this in the database.
994  serviceId = Sid(it);
995  LOG(VB_MHEG, LOG_INFO, QString("[mhi] GetServiceInfo %1 => NID=%2 TID=%3 SID=%4")
996  .arg(channelId).arg(netId).arg(transportId).arg(serviceId));
997  return true;
998  }
999  }
1000 
1001  LOG(VB_MHEG, LOG_WARNING, QString("[mhi] GetServiceInfo %1 failed").arg(channelId));
1002  return false;
1003 }
1004 
1005 bool MHIContext::TuneTo(int channel, int tuneinfo)
1006 {
1007  if (!m_isLive)
1008  {
1009  LOG(VB_MHEG, LOG_WARNING, QString("[mhi] Can't TuneTo %1 0x%2 while not live")
1010  .arg(channel).arg(tuneinfo,0,16));
1011  return false; // Can't tune if this is a recording.
1012  }
1013 
1014  LOG(VB_GENERAL, LOG_INFO, QString("[mhi] TuneTo %1 0x%2")
1015  .arg(channel).arg(tuneinfo,0,16));
1016  m_tuneInfo.append(tuneinfo);
1017 
1018  // Post an event requesting a channel change.
1019  MythEvent me(QString("NETWORK_CONTROL CHANID %1").arg(channel));
1020  gCoreContext->dispatch(me);
1021  // Reset the NBI version here to prevent a reboot.
1022  QMutexLocker locker(&m_dsmccLock);
1024  m_nbiData.resize(0);
1025  return true;
1026 }
1027 
1028 
1029 // Begin playing the specified stream
1030 bool MHIContext::BeginStream(const QString &stream, MHStream *notify)
1031 {
1032  LOG(VB_MHEG, LOG_INFO, QString("[mhi] BeginStream %1 0x%2")
1033  .arg(stream).arg((quintptr)notify,0,16));
1034 
1035  m_audioTag = -1;
1036  m_videoTag = -1;
1037  m_notify = notify;
1038 
1039  if (stream.startsWith("http://") || stream.startsWith("https://"))
1040  {
1041  m_currentStream = -1;
1042 
1043  // The url is sometimes only http:// during stream startup
1044  if (QUrl(stream).authority().isEmpty())
1045  return false;
1046 
1047  emit m_parent->GetPlayer()->SetInteractiveStream(stream);
1048  return !stream.isEmpty();
1049  }
1050 
1051  int chan = GetChannelIndex(stream);
1052  if (chan < 0)
1053  return false;
1054  if (VERBOSE_LEVEL_CHECK(VB_MHEG, LOG_ANY))
1055  {
1056  int netId = 0;
1057  int origNetId = 0;
1058  int transportId = 0;
1059  int serviceId = 0;
1060  GetServiceInfo(chan, netId, origNetId, transportId, serviceId);
1061  }
1062 
1063  if (chan != m_currentStream)
1064  {
1065  // We have to tune to the channel where the stream is to be found.
1066  // Because the audio and video are both components of an MHEG stream
1067  // they will both be on the same channel.
1068  m_currentStream = chan;
1070  }
1071 
1072  return true;
1073 }
1074 
1076 {
1077  LOG(VB_MHEG, LOG_INFO, QString("[mhi] EndStream 0x%1")
1078  .arg((quintptr)m_notify,0,16) );
1079 
1080  m_notify = nullptr;
1081  emit m_parent->GetPlayer()->SetInteractiveStream(QString());
1082 }
1083 
1084 // Callback from MythPlayer when a stream starts or stops
1085 bool MHIContext::StreamStarted(bool bStarted)
1086 {
1087  if (!m_engine || !m_notify)
1088  return false;
1089 
1090  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Stream 0x%1 %2")
1091  .arg((quintptr)m_notify,0,16).arg(bStarted ? "started" : "stopped"));
1092 
1093  QMutexLocker locker(&m_runLock);
1094  m_engine->StreamStarted(m_notify, bStarted);
1095  if (!bStarted)
1096  m_notify = nullptr;
1097  return m_currentStream == -1; // Return true if it's an http stream
1098 }
1099 
1100 // Begin playing audio
1102 {
1103  LOG(VB_MHEG, LOG_INFO, QString("[mhi] BeginAudio %1").arg(tag));
1104 
1105  if (tag < 0)
1106  return true; // Leave it at the default.
1107 
1108  m_audioTag = tag;
1109  if (m_parent->GetPlayer())
1110  return m_parent->GetPlayer()->SetAudioByComponentTag(tag);
1111  return false;
1112  }
1113 
1114 // Stop playing audio
1116 {
1117  // Do nothing at the moment.
1118 }
1119 
1120 // Begin displaying video from the specified stream
1122 {
1123  LOG(VB_MHEG, LOG_INFO, QString("[mhi] BeginVideo %1").arg(tag));
1124 
1125  if (tag < 0)
1126  return true; // Leave it at the default.
1127 
1128  m_videoTag = tag;
1129  if (m_parent->GetPlayer())
1130  return m_parent->GetPlayer()->SetVideoByComponentTag(tag);
1131  return false;
1132 }
1133 
1134  // Stop displaying video
1136 {
1137  // Do nothing at the moment.
1138 }
1139 
1140 // Get current stream position, -1 if unknown
1141 std::chrono::milliseconds MHIContext::GetStreamPos()
1142 {
1143  return m_parent->GetPlayer() ? m_parent->GetPlayer()->GetStreamPos() : -1ms;
1144 }
1145 
1146 // Get current stream size, -1 if unknown
1147 std::chrono::milliseconds MHIContext::GetStreamMaxPos()
1148 {
1149  return m_parent->GetPlayer() ? m_parent->GetPlayer()->GetStreamMaxPos() : -1ms;
1150 }
1151 
1152 // Set current stream position
1153 std::chrono::milliseconds MHIContext::SetStreamPos(std::chrono::milliseconds pos)
1154 {
1155  if (m_parent->GetPlayer())
1157  // Note: return value is never used
1158  return 0ms;
1159 }
1160 
1161 // Play or pause a stream
1162 void MHIContext::StreamPlay(bool play)
1163 {
1164  if (m_parent->GetPlayer())
1165  emit m_parent->GetPlayer()->PlayInteractiveStream(play);
1166 }
1167 
1168 // Create a new object to draw dynamic line art.
1170  bool isBoxed, MHRgba lineColour, MHRgba fillColour)
1171 {
1172  return new MHIDLA(this, isBoxed, lineColour, fillColour);
1173 }
1174 
1175 // Create a new object to draw text.
1177 {
1178  return new MHIText(this);
1179 }
1180 
1181 // Create a new object to draw bitmaps.
1183 {
1184  return new MHIBitmap(this, tiled);
1185 }
1186 
1187 // Draw a rectangle. This is complicated if we want to get transparency right.
1188 void MHIContext::DrawRect(int xPos, int yPos, int width, int height,
1189  MHRgba colour)
1190 {
1191  if (colour.alpha() == 0 || height == 0 || width == 0)
1192  return; // Fully transparent
1193 
1194  QImage qImage(width, height, QImage::Format_ARGB32);
1195  qImage.fill(qRgba(colour.red(), colour.green(), colour.blue(), colour.alpha()));
1196 
1197  AddToDisplay(qImage, QRect(xPos, yPos, width, height));
1198 }
1199 
1200 // Draw an image at the specified position.
1201 // Generally the whole of the image is drawn but sometimes the
1202 // image may be clipped. x and y define the origin of the bitmap
1203 // and usually that will be the same as the origin of the bounding
1204 // box (clipRect).
1205 void MHIContext::DrawImage(int x, int y, const QRect clipRect,
1206  const QImage &qImage, bool bScaled, bool bUnder)
1207 {
1208  if (qImage.isNull())
1209  return;
1210 
1211  QRect imageRect(x, y, qImage.width(), qImage.height());
1212  QRect displayRect = clipRect & imageRect;
1213 
1214  if (bScaled || displayRect == imageRect) // No clipping required
1215  {
1216  AddToDisplay(qImage, displayRect, bUnder);
1217  }
1218  else if (!displayRect.isEmpty())
1219  { // We must clip the image.
1220  QImage clipped = qImage.copy(displayRect.translated(-x, -y));
1221  AddToDisplay(clipped, displayRect, bUnder);
1222  }
1223  // Otherwise draw nothing.
1224 }
1225 
1226 // Fill in the background. This is only called if there is some area of
1227 // the screen that is not covered with other visibles.
1228 void MHIContext::DrawBackground(const QRegion &reg)
1229 {
1230  if (reg.isEmpty())
1231  return;
1232 
1233  QRect bounds = reg.boundingRect();
1234  DrawRect(bounds.x(), bounds.y(), bounds.width(), bounds.height(),
1235  MHRgba(0, 0, 0, 255)/* black. */);
1236 }
1237 
1238 void MHIText::Draw(int x, int y)
1239 {
1240  m_parent->DrawImage(x, y, QRect(x, y, m_width, m_height), m_image);
1241 }
1242 
1243 void MHIText::SetSize(int width, int height)
1244 {
1245  m_width = width;
1246  m_height = height;
1247 }
1248 
1249 void MHIText::SetFont(int size, bool isBold, bool isItalic)
1250 {
1251  m_fontSize = size;
1252  m_fontItalic = isItalic;
1253  m_fontBold = isBold;
1254  // TODO: Only the size is currently used.
1255  // Bold and Italic are currently ignored.
1256 }
1257 
1258 // FT sizes are in 26.6 fixed point form
1259 const int kShift = 6;
1260 static inline FT_F26Dot6 Point2FT(int pt)
1261 {
1262  return pt << kShift;
1263 }
1264 
1265 static inline int FT2Point(FT_F26Dot6 fp)
1266 {
1267  return (fp + (1<<(kShift-1))) >> kShift;
1268 }
1269 
1270 // Return the bounding rectangle for a piece of text drawn in the
1271 // current font. If maxSize is non-negative it sets strLen to the
1272 // number of characters that will fit in the space and returns the
1273 // bounds for those characters.
1274 // N.B. The box is relative to the origin so the y co-ordinate will
1275 // be negative. It's also possible that the x co-ordinate could be
1276 // negative for slanted fonts but that doesn't currently happen.
1277 QRect MHIText::GetBounds(const QString &str, int &strLen, int maxSize)
1278 {
1279  if (!m_parent->IsFaceLoaded())
1280  return {0,0,0,0};
1281 
1282  FT_Face face = m_parent->GetFontFace();
1283  FT_Error error = FT_Set_Char_Size(face, 0, Point2FT(m_fontSize),
1285  if (error)
1286  return {0,0,0,0};
1287 
1288  int maxAscent = face->size->metrics.ascender;
1289  int maxDescent = -face->size->metrics.descender;
1290  int width = 0;
1291  FT_Bool useKerning = FT_HAS_KERNING(face);
1292  FT_UInt previous = 0;
1293 
1294  for (int n = 0; n < strLen; n++)
1295  {
1296  QChar ch = str.at(n);
1297  FT_UInt glyphIndex = FT_Get_Char_Index(face, ch.unicode());
1298 
1299  if (glyphIndex == 0)
1300  {
1301  LOG(VB_MHEG, LOG_INFO, QString("[mhi] Unknown glyph 0x%1")
1302  .arg(ch.unicode(),0,16));
1303  previous = 0;
1304  continue;
1305  }
1306 
1307  int kerning = 0;
1308 
1309  if (useKerning && previous != 0)
1310  {
1311  FT_Vector delta;
1312  FT_Get_Kerning(face, previous, glyphIndex,
1313  FT_KERNING_DEFAULT, &delta);
1314  kerning = delta.x;
1315  }
1316 
1317  error = FT_Load_Glyph(face, glyphIndex, 0); // Don't need to render.
1318 
1319  if (error)
1320  continue; // ignore errors.
1321 
1322  FT_GlyphSlot slot = face->glyph; /* a small shortcut */
1323  FT_Pos advance = slot->metrics.horiAdvance + kerning;
1324 
1325  if (maxSize >= 0)
1326  {
1327  if (FT2Point(width + advance) > maxSize)
1328  {
1329  // There isn't enough space for this character.
1330  strLen = n;
1331  break;
1332  }
1333  }
1334  // Calculate the ascent and descent of this glyph.
1335  int descent = slot->metrics.height - slot->metrics.horiBearingY;
1336 
1337  maxAscent = std::max<FT_Pos>(slot->metrics.horiBearingY, maxAscent);
1338 
1339  maxDescent = std::max(descent, maxDescent);
1340 
1341  width += advance;
1342  previous = glyphIndex;
1343  }
1344 
1345  return {0, -FT2Point(maxAscent), FT2Point(width), FT2Point(maxAscent + maxDescent)};
1346 }
1347 
1348 // Reset the image and fill it with transparent ink.
1349 // The UK MHEG profile says that we should consider the background
1350 // as paper and the text as ink. We have to consider these as two
1351 // different layers. The background is drawn separately as a rectangle.
1352 void MHIText::Clear(void)
1353 {
1354  m_image = QImage(m_width, m_height, QImage::Format_ARGB32);
1355  // QImage::fill doesn't set the alpha buffer.
1356  for (int i = 0; i < m_height; i++)
1357  {
1358  for (int j = 0; j < m_width; j++)
1359  {
1360  m_image.setPixel(j, i, qRgba(0, 0, 0, 0));
1361  }
1362  }
1363 }
1364 
1365 // Draw a line of text in the given position within the image.
1366 // It would be nice to be able to use TTFFont for this but it doesn't provide
1367 // what we want.
1368 void MHIText::AddText(int x, int y, const QString &str, MHRgba colour)
1369 {
1370  if (!m_parent->IsFaceLoaded()) return;
1371  FT_Face face = m_parent->GetFontFace();
1372 
1373  FT_Set_Char_Size(face, 0, Point2FT(m_fontSize),
1375 
1376  // X positions are computed to 64ths and rounded.
1377  // Y positions are in pixels
1378  int posX = Point2FT(x);
1379  int pixelY = y;
1380  FT_Bool useKerning = FT_HAS_KERNING(face);
1381  FT_UInt previous = 0;
1382 
1383  int len = str.length();
1384  for (int n = 0; n < len; n++)
1385  {
1386  // Load the glyph.
1387  QChar ch = str[n];
1388  FT_UInt glyphIndex = FT_Get_Char_Index(face, ch.unicode());
1389  if (glyphIndex == 0)
1390  {
1391  previous = 0;
1392  continue;
1393  }
1394 
1395  if (useKerning && previous != 0)
1396  {
1397  FT_Vector delta;
1398  FT_Get_Kerning(face, previous, glyphIndex,
1399  FT_KERNING_DEFAULT, &delta);
1400  posX += delta.x;
1401  }
1402  FT_Error error = FT_Load_Glyph(face, glyphIndex, FT_LOAD_RENDER);
1403 
1404  if (error)
1405  continue; // ignore errors
1406 
1407  FT_GlyphSlot slot = face->glyph;
1408  if (slot->format != FT_GLYPH_FORMAT_BITMAP)
1409  continue; // Problem
1410 
1411  if ((enum FT_Pixel_Mode_)slot->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
1412  continue;
1413 
1414  unsigned char *source = slot->bitmap.buffer;
1415  // Get the origin for the bitmap
1416  int baseX = FT2Point(posX) + slot->bitmap_left;
1417  int baseY = pixelY - slot->bitmap_top;
1418  // Copy the bitmap into the image.
1419  for (unsigned int i = 0; i < slot->bitmap.rows; i++)
1420  {
1421  for (unsigned int j = 0; j < slot->bitmap.width; j++)
1422  {
1423  int greyLevel = source[j];
1424  // Set the pixel to the specified colour but scale its
1425  // brightness according to the grey scale of the pixel.
1426  int red = colour.red();
1427  int green = colour.green();
1428  int blue = colour.blue();
1429  int alpha = colour.alpha() *
1430  greyLevel / slot->bitmap.num_grays;
1431  int xBit = j + baseX;
1432  int yBit = i + baseY;
1433 
1434  // The bits ought to be inside the bitmap but
1435  // I guess there's the possibility
1436  // that rounding might put it outside.
1437  if (xBit >= 0 && xBit < m_width &&
1438  yBit >= 0 && yBit < m_height)
1439  {
1440  m_image.setPixel(xBit, yBit,
1441  qRgba(red, green, blue, alpha));
1442  }
1443  }
1444  source += slot->bitmap.pitch;
1445  }
1446  posX += slot->advance.x;
1447  previous = glyphIndex;
1448  }
1449 }
1450 
1451 // Internal function to fill a rectangle with a colour
1452 void MHIDLA::DrawRect(int x, int y, int width, int height, MHRgba colour)
1453 {
1454  QRgb qColour = qRgba(colour.red(), colour.green(),
1455  colour.blue(), colour.alpha());
1456 
1457  // Constrain the drawing within the image.
1458  if (x < 0)
1459  {
1460  width += x;
1461  x = 0;
1462  }
1463 
1464  if (y < 0)
1465  {
1466  height += y;
1467  y = 0;
1468  }
1469 
1470  if (width <= 0 || height <= 0)
1471  return;
1472 
1473  int imageWidth = m_image.width();
1474  int imageHeight = m_image.height();
1475  if (x+width > imageWidth)
1476  width = imageWidth - x;
1477 
1478  if (y+height > imageHeight)
1479  height = imageHeight - y;
1480 
1481  if (width <= 0 || height <= 0)
1482  return;
1483 
1484  for (int i = 0; i < height; i++)
1485  {
1486  for (int j = 0; j < width; j++)
1487  {
1488  m_image.setPixel(x+j, y+i, qColour);
1489  }
1490  }
1491 }
1492 
1493 // Reset the drawing.
1495 {
1496  if (m_width == 0 || m_height == 0)
1497  {
1498  m_image = QImage();
1499  return;
1500  }
1501  m_image = QImage(m_width, m_height, QImage::Format_ARGB32);
1502  // Fill the image with "transparent colour".
1503  DrawRect(0, 0, m_width, m_height, MHRgba(0, 0, 0, 0));
1504 }
1505 
1506 void MHIDLA::Draw(int x, int y)
1507 {
1508  QRect bounds(x, y, m_width, m_height);
1509  if (m_boxed && m_lineWidth != 0)
1510  {
1511  // Draw the lines round the outside.
1512  // These don't form part of the drawing.
1513  m_parent->DrawRect(x, y, m_width,
1515 
1518 
1519  m_parent->DrawRect(x, y + m_lineWidth,
1520  m_lineWidth, m_height - (m_lineWidth * 2),
1521  m_boxLineColour);
1522 
1524  m_lineWidth, m_height - (m_lineWidth * 2),
1525  m_boxLineColour);
1526 
1527  // Deflate the box to within the border.
1528  bounds = QRect(bounds.x() + m_lineWidth,
1529  bounds.y() + m_lineWidth,
1530  bounds.width() - (2*m_lineWidth),
1531  bounds.height() - (2*m_lineWidth));
1532  }
1533 
1534  // Draw the background.
1536  y + m_lineWidth,
1537  m_width - (m_lineWidth * 2),
1538  m_height - (m_lineWidth * 2),
1539  m_boxFillColour);
1540 
1541  // Now the drawing.
1542  m_parent->DrawImage(x, y, bounds, m_image);
1543 }
1544 
1545 // The UK MHEG profile defines exactly how transparency is supposed to work.
1546 // The drawings are made using possibly transparent ink with any crossings
1547 // just set to that ink and then the whole drawing is alpha-merged with the
1548 // underlying graphics.
1549 // DynamicLineArt no longer seems to be used in transmissions in the UK
1550 // although it appears that DrawPoly is used in New Zealand. These are
1551 // very basic implementations of the functions.
1552 
1553 // Lines
1554 void MHIDLA::DrawLine(int x1, int y1, int x2, int y2)
1555 {
1556  // Get the arguments so that the lower x comes first and the
1557  // absolute gradient is less than one.
1558  if (abs(y2-y1) > abs(x2-x1))
1559  {
1560  if (y2 > y1)
1561  DrawLineSub(y1, x1, y2, x2, true);
1562  else
1563  DrawLineSub(y2, x2, y1, x1, true);
1564  }
1565  else
1566  {
1567  if (x2 > x1)
1568  DrawLineSub(x1, y1, x2, y2, false);
1569  else
1570  DrawLineSub(x2, y2, x1, y1, false);
1571  }
1572 }
1573 
1574 // Based on the Bresenham line drawing algorithm but extended to draw
1575 // thick lines.
1576 void MHIDLA::DrawLineSub(int x1, int y1, int x2, int y2, bool swapped)
1577 {
1578  QRgb colour = qRgba(m_lineColour.red(), m_lineColour.green(),
1580  int dx = x2-x1;
1581  int dy = abs(y2-y1);
1582  int yStep = y2 >= y1 ? 1 : -1;
1583  // Adjust the starting positions to take account of the
1584  // line width.
1585  int error2 = dx/2;
1586  for (int k = 0; k < m_lineWidth/2; k++)
1587  {
1588  y1--;
1589  y2--;
1590  error2 += dy;
1591  if (error2*2 > dx)
1592  {
1593  error2 -= dx;
1594  x1 += yStep;
1595  x2 += yStep;
1596  }
1597  }
1598  // Main loop
1599  int y = y1;
1600  int error = dx/2;
1601  for (int x = x1; x <= x2; x++) // Include both endpoints
1602  {
1603  error2 = dx/2;
1604  int j = 0;
1605  // Inner loop also uses the Bresenham algorithm to draw lines
1606  // perpendicular to the principal direction.
1607  for (int i = 0; i < m_lineWidth; i++)
1608  {
1609  if (swapped)
1610  {
1611  if (x+j >= 0 && y+i >= 0 && y+i < m_width && x+j < m_height)
1612  m_image.setPixel(y+i, x+j, colour);
1613  }
1614  else
1615  {
1616  if (x+j >= 0 && y+i >= 0 && x+j < m_width && y+i < m_height)
1617  m_image.setPixel(x+j, y+i, colour);
1618  }
1619  error2 += dy;
1620  if (error2*2 > dx)
1621  {
1622  error2 -= dx;
1623  j -= yStep;
1624  if (i < m_lineWidth-1)
1625  {
1626  // Add another pixel in this case.
1627  if (swapped)
1628  {
1629  if (x+j >= 0 && y+i >= 0 && y+i < m_width && x+j < m_height)
1630  m_image.setPixel(y+i, x+j, colour);
1631  }
1632  else
1633  {
1634  if (x+j >= 0 && y+i >= 0 && x+j < m_width && y+i < m_height)
1635  m_image.setPixel(x+j, y+i, colour);
1636  }
1637  }
1638  }
1639  }
1640  error += dy;
1641  if (error*2 > dx)
1642  {
1643  error -= dx;
1644  y += yStep;
1645  }
1646  }
1647 }
1648 
1649 // Rectangles
1650 void MHIDLA::DrawBorderedRectangle(int x, int y, int width, int height)
1651 {
1652  if (m_lineWidth != 0)
1653  {
1654  // Draw the lines round the rectangle.
1655  DrawRect(x, y, width, m_lineWidth,
1656  m_lineColour);
1657 
1658  DrawRect(x, y + height - m_lineWidth,
1659  width, m_lineWidth,
1660  m_lineColour);
1661 
1662  DrawRect(x, y + m_lineWidth,
1663  m_lineWidth, height - (m_lineWidth * 2),
1664  m_lineColour);
1665 
1666  DrawRect(x + width - m_lineWidth, y + m_lineWidth,
1667  m_lineWidth, height - (m_lineWidth * 2),
1668  m_lineColour);
1669 
1670  // Fill the rectangle.
1671  DrawRect(x + m_lineWidth, y + m_lineWidth,
1672  width - (m_lineWidth * 2), height - (m_lineWidth * 2),
1673  m_fillColour);
1674  }
1675  else
1676  {
1677  DrawRect(x, y, width, height, m_fillColour);
1678  }
1679 }
1680 
1681 // Ovals (ellipses)
1682 void MHIDLA::DrawOval(int /*x*/, int /*y*/, int /*width*/, int /*height*/)
1683 {
1684  // Not implemented. Not actually used in practice.
1685 }
1686 
1687 // Arcs and sectors
1688 void MHIDLA::DrawArcSector(int /*x*/, int /*y*/, int /*width*/, int /*height*/,
1689  int /*start*/, int /*arc*/, bool /*isSector*/)
1690 {
1691  // Not implemented. Not actually used in practice.
1692 }
1693 
1694 // Polygons. This is used directly and also to draw other figures.
1695 // The UK profile says that MHEG should not contain concave or
1696 // self-crossing polygons but we can get the former at least as
1697 // a result of rounding when drawing ellipses.
1698 struct lineSeg { int m_yBottom, m_yTop, m_xBottom; float m_slope; };
1699 
1700 void MHIDLA::DrawPoly(bool isFilled, const MHPointVec& xArray, const MHPointVec& yArray)
1701 {
1702  int nPoints = xArray.size();
1703  if (nPoints < 2)
1704  return;
1705 
1706  if (isFilled)
1707  {
1708  QVector <lineSeg> lineArray(nPoints);
1709  int nLines = 0;
1710  // Initialise the line segment array. Include all lines
1711  // apart from horizontal. Close the polygon by starting
1712  // with the last point in the array.
1713  int lastX = xArray[nPoints-1]; // Last point
1714  int lastY = yArray[nPoints-1];
1715  int yMin = lastY;
1716  int yMax = lastY;
1717  for (int k = 0; k < nPoints; k++)
1718  {
1719  int thisX = xArray[k];
1720  int thisY = yArray[k];
1721  if (lastY != thisY)
1722  {
1723  if (lastY > thisY)
1724  {
1725  lineArray[nLines].m_yBottom = thisY;
1726  lineArray[nLines].m_yTop = lastY;
1727  lineArray[nLines].m_xBottom = thisX;
1728  }
1729  else
1730  {
1731  lineArray[nLines].m_yBottom = lastY;
1732  lineArray[nLines].m_yTop = thisY;
1733  lineArray[nLines].m_xBottom = lastX;
1734  }
1735  lineArray[nLines++].m_slope =
1736  (float)(thisX-lastX) / (float)(thisY-lastY);
1737  }
1738  yMin = std::min(thisY, yMin);
1739  yMax = std::max(thisY, yMax);
1740  lastX = thisX;
1741  lastY = thisY;
1742  }
1743 
1744  // Find the intersections of each line in the line segment array
1745  // with the scan line. Because UK MHEG says that figures should be
1746  // convex we only need to consider two intersections.
1747  QRgb fillColour = qRgba(m_fillColour.red(), m_fillColour.green(),
1749  for (int y = yMin; y < yMax; y++)
1750  {
1751  int crossings = 0;
1752  int xMin = 0;
1753  int xMax = 0;
1754  for (int l = 0; l < nLines; l++)
1755  {
1756  if (y >= lineArray[l].m_yBottom && y < lineArray[l].m_yTop)
1757  {
1758  int x = (int)round((float)(y - lineArray[l].m_yBottom) *
1759  lineArray[l].m_slope) + lineArray[l].m_xBottom;
1760  if (crossings == 0 || x < xMin)
1761  xMin = x;
1762  if (crossings == 0 || x > xMax)
1763  xMax = x;
1764  crossings++;
1765  }
1766  }
1767  if (crossings == 2)
1768  {
1769  for (int x = xMin; x <= xMax; x++)
1770  m_image.setPixel(x, y, fillColour);
1771  }
1772  }
1773 
1774  // Draw the boundary
1775  int lastXpoint = xArray[nPoints-1]; // Last point
1776  int lastYpoint = yArray[nPoints-1];
1777  for (int i = 0; i < nPoints; i++)
1778  {
1779  DrawLine(xArray[i], yArray[i], lastXpoint, lastYpoint);
1780  lastXpoint = xArray[i];
1781  lastYpoint = yArray[i];
1782  }
1783  }
1784  else // PolyLine - draw lines between the points but don't close it.
1785  {
1786  for (int i = 1; i < nPoints; i++)
1787  {
1788  DrawLine(xArray[i], yArray[i], xArray[i-1], yArray[i-1]);
1789  }
1790  }
1791 }
1792 
1793 MHIBitmap::MHIBitmap(MHIContext *parent, bool tiled)
1794  : m_parent(parent), m_tiled(tiled),
1795  m_copyCtx(new MythAVCopy())
1796 {
1797 }
1798 
1800 {
1801  delete m_copyCtx;
1802 }
1803 
1804 void MHIBitmap::Draw(int x, int y, QRect rect, bool tiled, bool bUnder)
1805 {
1806  if (tiled)
1807  {
1808  if (m_image.width() == 0 || m_image.height() == 0)
1809  return;
1810  // Construct an image the size of the bounding box and tile the
1811  // bitmap over this.
1812  QImage tiledImage = QImage(rect.width(), rect.height(),
1813  QImage::Format_ARGB32);
1814 
1815  for (int i = 0; i < rect.width(); i++)
1816  {
1817  for (int j = 0; j < rect.height(); j++)
1818  {
1819  tiledImage.setPixel(i, j, m_image.pixel(i % m_image.width(), j % m_image.height()));
1820  }
1821  }
1822  m_parent->DrawImage(rect.x(), rect.y(), rect, tiledImage, true, bUnder);
1823  }
1824  else
1825  {
1826  // NB THe BBC expects bitmaps to be scaled, not clipped
1827  m_parent->DrawImage(x, y, rect, m_image, true, bUnder);
1828  }
1829 }
1830 
1831 // Create a bitmap from PNG.
1832 void MHIBitmap::CreateFromPNG(const unsigned char *data, int length)
1833 {
1834  m_image = QImage();
1835 
1836  if (!m_image.loadFromData(data, length, "PNG"))
1837  {
1838  m_image = QImage();
1839  return;
1840  }
1841 
1842  // Assume that if it has an alpha buffer then it's partly transparent.
1843  m_opaque = ! m_image.hasAlphaChannel();
1844 }
1845 
1846 // Create a bitmap from JPEG.
1847 //virtual
1848 void MHIBitmap::CreateFromJPEG(const unsigned char *data, int length)
1849 {
1850  m_image = QImage();
1851 
1852  if (!m_image.loadFromData(data, length, "JPG"))
1853  {
1854  m_image = QImage();
1855  return;
1856  }
1857 
1858  // Assume that if it has an alpha buffer then it's partly transparent.
1859  m_opaque = ! m_image.hasAlphaChannel();
1860 }
1861 
1862 // Convert an MPEG I-frame into a bitmap. This is used as the way of
1863 // sending still pictures. We convert the image to a QImage even
1864 // though that actually means converting it from YUV and eventually
1865 // converting it back again but we do this very infrequently so the
1866 // cost is outweighed by the simplification.
1867 void MHIBitmap::CreateFromMPEG(const unsigned char *data, int length)
1868 {
1869  AVCodecContext *c = nullptr;
1870  MythAVFrame picture;
1871  AVPacket pkt;
1872  uint8_t *buff = nullptr;
1873  bool gotPicture = false;
1874  m_image = QImage();
1875 
1876  // Find the mpeg2 video decoder.
1877  const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MPEG2VIDEO);
1878  if (!codec)
1879  return;
1880  if (!picture)
1881  return;
1882 
1883  c = avcodec_alloc_context3(nullptr);
1884 
1885  if (avcodec_open2(c, codec, nullptr) < 0)
1886  goto Close;
1887 
1888  // Copy the data into AVPacket
1889  if (av_new_packet(&pkt, length) < 0)
1890  goto Close;
1891 
1892  memcpy(pkt.data, data, length);
1893  buff = pkt.data;
1894 
1895  // Get a picture from the packet. Allow 9 loops for
1896  // packet to be decoded. It should take only 2-3 loops
1897  for (int limit=0; limit<10 && !gotPicture; limit++)
1898  {
1899  int len = avcodec_receive_frame(c, picture);
1900  if (len == 0)
1901  gotPicture = true;
1902  if (len == AVERROR(EAGAIN))
1903  len = 0;
1904  if (len == 0)
1905  len = avcodec_send_packet(c, &pkt);
1906  if (len == AVERROR(EAGAIN) || len == AVERROR_EOF)
1907  len = 0;
1908  if (len < 0) // Error
1909  {
1910  std::string error;
1911  LOG(VB_GENERAL, LOG_ERR,
1912  QString("[mhi] video decode error: %1 (%2)")
1913  .arg(av_make_error_stdstring(error, len))
1914  .arg(gotPicture));
1915  goto Close;
1916  }
1917  else
1918  {
1919  pkt.data = nullptr;
1920  pkt.size = 0;
1921  }
1922  }
1923 
1924  if (gotPicture)
1925  {
1926  int nContentWidth = c->width;
1927  int nContentHeight = c->height;
1928  m_image = QImage(nContentWidth, nContentHeight, QImage::Format_ARGB32);
1929  m_opaque = true; // MPEG images are always opaque.
1930 
1931  AVFrame retbuf;
1932  memset(&retbuf, 0, sizeof(AVFrame));
1933 
1934  int bufflen = nContentWidth * nContentHeight * 3;
1935  auto *outputbuf = (unsigned char*)av_malloc(bufflen);
1936 
1937  av_image_fill_arrays(retbuf.data, retbuf.linesize,
1938  outputbuf, AV_PIX_FMT_RGB24,
1939  nContentWidth, nContentHeight,IMAGE_ALIGN);
1940 
1941  AVFrame *tmp = picture;
1942  m_copyCtx->Copy(&retbuf, AV_PIX_FMT_RGB24, tmp, c->pix_fmt,
1943  nContentWidth, nContentHeight);
1944 
1945  uint8_t * buf = outputbuf;
1946 
1947  // Copy the data a pixel at a time.
1948  // This should handle endianness correctly.
1949  for (int i = 0; i < nContentHeight; i++)
1950  {
1951  for (int j = 0; j < nContentWidth; j++)
1952  {
1953  int red = *buf++;
1954  int green = *buf++;
1955  int blue = *buf++;
1956  m_image.setPixel(j, i, qRgb(red, green, blue));
1957  }
1958  }
1959  av_freep(reinterpret_cast<void*>(&outputbuf));
1960  }
1961 
1962 Close:
1963  pkt.data = buff;
1964  av_packet_unref(&pkt);
1965  avcodec_free_context(&c);
1966 }
1967 
1968 // Scale the bitmap. Only used for image derived from MPEG I-frames.
1969 void MHIBitmap::ScaleImage(int newWidth, int newHeight)
1970 {
1971  if (m_image.isNull())
1972  return;
1973 
1974  if (newWidth == m_image.width() && newHeight == m_image.height())
1975  return;
1976 
1977  if (newWidth <= 0 || newHeight <= 0)
1978  { // This would be a bit silly but handle it anyway.
1979  m_image = QImage();
1980  return;
1981  }
1982 
1983  m_image = m_image.scaled(newWidth, newHeight,
1984  Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
1985 }
ACTION_PLAY
#define ACTION_PLAY
Definition: tv_actions.h:30
MHIContext::m_isLive
bool m_isLive
Definition: mhi.h:212
MHIContext::CreateText
MHTextDisplay * CreateText(void) override
Definition: mhi.cpp:1176
MythPlayerCaptionsUI::PlayInteractiveStream
void PlayInteractiveStream(bool Play)
MHIText::Draw
void Draw(int x, int y) override
Definition: mhi.cpp:1238
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:215
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:127
mythrect.h
mythevent.h
MHIContext::m_updated
bool m_updated
Definition: mhi.h:201
MHIContext::GetFontFace
FT_Face GetFontFace(void)
Definition: mhi.h:163
MHIImageData::m_y
int m_y
Definition: mhi.cpp:74
MHIContext::IsFaceLoaded
bool IsFaceLoaded(void) const
Definition: mhi.h:164
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:283
MHIContext::m_notify
MHStream * m_notify
Definition: mhi.h:189
ACTION_DOWN
static constexpr const char * ACTION_DOWN
Definition: mythuiactions.h:17
MHIContext::m_ic
MHInteractionChannel m_ic
Definition: mhi.h:188
MHIContext::Restart
void Restart(int chanid, int sourceid, bool isLive)
Restart the MHEG engine.
Definition: mhi.cpp:174
MHIDLA::DrawOval
void DrawOval(int x, int y, int width, int height) override
Definition: mhi.cpp:1682
NBI_VERSION_UNSET
static constexpr uint16_t NBI_VERSION_UNSET
Definition: mhi.h:45
MHIContext::m_currentStream
int m_currentStream
Definition: mhi.h:211
MHIContext::m_lastNbiVersion
uint m_lastNbiVersion
Definition: mhi.h:219
ACTION_JUMPRWND
#define ACTION_JUMPRWND
Definition: tv_actions.h:45
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MHIContext::EndStream
void EndStream() override
Definition: mhi.cpp:1075
MHIContext::BeginVideo
bool BeginVideo(int tag) override
Begin displaying video.
Definition: mhi.cpp:1121
MHIContext::m_display
std::list< MHIImageData * > m_display
Definition: mhi.h:203
MHIContext::GetStreamMaxPos
std::chrono::milliseconds GetStreamMaxPos() override
Definition: mhi.cpp:1147
MHIText::AddText
void AddText(int x, int y, const QString &str, MHRgba colour) override
Definition: mhi.cpp:1368
error
static void error(const char *str,...)
Definition: vbi.cpp:37
MHIContext::run
void run(void) override
Definition: mhi.cpp:241
MHInteractionChannel::status
static EStatus status()
Definition: mhegic.cpp:39
ACTION_PLAYBACK
#define ACTION_PLAYBACK
Definition: tv_actions.h:7
mythplayerui.h
MHIContext::ScaleVideoY
int ScaleVideoY(int n, bool roundup=false) const
Definition: mhi.cpp:777
MHIContext::MHIContext
MHIContext(InteractiveTV *parent)
Definition: mhi.cpp:78
MHIContext::m_dsmcc
Dsmcc * m_dsmcc
Definition: mhi.h:184
mythdb.h
MHKeyLookup::MHKeyLookup
MHKeyLookup()
Definition: mhi.cpp:550
MHIContext::m_displayRect
QRect m_displayRect
Definition: mhi.h:223
MHStream
Definition: Stream.h:32
MHIDLA::m_height
int m_height
Height of the drawing.
Definition: mhi.h:357
ACTION_TEXTEXIT
#define ACTION_TEXTEXIT
Definition: tv_actions.h:81
MHIContext::m_tuneInfo
QList< int > m_tuneInfo
Definition: mhi.h:217
MHIText::Clear
void Clear(void) override
Definition: mhi.cpp:1352
MHIDLA::DrawRect
void DrawRect(int x, int y, int width, int height, MHRgba colour)
Definition: mhi.cpp:1452
MHIDLA::m_lineWidth
int m_lineWidth
Current line width.
Definition: mhi.h:363
MHDLADisplay
Definition: freemheg.h:174
MHIContext::GetChannelIndex
int GetChannelIndex(const QString &str) override
Definition: mhi.cpp:891
MHIContext::CheckCarouselObject
bool CheckCarouselObject(const QString &objectPath) override
Definition: mhi.cpp:368
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:300
MHIContext::Nid
static int Nid(ChannelCache_t::const_iterator it)
Definition: mhi.h:233
x2
static int x2
Definition: mythsocket.cpp:51
MHIDLA::DrawArcSector
void DrawArcSector(int x, int y, int width, int height, int start, int arc, bool isSector) override
Definition: mhi.cpp:1688
MHInteractionChannel::GetFile
EResult GetFile(const QString &csPath, QByteArray &data, const QByteArray &cert=QByteArray())
Definition: mhegic.cpp:98
MHIContext::m_keyProfile
int m_keyProfile
Definition: mhi.h:193
MHIContext::SetStreamPos
std::chrono::milliseconds SetStreamPos(std::chrono::milliseconds pos) override
Definition: mhi.cpp:1153
kTuneKeepChnl
const unsigned kTuneKeepChnl
Definition: mhi.cpp:63
kTuneQuietly
const unsigned kTuneQuietly
Definition: mhi.cpp:56
MHIBitmap::CreateFromPNG
void CreateFromPNG(const unsigned char *data, int length) override
Create bitmap from PNG.
Definition: mhi.cpp:1832
MHIContext::Reinit
void Reinit(QRect videoRect, QRect dispRect, float aspect)
The display area has changed.
Definition: mhi.cpp:624
MythPlayerCaptionsUI::SetInteractiveStream
void SetInteractiveStream(const QString &Stream)
MHRgba::alpha
int alpha() const
Definition: freemheg.h:91
MythPainter::GetFormatImage
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
Definition: mythpainter.cpp:525
MHIContext::m_engineThread
MThread * m_engineThread
Definition: mhi.h:208
MHIContext::kStdDisplayHeight
static const int kStdDisplayHeight
Definition: mhi.h:169
MythAVFrame
MythAVFrame little utility class that act as a safe way to allocate an AVFrame which can then be allo...
Definition: mythavframe.h:26
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MHIContext::Scale
QRect Scale(QRect r) const
Definition: mhi.cpp:766
MHIBitmap::m_image
QImage m_image
Definition: mhi.h:307
ACTION_0
static constexpr const char * ACTION_0
Definition: mythuiactions.h:4
VERBOSE_LEVEL_CHECK
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
Definition: mythlogging.h:29
MHKeyLookup::key
void key(const QString &name, int code, int r1, int r2=0, int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0, int r9=0)
Definition: mhi.cpp:527
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:204
DSMCCPacket::m_length
int m_length
Definition: mhi.h:387
mythdbcon.h
ACTION_LEFT
static constexpr const char * ACTION_LEFT
Definition: mythuiactions.h:18
GetFontsDir
QString GetFontsDir(void)
Definition: mythdirs.cpp:341
MHEG::StreamStarted
virtual void StreamStarted(MHStream *, bool bStarted=true)=0
ft_loaded
static bool ft_loaded
Definition: mhi.cpp:47
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:618
MHIContext::GetDSMCCObject
bool GetDSMCCObject(const QString &objectPath, QByteArray &result)
Definition: mhi.cpp:388
MythPlayerCaptionsUI::GetStreamPos
std::chrono::milliseconds GetStreamPos()
Definition: mythplayercaptionsui.cpp:637
MHIContext::NetworkBootRequested
void NetworkBootRequested(void)
Definition: mhi.cpp:340
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
ACTION_MENUYELLOW
#define ACTION_MENUYELLOW
Definition: tv_actions.h:79
MHIContext::m_face
FT_Face m_face
Definition: mhi.h:205
MHIContext::QueueDSMCCPacket
void QueueDSMCCPacket(unsigned char *data, int length, int componentTag, unsigned carouselId, int dataBroadcastId)
Definition: mhi.cpp:295
MHIContext::CheckAccess
bool CheckAccess(const QString &objectPath, QByteArray &cert)
Definition: mhi.cpp:396
MHIText::m_image
QImage m_image
Definition: mhi.h:256
mythavframe.h
mythdirs.h
MHIBitmap::m_parent
MHIContext * m_parent
Definition: mhi.h:305
MHIContext::m_engineWait
QWaitCondition m_engineWait
Definition: mhi.h:198
MHIContext::m_engine
MHEG * m_engine
Definition: mhi.h:195
ACTION_SELECT
static constexpr const char * ACTION_SELECT
Definition: mythuiactions.h:15
MythRect
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
ACTION_9
static constexpr const char * ACTION_9
Definition: mythuiactions.h:13
MHInteractionChannel::kError
@ kError
Definition: mhegic.h:35
MHIContext::BeginStream
bool BeginStream(const QString &str, MHStream *notify) override
Begin playing the specified stream.
Definition: mhi.cpp:1030
MHIContext::m_currentChannel
int m_currentChannel
Definition: mhi.h:210
MHIContext::GetServiceInfo
bool GetServiceInfo(int channelId, int &netId, int &origNetId, int &transportId, int &serviceId) override
Get netId etc from the channel index.
Definition: mhi.cpp:980
MHIContext::ClearQueue
void ClearQueue(void)
Definition: mhi.cpp:149
mythuiimage.h
MythUIType::DeleteAllChildren
void DeleteAllChildren(void)
Delete all child widgets.
Definition: mythuitype.cpp:222
MHIDLA::m_boxFillColour
MHRgba m_boxFillColour
Fill colour for the background.
Definition: mhi.h:360
MHIContext::OfferKey
bool OfferKey(const QString &key)
Definition: mhi.cpp:608
MHIContext::BeginAudio
bool BeginAudio(int tag) override
Begin playing audio.
Definition: mhi.cpp:1101
MHKeyLookup
Definition: mhi.cpp:510
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
MHEG::SetBooting
virtual void SetBooting()=0
lineSeg::m_xBottom
int m_xBottom
Definition: mhi.cpp:1698
MHIImageData::m_image
QImage m_image
Definition: mhi.cpp:72
MHIContext::m_videoTag
int m_videoTag
Definition: mhi.h:216
MHIContext::DrawRect
void DrawRect(int xPos, int yPos, int width, int height, MHRgba colour) override
Additional drawing functions.
Definition: mhi.cpp:1188
MHIContext::Sid
static int Sid(ChannelCache_t::const_iterator it)
Definition: mhi.h:234
MHIContext::ScaleY
int ScaleY(int n, bool roundup=false) const
Definition: mhi.cpp:761
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
MHIBitmap::m_opaque
bool m_opaque
Definition: mhi.h:308
MHIImageData::m_x
int m_x
Definition: mhi.cpp:73
MHIImageData::m_bUnder
bool m_bUnder
Definition: mhi.cpp:75
MHIText::m_fontSize
int m_fontSize
Definition: mhi.h:257
MHIContext::CreateBitmap
MHBitmapDisplay * CreateBitmap(bool tiled) override
Definition: mhi.cpp:1182
MHIContext::m_keyQueue
MythDeque< int > m_keyQueue
Definition: mhi.h:192
mythlogging.h
ACTION_MENURED
#define ACTION_MENURED
Definition: tv_actions.h:77
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:256
MHIContext::SetInputRegister
void SetInputRegister(int num) override
Definition: mhi.cpp:650
ACTION_1
static constexpr const char * ACTION_1
Definition: mythuiactions.h:5
MHIText::m_width
int m_width
Definition: mhi.h:260
tv_actions.h
MHIContext::Key_t
QPair< int, int > Key_t
Definition: mhi.h:227
MHIDLA::m_lineColour
MHRgba m_lineColour
Current line colour.
Definition: mhi.h:361
MHIContext::m_faceLoaded
bool m_faceLoaded
Definition: mhi.h:206
MHIContext::m_videoRect
QRect m_videoRect
Definition: mhi.h:222
MHIContext::StopVideo
void StopVideo() override
Stop displaying video.
Definition: mhi.cpp:1135
lineSeg
Definition: mhi.cpp:1698
hardwareprofile.i18n.t
t
Definition: i18n.py:36
kTuneCarReset
const unsigned kTuneCarReset
Definition: mhi.cpp:59
MHIContext::m_stop
bool m_stop
Definition: mhi.h:199
MHIBitmap::Draw
void Draw(int x, int y, QRect rect, bool tiled, bool bUnder) override
Draw the completed drawing onto the display.
Definition: mhi.cpp:1804
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:550
MHEG::EngineEvent
virtual void EngineEvent(int)=0
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:225
MHIBitmap::m_copyCtx
MythAVCopy * m_copyCtx
Definition: mhi.h:309
MythPlayerCaptionsUI::SetAudioByComponentTag
bool SetAudioByComponentTag(int Tag)
Selects the audio stream using the DVB component tag.
Definition: mythplayercaptionsui.cpp:589
MHIDLA::DrawLineSub
void DrawLineSub(int x1, int y1, int x2, int y2, bool swapped)
Definition: mhi.cpp:1576
GetShareDir
QString GetShareDir(void)
Definition: mythdirs.cpp:254
x1
static int x1
Definition: mythsocket.cpp:50
MHIContext::GetInitialStreams
void GetInitialStreams(int &audioTag, int &videoTag) const
Get the initial component tags.
Definition: mhi.cpp:735
DSMCCPacket::m_dataBroadcastId
int m_dataBroadcastId
Definition: mhi.h:390
ACTION_PAUSE
#define ACTION_PAUSE
Definition: tv_actions.h:15
MHEG::RunAll
virtual std::chrono::milliseconds RunAll(void)=0
MHIContext::m_keyLock
QMutex m_keyLock
Definition: mhi.h:191
MythPlayerCaptionsUI::ResizeForInteractiveTV
void ResizeForInteractiveTV(const QRect &Rect)
MHIContext::m_audioTag
int m_audioTag
Definition: mhi.h:215
MythImage::DecrRef
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:52
MHIBitmap::~MHIBitmap
~MHIBitmap() override
Definition: mhi.cpp:1799
MHIDLA::m_image
QImage m_image
Definition: mhi.h:355
MHIContext::ScaleVideoX
int ScaleVideoX(int n, bool roundup=false) const
Definition: mhi.cpp:772
MHIContext::m_parent
InteractiveTV * m_parent
Definition: mhi.h:181
Dsmcc::GetDSMCCObject
int GetDSMCCObject(QStringList &objectPath, QByteArray &result)
Definition: dsmcc.cpp:550
MHIContext::m_currentSource
int m_currentSource
Definition: mhi.h:213
MHIText::GetBounds
QRect GetBounds(const QString &str, int &strLen, int maxSize=-1) override
Definition: mhi.cpp:1277
Dsmcc::ProcessSection
void ProcessSection(const unsigned char *data, int length, int componentTag, unsigned carouselId, int dataBroadcastId)
Definition: dsmcc.cpp:451
MHEG::DrawDisplay
virtual void DrawDisplay(const QRegion &toDraw)=0
ACTION_SEEKRWND
#define ACTION_SEEKRWND
Definition: tv_actions.h:42
DSMCCPacket::m_data
unsigned char * m_data
Definition: mhi.h:386
MHIDLA::m_fillColour
MHRgba m_fillColour
Current fill colour.
Definition: mhi.h:362
ACTION_8
static constexpr const char * ACTION_8
Definition: mythuiactions.h:12
MHBitmapDisplay
Definition: freemheg.h:211
MHIBitmap::ScaleImage
void ScaleImage(int newWidth, int newHeight) override
Scale the bitmap. Only used for image derived from MPEG I-frames.
Definition: mhi.cpp:1969
MHIDLA::DrawLine
void DrawLine(int x1, int y1, int x2, int y2) override
Definition: mhi.cpp:1554
ACTION_STOP
#define ACTION_STOP
Definition: tv_actions.h:8
mythpainter.h
MHRgba::blue
int blue() const
Definition: freemheg.h:90
MHCreateEngine
MHEG * MHCreateEngine(MHContext *context)
Definition: Engine.cpp:43
MHInteractionChannel::CheckFile
bool CheckFile(const QString &csPath, const QByteArray &cert=QByteArray())
Definition: mhegic.cpp:64
ACTION_7
static constexpr const char * ACTION_7
Definition: mythuiactions.h:11
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MHIText::m_fontItalic
bool m_fontItalic
Definition: mhi.h:258
interactivescreen.h
MHIText::m_fontBold
bool m_fontBold
Definition: mhi.h:259
MHIContext::m_dsmccQueue
MythDeque< DSMCCPacket * > m_dsmccQueue
Definition: mhi.h:186
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
MHIBitmap::MHIBitmap
MHIBitmap(MHIContext *parent, bool tiled)
Definition: mhi.cpp:1793
MHIContext::StreamPlay
void StreamPlay(bool play) override
Definition: mhi.cpp:1162
MHIContext::ScaleVideo
QRect ScaleVideo(QRect r) const
Definition: mhi.cpp:782
MHIDLA::m_boxed
bool m_boxed
Does it have a border?
Definition: mhi.h:358
ACTION_MENUTEXT
#define ACTION_MENUTEXT
Definition: tv_actions.h:82
Dsmcc::Reset
void Reset()
Definition: dsmcc.cpp:541
MHIText::SetSize
void SetSize(int width, int height) override
Definition: mhi.cpp:1243
FONT_TO_USE
static constexpr const char * FONT_TO_USE
Definition: mhi.cpp:52
MHIContext::StopEngine
void StopEngine(void)
Stop the MHEG engine if it's running and waits until it has.
Definition: mhi.cpp:157
ACTION_UP
static constexpr const char * ACTION_UP
Definition: mythuiactions.h:16
kShift
const int kShift
Definition: mhi.cpp:1259
MHIContext::m_videoDisplayRect
QRect m_videoDisplayRect
Definition: mhi.h:222
MHKeyLookup::key_t
QPair< QString, int > key_t
Definition: mhi.cpp:512
MHIBitmap::CreateFromMPEG
void CreateFromMPEG(const unsigned char *data, int length) override
Create bitmap from single I frame MPEG.
Definition: mhi.cpp:1867
MHIBitmap
Object for drawing bitmaps.
Definition: mhi.h:267
MythPlayerCaptionsUI::GetStreamMaxPos
std::chrono::milliseconds GetStreamMaxPos()
Definition: mythplayercaptionsui.cpp:643
MHIText::SetFont
void SetFont(int size, bool isBold, bool isItalic) override
Definition: mhi.cpp:1249
ACTION_MENUBLUE
#define ACTION_MENUBLUE
Definition: tv_actions.h:80
MHIContext::m_dsmccLock
QMutex m_dsmccLock
Definition: mhi.h:185
MHIText::m_parent
MHIContext * m_parent
Definition: mhi.h:255
GET_KEY
static QString GET_KEY(const QString &Context, const QString &Action)
Definition: mythmainwindow.h:182
mythimage.h
InteractiveScreen
Definition: interactivescreen.h:9
MHIContext::Cid
static int Cid(ChannelCache_t::const_iterator it)
Definition: mhi.h:232
MHIDLA::m_parent
MHIContext * m_parent
Definition: mhi.h:354
MHIContext::StreamStarted
bool StreamStarted(bool bStarted=true)
Definition: mhi.cpp:1085
ACTION_4
static constexpr const char * ACTION_4
Definition: mythuiactions.h:8
DSMCCPacket
Data for the queued DSMCC tables.
Definition: mhi.h:369
MHIContext::UpdateOSD
void UpdateOSD(InteractiveScreen *osdWindow, MythPainter *osdPainter)
Update the display.
Definition: mhi.cpp:665
MHIContext::CreateDynamicLineArt
MHDLADisplay * CreateDynamicLineArt(bool isBoxed, MHRgba lineColour, MHRgba fillColour) override
Creation functions for various visibles.
Definition: mhi.cpp:1169
InteractiveScreen::OptimiseDisplayedArea
void OptimiseDisplayedArea()
Definition: interactivescreen.cpp:34
MHIContext::m_channelMutex
QMutex m_channelMutex
Definition: mhi.h:230
ACTION_3
static constexpr const char * ACTION_3
Definition: mythuiactions.h:7
ACTION_RIGHT
static constexpr const char * ACTION_RIGHT
Definition: mythuiactions.h:19
Dsmcc
Definition: dsmcc.h:77
MHIContext::LoadFont
bool LoadFont(const QString &name)
Definition: mhi.cpp:98
mythcorecontext.h
MHIBitmap::CreateFromJPEG
void CreateFromJPEG(const unsigned char *data, int length) override
Create bitmap from JPEG.
Definition: mhi.cpp:1848
ACTION_MENUGREEN
#define ACTION_MENUGREEN
Definition: tv_actions.h:78
MythPlayerCaptionsUI::SetInteractiveStreamPos
void SetInteractiveStreamPos(std::chrono::milliseconds Position)
MythPainter
Definition: mythpainter.h:34
MythImage
Definition: mythimage.h:36
MHKeyLookup::m_map
QHash< key_t, int > m_map
Definition: mhi.cpp:524
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:888
MHIDLA::Clear
void Clear(void) override
Clear the drawing.
Definition: mhi.cpp:1494
MHInteractionChannel::kPending
@ kPending
Definition: mhegic.h:35
MHEG::GenerateUserAction
virtual void GenerateUserAction(int nCode)=0
ACTION_5
static constexpr const char * ACTION_5
Definition: mythuiactions.h:9
MHIContext::Val_t
QPair< int, int > Val_t
Definition: mhi.h:226
mythavutil.h
MHRgba::red
int red() const
Definition: freemheg.h:88
MHIContext::ClearDisplay
void ClearDisplay(void)
Definition: mhi.cpp:140
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1105
MHIContext::m_channelCache
ChannelCache_t m_channelCache
Definition: mhi.h:229
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
MHIContext::LoadChannelCache
bool LoadChannelCache()
Definition: mhi.cpp:856
MHInteractionChannel::kSuccess
@ kSuccess
Definition: mhegic.h:35
MHIText
Definition: mhi.h:238
Roundup
int Roundup(int n, int r)
Definition: mhi.cpp:823
MHRgba::green
int green() const
Definition: freemheg.h:89
MHIDLA::Draw
void Draw(int x, int y) override
Draw the completed drawing onto the display.
Definition: mhi.cpp:1506
ACTION_JUMPFFWD
#define ACTION_JUMPFFWD
Definition: tv_actions.h:44
mthread.h
FONT_WIDTHRES
static constexpr uint8_t FONT_WIDTHRES
Definition: mhi.cpp:50
Point2FT
static FT_F26Dot6 Point2FT(int pt)
Definition: mhi.cpp:1260
MHIContext::ScaleX
int ScaleX(int n, bool roundup=false) const
Definition: mhi.cpp:756
MHIContext::m_nbiData
std::vector< unsigned char > m_nbiData
Definition: mhi.h:220
build_compdb.action
action
Definition: build_compdb.py:9
MythAVCopy
Definition: mythavutil.h:44
MHIContext::RequireRedraw
void RequireRedraw(const QRegion &region) override
An area of the screen/image needs to be redrawn.
Definition: mhi.cpp:745
MHIContext::GetCarouselData
bool GetCarouselData(const QString &objectPath, QByteArray &result) override
Definition: mhi.cpp:436
interactivetv.h
MythPlayerCaptionsUI::SetVideoByComponentTag
bool SetVideoByComponentTag(int Tag)
Selects the video stream using the DVB component tag.
Definition: mythplayercaptionsui.cpp:601
MHIContext
Contains various utility functions for interactive television.
Definition: mhi.h:50
kTuneKeepApp
const unsigned kTuneKeepApp
Definition: mhi.cpp:57
mythuiactions.h
MHIDLA::DrawPoly
void DrawPoly(bool isFilled, const MHPointVec &xArray, const MHPointVec &yArray) override
Definition: mhi.cpp:1700
MHIText::m_height
int m_height
Definition: mhi.h:261
FONT_HEIGHTRES
static constexpr uint8_t FONT_HEIGHTRES
Definition: mhi.cpp:51
MHIContext::ProcessDSMCCQueue
void ProcessDSMCCQueue(void)
Definition: mhi.cpp:276
lineSeg::m_yTop
int m_yTop
Definition: mhi.cpp:1698
lineSeg::m_yBottom
int m_yBottom
Definition: mhi.cpp:1698
MHIContext::DrawImage
void DrawImage(int x, int y, QRect rect, const QImage &image, bool bScaled=false, bool bUnder=false)
Definition: mhi.cpp:1205
MHIContext::StopAudio
void StopAudio() override
Stop playing audio.
Definition: mhi.cpp:1115
MHIContext::AddToDisplay
void AddToDisplay(const QImage &image, QRect rect, bool bUnder=false)
Definition: mhi.cpp:788
ACTION_2
static constexpr const char * ACTION_2
Definition: mythuiactions.h:6
lineSeg::m_slope
float m_slope
Definition: mhi.cpp:1698
kTuneCarId
const unsigned kTuneCarId
Definition: mhi.cpp:58
MHIImageData
Data for items in the interactive television display stack.
Definition: mhi.cpp:69
MythImage::Assign
void Assign(const QImage &img)
Definition: mythimage.cpp:77
InteractiveTV
This is the interface between an MHEG engine and a MythTV TV object.
Definition: interactivetv.h:15
MythAVCopy::Copy
int Copy(AVFrame *To, const MythVideoFrame *From, unsigned char *Buffer, AVPixelFormat Fmt=AV_PIX_FMT_YUV420P)
Initialise AVFrame and copy contents of VideoFrame frame into it, performing any required conversion.
Definition: mythavutil.cpp:267
MHIContext::SetNetBootInfo
void SetNetBootInfo(const unsigned char *data, uint length)
Definition: mhi.cpp:315
MHIDLA
Object for displaying Dynamic Line Art.
Definition: mhi.h:315
MHIContext::~MHIContext
~MHIContext() override
Definition: mhi.cpp:128
MHIContext::GetStreamPos
std::chrono::milliseconds GetStreamPos() override
Definition: mhi.cpp:1141
FT2Point
static int FT2Point(FT_F26Dot6 fp)
Definition: mhi.cpp:1265
ACTION_MENUEPG
#define ACTION_MENUEPG
Definition: tv_actions.h:83
ft_library
static FT_Library ft_library
Definition: mhi.cpp:48
MHIContext::Tid
static int Tid(ChannelCache_t::const_iterator it)
Definition: mhi.h:231
MHIContext::DrawVideo
void DrawVideo(const QRect &videoRect, const QRect &dispRect) override
Definition: mhi.cpp:832
MythDeque::dequeue
T dequeue()
Removes item from front of list and returns a copy. O(1).
Definition: mythdeque.h:31
MHIDLA::m_width
int m_width
Width of the drawing.
Definition: mhi.h:356
MHTextDisplay
Definition: freemheg.h:195
mythmainwindow.h
MHIDLA::m_boxLineColour
MHRgba m_boxLineColour
Line colour for the background.
Definition: mhi.h:359
MHIContext::TuneTo
bool TuneTo(int channel, int tuneinfo) override
Definition: mhi.cpp:1005
dsmcc.h
MythCoreContext::dispatch
void dispatch(const MythEvent &event)
Definition: mythcorecontext.cpp:1727
MHKeyLookup::Find
int Find(const QString &name, int reg) const
Definition: mhi.cpp:517
ACTION_6
static constexpr const char * ACTION_6
Definition: mythuiactions.h:10
mhi.h
mythaverror.h
ACTION_SEEKFFWD
#define ACTION_SEEKFFWD
Definition: tv_actions.h:43
DSMCCPacket::m_componentTag
int m_componentTag
Definition: mhi.h:388
MHIDLA::DrawBorderedRectangle
void DrawBorderedRectangle(int x, int y, int width, int height) override
Definition: mhi.cpp:1650
av_make_error_stdstring
char * av_make_error_stdstring(std::string &errbuf, int errnum)
A C++ equivalent to av_make_error_string.
Definition: mythaverror.cpp:42
InteractiveTV::GetPlayer
MythPlayerCaptionsUI * GetPlayer(void)
Definition: interactivetv.h:51
MHIContext::DrawBackground
void DrawBackground(const QRegion &reg) override
Definition: mhi.cpp:1228
DSMCCPacket::m_carouselId
unsigned m_carouselId
Definition: mhi.h:389
MHRgba
Definition: freemheg.h:82
MHIContext::m_runLock
QMutex m_runLock
Definition: mhi.h:197
MHPointVec
std::vector< int > MHPointVec
Definition: BaseClasses.h:31
uint
unsigned int uint
Definition: freesurround.h:24
MythDeque::enqueue
void enqueue(const T &d)
Adds item to the back of the list. O(1).
Definition: mythdeque.h:41
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:837
MHIContext::m_displayLock
QMutex m_displayLock
Definition: mhi.h:200
MHIContext::GetICStatus
int GetICStatus() override
Definition: mhi.cpp:658
MHIContext::kStdDisplayWidth
static const int kStdDisplayWidth
Definition: mhi.h:168