• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MediaStreamType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            MediaStreamSample audioSample = null;

            if (!sample_enumerator.MoveNext ())
            {
                // If you are near the end of the file, return a null stream, which
                // tells the MediaStreamSource and MediaElement to close down.
                audioSample = new MediaStreamSample(
                    this.audioStreamDescription,
                    null,
                    0,
                    0,
                    0,
                    emptyDict);
                this.ReportGetSampleCompleted(audioSample);
            }
            else
            {
                // FIXME: Stream should not be created every time.
                SampleBuffer buf = (SampleBuffer) sample_enumerator.Current;
                audioSample = new MediaStreamSample(
                    this.audioStreamDescription,
                    new MemoryStream (buf.Data, buf.Index, buf.Count, false),
                    buf.Index,
                    buf.Count,
                    timePosition,
                    emptyDict);
                timePosition += buf.Count * 10000000 / (44100 * 2 * 2);
                this.ReportGetSampleCompleted(audioSample);
            }
        }
开发者ID:mono,项目名称:mooncodecs,代码行数:32,代码来源:AdpcmMediaStreamSource.cs


示例2: GetSampleAsync

        //private int AlignUp(int a, int b)
        //{
        //    int tmp = a + b - 1;
        //    return tmp - (tmp % b);
        //}
        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            int numSamples = ChannelCount * 256;
            int bufferByteCount = BitsPerSample / 8 * numSamples;

            // fill the stream with noise
            for (int i = 0; i < numSamples; i++)
            {
                short sample = (short)_random.Next(
                    short.MinValue, short.MaxValue);

                _stream.Write(BitConverter.GetBytes(sample),
                              0,
                              sizeof(short));
            }

            // Send out the next sample
            MediaStreamSample msSamp = new MediaStreamSample(
                _audioDesc,
                _stream,
                _currentPosition,
                bufferByteCount,
                _currentTimeStamp,
                _emptySampleDict);

            // Move our timestamp and position forward
            _currentTimeStamp += _waveFormat.AudioDurationFromBufferSize(
                                    (uint)bufferByteCount);
            _currentPosition += bufferByteCount;

            ReportGetSampleCompleted(msSamp);
        }
开发者ID:prog76,项目名称:Pacman,代码行数:37,代码来源:MyMediaStreamSource.cs


示例3: GetMediaStreamTypes

 /// <summary>
 /// メディアストリームタイプ一覧を得る
 /// </summary>
 /// <param name="deviceIndex">デバイスインデックス</param>
 /// <returns>一覧</returns>
 public async Task<string[]> GetMediaStreamTypes(int deviceIndex)
 {
     if (!(deviceIndex < _Devices.Count))
     {
         // 無効なindexを排除する
         return null;
     }
     selectedId = _Devices[deviceIndex].Id;
     _Settings.VideoDeviceId = selectedId;
     await _MediaCapture.InitializeAsync(_Settings);
     var types = new MediaStreamType[] { MediaStreamType.Photo, MediaStreamType.VideoPreview, MediaStreamType.VideoRecord };
     _MediaStreamTypes = new List<MediaStreamType>();
     foreach (var type in types)
     {
         var properties = _MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(type);
         // VideoEncodingProperty/ImageEncodngPropertyの区別が必要
         if (properties.Count > 0)
         {
             _MediaStreamTypes.Add(type);
         }
     }
     var result = new List<string>();
     foreach (var type in _MediaStreamTypes)
     {
         result.Add(type.ToString());
     }
     return result.ToArray();
 }
开发者ID:yono-ms,项目名称:VisualStudioWorkbench,代码行数:33,代码来源:CameraUtility.cs


示例4: MediaChunk

 /// <summary>
 /// Initializes a new instance of the MediaChunk class
 /// </summary>
 /// <param name="chunkId">the id of this chunk</param>
 /// <param name="mediaType">the media type of this chunk</param>
 /// <param name="streamId">the id of the stream this chunk is contained in</param>
 public MediaChunk(int chunkId, MediaStreamType mediaType, int streamId)
 {
     ChunkId = chunkId;
     MediaType = mediaType;
     StreamId = streamId;
     DownloadedPiece = null;
 }
