当前位置: 首页>>代码示例>>C#>>正文


C# AtomCollection.SetChanInfoType方法代码示例

本文整理汇总了C#中AtomCollection.SetChanInfoType方法的典型用法代码示例。如果您正苦于以下问题:C# AtomCollection.SetChanInfoType方法的具体用法?C# AtomCollection.SetChanInfoType怎么用?C# AtomCollection.SetChanInfoType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AtomCollection的用法示例。


在下文中一共展示了AtomCollection.SetChanInfoType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

 public ParsedContent Read(Stream stream)
 {
     var chunks = 0;
       var res = new ParsedContent();
       var pos = Channel.ContentPosition;
       try {
     while (chunks<8) {
       var chunk = ASFChunk.Read(stream);
       chunks++;
       switch (chunk.KnownType) {
       case ASFChunk.ChunkType.Header: {
       var header = ASFHeader.Read(chunk);
       var info = new AtomCollection(Channel.ChannelInfo.Extra);
       info.SetChanInfoBitrate(header.Bitrate);
       if (header.Streams.Any(type => type==ASFHeader.StreamType.Video)) {
         info.SetChanInfoType("WMV");
         info.SetChanInfoStreamType("video/x-ms-wmv");
         info.SetChanInfoStreamExt(".wmv");
       }
       else if (header.Streams.Any(type => type==ASFHeader.StreamType.Audio)) {
         info.SetChanInfoType("WMA");
         info.SetChanInfoStreamType("audio/x-ms-wma");
         info.SetChanInfoStreamExt(".wma");
       }
       else {
         info.SetChanInfoType("ASF");
         info.SetChanInfoStreamType("video/x-ms-asf");
         info.SetChanInfoStreamExt(".asf");
       }
       res.ChannelInfo = new ChannelInfo(info);
       streamIndex = Channel.GenerateStreamID();
       streamOrigin = DateTime.Now;
       res.ContentHeader = new Content(streamIndex, TimeSpan.Zero, pos, chunk.ToByteArray());
       pos += chunk.TotalLength;
     }
     break;
       case ASFChunk.ChunkType.Data:
     if (res.Contents==null) res.Contents = new System.Collections.Generic.List<Content>();
     res.Contents.Add(new Content(streamIndex, DateTime.Now-streamOrigin, pos, chunk.ToByteArray()));
     pos += chunk.TotalLength;
     break;
       case ASFChunk.ChunkType.Unknown:
     break;
       }
     }
       }
       catch (EndOfStreamException) {
     if (chunks==0) throw;
       }
       return res;
 }
开发者ID:psjp,项目名称:peercaststation,代码行数:51,代码来源:ASFContentReader.cs

