/* * protected override bool addAudioWavWithEndOfFileTolerance(urakawa.media.data.audio.codec.WavAudioMediaData mediaData, urakawa.data.FileDataProvider dataProv, Time clipB, Time clipE, TreeNode treeNode) * { * bool isClipEndError = true; * * uint dataLength = 0; * Stream wavStream = null; * AudioLibPCMFormat PCMFormat = null; * try * { * wavStream = dataProv.OpenInputStream(); * PCMFormat = AudioLibPCMFormat.RiffHeaderParse(wavStream, out dataLength); * } * catch (System.Exception ex) * { * Console.WriteLine(ex.ToString()); * isClipEndError = true; * } * finally * { * if (wavStream != null) wavStream.Close(); * } * * Time fileDuration = new Time(PCMFormat.ConvertBytesToTime((long)dataLength)); * if (clipB.IsLessThan(clipE)) * {//1 * double diff = clipE.AsMilliseconds - fileDuration.AsMilliseconds; * if (clipB.IsLessThan(fileDuration)) * {//2 * try * {//3 * mediaData.AppendPcmData(dataProv, clipB, fileDuration); * isClipEndError = false; * Console.WriteLine("Obi: clip end adjust according to file length : Clip end" + clipE.AsTimeSpan.ToString() + " File length:" + fileDuration.AsTimeSpan.ToString()); * }//-3 * catch (Exception ex) * {//3 * isClipEndError = true; * }//-3 * // to do: add obi specific code here * //if (diff > 100 && treeNode != null ) * if (diff > m_Settings.ImportToleranceForAudioInMs && treeNode != null) * { * EmptyNode eNode = (EmptyNode)treeNode; * eNode.TODO = true; * if (eNode.Role_ == EmptyNode.Role.Plain) * { * eNode.Role_ = EmptyNode.Role.Custom; * eNode.CustomRole = Localizer.Message("DAISY3_ObiImport_ErrorsList_truncated_audio"); * } * m_ErrorsList.Add(Localizer.Message("DAISY3_ObiImport_ErrorsList_truncated_audio_in_phrase") + eNode.Index.ToString() + Localizer.Message("DAISY3_ObiImport_ErrorsList_in_section") + eNode.ParentAs<SectionNode>().Label); * m_ErrorsList.Add(Localizer.Message("DAISY3_ObiImport_ErrorsList_expected_clip_end") + clipE.Format_H_MN_S_MS() + Localizer.Message("DAISY3_ObiImport_ErrorsList_imported_clip_end") + fileDuration.Format_H_MN_S_MS()); * } * }//-2 * * }//-1 * else * {//1 * Console.WriteLine("clip begin is larger than clip end"); * }//-1 * return isClipEndError; * } */ private void ReplaceExternalAudioMediaPhraseWithEmptyNode(TreeNode node) { if (node is PhraseNode) { PhraseNode phrase = (PhraseNode)node; SectionNode section = phrase.ParentAs <SectionNode>(); Console.WriteLine("replacing phrase node with empty node due to clip problem " + section.Label + " phrase index:" + phrase.Index.ToString()); int phraseIndex = phrase.Index; EmptyNode emptyNode = m_Presentation.TreeNodeFactory.Create <EmptyNode>(); emptyNode.CopyAttributes(phrase); phrase.Detach(); section.Insert(emptyNode, phraseIndex); emptyNode.TODO = true; m_ErrorsList.Add(Localizer.Message("DAISY3_ObiImport_ErrorsList_error_no_audio") + phraseIndex.ToString() + Localizer.Message("DAISY3_ObiImport_ErrorsList_in_section") + section.Label); } }