Example #1
0
        public ISMCFile(Stream fs)
        {
            StreamReader sr     = new StreamReader(fs);
            XmlReader    reader = XmlReader.Create(sr);

            while (reader.Read())
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                // A StreamIndex may include several tracks, all with the same contents but at different bit rates.
                if (reader.Name == "StreamIndex")
                {
                    StreamIndex idx = new StreamIndex();
                    idx.Type    = reader.GetAttribute("Type");
                    idx.Subtype = reader.GetAttribute("Subtype");
                    idx.Chuncks = reader.GetAttribute("Chuncks");
                    idx.Url     = reader.GetAttribute("Url");
                    indexs.Add(idx);
                    tmpLastIndex = idx;
                }

                // A QualityLevel within a StreamIndex is basically a track in MP4 parlance.
                if (reader.Name == "QualityLevel")
                {
                    QualityLevel ql = new QualityLevel();
                    ql.TrackID = reader.GetAttribute("Index");
                    ql.Bitrate = reader.GetAttribute("Bitrate");
                    ql.FourCC  = reader.GetAttribute("FourCC");
                    ql.Width   = reader.GetAttribute("Width");
                    ql.Height  = reader.GetAttribute("Height");
                    if (ql.Width == null)
                    {
                        ql.Width  = reader.GetAttribute("MaxWidth");
                        ql.Height = reader.GetAttribute("MaxHeight");
                    }

                    ql.SamplingRate     = reader.GetAttribute("SamplingRate");
                    ql.Channels         = reader.GetAttribute("Channels");
                    ql.BitsPerSample    = reader.GetAttribute("BitsPerSample");
                    ql.AudioTag         = reader.GetAttribute("AudioTag");
                    ql.CodecPrivateData = reader.GetAttribute("CodecPrivateData");
                    tmpLastIndex.QualityLevels.Add(ql);
                }

                if (reader.Name == "c")
                {
                    c tc = new c();
                    tc.n = reader.GetAttribute("n");
                    tc.d = reader.GetAttribute("d");
                    tmpLastIndex.cs.Add(tc);
                }

                // Do some work here on the data.
                //Console.WriteLine(reader.Name);
            }
            reader.Close();
        }
Example #2
0
        public void Init(StreamReader inStream)
        {
            XmlReader reader = XmlReader.Create(inStream);

            while (reader.Read()) {
                if (reader.NodeType != XmlNodeType.Element) continue;

                if (reader.Name == "audio" || reader.Name == "video") {
                    if ((tmpLastIndex == null) || (tmpLastIndex.Type != reader.Name)) {
                        StreamIndex idx = new StreamIndex();
                        idx.Type = reader.Name;
                        tmpLastIndex = idx;
                        indexs.Add(tmpLastIndex);
                    }

                    QualityLevel ql = new QualityLevel();
                    ql.Bitrate = reader.GetAttribute("systemBitrate");
                    tmpLastIndex.QualityLevels.Add(ql);
                    tmpLastQL = ql;
                }

                if (reader.Name == "param") {
                    string name = reader.GetAttribute("name");
                    string vtype = reader.GetAttribute("valuetype");
                    string value = reader.GetAttribute("value");

                    switch (name) {
                        case "systemBitrate": tmpLastQL.Bitrate = value; break;
                        case "trackID": tmpLastQL.TrackID = value; break;
                        case "FourCC": tmpLastQL.FourCC = value; break;
                        case "CodecPrivateData": tmpLastQL.CodecPrivateData = value; break;
                        case "AudioTag": tmpLastQL.AudioTag = value; break;
                        case "Channels": tmpLastQL.Channels = value; break;
                        case "SamplingRate": tmpLastQL.SamplingRate = value; break;
                        case "BitsPerSample": tmpLastQL.BitsPerSample = value; break;
            //						case "PacketSize": break;
                        case "SubType": tmpLastIndex.Subtype = value; break;
                        case "MaxWidth": tmpLastQL.Width = value; break;
                        case "MaxHeight": tmpLastQL.Height = value; break;
                    }

                    //QualityLevel ql = new QualityLevel();
                    //ql.Bitrate = reader.GetAttribute("Bitrate");
                    //ql.FourCC = reader.GetAttribute("FourCC");
                    //ql.Width = reader.GetAttribute("Width");
                    //ql.Height = reader.GetAttribute("Height");
                    //ql.CodecPrivateData = reader.GetAttribute("CodecPrivateData");
                    //tmpLastIndex.QualityLevels.Add(ql);
                }

            }
        }