开发者ID:Titaye,项目名称:SLExtensions,代码行数:13,代码来源:MediaChunk.cs


示例5: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            for (int i = 0; i < numSamples; i++)
            {

                if (this.index < this.StartPoint |
                    this.index > this.EndPoint)
                    this.index = this.StartPoint;

                memoryStream.WriteByte(this.sourceData[index]);
                memoryStream.WriteByte(this.sourceData[index + 1]);
                memoryStream.WriteByte(this.sourceData[index + 2]);
                memoryStream.WriteByte(this.sourceData[index + 3]);

                index += 4;
            }

            MediaStreamSample mediaStreamSample =
                new MediaStreamSample(
                    mediaStreamDescription,
                    memoryStream,
                    currentPosition,
                    bufferByteCount,
                    currentTimeStamp,
                    emptySampleDict);

            currentTimeStamp += bufferByteCount * 10000000L / byteRate;
            currentPosition += bufferByteCount;

            ReportGetSampleCompleted(mediaStreamSample);
        }
开发者ID:kindohm,项目名称:silverlight-mic-capture,代码行数:31,代码来源:AudioDecoder.cs


示例6: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            for (int i = 0; i < numSamples; i++)
            {
                StereoSample sample;
                if (this.Input != null)
                    sample = this.Input.GetSample();
                else
                    sample = new StereoSample();

                //left channel
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample & 0xFF));
                memoryStream.WriteByte(
                    (byte)(sample.LeftSample >> 8));


                //right channel
                memoryStream.WriteByte(
                        (byte)(sample.RightSample & 0xFF));
                memoryStream.WriteByte(
                        (byte)(sample.RightSample >> 8));

            }

            MediaStreamSample mediaStreamSample =
                new MediaStreamSample(mediaStreamDescription, memoryStream, currentPosition,
                                      bufferByteCount, currentTimeStamp, emptySampleDict);

            currentTimeStamp += bufferByteCount * 10000000L / byteRate;
            currentPosition += bufferByteCount;

            ReportGetSampleCompleted(mediaStreamSample);
        }
开发者ID:cmcginn,项目名称:MHFinance,代码行数:34,代码来源:StereoPcmStreamSource.cs


示例7: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            lock (_syncRoot)
            {
                if (_pendingPackets.Count > 0)
                {
                    var frame = _pendingPackets.First.Value;
                    _pendingPackets.RemoveFirst();
                    long ts = frame.getTimeStamp();
                    ts *= 10000;
                    var attrs = frame.isFrameTypeI() ? _iSampleAttrs : _pSampleAttrs;
                    attrs[MediaSampleAttributeKeys.FrameWidth] = frame.getWidth().ToString();
                    attrs[MediaSampleAttributeKeys.FrameHeight] = frame.getHeight().ToString();
                    Debug.WriteLine("GetSample completed");
                    ReportGetSampleCompleted(new MediaStreamSample(_mediaStreamDescription,
                                                                   new ARDroneVideoPacketStream(frame),
                                                                   0,
                                                                   frame.getDataLength(),
                                                                   ts, attrs));
                }
                else
                {
                    ++_waitingForPacket;

                    Debug.WriteLine("GetSample progress");
                    ReportGetSampleProgress(0);
                }
            }
        }
开发者ID:Eggies,项目名称:SDK,代码行数:29,代码来源:ARDroneStreamSource.cs


