Exemplo n.º 1
0
        public void HalfChange()
        {
            ulong         len         = (ulong)kSdpFullString.Length + 1; // at least as big as input (+ null terminator)
            StringBuilder buffer      = new StringBuilder((int)len);
            var           audioFilter = new Utils.SdpFilter
            {
                CodecName = "opus"
            };
            var videoFilter = new Utils.SdpFilter
            {
                CodecName = "a non-existing codec name causing no change"
            };
            uint res = Utils.SdpForceCodecs(kSdpFullString, audioFilter, videoFilter, buffer, ref len);

            Assert.AreEqual(res, Utils.MRS_SUCCESS);
            string output = buffer.ToString();

            // Audio codec should be "opus" alone
            {
                var regex      = new Regex("m=audio [^ ]+ [^ ]+ ([^\\r\\n]+)\\r?\\n");
                var audioMedia = regex.Match(output);
                Assert.NotNull(audioMedia);
                Assert.AreEqual(2, audioMedia.Groups.Count);        // [0] is always the entire match
                Assert.AreEqual("111", audioMedia.Groups[1].Value); // [1] is the first capture
            }

            // Video codec should be left unchanged
            {
                var regex      = new Regex("m=video [^ ]+ [^ ]+ ([^\\r\\n]+)\\r?\\n");
                var videoMedia = regex.Match(output);
                Assert.NotNull(videoMedia);
                Assert.AreEqual(2, videoMedia.Groups.Count);        // [0] is always the entire match
                Assert.AreEqual("120", videoMedia.Groups[1].Value); // [1] is the first capture
            }
        }
Exemplo n.º 2
0
        public void ShortBuffer()
        {
            ulong         len         = (ulong)kSdpFullString.Length; // missing space for null terminator
            StringBuilder buffer      = new StringBuilder((int)len);
            var           audioFilter = new Utils.SdpFilter();
            var           videoFilter = new Utils.SdpFilter();
            uint          res         = Utils.SdpForceCodecs(kSdpFullString, audioFilter, videoFilter, buffer, ref len);

            Assert.AreEqual(Utils.MRS_E_INVALID_PARAMETER, res);
        }
Exemplo n.º 3
0
        public void NoOp()
        {
            ulong         len         = (ulong)kSdpFullString.Length + 1; // exact size + null terminator
            StringBuilder buffer      = new StringBuilder((int)len);
            var           audioFilter = new Utils.SdpFilter();
            var           videoFilter = new Utils.SdpFilter();
            uint          res         = Utils.SdpForceCodecs(kSdpFullString, audioFilter, videoFilter, buffer, ref len);

            Assert.AreEqual(Utils.MRS_SUCCESS, res);
            Assert.AreEqual(kSdpFullString, buffer.ToString());
        }