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