1
Vote

Outof bounds clip causes hang

description

If one calls Track.AddClip() and specifies a clip end beyond the end of the file a deadlock occurs between the Media Event Thread and the main thread.
 
Not sure what should happen here. Either throw an exception based on checking the arguments against reality or work with the length of the clip that is available and don't complain.
 
Unit test that hangs follows. This can be inserted in the WindowsMediaRendererFixture file...
 
    [Test]
    public void ConvertAviToWMVWithBadClipLength()
    {
        string outputFile = "ConvertAviToWMV.wmv";
 
        using (ITimeline timeline = new DefaultTimeline())
        {
            IGroup videoGroup = timeline.AddVideoGroup(0x20, 320, 240);
            ITrack videoTrack = videoGroup.AddTrack();
            IClip clockClip =
                videoTrack.AddClip("transitions.wmv", GroupMediaType.Video, InsertPosition.Absolute, 0, 0, 5000);
 
            Assert.IsTrue(clockClip.Duration > 0);
 
            IGroup audioGroup = timeline.AddAudioGroup();
            ITrack audioTrack = audioGroup.AddTrack();
            audioTrack.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, 2);
 
            using (
                WindowsMediaRenderer renderer =
                    new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo))
            {
                ExecuteRenderer(renderer,
                                @"<timeline framerate=""30.0000000"">
<group type=""video"" bitdepth=""32"" framerate=""30.0000000"" previewmode=""0"">
    <track>
        <clip start=""0"" stop=""5000"" src=""transitions.wmv"" mstart=""0"" />
    </track>
</group>
<group type=""audio"" framerate=""30.0000000"" previewmode=""0"">
    <track>
        <clip start=""0"" stop=""2"" src=""testinput.mp3"" mstart=""0"" />
    </track>
</group>
</timeline>");
            }
 
            Assert.IsTrue(File.Exists(outputFile));
            AssertLengths(timeline, 2, outputFile);
        }
    }

comments