/// <summary>
        /// Fires the <see cref="PCMFormatChanged"/> event
        /// </summary>
        /// <param name="source">The source, that is the <see cref="AudioMediaData"/> whoose <see cref="PCMFormatInfo"/> has changed</param>
        /// <param name="newFormat">The new value</param>
        /// <param name="prevFormat">The value prior to the change</param>
        protected void NotifyPCMFormatChanged(AudioMediaData source, PCMFormatInfo newFormat, PCMFormatInfo prevFormat)
        {
            EventHandler <events.media.data.audio.PCMFormatChangedEventArgs> d = PCMFormatChanged;

            if (d != null)
            {
                d(this, new urakawa.events.media.data.audio.PCMFormatChangedEventArgs(source, newFormat, prevFormat));
            }
        }
Exemplo n.º 2
0
        private void TestRoundTrim(PCMFormatInfo info)
        {
            StringBuilder sb = new StringBuilder();
            XmlWriter     wr = XmlWriter.Create(sb);

            info.XukOut(wr, new Uri(System.IO.Directory.GetCurrentDirectory()), null);
            wr.Close();
            PCMFormatInfo realodedInfo = new PCMFormatInfo();
            XmlReader     rd           = XmlReader.Create(new System.IO.StringReader(sb.ToString()));

            rd.ReadToFollowing(info.XukLocalName, info.XukNamespaceUri);
            realodedInfo.XukIn(rd, null);
            Assert.IsTrue(info.ValueEquals(realodedInfo));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update the audio properties of the presentation, if possible. Return true on success.
        /// </summary>
        public bool UpdatePresentationAudioProperties(int channels, int bitDepth, int sampleRate)
        {
            try
            {
                //sdk2
                urakawa.media.data.audio.PCMFormatInfo defaultPCMFormat = new urakawa.media.data.audio.PCMFormatInfo((ushort)channels, (uint)sampleRate, (ushort)bitDepth);
                MediaDataManager.DefaultPCMFormat       = defaultPCMFormat;
                MediaDataManager.EnforceSinglePCMFormat = true;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public void XukIn_XukOut_RoundTrim()
        {
            PCMFormatInfo pcmInfo;

            pcmInfo = new PCMFormatInfo(1, 44100, 16);
            TestRoundTrim(pcmInfo);
            pcmInfo = new PCMFormatInfo(1, 22050, 16);
            TestRoundTrim(pcmInfo);
            pcmInfo = new PCMFormatInfo(2, 44100, 16);
            TestRoundTrim(pcmInfo);
            pcmInfo = new PCMFormatInfo(2, 22050, 16);
            TestRoundTrim(pcmInfo);
            pcmInfo = new PCMFormatInfo(1, 44100, 8);
            TestRoundTrim(pcmInfo);
            pcmInfo = new PCMFormatInfo(1, 22050, 8);
            TestRoundTrim(pcmInfo);
        }
Exemplo n.º 5
0
        private void Duration_DataLength_RoundTrip(PCMFormatInfo pcmInfo)
        {
            Random rnd = new Random();
            uint   ba  = pcmInfo.Data.BlockAlign;

            for (int i = 0; i < 20480; i++)
            {
                uint dl = (uint)Math.Round(rnd.NextDouble() * UInt32.MaxValue);
                dl -= dl % ba;
                //uint roundI = pcmInfo.Data.GetDataLength(pcmInfo.Data.GetDuration(dl));
                uint roundI = (uint)pcmInfo.Data.ConvertTimeToBytes(pcmInfo.Data.ConvertBytesToTime(dl));
                Assert.AreEqual(
                    dl,
                    roundI,
                    "Wrong round trip data langth value");
            }
        }
Exemplo n.º 6
0
        public void Duration_DataLength_RoundTrip()
        {
            PCMFormatInfo pcmInfo = new PCMFormatInfo();

            pcmInfo.Data.BitDepth         = 16;
            pcmInfo.Data.NumberOfChannels = 1;
            pcmInfo.Data.SampleRate       = 22050;
            Duration_DataLength_RoundTrip(pcmInfo);
            pcmInfo.Data.BitDepth         = 16;
            pcmInfo.Data.NumberOfChannels = 1;
            pcmInfo.Data.SampleRate       = 44100;
            Duration_DataLength_RoundTrip(pcmInfo);
            pcmInfo.Data.BitDepth         = 8;
            pcmInfo.Data.NumberOfChannels = 2;
            pcmInfo.Data.SampleRate       = 22050;
            Duration_DataLength_RoundTrip(pcmInfo);
        }
        /// <summary>
        /// Determines if a PCM Format change is ok
        /// </summary>
        /// <param name="newFormat">The new PCM Format value - assumed not to be <c>null</c></param>
        /// <param name="failReason">The <see cref="string"/> to which a failure reason must be written in case the change is not ok</param>
        /// <returns>A <see cref="bool"/> indicating if the change is ok</returns>
        protected virtual bool IsPCMFormatChangeOk(PCMFormatInfo newFormat, out string failReason)
        {
            if (OriginalRelativePath != null && DataProvider != null)
            {
                throw new NotImplementedException();
            }

            failReason = "";

            if (Presentation.MediaDataManager.EnforceSinglePCMFormat &&
                !Presentation.MediaDataManager.DefaultPCMFormat.Data.IsCompatibleWith(newFormat.Data))
            {
                failReason =
                    "When the MediaDataManager enforces a single PCM Format, "
                    + "the PCM Format of the AudioMediaData must match the default defined by the manager";
                return(false);
            }

            return(true);
        }