示例8: GetSampleAsync

		protected override void GetSampleAsync (MediaStreamType mediaStreamType)
		{
			Mp3Frame frame;
			MediaStreamSample sample;
			Dictionary<MediaSampleAttributeKeys, string> attribs = new Dictionary<MediaSampleAttributeKeys, string> ();

			//string format = "HH:mm:ss.ffff";
			//if (opened == DateTime.MinValue)
			//    opened = DateTime.Now;
			//Debug.WriteLine ("{0} GetSampleAsync stamp: {1}", (DateTime.Now - opened).ToString (), TimeSpan.FromMilliseconds (current_pts / 10000).ToString ());

			try {
				if (this.frame != null) {
					frame = this.frame;
					this.frame = null;
				} else {
					frame = Mp3Frame.Read (stream);
				}

				sample = new MediaStreamSample (description, new MemoryStream (frame.data), 0, frame.data.Length, current_pts, attribs);

				current_pts += frame.Duration;

				ReportGetSampleCompleted (sample);
			} catch (System.IO.EndOfStreamException ex) {
				Console.WriteLine (ex);
				sample = new MediaStreamSample (description, null, 0, 0, 0, attribs);
				ReportGetSampleCompleted (sample);
			} catch (Exception ex) {
				Console.WriteLine (ex);
				ReportGetSampleCompleted (null);
			}
		}
开发者ID:dfr0,项目名称:moon,代码行数:33,代码来源:Mp3Demuxer.cs


示例9: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            CameraStreamSourceDataSingleton dataSource = CameraStreamSourceDataSingleton.Instance;

            if (frameStreamOffset + dataSource.FrameBufferSize > dataSource.FrameStreamSize)
            {
                dataSource.FrameStream.Seek(0, SeekOrigin.Begin);
                frameStreamOffset = 0;
            }

            Task tsk = dataSource.CameraEffect.GetNewFrameAndApplyEffect().AsTask();

            // Wait that the asynchroneous call completes, and proceed by reporting
            // the MediaElement that new samples are ready.
            tsk.ContinueWith((task) =>
            {
                dataSource.FrameStream.Position = 0;

                MediaStreamSample msSamp = new MediaStreamSample(
                    videoStreamDescription,
                    dataSource.FrameStream,
                    frameStreamOffset,
                    dataSource.FrameBufferSize,
                    currentTime,
                    emptySampleDict);

                ReportGetSampleCompleted(msSamp);
                currentTime += frameTime;
                frameStreamOffset += dataSource.FrameBufferSize;
            });
        }
开发者ID:JuannyWang,项目名称:native-filter-demo,代码行数:31,代码来源:CameraStreamSource.cs


示例10: GetSampleAsync

        protected override void GetSampleAsync(
            MediaStreamType mediaStreamType)
        {
            while (mediaStreamSamples_[mediaStreamType].Count == 0)
            {
                Sample sample;
                Error ec = demuxer_.get_sample(out sample);
                if (ec == Error.success)
                {
                    Dictionary<MediaSampleAttributeKeys, string> mediaSampleAttributes =
                        new Dictionary<MediaSampleAttributeKeys, string>();
                    if (sample.is_sync)
                    {
                        mediaSampleAttributes[MediaSampleAttributeKeys.KeyFrameFlag] = bool.TrueString;
                    }
                    MediaStreamType type = mediaStreamTypes_[(int)sample.index];
                    MediaStreamSample sample2 = new MediaStreamSample(
                        mediaStreamDescriptions_[type],
                        new System.IO.MemoryStream(sample.data),
                        0,
                        sample.data.Length,
                        (long)sample.time,
                        mediaSampleAttributes);
                    mediaStreamSamples_[type].Add(sample2);
                }
                else
                {
                    if (ec == Error.would_block)
                    {
                        if (pending_)
                        {
                            System.Threading.Thread.Sleep(100);
                            continue;
                        }
                        else
                        {
                            pending_ = true;
                            System.Threading.ThreadPool.QueueUserWorkItem(
                                GetSamplePending, mediaStreamType);
                        }
                    }
                    else if (ec == Error.stream_end)
                    {
                        ReportGetSampleCompleted(null);
                    }
                    else
                    {
                        ErrorOccurred(ec.ToString());
                    }
                    return;
                }
            }

            pending_ = false;

            MediaStreamSample sample3 = mediaStreamSamples_[mediaStreamType][0];
            mediaStreamSamples_[mediaStreamType].RemoveAt(0);
            ReportGetSampleCompleted(sample3);
        }
开发者ID:uvbs,项目名称:MyProjects,代码行数:59,代码来源:PpboxSource.cs