Example #3
0
        public ISMCFile(Stream fs)
        {
            StreamReader sr = new StreamReader(fs);
              XmlReader reader = XmlReader.Create(sr);

              while (reader.Read()) {
            if (reader.NodeType != XmlNodeType.Element) continue;

            // A StreamIndex may include several tracks, all with the same contents but at different bit rates.
            if (reader.Name == "StreamIndex") {
              StreamIndex idx = new StreamIndex();
              idx.Type = reader.GetAttribute("Type");
              idx.Subtype = reader.GetAttribute("Subtype");
              idx.Chuncks = reader.GetAttribute("Chuncks");
              idx.Url = reader.GetAttribute("Url");
              indexs.Add(idx);
              tmpLastIndex = idx;
            }

            // A QualityLevel within a StreamIndex is basically a track in MP4 parlance.
            if (reader.Name == "QualityLevel") {
              QualityLevel ql = new QualityLevel();
                    ql.TrackID = reader.GetAttribute("Index");
              ql.Bitrate = reader.GetAttribute("Bitrate");
              ql.FourCC = reader.GetAttribute("FourCC");
              ql.Width = reader.GetAttribute("Width");
              ql.Height = reader.GetAttribute("Height");
                    if (ql.Width == null) {
                        ql.Width = reader.GetAttribute("MaxWidth");
                        ql.Height = reader.GetAttribute("MaxHeight");
                    }

                    ql.SamplingRate = reader.GetAttribute("SamplingRate");
                    ql.Channels = reader.GetAttribute("Channels");
                    ql.BitsPerSample = reader.GetAttribute("BitsPerSample");
                    ql.AudioTag = reader.GetAttribute("AudioTag");
              ql.CodecPrivateData = reader.GetAttribute("CodecPrivateData");
              tmpLastIndex.QualityLevels.Add(ql);
            }

            if (reader.Name == "c") {
              c tc = new c();
              tc.n = reader.GetAttribute("n");
              tc.d = reader.GetAttribute("d");
              tmpLastIndex.cs.Add(tc);
            }

            // Do some work here on the data.
            //Console.WriteLine(reader.Name);
              }
              reader.Close();
        }
Example #4
0
        public void Init(StreamReader inStream)
        {
            XmlReader reader = XmlReader.Create(inStream);

            while (reader.Read())
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (reader.Name == "audio" || reader.Name == "video")
                {
                    if ((tmpLastIndex == null) || (tmpLastIndex.Type != reader.Name))
                    {
                        StreamIndex idx = new StreamIndex();
                        idx.Type     = reader.Name;
                        tmpLastIndex = idx;
                        indexs.Add(tmpLastIndex);
                    }

                    QualityLevel ql = new QualityLevel();
                    ql.Bitrate = reader.GetAttribute("systemBitrate");
                    tmpLastIndex.QualityLevels.Add(ql);
                    tmpLastQL = ql;
                }

                if (reader.Name == "param")
                {
                    string name  = reader.GetAttribute("name");
                    string vtype = reader.GetAttribute("valuetype");
                    string value = reader.GetAttribute("value");

                    switch (name)
                    {
                    case "systemBitrate": tmpLastQL.Bitrate = value; break;

                    case "trackID": tmpLastQL.TrackID = value; break;

                    case "FourCC": tmpLastQL.FourCC = value; break;

                    case "CodecPrivateData": tmpLastQL.CodecPrivateData = value; break;

                    case "AudioTag": tmpLastQL.AudioTag = value; break;

                    case "Channels": tmpLastQL.Channels = value; break;

                    case "SamplingRate": tmpLastQL.SamplingRate = value; break;

                    case "BitsPerSample": tmpLastQL.BitsPerSample = value; break;

//						case "PacketSize": break;
                    case "SubType": tmpLastIndex.Subtype = value; break;

                    case "MaxWidth": tmpLastQL.Width = value; break;

                    case "MaxHeight": tmpLastQL.Height = value; break;
                    }

                    //QualityLevel ql = new QualityLevel();
                    //ql.Bitrate = reader.GetAttribute("Bitrate");
                    //ql.FourCC = reader.GetAttribute("FourCC");
                    //ql.Width = reader.GetAttribute("Width");
                    //ql.Height = reader.GetAttribute("Height");
                    //ql.CodecPrivateData = reader.GetAttribute("CodecPrivateData");
                    //tmpLastIndex.QualityLevels.Add(ql);
                }
            }
        }