示例2: OnMetaData

 private void OnMetaData(DataMessage msg)
 {
   this.metadata = msg;
   var info = new AtomCollection();
   info.SetChanInfoType("FLV");
   info.SetChanInfoStreamType("video/x-flv");
   info.SetChanInfoStreamExt(".flv");
   if (metadata.Arguments[0].Type==AMF.AMFValueType.ECMAArray || metadata.Arguments[0].Type==AMF.AMFValueType.Object){
     var bitrate = 0.0;
     var val = metadata.Arguments[0]["maxBitrate"];
     if (!AMF.AMFValue.IsNull(val)) {
       double maxBitrate;
       string maxBitrateStr = System.Text.RegularExpressions.Regex.Replace((string)val, @"([\d]+)k", "$1");
       if (double.TryParse(maxBitrateStr, out maxBitrate)) {
         bitrate += maxBitrate;
       }
     }
     else if (!AMF.AMFValue.IsNull(val = metadata.Arguments[0]["videodatarate"])) {
       bitrate += (double)val;
     }
     if (!AMF.AMFValue.IsNull(val = metadata.Arguments[0]["audiodatarate"])) {
       bitrate += (double)val;
     }
     info.SetChanInfoBitrate((int)bitrate);
   }
   OnChannelInfoChanged(info);
   OnHeaderChanged(msg);
   OnContentChanged(msg);
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:29,代码来源:FLVContentBuffer.cs

示例3: Read

 public ParsedContent Read(Stream stream)
 {
     if (stream.Length-stream.Position<=0) throw new EndOfStreamException();
       var res = new ParsedContent();
       var pos = Channel.ContentPosition;
       if (Channel.ContentHeader==null) {
     streamIndex = Channel.GenerateStreamID();
     streamOrigin = DateTime.Now;
     res.ContentHeader = new Content(streamIndex, TimeSpan.Zero, pos, new byte[] { });
     var channel_info = new AtomCollection(Channel.ChannelInfo.Extra);
     channel_info.SetChanInfoType("RAW");
     channel_info.SetChanInfoStreamType("application/octet-stream");
     channel_info.SetChanInfoStreamExt("");
     res.ChannelInfo = new ChannelInfo(channel_info);
       }
       res.Contents = new List<Content>();
       while (stream.Length-stream.Position>0) {
     var bytes = new byte[Math.Min(8192, stream.Length-stream.Position)];
     var sz = stream.Read(bytes, 0, bytes.Length);
     if (sz>0) {
       Array.Resize(ref bytes, sz);
       res.Contents.Add(new Content(streamIndex, DateTime.Now-streamOrigin, pos, bytes));
       pos += sz;
     }
       }
       return res;
 }
开发者ID:At-sushi,项目名称:peercaststation,代码行数:27,代码来源:RawContentReader.cs

示例4: OnFLVHeader

 public void OnFLVHeader()
 {
   var info = new AtomCollection();
   info.SetChanInfoType("FLV");
   info.SetChanInfoStreamType("video/x-flv");
   info.SetChanInfoStreamExt(".flv");
   OnChannelInfoChanged(info);
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:8,代码来源:FLVContentBuffer.cs

示例5: OnPCPChanInfo

 protected void OnPCPChanInfo(Atom atom)
 {
     var channel_info = new ChannelInfo(atom.Children);
       var content_type = channel_info.ContentType;
       if (content_type==null || content_type=="UNKNOWN") {
     var header = Channel.ContentHeader;
     string mime_type = null;
     if (header!=null &&
     PeerCast.ContentReaderFactories.Any(
       factory => factory.TryParseContentType(header.Data, out content_type, out mime_type))) {
       var new_info = new AtomCollection(atom.Children);
       new_info.SetChanInfoType(content_type);
       new_info.SetChanInfoStreamType(mime_type);
       channel_info = new ChannelInfo(new_info);
     }
       }
       Channel.ChannelInfo = channel_info;
       BroadcastHostInfo();
 }
开发者ID:At-sushi,项目名称:peercaststation,代码行数:19,代码来源:PCPSourceStream.cs

示例6: Read

 public ParsedContent Read(Stream stream)
 {
     var res = new ParsedContent();
       var bodies = new List<Element>();
       var info = new AtomCollection(Channel.ChannelInfo.Extra);
       var processed = false;
       var eos = false;
       while (!eos) {
     var start_pos = stream.Position;
     try {
       var elt = Element.ReadHeader(stream);
       if (ebml.MaxIDLength  <elt.ID.Length ||
       ebml.MaxSizeLength<elt.Size.Length) {
     throw new BadDataException();
       }
       switch (state) {
       case ReaderState.EBML:
     if (elt.ID.BinaryEquals(Elements.EBML)) {
       elt.ReadBody(stream);
       ebml = new EBML(elt);
       state = ReaderState.Segment;
     }
     else {
       throw new BadDataException();
     }
     break;
       case ReaderState.Segment:
     if (elt.ID.BinaryEquals(Elements.Segment)) {
       segment = new Segment(elt);
       state = ReaderState.EndOfHeader;
     }
     else if (elt.ID.BinaryEquals(Elements.EBML)) {
       stream.Position = elt.Position;
       state = ReaderState.EBML;
       continue;
     }
     else if (elt.ID.BinaryEquals(Elements.Void) ||
              elt.ID.BinaryEquals(Elements.CRC32)) {
       elt.ReadBody(stream);
     }
     else {
       throw new BadDataException();
     }
     break;
       case ReaderState.EndOfHeader:
     if (elt.ID.BinaryEquals(Elements.Segment)) {
       stream.Position = elt.Position;
       state = ReaderState.Segment;
       continue;
     }
     else if (elt.ID.BinaryEquals(Elements.EBML)) {
       stream.Position = elt.Position;
       state = ReaderState.EBML;
       continue;
     }
     else if (elt.ID.BinaryEquals(Elements.Cluster)) {
       stream.Position = elt.Position;
       state = ReaderState.Cluster;
       clusters.Clear();
       MemoryStream header;
       using (header=new MemoryStream()) {
         ebml.Element.Write(header);
         segment.Element.Write(header);
         foreach (var c in segment.HeaderElements) {
           c.Write(header);
         }
       }
       streamIndex = Channel.GenerateStreamID();
       streamOrigin = DateTime.Now;
       res.ContentHeader = new Content(streamIndex, TimeSpan.Zero, 0, header.ToArray());
       if (ebml.DocType=="webm") {
         info.SetChanInfoType("WEBM");
         info.SetChanInfoStreamType("video/webm");
         info.SetChanInfoStreamExt(".webm");
       }
       else {
         info.SetChanInfoType("MKV");
         info.SetChanInfoStreamType("video/x-matroska");
         info.SetChanInfoStreamExt(".mkv");
       }
       res.ChannelInfo = new ChannelInfo(info);
     }
     else {
       elt.ReadBody(stream);
       segment.AddHeader(elt);
     }
     break;
       case ReaderState.Cluster:
     if (elt.ID.BinaryEquals(Elements.Segment)) {
       stream.Position = elt.Position;
       state = ReaderState.Segment;
       continue;
     }
     else if (elt.ID.BinaryEquals(Elements.EBML)) {
       stream.Position = elt.Position;
       state = ReaderState.EBML;
       continue;
     }
     else if (elt.ID.BinaryEquals(Elements.Cluster)) {
       if (clusters.Count>0) {
//.........这里部分代码省略.........
开发者ID:psjp,项目名称:peercaststation,代码行数:101,代码来源:MKVContentReader.cs

示例7: ReadAsync

    public async Task ReadAsync(IContentSink sink, Stream stream, CancellationToken cancel_token)
    {
      var state = ReaderState.EBML;
      var position = 0L;
      var stream_index = -1;
      var stream_origin = DateTime.Now;
      var timecode_scale = 1000000.0;
      var ebml     = new EBML();
      var clusters = new LinkedList<Cluster>();
      var headers  = new List<Element>();

      var eos = false;
      while (!eos) {
        try {
          var elt = await Element.ReadHeaderAsync(stream, cancel_token);
          if (ebml.MaxIDLength  <elt.ID.Length ||
              ebml.MaxSizeLength<elt.Size.Length) {
            throw new BadDataException();
          }
        parse_retry:
          switch (state) {
          case ReaderState.EBML:
            if (elt.ID.BinaryEquals(Elements.EBML)) {
              await elt.ReadBodyAsync(stream, cancel_token);
              headers.Clear();
              headers.Add(elt);
              ebml = new EBML(elt);
              state = ReaderState.Segment;
            }
            else {
              throw new BadDataException();
            }
            break;
          case ReaderState.Segment:
            if (elt.ID.BinaryEquals(Elements.Segment)) {
              headers.Add(elt);
              state = ReaderState.EndOfHeader;
            }
            else if (elt.ID.BinaryEquals(Elements.EBML)) {
              state = ReaderState.EBML;
              goto parse_retry;
            }
            else if (elt.ID.BinaryEquals(Elements.Void) ||
                     elt.ID.BinaryEquals(Elements.CRC32)) {
              await elt.ReadBodyAsync(stream, cancel_token);
              headers.Add(elt);
            }
            else {
              throw new BadDataException();
            }
            break;
          case ReaderState.EndOfHeader:
            if (elt.ID.BinaryEquals(Elements.Segment)) {
              state = ReaderState.Segment;
              goto parse_retry;
            }
            else if (elt.ID.BinaryEquals(Elements.EBML)) {
              state = ReaderState.EBML;
              goto parse_retry;
            }
            else if (elt.ID.BinaryEquals(Elements.Cluster)) {
              clusters.Clear();
              MemoryStream header;
              using (header=new MemoryStream()) {
                foreach (var c in headers) {
                  c.Write(header);
                }
              }
              headers.Clear();

              stream_index  = Channel.GenerateStreamID();
              stream_origin = DateTime.Now;
              position = 0;
              sink.OnContentHeader(
                new Content(stream_index, TimeSpan.Zero, 0, header.ToArray())
              );
              position += header.ToArray().LongLength;
              var info = new AtomCollection();
              if (ebml.DocType=="webm") {
                info.SetChanInfoType("WEBM");
                info.SetChanInfoStreamType("video/webm");
                info.SetChanInfoStreamExt(".webm");
              }
              else {
                info.SetChanInfoType("MKV");
                info.SetChanInfoStreamType("video/x-matroska");
                info.SetChanInfoStreamExt(".mkv");
              }
              sink.OnChannelInfo(new ChannelInfo(info));

              state = ReaderState.Cluster;
              goto parse_retry;
            }
            else if (elt.ID.BinaryEquals(Elements.Info)) {
              await elt.ReadBodyAsync(stream, cancel_token);
              var s = new MemoryStream(elt.Data);
              while (s.Position<s.Length) {
                var child = Element.ReadHeader(s);
                if (child.ID.BinaryEquals(Elements.TimecodeScale)) {
                  timecode_scale = Element.ReadUInt(s, child.Size.Value) * 1.0;
//.........这里部分代码省略.........
开发者ID:kumaryu,项目名称:peercaststation,代码行数:101,代码来源:MKVContentReader.cs

示例8: ResetContentType

    private ChannelInfo ResetContentType(ChannelInfo channel_info, Content content_header)
    {
      if (channel_info==null) throw new ArgumentNullException("channel_info");

      var content_type = channel_info.ContentType;
      if (content_type==null || content_type=="UNKNOWN") {
        string mime_type = null;
        if (content_header!=null &&
            PeerCast.ContentReaderFactories.Any(
              factory => factory.TryParseContentType(content_header.Data, out content_type, out mime_type))) {
          var new_info = new AtomCollection(channel_info.Extra);
          new_info.SetChanInfoType(content_type);
          new_info.SetChanInfoStreamType(mime_type);
          channel_info = new ChannelInfo(new_info);
        }
      }
      return channel_info;
    }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:18,代码来源:PCPSourceStream.cs

示例9: Read

 public ParsedContent Read(Stream stream)
 {
     var res = new ParsedContent();
       var info = new AtomCollection(Channel.ChannelInfo.Extra);
       var processed = false;
       var eos = false;
       while (!eos) {
     var start_pos = stream.Position;
     try {
       switch (state) {
       case ReaderState.Header:
     {
       var bin = ReadBytes(stream, 13);
       var header = new FileHeader(bin);
       if (header.IsValid) {
         Logger.Info("FLV Header found");
         fileHeader = header;
         bin = header.Binary;
         res.ContentHeader = new Content(position, bin);
         res.Contents = null;
         info.SetChanInfoType("FLV");
         info.SetChanInfoStreamType("video/x-flv");
         info.SetChanInfoStreamExt(".flv");
         res.ChannelInfo = new ChannelInfo(info);
         position = bin.Length;
         tags.Clear();
         state = ReaderState.Body;
       }
       else {
         throw new BadDataException();
       }
     }
     break;
       case ReaderState.Body:
     {
       var bin = ReadBytes(stream, 11);
       var read_valid = false;
       var body = new FLVTag(bin);
       if (body.IsValidHeader) {
         body.ReadBody(stream);
         body.ReadFooter(stream);
         if (body.IsValidFooter) {
           read_valid = true;
           bin = body.Binary;
           if (res.Contents==null) res.Contents = new List<Content>();
           res.Contents.Add(new Content(position, bin));
           tags.AddLast(new TagDesc { Timestamp=body.Timestamp/1000.0, DataSize=body.DataSize });
           var timespan = tags.Last.Value.Timestamp-tags.First.Value.Timestamp;
           if (timespan>=30.0) {
             var sz = tags.Take(tags.Count-1).Sum(t => t.DataSize);
             info.SetChanInfoBitrate((int)(sz*8/timespan+900)/1000);
             res.ChannelInfo = new ChannelInfo(info);
             while (tags.Count>1) tags.RemoveFirst();
           }
           position += bin.Length;
         }
       }
       if (!read_valid) {
         stream.Position = start_pos;
         var header = new FileHeader(ReadBytes(stream, 13));
         if (header.IsValid) {
           Logger.Info("New FLV Header found");
           read_valid = true;
           fileHeader = header;
           bin = header.Binary;
           res.ContentHeader = new Content(0, bin);
           res.Contents = null;
           info.SetChanInfoType("FLV");
           info.SetChanInfoStreamType("video/x-flv");
           info.SetChanInfoStreamExt(".flv");
           res.ChannelInfo = new ChannelInfo(info);
           tags.Clear();
           position = bin.Length;
         }
       }
       if (!read_valid) throw new BadDataException();
     }
     break;
       }
       processed = true;
     }
     catch (EndOfStreamException) {
       if (!processed) throw;
       stream.Position = start_pos;
       eos = true;
     }
     catch (BadDataException) {
       stream.Position = start_pos+1;
     }
       }
       return res;
 }
开发者ID:j0hn---,项目名称:peercaststation,代码行数:92,代码来源:FLVContentReader.cs


注:本文中的AtomCollection.SetChanInfoType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。