示例11: MediaChunkQueue

 /// <summary>
 /// Initializes a new instance of the MediaChunkQueue class
 /// </summary>
 /// <param name="count">the number of chunks in the queue</param>
 /// <param name="mediaType">the media type of the queue</param>
 /// <param name="streamId">the id of the stream this queue belongs to</param>
 public MediaChunkQueue(int count, MediaStreamType mediaType, int streamId)
 {
     m_dataQueue = new MediaChunk[count];
     for (int i = 0; i < count; i++)
     {
         m_dataQueue[i] = new MediaChunk(i, mediaType, streamId);
     }
 }
开发者ID:Titaye,项目名称:SLExtensions,代码行数:14,代码来源:MediaChunkQueue.cs


示例12: GetSampleAsync

	protected override void GetSampleAsync(MediaStreamType mediaStreamType)
	{
		int blocksPlayed = this.Asap.GetBlocksPlayed();
		int bufferLen = this.Asap.Generate(buffer, buffer.Length, BitsPerSample == 8 ? ASAPSampleFormat.U8 : ASAPSampleFormat.S16LE);
		Stream s = bufferLen == 0 ? null : new MemoryStream(buffer);
		MediaStreamSample mss = new MediaStreamSample(this.MediaStreamDescription, s, 0, bufferLen,
			blocksPlayed * 10000000L / ASAP.SampleRate, SampleAttributes);
		ReportGetSampleCompleted(mss);
	}
开发者ID:hudokkow,项目名称:audiodecoder.asap,代码行数:9,代码来源:SilverASAP.cs


示例13: StreamInfo

        /// <summary>
        /// Initializes a new instance of the StreamInfo class
        /// </summary>
        /// <param name="baseUrl">the base url for chunks in this stream</param>
        /// <param name="language">the language of this stream</param>
        /// <param name="numberOfChunks">the number of chunks in this stream</param>
        /// <param name="mediaType">the MediaStreamType of this stream</param>
        /// <param name="streamId">the id of this stream</param>
        public StreamInfo(string baseUrl, string language, int numberOfChunks, MediaStreamType mediaType, int streamId)
        {
            m_baseUrl = baseUrl;
            m_mediaType = mediaType;
            m_language = language;
            m_numberOfChunksInStream = numberOfChunks;

            // Initialize our queue of chunks
            m_chunksQueue = new MediaChunkQueue(numberOfChunks, MediaType, streamId);
        }
开发者ID:Titaye,项目名称:SLExtensions,代码行数:18,代码来源:StreamInfo.cs


示例14: GetSampleAsync

 protected override void GetSampleAsync(MediaStreamType mediaStreamType)
 {
     if (mediaStreamType != MediaStreamType.Audio)
         throw new InvalidOperationException ("Only audio stream type is supported");
     q.BeginGetNextSample ((result) => {
         var sample = q.EndGetNextSample (result);
         ArraySegment<byte> buf = sample.Buffer;
         position += ToTick (sample.Duration);
         var s = new MediaStreamSample (media_desc, new MemoryStream (buf.Array), buf.Offset, buf.Count, position, empty_atts);
         this.ReportGetSampleCompleted (s);
         }, null);
 }
开发者ID:atsushieno,项目名称:synthesis,代码行数:12,代码来源:AudioQueueMediaStreamSource.cs


示例15: GetSampleAsync

 protected override void GetSampleAsync(MediaStreamType mediaStreamType)
 {
     switch (mediaStreamType)
     {
         case MediaStreamType.Video:
             GetVideoSample();
             break;
         case MediaStreamType.Audio:
             Debug.WriteLine("audio?!");
             break;
     }
 }
开发者ID:kindohm,项目名称:silverlight-app-does-what,代码行数:12,代码来源:VideoDecoder.cs


