/// <summary> /// Nimmt eine analyiserte Seite entgegen. /// </summary> /// <param name="page">Die analysierte Seite.</param> private void PageAnalysed(TTXPage page) { // Replace in cache lock (m_Pages) if (m_Parser.EnableParser) { m_Pages[page.Page] = page; } // Current page of interest int?currentPage = m_CurrentPage; // See if someone is interested if (currentPage.HasValue) { if (currentPage.Value == page.Page) { // Attach to handler TTXParser.PageHandler handler = OnPageAvailable; // Fire event if (null != handler) { handler(page); } } } }
/// <summary> /// Nimmt eine analyiserte Seite entgegen. /// </summary> /// <param name="page">Die analysierte Seite.</param> private void PageAnalysed( TTXPage page ) { // Replace in cache lock (m_Pages) if (m_Parser.EnableParser) m_Pages[page.Page] = page; // Current page of interest int? currentPage = m_CurrentPage; // See if someone is interested if (currentPage.HasValue) if (currentPage.Value == page.Page) { // Attach to handler TTXParser.PageHandler handler = OnPageAvailable; // Fire event if (null != handler) handler( page ); } }
/// <summary> /// Wertet den Videotext Kopf aus (Y/0). /// </summary> /// <param name="offset">Erstes auszuwertendes Byte.</param> /// <param name="length">Anzahl der auszuwertenden Bytes.</param> /// <param name="magazine">Magazinkennung (X oder M).</param> /// <param name="subTitle">Gesetzt für Untertitelseiten.</param> /// <returns>Gesetzt, wenn die Daten zulässig waren.</returns> private bool ProcessEBUPageHeader( int offset, int length, int magazine, bool subTitle ) { // Finish any outstanding page if (m_Page[magazine] != null) { // Send notification var handler = OnPage; if (handler != null) handler( m_Page[magazine] ); // Forget m_Page[magazine] = null; } // Extract the pager number int units = Hamming8To4[m_PacketBuffer[offset++]], tens = Hamming8To4[m_PacketBuffer[offset++]]; // Check it if ((255 == units) || (255 == tens)) { // Count ++m_ParityError; // Leave return false; } // Get the page number int page = (10 * tens) + units; // Process only if this is a regular page (100 - 899) if (page > 99) { // Silent skip return true; } // Read the rest int s1 = Hamming8To4[m_PacketBuffer[offset++]]; int s2c4 = Hamming8To4[m_PacketBuffer[offset++]]; int s3 = Hamming8To4[m_PacketBuffer[offset++]]; int s4c5c6 = Hamming8To4[m_PacketBuffer[offset++]]; int c7To10 = Hamming8To4[m_PacketBuffer[offset++]]; int c11To14 = Hamming8To4[m_PacketBuffer[offset++]]; // Verify all if ((255 == s1) || (255 == s2c4) || (255 == s3) || (255 == s4c5c6) || (255 == c7To10) || (255 == c11To14)) { // Count ++m_ParityError; // Leave return false; } // Can adjust length now length -= 8; // Extract sub code int subcode = ((s4c5c6 & 0x3) * 1000) + (s3 * 100) + ((s2c4 & 0x7) * 10) + s1; // Read data byte[] data = ReadOddParityBytes( offset, length ); if (data == null) return false; // Create the new page m_Page[magazine] = new TTXPage( magazine, page, subcode, data ) { IsSubtitle = subTitle || (0 != (s4c5c6 & 0x08)), MagazineSerial = (0 != (c11To14 & 0x01)), OutOfSequence = (0 != (c7To10 & 0x04)), NoHeader = (0 != (c7To10 & 0x01)), NationalOptions = (c11To14 >> 1), Updated = (0 != (c7To10 & 0x02)), Flash = (0 != (s4c5c6 & 0x04)), Hide = (0 != (c7To10 & 0x08)), Erase = (0 != (s2c4 & 0x08)), TimeStamp = m_LastPTS, }; // Done return true; }
/// <summary> /// Nimmt eine Videotextseite entgegen. /// </summary> /// <param name="page">Die gewünschte Videotextseite, eventuell leer.</param> /// <param name="digits">Informationen zum Auftreten von Zahlen in der Darstellung.</param> /// <returns>Gesetzt, wenn eine Seite erfolgreich angezeigt wurde.</returns> public bool ShowPage( TTXPage page, out DigitManager digits ) { // Safe create try { // Create the bitmap from the page RectangleF extend; using (var ttx = page.CreatePage( this, out digits, out extend )) { // Default position double left = GetNormalizedBorder( 0.8 ), top = 0.1; double right = 1.0 - left, bottom = 1.0 - top; // Get the transparency color if (page.IsTransparent) { // There is nothing to show if (extend.IsEmpty) return true; // Check mode if (UseLegacyOverlay) { // Get size double width = right - left, height = bottom - top; // Correct against bounds left += width * extend.Left; top += height * extend.Top; // Correct against bounds right = left + width * extend.Width; bottom = top + height * extend.Height; // Get the range of interest var srcRange = new RectangleF ( (float) (extend.Left * ttx.Width), (float) (extend.Top * ttx.Height), (float) (extend.Width * ttx.Width), (float) (extend.Height * ttx.Height) ); // Create new bitmap using (var clipped = new Bitmap( ttx, (int) Math.Round( srcRange.Width ), (int) Math.Round( srcRange.Height ) )) { // Prepare to update using (var dest = Graphics.FromImage( clipped )) { // Get full ranges var destRange = new RectangleF( 0, 0, clipped.Width, clipped.Height ); // Fill dest.DrawImage( ttx, destRange, srcRange, GraphicsUnit.Pixel ); } // Simpy show up ShowOverlay( clipped, left, top, right, bottom, null, null ); } } else { // Simpy show up ShowOverlay( ttx, left, top, right, bottom, null, TTXPage.TransparentColor.Color ); } } else { // Simpy show up ShowOverlay( ttx, left, top, right, bottom, null, null ); } } // Did it return true; } catch { // Reset digits = null; // Leave return false; } }
/// <summary> /// Nimmt eine Videotextseite entgegen. /// </summary> /// <param name="page">Die gewünschte Videotextseite, eventuell leer.</param> /// <returns>Gesetzt, wenn eine Seite erfolgreich angezeigt wurde.</returns> public bool ShowPage( TTXPage page ) { // Helper DigitManager digits; // Forward return ShowPage( page, out digits ); }
/// <summary> /// Wertet den Videotext Kopf aus (Y/0). /// </summary> /// <param name="offset">Erstes auszuwertendes Byte.</param> /// <param name="length">Anzahl der auszuwertenden Bytes.</param> /// <param name="magazine">Magazinkennung (X oder M).</param> /// <param name="subTitle">Gesetzt für Untertitelseiten.</param> /// <returns>Gesetzt, wenn die Daten zulässig waren.</returns> private bool ProcessEBUPageHeader(int offset, int length, int magazine, bool subTitle) { // Finish any outstanding page if (m_Page[magazine] != null) { // Send notification var handler = OnPage; if (handler != null) { handler(m_Page[magazine]); } // Forget m_Page[magazine] = null; } // Extract the pager number int units = Hamming8To4[m_PacketBuffer[offset++]], tens = Hamming8To4[m_PacketBuffer[offset++]]; // Check it if ((255 == units) || (255 == tens)) { // Count ++m_ParityError; // Leave return(false); } // Get the page number int page = (10 * tens) + units; // Process only if this is a regular page (100 - 899) if (page > 99) { // Silent skip return(true); } // Read the rest int s1 = Hamming8To4[m_PacketBuffer[offset++]]; int s2c4 = Hamming8To4[m_PacketBuffer[offset++]]; int s3 = Hamming8To4[m_PacketBuffer[offset++]]; int s4c5c6 = Hamming8To4[m_PacketBuffer[offset++]]; int c7To10 = Hamming8To4[m_PacketBuffer[offset++]]; int c11To14 = Hamming8To4[m_PacketBuffer[offset++]]; // Verify all if ((255 == s1) || (255 == s2c4) || (255 == s3) || (255 == s4c5c6) || (255 == c7To10) || (255 == c11To14)) { // Count ++m_ParityError; // Leave return(false); } // Can adjust length now length -= 8; // Extract sub code int subcode = ((s4c5c6 & 0x3) * 1000) + (s3 * 100) + ((s2c4 & 0x7) * 10) + s1; // Read data byte[] data = ReadOddParityBytes(offset, length); if (data == null) { return(false); } // Create the new page m_Page[magazine] = new TTXPage(magazine, page, subcode, data) { IsSubtitle = subTitle || (0 != (s4c5c6 & 0x08)), MagazineSerial = (0 != (c11To14 & 0x01)), OutOfSequence = (0 != (c7To10 & 0x04)), NoHeader = (0 != (c7To10 & 0x01)), NationalOptions = (c11To14 >> 1), Updated = (0 != (c7To10 & 0x02)), Flash = (0 != (s4c5c6 & 0x04)), Hide = (0 != (c7To10 & 0x08)), Erase = (0 != (s2c4 & 0x08)), TimeStamp = m_LastPTS, }; // Done return(true); }