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


C# StreamState类代码示例

本文整理汇总了C#中StreamState的典型用法代码示例。如果您正苦于以下问题:C# StreamState类的具体用法?C# StreamState怎么用?C# StreamState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetAudioArguments

        /// <summary>
        /// Gets the audio arguments.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>System.String.</returns>
        protected override string GetAudioArguments(StreamState state)
        {
            var codec = GetAudioCodec(state.Request);

            var args = "-codec:a " + codec;

            var channels = GetNumAudioChannelsParam(state.Request, state.AudioStream);

            if (channels.HasValue)
            {
                args += " -ac " + channels.Value;
            }

            if (state.Request.AudioSampleRate.HasValue)
            {
                args += " -ar " + state.Request.AudioSampleRate.Value;
            }

            if (state.Request.AudioBitRate.HasValue)
            {
                args += " -ab " + state.Request.AudioBitRate.Value;
            }

            return args;
        }
开发者ID:Brendon-MB3,项目名称:MediaBrowser,代码行数:30,代码来源:AudioHlsService.cs

示例2: Allow

  /////////////
  /// Public Methods
  ////////////
 
  /**
   * Implementing the interface from ITransferManager
   * When a request is allowed, we set up the state and
   * start acting
   */
  public Status Allow(Request req, System.IO.Stream data) {
 
    Status stat = new Status(req, data);
    lock( _sync ) { 
      _tid_to_status[req.LocalTID] = stat; 
    }

    if( req.Reqtype == Opcode.ReadReq ) {
      /**
       * We are starting a read request here.  We send the
       * first data packet as an ack of this request
       */
      StreamState rs = new StreamState();
      int new_block = 1;
      stat.StartBlock(new_block, rs);
      rs.Stat = stat;
      rs.Block = new_block;
      rs.Data = new byte[ stat.Request.Blksize ];
      rs.Offset = 0;
      stat.Data.BeginRead(rs.Data, rs.Offset, stat.Request.Blksize,
			  new AsyncCallback(this.ReadHandler),
			  rs);
    }
    else if( req.Reqtype == Opcode.WriteReq ) {
      SendAck(req, 0);
    }
    else {
      /**
       * This can't happen because we would only process Read or Write
       * requests
       * @todo add error handling if ReqType is non-sensical
       */
    }
    return stat;
  }
开发者ID:xujyan,项目名称:brunet,代码行数:44,代码来源:Agent.cs

示例3: GetManifestText

        public string GetManifestText(StreamState state, string playlistUrl)
        {
            var builder = new StringBuilder();

            var time = TimeSpan.FromTicks(state.RunTimeTicks.Value);

            var duration = "PT" + time.Hours.ToString("00", UsCulture) + "H" + time.Minutes.ToString("00", UsCulture) + "M" + time.Seconds.ToString("00", UsCulture) + ".00S";

            builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

            builder.AppendFormat(
                "<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:mpeg:dash:schema:mpd:2011\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd\" profiles=\"urn:mpeg:dash:profile:isoff-live:2011\" type=\"static\" mediaPresentationDuration=\"{0}\" minBufferTime=\"PT5.0S\">",
                duration);

            builder.Append("<ProgramInformation>");
            builder.Append("</ProgramInformation>");

            builder.Append("<Period start=\"PT0S\">");
            builder.Append(GetVideoAdaptationSet(state, playlistUrl));
            builder.Append(GetAudioAdaptationSet(state, playlistUrl));
            builder.Append("</Period>");

            builder.Append("</MPD>");

            return builder.ToString();
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:26,代码来源:ManifestBuilder.cs

示例4: GetCommandLineArguments

        /// <summary>
        /// Gets the command line arguments.
        /// </summary>
        /// <param name="outputPath">The output path.</param>
        /// <param name="state">The state.</param>
        /// <param name="performSubtitleConversions">if set to <c>true</c> [perform subtitle conversions].</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.InvalidOperationException">Only aac and mp3 audio codecs are supported.</exception>
        protected override string GetCommandLineArguments(string outputPath, StreamState state, bool performSubtitleConversions)
        {
            var request = state.Request;

            var audioTranscodeParams = new List<string>();

            var bitrate = GetAudioBitrateParam(state);

            if (bitrate.HasValue)
            {
                audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(UsCulture));
            }

            var channels = GetNumAudioChannelsParam(request, state.AudioStream);

            if (channels.HasValue)
            {
                audioTranscodeParams.Add("-ac " + channels.Value);
            }
            
            if (request.AudioSampleRate.HasValue)
            {
                audioTranscodeParams.Add("-ar " + request.AudioSampleRate.Value);
            }

            const string vn = " -vn";

            return string.Format("{0} -i {1}{2} -threads 0{5} {3} -id3v2_version 3 -write_id3v1 1 \"{4}\"",
                GetFastSeekCommandLineParameter(request),
                GetInputArgument(state.Item, state.IsoMount),
                GetSlowSeekCommandLineParameter(request),
                string.Join(" ", audioTranscodeParams.ToArray()),
                outputPath,
                vn).Trim();
        }