示例16: GetSampleAsync

    /// <summary>
    /// Return the next sample requested
    /// </summary>
    /// <param name="mediaStreamType">The stream type that we are getting a sample for</param>
    protected override void GetSampleAsync(MediaStreamType mediaStreamType) {

      long bufferSize = Math.Min(sampleSize, startPosition + pcmDataLen - currentPosition);
      // Send out the next sample
      if (bufferSize > 0) {
        MediaStreamSample sample = new MediaStreamSample(audioDesc, stream, currentPosition, bufferSize, currentTimeStamp, emptySampleDict);
        currentTimeStamp += header.AudioDurationFromDataLen(bufferSize);
        currentPosition += bufferSize;
        ReportGetSampleCompleted(sample);
      } else
        // Report EOS
        ReportGetSampleCompleted(new MediaStreamSample(audioDesc, null, 0, 0, 0, this.emptySampleDict));
    }
开发者ID:PavelPZ,项目名称:REW,代码行数:17,代码来源:WaveMediaStreamSource2.cs


示例17: GetSortedStreams

        private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, List<string> languagePreferences)
        {
            // Give some preferance to external text subs for better performance
            return streams.Where(i => i.Type == type)
                .OrderBy(i =>
            {
                var index = languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase));

                return index == -1 ? 100 : index;
            })
                 .ThenBy(i => GetBooleanOrderBy(i.IsDefault))
                 .ThenBy(i => GetBooleanOrderBy(i.SupportsExternalStream))
                 .ThenBy(i => GetBooleanOrderBy(i.IsTextSubtitleStream))
                 .ThenBy(i => GetBooleanOrderBy(i.IsExternal))
                 .ThenBy(i => i.Index);
        }
开发者ID:jrags56,项目名称:MediaBrowser,代码行数:16,代码来源:MediaStreamSelector.cs


示例18: GetSampleAsync

 protected override void GetSampleAsync(MediaStreamType mediaStreamType)
 {
     if (mediaStreamType != MediaStreamType.Audio)
         throw new InvalidOperationException ("Only audio stream type is supported");
     if (samples == null) {
         samples = new Queue<IMediaSample> ();
         gen.BufferArrived += sample => {
             if (stuck_count-- > 0)
                 this.ReportGetSampleCompleted (sample);
             else
                 samples.Enqueue (sample);
         };
     }
     if (samples.Count > 0)
         ReportGetSampleCompleted (samples.Dequeue ());
     else
         stuck_count++;
 }
开发者ID:atsushieno,项目名称:synthesis,代码行数:18,代码来源:BufferGeneratorMediaStreamSource.cs


示例19: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            MemoryStream frame = new MemoryStream ();
            org.diracvideo.Jirac.Picture p = dec.Pull ();
            MediaStreamSample sample;
            int [] pixels;

            p.Decode ();
            pixels = p.GetImage ();

            foreach (int i in pixels)
                frame.Write (BitConverter.GetBytes (i), 0, 4);

            sample = new MediaStreamSample (streamDescription, frame, 0, frame.Length, timestamp, empty_dict);

            timestamp += 50;

            ReportGetSampleCompleted(sample);
        }
开发者ID:mono,项目名称:mooncodecs,代码行数:19,代码来源:DiracStreamSource.cs


示例20: GetSampleAsync

        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            if (index < this.sourceData.Length)
            {
                for (int i = 0; i < numSamples; i++)
                {
                    if (index >= this.sourceData.Length)
                        break;

                    memoryStream.WriteByte(
                        this.sourceData[index]);
                    memoryStream.WriteByte(
                        this.sourceData[index + 1]);
                    index += 2;

                    if (this.Channels == 2)
                    {
                        memoryStream.WriteByte(
                            this.sourceData[index]);
                        memoryStream.WriteByte(
                            this.sourceData[index + 1]);
                        index += 2;
                    }

                }

                MediaStreamSample mediaStreamSample =
                    new MediaStreamSample(mediaStreamDescription, memoryStream, currentPosition,
                                          bufferByteCount, currentTimeStamp, emptySampleDict);

                currentTimeStamp += bufferByteCount * 10000000L / byteRate;
                currentPosition += bufferByteCount;

                ReportGetSampleCompleted(mediaStreamSample);
            }
            else
            {
                this.CloseMedia();
            }
        }
开发者ID:kindohm,项目名称:silverlight-app-does-what,代码行数:40,代码来源:AudioPlayer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MediaType类代码示例发布时间:2022-05-24
下一篇:
C# MediaState类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap