コード例 #1
0
 public bool DataEquals(ExtendedTranscoderProfile cmp)
 {
     if (cmp == null)
         return false;
     return cmp.Name == this.Name &&
         cmp.UseTranscoding == this.UseTranscoding &&
         cmp.Transcoder == this.Transcoder &&
         cmp.Parameters == this.Parameters &&
         cmp.InputMethod == this.InputMethod &&
         cmp.OutputMethod == this.OutputMethod &&
         cmp.MIME == this.MIME &&
         cmp.Id == this.Id;
 }
コード例 #2
0
        protected void Read()
        {
            // default settings
            Port = 8080;
            UseWebserver = true;
            ManageTV4Home = true;
            Username = "******";
            Password = "******";
            EnableAuthentication = true;
            SiteRoot = "http://" + System.Environment.MachineName + "/";
            LogFile = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Team MediaPortal\MediaPortal TV Server\log\mpwebstream.log";
            TranscoderLog = true;
            Transcoders = new List<ExtendedTranscoderProfile>();
            Transcoders.Add(new ExtendedTranscoderProfile() {
                Name = "Direct",
                UseTranscoding = false,
                Transcoder = "",
                Parameters = "",
                InputMethod = TransportMethod.NamedPipe,
                OutputMethod = TransportMethod.NamedPipe,
                Id = 1,
                MIME = "video/MP2T"
            });

            // default transcoders
            Dictionary<string, string> configurations = new Dictionary<string, string>();
            configurations["H264, 426x240, 250Kbit/s"] = "-y -i %in -s 426x240 -b 175k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 64k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, 426x240, 500Kbit/s"] = "-y -i %in -s 426x240 -b 400k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 64k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, 426x240, 1Mbit/s"] = "-y -i %in -s 426x240 -b 700k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 128k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, WVGA, 1.5Mbit/s"] = "-y -i %in -s wvga -b 1400k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 128k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, WVGA, 2Mbit/s"] = "-y -i %in -s wvga -b 1800k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 128k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, 720p, 5Mbit/s"] = "-y -i %in -s hd720 -b 4700k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 192k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, 5Mbit/s"] = "-y -i %in -b 4700k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 192k -threads %threads -async 1 -f mpegts %out";
            configurations["H264, 10Mbit/s"] = "-y -i %in -b 9500k -vcodec libx264 -vprofile baseline -preset ultrafast -acodec aac -strict experimental -ab 256k -threads %threads -async 1 -f mpegts %out";
            int i = 2;
            foreach (KeyValuePair<string, string> config in configurations) {
                Transcoders.Add(new ExtendedTranscoderProfile() {
                    Name = config.Key,
                    UseTranscoding = true,
                    Transcoder = Path.Combine(BasePath, @"ffmpeg\bin\ffmpeg.exe"),
                    Parameters = config.Value.Replace("%threads", Environment.ProcessorCount.ToString()).Replace("%in", "\"{0}\"").Replace("%out", "\"{1}\""),
                    InputMethod = TransportMethod.NamedPipe,
                    OutputMethod = TransportMethod.NamedPipe,
                    Id = i,
                    MIME = "video/MP2T",
                    Type = TranscoderProfileType.System
                });
                i++;
            }

            // create file if it doesn't exists
            if (!File.Exists(ConfigPath))
                Write();

            XmlDocument doc = new XmlDocument();
            doc.Load(ConfigPath);
            Port = Int32.Parse(doc.SelectSingleNode("/mpwebstream/port").InnerText);
            UseWebserver = doc.SelectSingleNode("/mpwebstream/useWebserver").InnerText == "true";
            ManageTV4Home = doc.SelectSingleNode("/mpwebstream/manageTV4Home").InnerText == "true";
            Username = doc.SelectSingleNode("/mpwebstream/username").InnerText;
            Password = doc.SelectSingleNode("/mpwebstream/password").InnerText;
            if (doc.SelectSingleNode("/mpwebstream/enableAuthentication") != null)
                EnableAuthentication = doc.SelectSingleNode("/mpwebstream/enableAuthentication").InnerText == "true";
            if (doc.SelectSingleNode("/mpwebstream/siteroot") != null)
                SiteRoot = doc.SelectSingleNode("/mpwebstream/siteroot").InnerText;
            if (doc.SelectSingleNode("/mpwebstream/logfile") != null)
                LogFile = doc.SelectSingleNode("/mpwebstream/logfile").InnerText;
            if (doc.SelectSingleNode("/mpwebstream/transcoderlog") != null)
                TranscoderLog = doc.SelectSingleNode("/mpwebstream/transcoderlog").InnerText == "true";
            if (doc.SelectSingleNode("/mpwebstream/transcoderProfiles") != null) {
                Transcoders = new List<ExtendedTranscoderProfile>();
                XmlNodeList nodes = doc.SelectNodes("/mpwebstream/transcoderProfiles/transcoder");
                foreach (XmlNode node in nodes) {
                    // TODO: this can be done easier
                    ExtendedTranscoderProfile transcoder = new ExtendedTranscoderProfile();
                    transcoder.Type = TranscoderProfileType.User;
                    foreach (XmlNode child in node.ChildNodes) {
                        if (child.Name == "name") transcoder.Name = child.InnerText;
                        if (child.Name == "useTranscoding") transcoder.UseTranscoding = child.InnerText == "true";
                        if (child.Name == "inputMethod") transcoder.InputMethod = (TransportMethod)Enum.Parse(typeof(TransportMethod), child.InnerText, true);
                        if (child.Name == "outputMethod") transcoder.OutputMethod = (TransportMethod)Enum.Parse(typeof(TransportMethod), child.InnerText, true);
                        if (child.Name == "transcoder") transcoder.Transcoder = child.InnerText;
                        if (child.Name == "parameters") transcoder.Parameters = child.InnerText;
                        if (child.Name == "mime") transcoder.MIME = child.InnerText;
                        if (child.Name == "id") transcoder.Id = Int32.Parse(child.InnerText);
                        if (child.Name == "type") transcoder.Type = (TranscoderProfileType)Enum.Parse(typeof(TranscoderProfileType), child.InnerText, true);
                    }
                    Transcoders.Add(transcoder);
                }
            }
        }