Пример #1
0
        public void Flag_RegistAlias()
        {
            EnumHelper.RegistAlias <SampleFlag>(enumValue =>
            {
                return(new EnumAliasInfo(enumValue.ToString().ToUpper()));
            }
                                                );

            bool result = EnumHelper.HasAlias(SampleFlag.Left);

            Assert.AreEqual(result, true);

            SampleFlag value = EnumHelper.FromAlias <SampleFlag>("LEFT");

            Assert.AreEqual(value, SampleFlag.Left);

            string alias = EnumHelper.GetAlias(SampleFlag.Right);

            Assert.AreEqual(alias, "RIGHT");

            EnumHelper.UnregistAlias <SampleFlag>();

            result = EnumHelper.HasAlias(SampleFlag.Left);
            Assert.AreEqual(result, true);

            value = EnumHelper.FromAlias <SampleFlag>("L");
            Assert.AreEqual(value, SampleFlag.Left);

            alias = EnumHelper.GetAlias(SampleFlag.Right);
            Assert.AreEqual(alias, "R");
        }
Пример #2
0
 //------------------------------------------------------------------------------
 // Name: CWMVCopy::OnSample()
 // Desc: Implementation of IWMReaderCallback::OnSample.
 //------------------------------------------------------------------------------
 public void OnSample(
     int dwOutputNum,
     long qwSampleTime,
     long qwSampleDuration,
     SampleFlag dwFlags,
     INSSBuffer pSample,
     IntPtr pvContext)
 {
     //
     // The samples are expected in OnStreamSample
     //
     m_hr = E_Unexpected;
     Console.WriteLine(string.Format("Reader Callback: Received a decompressed sample (hr=0x{0:x}).", m_hr));
     m_hEvent.Set();
 }
Пример #3
0
 private bool ReadNextSample(out INSSBuffer buffer, out long duration,
                             out SampleFlag sampleFlag)
 {
     try
     {
         long  sampleTime;
         int   outputNum;
         short streamNum;
         syncReader.GetNextSample(0, out buffer, out sampleTime, out duration, out sampleFlag,
                                  out outputNum, out streamNum);
     }
     catch (Exception)
     {
         buffer     = null;
         duration   = 0;
         sampleFlag = 0;
         return(false);
     }
     return(true);
 }
Пример #4
0
		private bool ReadNextSample(out INSSBuffer buffer, out long duration,
			out SampleFlag sampleFlag)
		{
			try
			{
				long sampleTime;
				int outputNum;
				short streamNum;
				syncReader.GetNextSample(0, out buffer, out sampleTime, out duration, out sampleFlag,
					out outputNum, out streamNum);
			}
			catch (Exception)
			{
				buffer = null;
				duration = 0;
				sampleFlag = 0;
				return false;
			}
			return true;
		}
 public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     m_CallbackCalled = true;
 }
