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


C# AtomCollection.SetChanInfoBitrate方法代码示例

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


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

示例1: 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

示例2: BroadcastStart_Click

 private void BroadcastStart_Click(object sender, EventArgs args)
 {
   Uri source;
   if (Uri.TryCreate(bcStreamUrl.Text, UriKind.Absolute, out source)) {
     StreamSource = source;
   }
   else {
     StreamSource = null;
   }
   var reader = bcContentType.SelectedItem as ContentReaderItem;
   if (reader!=null) ContentReaderFactory = reader.ContentReaderFactory;
   var yp = bcYP.SelectedItem as YellowPageItem;
   if (yp!=null) YellowPage = yp.YellowPage;
   var info = new AtomCollection();
   int bitrate;
   if (Int32.TryParse(bcBitrate.Text, out bitrate)) {
     info.SetChanInfoBitrate(bitrate);
   }
   info.SetChanInfoName(bcChannelName.Text);
   info.SetChanInfoGenre(bcGenre.Text);
   info.SetChanInfoDesc(bcDescription.Text);
   info.SetChanInfoComment(bcComment.Text);
   info.SetChanInfoURL(bcContactUrl.Text);
   ChannelInfo = new ChannelInfo(info);
   var track = new AtomCollection();
   track.SetChanTrackTitle(bcTrackTitle.Text);
   track.SetChanTrackGenre(bcTrackGenre.Text);
   track.SetChanTrackAlbum(bcAlbum.Text);
   track.SetChanTrackCreator(bcCreator.Text);
   track.SetChanTrackURL(bcTrackURL.Text);
   ChannelTrack = new ChannelTrack(track);
   if (StreamSource!=null && ContentReaderFactory!=null && !String.IsNullOrEmpty(ChannelInfo.Name)) {
     DialogResult = DialogResult.OK;
   }
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:35,代码来源:BroadcastDialog.cs

示例3: 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

示例4: CreateChannelInfo

 private ChannelInfo CreateChannelInfo(BroadcastViewModel viewModel)
 {
     var info = new AtomCollection();
       if (viewModel.bitrate.HasValue) info.SetChanInfoBitrate(viewModel.bitrate.Value);
       info.SetChanInfoName(viewModel.channelName);
       info.SetChanInfoGenre(viewModel.genre);
       info.SetChanInfoDesc(viewModel.description);
       info.SetChanInfoComment(viewModel.comment);
       info.SetChanInfoURL(viewModel.contactUrl);
       return new ChannelInfo(info);
 }
开发者ID:psjp,项目名称:peercaststation,代码行数:11,代码来源:BroadcastViewModel.cs

示例5: Read


//.........这里部分代码省略.........
         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) {
         var timespan = clusters.Sum(c => c.Timespan);
         if (timespan>=30.0) {
           var sz = clusters.Sum(c => c.Timespan>0 ? c.BlockSize : 0);
           var kbps = (int)((sz*8/timespan+900) / 1000.0);
           info.SetChanInfoBitrate(kbps);
           res.ChannelInfo = new ChannelInfo(info);
           while (clusters.Count>1) clusters.RemoveFirst();
         }
       }
       var cluster = new Cluster(elt);
       clusters.AddLast(cluster);
       bodies.Add(elt);
       state = ReaderState.Timecode;
     }
     else if (elt.ID.BinaryEquals(Elements.Void) ||
              elt.ID.BinaryEquals(Elements.CRC32)) {
       elt.ReadBody(stream);
       bodies.Add(elt);
     }
     else {
       throw new BadDataException();
     }
     break;
       case ReaderState.Timecode:
     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;
开发者ID:psjp,项目名称:peercaststation,代码行数:67,代码来源:MKVContentReader.cs

示例6: ReadAsync


//.........这里部分代码省略.........
              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;
                }
                else {
                  child.ReadBody(s);
                }
              }
              headers.Add(elt);
            }
            else {
              await elt.ReadBodyAsync(stream, cancel_token);
              headers.Add(elt);
            }
            break;
          case ReaderState.Cluster:
            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)) {
              if (clusters.Count>0) {
                var timespan = clusters.Sum(c => c.Timespan);
                if (timespan>=30.0) {
                  var sz = clusters.Sum(c => c.Timespan>0 ? c.BlockSize : 0);
                  var kbps = (int)((sz*8/timespan+900) / 1000.0);
                  var info = new AtomCollection();
                  info.SetChanInfoBitrate(kbps);
                  sink.OnChannelInfo(new ChannelInfo(info));
                  while (clusters.Count>1) clusters.RemoveFirst();
                }
              }
              var cluster = new Cluster(elt);
              clusters.AddLast(cluster);
              sink.OnContent(
                new Content(stream_index, DateTime.Now-stream_origin, position, elt.ToArray())
              );
              position += elt.ByteSize;
              state = ReaderState.Timecode;
            }
            else if (elt.ID.BinaryEquals(Elements.Void) ||
                     elt.ID.BinaryEquals(Elements.CRC32)) {
              await elt.ReadBodyAsync(stream, cancel_token);
              sink.OnContent(
                new Content(stream_index, DateTime.Now-stream_origin, position, elt.ToArray())
              );
              position += elt.ByteSize;
            }
            else {
              throw new BadDataException();
            }
            break;
          case ReaderState.Timecode:
            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;
开发者ID:kumaryu,项目名称:peercaststation,代码行数:67,代码来源:MKVContentReader.cs

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