/// <summary>
        /// Beginnt mit der Bearbeitung der Nutzdaten in einem PVA Paket.
        /// </summary>
        private void StartPackage()
        {
            // Next
            m_State = SyncStates.PayLoad;

            // Get length parts
            int high = m_Header[4];
            int low  = m_Header[5];

            // Reset length counter
            m_BytesLeft = low + 256 * high;

            // Special
            if (PTSPresent)
            {
                m_BytesLeft = Math.Max(m_BytesLeft - m_PTS.Length, 0);
            }

            // Reset transfer state
            m_VideoAlign = m_Header[3] & 0x3;
            m_PESCreated = false;
            m_PacketPos  = 0;
        }
Example #2
0
 public void AddObserver(SyncStates stateObserve, IOrmSyncObserver observer)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="start"></param>
        /// <param name="length"></param>
        private void Worker(byte[] buffer, int start, int length)
        {
            while (length > 0)
            {
                // Find the first byte of the magic word
                if (SyncStates.SyncA == m_State)
                {
                    // Find the sync byte
                    for (; ;)
                    {
                        // Is there any more data
                        if (length-- < 1)
                        {
                            return;
                        }

                        // Check for hit
                        if (0x41 == buffer[start++])
                        {
                            break;
                        }

                        // Count errors
                        ++m_Skipped;
                    }

                    // Next
                    m_State = SyncStates.SyncV;
                }

                // Find the second byte of the magic word
                if (SyncStates.SyncV == m_State)
                {
                    // Check if
                    if (0x56 != buffer[start])
                    {
                        // Count
                        ++m_Restarted;

                        // Start resync
                        m_State = SyncStates.SyncA;

                        // Test again
                        continue;
                    }

                    // Adjust
                    --length;
                    ++start;

                    // Next
                    m_State = SyncStates.Header;

                    // Reset header counter
                    m_BytesLeft = m_Header.Length;

                    // Done
                    if (length < 1)
                    {
                        return;
                    }
                }

                // Find the header
                if (SyncStates.Header == m_State)
                {
                    // How much to copy
                    int len = Math.Min(m_BytesLeft, length);

                    // Copy over
                    Array.Copy(buffer, start, m_Header, m_Header.Length - m_BytesLeft, len);

                    // Adjust
                    m_BytesLeft -= len;
                    length      -= len;
                    start       += len;

                    // Incomplete
                    if (m_BytesLeft > 0)
                    {
                        return;
                    }

                    // See if PTS follows
                    if (PTSPresent)
                    {
                        // Next
                        m_State = SyncStates.PTS;

                        // Reset header counter
                        m_BytesLeft = m_PTS.Length;
                    }
                    else
                    {
                        // Report
                        StartPackage();
                    }

                    // Done
                    if (length < 1)
                    {
                        return;
                    }
                }

                // Find the header
                if (SyncStates.PTS == m_State)
                {
                    // How much to copy
                    int len = Math.Min(m_BytesLeft, length);

                    // Copy over
                    Array.Copy(buffer, start, m_PTS, m_PTS.Length - m_BytesLeft, len);

                    // Adjust
                    m_BytesLeft -= len;
                    length      -= len;
                    start       += len;

                    // Incomplete
                    if (m_BytesLeft > 0)
                    {
                        return;
                    }

                    // Report
                    StartPackage();

                    // Done
                    if (length < 1)
                    {
                        return;
                    }
                }

                // How much to eat up
                int payload = Math.Min(m_BytesLeft, length);

                // Process
                SendPayload(buffer, start, payload);

                // Adjust
                m_BytesLeft -= payload;
                length      -= payload;
                start       += payload;

                // Start from scratch
                if (m_BytesLeft < 1)
                {
                    m_State = SyncStates.SyncA;
                }
            }
        }
Example #4
0
 public void SetNewState(SyncStates newState, IObservableProgession observableProgression)
 {
     _syncObserver.OnNewState(newState, true);
     observableProgression.AddObserver(newState, _syncObserver);
 }
Example #5
0
 public void SetNewState(SyncStates newState)
 {
     _syncObserver.OnNewState(newState, false);
 }
Example #6
0
 public static void SetState(DependencyObject obj, SyncStates value)
 {
     obj.SetValue(State, value);
 }
Example #7
0
		/// <summary>
		/// Beginnt mit der Bearbeitung der Nutzdaten in einem PVA Paket.
		/// </summary>
		private void StartPackage()
		{
			// Next
			m_State = SyncStates.PayLoad;

			// Get length parts
			int high = m_Header[4];
			int low = m_Header[5];

			// Reset length counter
			m_BytesLeft = low + 256 * high;

			// Special
			if (PTSPresent) m_BytesLeft = Math.Max(m_BytesLeft - m_PTS.Length, 0);

			// Reset transfer state
			m_VideoAlign = m_Header[3] & 0x3;
			m_PESCreated = false;
			m_PacketPos = 0;
		}
Example #8
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="buffer"></param>
		/// <param name="start"></param>
		/// <param name="length"></param>
		private void Worker(byte[] buffer, int start, int length)
		{
			while (length > 0)
			{
				// Find the first byte of the magic word
				if (SyncStates.SyncA == m_State)
				{
					// Find the sync byte
					for (; ; )
					{
						// Is there any more data
						if (length-- < 1) return;

						// Check for hit
						if (0x41 == buffer[start++]) break;

						// Count errors
						++m_Skipped;
					}

					// Next
					m_State = SyncStates.SyncV;
				}

				// Find the second byte of the magic word
				if (SyncStates.SyncV == m_State)
				{
					// Check if
					if (0x56 != buffer[start])
					{
						// Count
						++m_Restarted;

						// Start resync
						m_State = SyncStates.SyncA;

						// Test again
						continue;
					}

					// Adjust
					--length;
					++start;

					// Next
					m_State = SyncStates.Header;

					// Reset header counter
					m_BytesLeft = m_Header.Length;

					// Done
					if (length < 1) return;
				}

				// Find the header
				if (SyncStates.Header == m_State)
				{
					// How much to copy
					int len = Math.Min(m_BytesLeft, length);

					// Copy over
					Array.Copy(buffer, start, m_Header, m_Header.Length - m_BytesLeft, len);

					// Adjust
					m_BytesLeft -= len;
					length -= len;
					start += len;

					// Incomplete
					if (m_BytesLeft > 0) return;

					// See if PTS follows
					if (PTSPresent)
					{
						// Next
						m_State = SyncStates.PTS;

						// Reset header counter
						m_BytesLeft = m_PTS.Length;
					}
					else
					{
						// Report
						StartPackage();
					}

					// Done
					if (length < 1) return;
				}

				// Find the header
				if (SyncStates.PTS == m_State)
				{
					// How much to copy
					int len = Math.Min(m_BytesLeft, length);

					// Copy over
					Array.Copy(buffer, start, m_PTS, m_PTS.Length - m_BytesLeft, len);

					// Adjust
					m_BytesLeft -= len;
					length -= len;
					start += len;

					// Incomplete
					if (m_BytesLeft > 0) return;

					// Report
					StartPackage();

					// Done
					if (length < 1) return;
				}

				// How much to eat up
				int payload = Math.Min(m_BytesLeft, length);

				// Process
				SendPayload(buffer, start, payload);

				// Adjust
				m_BytesLeft -= payload;
				length -= payload;
				start += payload;

				// Start from scratch
				if (m_BytesLeft < 1) m_State = SyncStates.SyncA;
			}
		}