开发者ID:Jon-theHTPC,项目名称:MediaBrowser,代码行数:43,代码来源:AudioService.cs

示例5: GetCommandLineArguments

        protected override string GetCommandLineArguments(string outputPath, string transcodingJobId, StreamState state, bool isEncoding)
        {
            var audioTranscodeParams = new List<string>();

            var bitrate = state.OutputAudioBitrate;

            if (bitrate.HasValue)
            {
                audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(UsCulture));
            }

            if (state.OutputAudioChannels.HasValue)
            {
                audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
            }

            if (state.OutputAudioSampleRate.HasValue)
            {
                audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
            }

            const string vn = " -vn";

            var threads = GetNumberOfThreads(state, false);

            var inputModifier = GetInputModifier(state);

            return string.Format("{0} -i {1} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1 -y \"{5}\"",
                inputModifier,
                GetInputArgument(transcodingJobId, state),
                threads,
                vn,
                string.Join(" ", audioTranscodeParams.ToArray()),
                outputPath).Trim();
        }
开发者ID:bigjohn322,项目名称:MediaBrowser,代码行数:35,代码来源:AudioService.cs

示例6: ProcessRequestAsync

        /// <summary>
        /// Processes the request async.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>Task{System.Object}.</returns>
        public async Task<object> ProcessRequestAsync(StreamState state)
        {
            var playlist = GetOutputFilePath(state);
            var isPlaylistNewlyCreated = false;

            // If the playlist doesn't already exist, startup ffmpeg
            if (!File.Exists(playlist))
            {
                isPlaylistNewlyCreated = true;
                await StartFfMpeg(state, playlist).ConfigureAwait(false);
            }
            else
            {
                ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType.Hls);
            }

            // Get the current playlist text and convert to bytes
            var playlistText = await GetPlaylistFileText(playlist, isPlaylistNewlyCreated).ConfigureAwait(false);

            try
            {
                return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
            }
            finally
            {
                ApiEntryPoint.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);
            }
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:33,代码来源:BaseHlsService.cs

示例7: GetAudioArguments

        /// <summary>
        /// Gets the audio arguments.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>System.String.</returns>
        protected override string GetAudioArguments(StreamState state)
        {
            var codec = GetAudioEncoder(state);

            if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
            {
                return "-codec:a:0 copy";
            }

            var args = "-codec:a:0 " + codec;

            var channels = state.OutputAudioChannels;

            if (channels.HasValue)
            {
                args += " -ac " + channels.Value;
            }

            var bitrate = state.OutputAudioBitrate;

            if (bitrate.HasValue)
            {
                args += " -ab " + bitrate.Value.ToString(UsCulture);
            }

            args += " " + GetAudioFilterParam(state, true);

            return args;
        }
开发者ID:NickBolles,项目名称:Emby,代码行数:34,代码来源:VideoHlsService.cs