Пример #6
0
 public void OnStreamSample(short wStreamNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Пример #7
0
        public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
        {
            try
            {
                // Check the output number of the sample against the stored output number.
                // Because only the first audio output is stored, all other outputs,
                //  regardless of type, will be ignored.  Shouldn't be an issue since
                // SetStreams turned off delivery of samples for all streams except the
                // one we want
                if (dwOutputNum != m_dwAudioOutputNum)
                {
                    return;
                }

                // The rest of the code in this method uses Windows Multimedia wave
                //  handling functions to play the content.
                //
                IntPtr ip = (pSample as INSBuf).GetPtr();

                try
                {
                    //
                    // Send the sample to the wave output device.
                    //
                    int mmr = waveOut.Write(m_hWaveOut, ip, WAVHDRLEN);
                    waveOut.ThrowExceptionForError(mmr);
                }
                catch
                {
                    //
                    // Stop the player.
                    //
                    Stop();
                    throw;
                }
                if (TimeChanged != null)
                {
                    // Only send time events every 1/10 of a second
                    if (Math.Abs(cnsSampleTime - m_OldTime) > (ONESEC / 10))
                    {
                        m_OldTime = cnsSampleTime;
                        TimeChangeArgs ta = new TimeChangeArgs(cnsSampleTime);
                        try
                        {
                            TimeChanged(this, ta);
                        }
                        catch { }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            finally
            {
                // If we weren't allocating our own samples in IWMReaderCallbackAdvanced::AllocateForOutput,
                // we'd have to free this here.

                //Marshal.ReleaseComObject(pSample);
            }
        }
 public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     //throw new Exception("The method or operation is not implemented.");
     if (pvContext.ToInt32() == 567)
     {
         //m_CallbackCalled = true;
     }
 }
Пример #9
0
 public void OnStreamSample(short wStreamNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     Debug.WriteLine("OnStreamSample");
     // wmvcopy
 }
Пример #10
0
 public void Flag_FromAlias_Failed_2()
 {
     SampleFlag value = EnumHelper.FromAlias <SampleFlag>("L,R,X");
 }
Пример #11
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::OnStreamSample()
        // Desc: Implementation of IWMReaderCallbackAdvanced::OnStreamSample.
        //------------------------------------------------------------------------------
        public void OnStreamSample(
            short wStreamNum,
            long cnsSampleTime,
            long cnsSampleDuration,
            SampleFlag dwFlags,
            INSSBuffer pSample,
            IntPtr pvContext)
        {
            bool fMoveScript = false;

            while (m_dwProgress <= cnsSampleTime * 50 / m_qwDuration)
            {
                m_dwProgress++;
                Console.Write("*");
            }

            if (m_qwMaxDuration > 0 && cnsSampleTime > m_qwMaxDuration)
            {
                m_hEvent.Set();
                return;
            }

            if (m_fMoveScriptStream)
            {
                //
                // We may have multiple script streams in this file.
                //
                for (int i = 0; i < m_dwStreamCount; i++)
                {
                    if (m_pwStreamNumber[i] == wStreamNum)
                    {
                        if (MediaType.ScriptCommand == m_pguidStreamType[i])
                        {
                            fMoveScript = true;
                        }

                        break;
                    }
                }
            }

            try
            {
                if (fMoveScript)
                {
                    int           dwBufferLength;
                    int           nStringLength;
                    IntPtr        pwszTypeIP  = IntPtr.Zero;
                    StringBuilder pwszType    = null;
                    StringBuilder pwszCommand = null;

                    //
                    // Read the buffer and length of the script stream sample
                    //
                    pSample.GetBufferAndLength(out pwszTypeIP, out dwBufferLength);
                    pwszType = new StringBuilder(Marshal.PtrToStringUni(pwszTypeIP)); //todo - this won't work if the string doesn't have a final \0

                    nStringLength = dwBufferLength / 2;
                    if (nStringLength > 0)
                    {
                        //
                        // Get the command string of this script
                        //

                        // Todo - maybe the format of pwszTypeIP is Type\0Command\0 ???

#if false
                        pwszCommand = wcschr(pwszType, null);
                        if (pwszCommand - pwszType < nStringLength - 1)
                        {
                            pwszCommand++;
                        }
                        else
                        {
                            pwszCommand = " ";
                        }
#else
                        pwszCommand = new StringBuilder(" ");
#endif

                        //
                        // Add the script to the script list. We cannot write scripts
                        // directly to the writer after writing has begun.
                        //
                        m_ScriptList.Add(new CScript(pwszType.ToString(), pwszCommand.ToString(), cnsSampleTime));
                    }
                }
                else
                {
                    m_pWriterAdvanced.WriteStreamSample(wStreamNum,
                                                        cnsSampleTime,
                                                        0,
                                                        cnsSampleDuration,
                                                        dwFlags,
                                                        pSample);
                }
            }
            catch (Exception e)
            {
                int hr = Marshal.GetHRForException(e);
                m_hr = hr;
                m_hEvent.Set();
            }
            finally
            {
                Marshal.ReleaseComObject(pSample);
            }
        }
Пример #12
0
 public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     m_SampleCount++;
 }
Пример #13
0
 public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 //------------------------------------------------------------------------------
 // Name: OnSample()
 // Desc: Implementation of IWMReaderCallback::OnSample.
 //------------------------------------------------------------------------------
 public void OnSample(int dwOutputNum, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     //
     // Add your code to process samples here
     //
     m_SampleCount[dwOutputNum]++;
 }
Пример #15
0
 public void OnPostViewSample(short wStreamNumber, long cnsSampleTime, long cnsSampleDuration, SampleFlag dwFlags, INSSBuffer pSample, IntPtr pvContext)
 {
     Debug.Assert(pSample != null && pvContext.ToInt32() == 17);
     m_ViewSample = true;
 }