示例8: GetVideoRepresentationOpenElement

        private string GetVideoRepresentationOpenElement(StreamState state)
        {
            var codecs = GetVideoCodecDescriptor(state);

            var mime = "video/mp4";

            var xml = "<Representation id=\"0\" mimeType=\"" + mime + "\" codecs=\"" + codecs + "\"";

            if (state.OutputWidth.HasValue)
            {
                xml += " width=\"" + state.OutputWidth.Value.ToString(UsCulture) + "\"";
            }
            if (state.OutputHeight.HasValue)
            {
                xml += " height=\"" + state.OutputHeight.Value.ToString(UsCulture) + "\"";
            }
            if (state.OutputVideoBitrate.HasValue)
            {
                xml += " bandwidth=\"" + state.OutputVideoBitrate.Value.ToString(UsCulture) + "\"";
            }

            xml += ">";

            return xml;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:25,代码来源:ManifestBuilder.cs

示例9: FlowState

        internal FlowState(Flow flow)
        {
            this.Tasks = new List<TaskState>();
            this.Art = flow.Art;

            foreach (var task in flow.Nodes)
            {
                TaskState state = new TaskState()
                {
                    ItemsProcessed = task.ItemsProcessed,
                    Name = task.Name,
                    Status = task.Status,
                    TotalSecondsBlocked = task.TotalSecondsBlocked,
                    TotalSecondsProcessing = task.TotalSecondsProcessing,
                    Position = task.Position
                };

                this.Tasks.Add(state);
            }
            this.Streams = new List<StreamState>();
            foreach (var stream in flow.Streams)
            {
                StreamState state = new StreamState()
                {
                    Name = stream.Name,
                    Closed = stream.IsClosed,
                    Count = stream.Count,
                    InPoint = stream.InPoint
                };
                this.Streams.Add(state);
            }
        }
开发者ID:Teun,项目名称:BatchFlow,代码行数:32,代码来源:FlowState.cs

示例10: GetOutputFileExtension

        /// <summary>
        /// Gets the output file extension.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>System.String.</returns>
        protected override string GetOutputFileExtension(StreamState state)
        {
            var ext = base.GetOutputFileExtension(state);

            if (!string.IsNullOrEmpty(ext))
            {
                return ext;
            }

            var isVideoRequest = state.VideoRequest != null;

            // Try to infer based on the desired video codec
            if (isVideoRequest)
            {
                var videoCodec = state.VideoRequest.VideoCodec;

                if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
                {
                    return ".ts";
                }
                if (string.Equals(videoCodec, "theora", StringComparison.OrdinalIgnoreCase))
                {
                    return ".ogv";
                }
                if (string.Equals(videoCodec, "vpx", StringComparison.OrdinalIgnoreCase))
                {
                    return ".webm";
                }
                if (string.Equals(videoCodec, "wmv", StringComparison.OrdinalIgnoreCase))
                {
                    return ".asf";
                }
            }

            // Try to infer based on the desired audio codec
            if (!isVideoRequest)
            {
                var audioCodec = state.Request.AudioCodec;

                if (string.Equals("aac", audioCodec, StringComparison.OrdinalIgnoreCase))
                {
                    return ".aac";
                }
                if (string.Equals("mp3", audioCodec, StringComparison.OrdinalIgnoreCase))
                {
                    return ".mp3";
                }
                if (string.Equals("vorbis", audioCodec, StringComparison.OrdinalIgnoreCase))
                {
                    return ".ogg";
                }
                if (string.Equals("wma", audioCodec, StringComparison.OrdinalIgnoreCase))
                {
                    return ".wma";
                }
            }

            return null;
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:64,代码来源:BaseProgressiveStreamingService.cs

示例11: GetOutputFilePath

        protected override string GetOutputFilePath(StreamState state)
        {
            var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;

            var outputFileExtension = GetOutputFileExtension(state);

            return Path.Combine(folder, GetCommandLineArguments("dummy\\dummy", state, false).GetMD5() + (outputFileExtension ?? string.Empty).ToLower());
        }
开发者ID:jscorrea,项目名称:MediaBrowser,代码行数:8,代码来源:BaseHlsService.cs

示例12: GetOutputFilePath

        protected override string GetOutputFilePath(StreamState state)
        {
            var folder = ApplicationPaths.EncodedMediaCachePath;

            var outputFileExtension = GetOutputFileExtension(state);

            return Path.Combine(folder, GetCommandLineArguments("dummy\\dummy", state, false).GetMD5() + (outputFileExtension ?? string.Empty).ToLower());
        }
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:8,代码来源:BaseHlsService.cs

示例13: GetOutputFileExtension

        /// <summary>
        /// Gets the output file extension.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>System.String.</returns>
        protected override string GetOutputFileExtension(StreamState state)
        {
            var ext = base.GetOutputFileExtension(state);

            if (!string.IsNullOrEmpty(ext))
            {
                return ext;
            }

            var videoRequest = state.Request as VideoStreamRequest;

            // Try to infer based on the desired video codec
            if (videoRequest != null && videoRequest.VideoCodec.HasValue)
            {
                var video = state.Item as Video;

                if (video != null)
                {
                    switch (videoRequest.VideoCodec.Value)
                    {
                        case VideoCodecs.H264:
                            return ".ts";
                        case VideoCodecs.Theora:
                            return ".ogv";
                        case VideoCodecs.Vpx:
                            return ".webm";
                        case VideoCodecs.Wmv:
                            return ".asf";
                    }
                }
            }

            // Try to infer based on the desired audio codec
            if (state.Request.AudioCodec.HasValue)
            {
                var audio = state.Item as Audio;

                if (audio != null)
                {
                    switch (state.Request.AudioCodec.Value)
                    {
                        case AudioCodecs.Aac:
                            return ".aac";
                        case AudioCodecs.Mp3:
                            return ".mp3";
                        case AudioCodecs.Vorbis:
                            return ".ogg";
                        case AudioCodecs.Wma:
                            return ".wma";
                    }
                }
            }

            return null;
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:60,代码来源:BaseProgressiveStreamingService.cs

示例14: ProcessRequestAsync

        /// <summary>
        /// Processes the request async.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>Task{System.Object}.</returns>
        public async Task<object> ProcessRequestAsync(StreamState state)
        {
            if (!state.VideoRequest.VideoBitRate.HasValue && (!state.VideoRequest.VideoCodec.HasValue || state.VideoRequest.VideoCodec.Value != VideoCodecs.Copy))
            {
                throw new ArgumentException("A video bitrate is required");
            }
            if (!state.Request.AudioBitRate.HasValue && (!state.Request.AudioCodec.HasValue || state.Request.AudioCodec.Value != AudioCodecs.Copy))
            {
                throw new ArgumentException("An audio bitrate is required");
            }

            var playlist = GetOutputFilePath(state);
            var isPlaylistNewlyCreated = false;

            // If the playlist doesn't already exist, startup ffmpeg
            if (!File.Exists(playlist))
            {
                isPlaylistNewlyCreated = true;
                await StartFfMpeg(state, playlist).ConfigureAwait(false);
            }
            else
            {
                ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType.Hls);
            }

            if (isPlaylistNewlyCreated)
            {
                await WaitForMinimumSegmentCount(playlist, 3).ConfigureAwait(false);
            }

            int audioBitrate;
            int videoBitrate;
            GetPlaylistBitrates(state, out audioBitrate, out videoBitrate);

            var appendBaselineStream = false;
            var baselineStreamBitrate = 64000;

            var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream;
            if (hlsVideoRequest != null)
            {
                appendBaselineStream = hlsVideoRequest.AppendBaselineStream;
                baselineStreamBitrate = hlsVideoRequest.BaselineStreamAudioBitRate ?? baselineStreamBitrate;
            }

            var playlistText = GetMasterPlaylistFileText(playlist, videoBitrate + audioBitrate, appendBaselineStream, baselineStreamBitrate);

            try
            {
                return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
            }
            finally
            {
                ApiEntryPoint.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);
            }
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:60,代码来源:BaseHlsService.cs

示例15: UserStreamReceiver

 public UserStreamReceiver(ApiAccessor accessor, IStreamHandler handler)
 {
     _accessor = accessor;
     _handler = handler;
     ChangeState(StreamState.Disconnected);
     // set default values to parameters
     StallWarnings = true;
     StreamFilterLevel = StreamFilterLevel.None;
     _currentState = StreamState.Connected;
     _backoffMode = BackoffMode.None;
     _backoffWait = 0;
     _hardErrorCount = 0;
 }
开发者ID:karno,项目名称:Cadena,代码行数:13,代码来源:UserStreamReceiver.cs


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