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


C# ByteBuffer.Rewind方法代码示例

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


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

示例1: CanHandleData

 public bool CanHandleData(ByteBuffer data)
 {
     if (data.Limit == 0)
         return false;// Empty buffer
     byte first = data.Get();
     bool result = ((first & 0x0f) == VideoCodec.H263.Id);
     data.Rewind();
     return result;
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:9,代码来源:SorensonVideo.cs

示例2: GetVideoCodec

        /// <summary>
        /// Create and return new video codec applicable for byte buffer data
        /// </summary>
        /// <param name="data">Byte buffer data.</param>
        /// <returns>Video codec.</returns>
        public IVideoStreamCodec GetVideoCodec(ByteBuffer data)
        {
            IVideoStreamCodec result = null;
            //get the codec identifying byte
            int codecId = data.Get() & 0x0f;
            switch (codecId)
            {
                case 2: //sorenson 
                    result = new SorensonVideo();
                    break;
                case 3: //screen video
                    result = new ScreenVideo();
                    break;
                case 7: //avc/h.264 video
                    result = new AVCVideo();
                    break;
            }
            data.Rewind();
            if (result == null)
            {
                IVideoStreamCodec codec;
                foreach (IVideoStreamCodec storedCodec in _codecs)
                {
                    // XXX: this is a bit of a hack to create new instances of the
                    // configured video codec for each stream
                    try
                    {
                        codec = Activator.CreateInstance(storedCodec.GetType()) as IVideoStreamCodec;
                    }
                    catch (Exception ex)
                    {
                        log.Error("Could not create video codec instance.", ex);
                        continue;
                    }

                    log.Info("Trying codec " + codec);
                    if (codec.CanHandleData(data))
                    {
                        result = codec;
                        break;
                    }
                }
            }
            return result;
        }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:50,代码来源:VideoCodecFactory.cs

示例3: OSArrayTag

 /// <summary>
 /// Creates TAG and sets its <c>size</c> as a size of byte array
 /// </summary>
 /// <param name="Type">The Matlab array type</param>
 /// <param name="Data"><c>ByteBuffer</c></param>
 public OSArrayTag( int Type, ByteBuffer Data )
     : base(Type, Data.Limit)
 {
     _data = Data;
     _data.Rewind();
     _compressed = Data.Limit <= 4;
     _padding = GetPadding( Data.Limit, _compressed );
 }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:13,代码来源:MatFileWriter.cs

示例4: CopyPixelsToBuffer

 public void CopyPixelsToBuffer(ByteBuffer buffer)
 {
     sbyte[] m_data = new sbyte[(this.m_data.Width * this.m_data.Height) * 4];
     this.m_data.GetData<sbyte>(m_data);
     buffer.Put(m_data, 0, m_data.Length);
     buffer.Rewind();
 }
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:7,代码来源:LImage.cs

示例5: AddData

 public bool AddData(ByteBuffer data)
 {
     if (data.Limit == 0)
         return false;// Empty buffer
     if (!CanHandleData(data))
         return false;
     byte first = data.Get();
     data.Rewind();
     if ((first & 0xf0) != VideoCodec.FLV_FRAME_KEY)
         return true;// Not a keyframe
     // Store last keyframe
     _dataCount = data.Limit;
     if (_blockSize < _dataCount)
     {
         _blockSize = _dataCount;
         _blockData = new byte[_blockSize];
     }
     data.Read(_blockData, 0, _dataCount);
     data.Rewind();
     return true;
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:21,代码来源:SorensonVideo.cs

示例6: AddData

		public bool AddData(ByteBuffer data) {
			if (data.Limit == 0)
				return false;// Empty buffer
			if (!CanHandleData(data))
				return false;
			data.Get();
			UpdateSize(data);
			int idx = 0;
			int pos = 0;
			byte[] tmpData = new byte[_blockDataSize];

			int countBlocks = _blockCount;
			while (data.Remaining > 0 && countBlocks > 0) {
				short size = data.GetShort();
				countBlocks--;
				if (size == 0) {
					// Block has not been modified
					idx += 1;
					pos += _blockDataSize;
					continue;
				}
				// Store new block data
				_blockSize[idx] = size;
				data.Read(tmpData, 0, size);
				Array.Copy(tmpData, 0, _blockData, pos, size);
				idx += 1;
				pos += _blockDataSize;
			}
			data.Rewind();
			return true;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:31,代码来源:ScreenVideo.cs

示例7: ReadToByteBuffer

        /// <summary>
        /// Reads the data into a <c>ByteBuffer</c>.
        /// </summary>
        /// <param name="dest">The destination <c>ByteBuffer</c></param>
        /// <param name="elements">The number of elements to read into a buffer</param>
        /// <param name="storage">The backing <c>ByteStorageSupport</c> that
        /// gives information on how data should be interpreted</param>
        /// <returns>Reference to the destination <c>ByteBuffer</c></returns>
        /// <exception cref="NotSupportedException">When attempting to read an unsupported
        /// class type from the buffer</exception>
        public ByteBuffer ReadToByteBuffer( ByteBuffer dest, int elements, 
			ByteStorageSupport storage )
        {
            int bytesAllocated = storage.GetBytesAllocated;
            int size = elements * bytesAllocated;

            // direct buffer copy
            if( MatDataTypes.SizeOf( _type ) == bytesAllocated )
            {
                int bufMaxSize = 1024;
                int bufSize = Math.Min( (int)(_buf.BaseStream.Length - _buf.BaseStream.Position), bufMaxSize );
                int bufPos = (int)_buf.BaseStream.Position;

                byte[] tmp = new byte[ bufSize ];

                while( dest.Remaining() > 0 )
                {
                    int length = Math.Min(dest.Remaining(), tmp.Length);
                    _buf.Read( tmp, 0, length );
                    dest.Put( tmp, 0, length );
                }
                _buf.BaseStream.Position = bufPos + size;
            }
            else
            {
                // Because Matlab writes data not respectively to the declared
                // matrix type, the reading is not straight forward (as above)
                Type clazz = storage.GetStorageType;
                while( dest.Remaining() > 0 )
                {
                    if( clazz.Equals( typeof(double) ) )
                    {
                        dest.PutDouble( ReadDouble() );
                        continue;
                    }
                    if( clazz.Equals( typeof(byte) ) )
                    {
                        dest.PutDouble( ReadByte() );
                        continue;
                    }
                    if( clazz.Equals( typeof(int) ) )
                    {
                        dest.PutDouble( ReadInt() );
                        continue;
                    }
                    if( clazz.Equals( typeof(long) ) )
                    {
                        dest.PutDouble( ReadLong() );
                        continue;
                    }
                    throw new NotSupportedException("Not supported buffer reader for " + clazz );
                }
            }
            dest.Rewind();
            return dest;
        }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:66,代码来源:MatFileInputStream.cs

示例8: AddData

        public bool AddData(ByteBuffer data)
        {
            if (data.Limit == 0)
                return true;
            if (!CanHandleData(data))
                return false;
            data.Rewind();
            byte frameType = data.Get();
            data.Rewind();
            if ((frameType & 0xf0) != VideoCodec.FLV_FRAME_KEY)
                return true;// Not a keyframe

            //If we don't have the AVCDecoderConfigurationRecord stored...
            if (_blockDataAVCDCR == null)
            {
                data.Get();//FT
                data.Get();//CODECID
                byte AVCPacketType = data.Get();
                //Sequence Header / here comes a AVCDecoderConfigurationRecord
                if (log.IsDebugEnabled)
                    log.Debug(string.Format("AVCPacketType: {0}", AVCPacketType));
                if (AVCPacketType == 0)
                {
                    data.Rewind();
                    // Store AVCDecoderConfigurationRecord data
                    _dataCountAVCDCR = data.Limit;
                    if (_blockSizeAVCDCR < _dataCountAVCDCR)
                    {
                        _blockSizeAVCDCR = _dataCountAVCDCR;
                        _blockDataAVCDCR = new byte[_blockSizeAVCDCR];
                    }
                    data.Read(_blockDataAVCDCR, 0, _dataCountAVCDCR);
                }
            }
            data.Rewind();
            // Store last keyframe
            _dataCountLKF = data.Limit;
            if (_blockSizeLKF < _dataCountLKF)
            {
                _blockSizeLKF = _dataCountLKF;
                _blockDataLKF = new byte[_blockSizeLKF];
            }
            data.Read(_blockDataLKF, 0, _dataCountLKF);
            data.Rewind();
            return true;            
        }
开发者ID:apakian,项目名称:fluorinefx,代码行数:46,代码来源:AVCVideo.cs

示例9: PromptUS

        public static String PromptUS(ByteBuffer bb, int maxlen)
        {
            if (bb.Length < 2) {
                return "";
            }

            var sb = new StringBuilder((int) bb.Length);
            bb.Rewind();
            sb.Append(bb.ReadInt16() & 0xffff);
            while (bb.Remaining >= 2 && sb.Length < maxlen) {
                sb.Append('\\').Append(bb.ReadInt16() & 0xffff);
            }

            return Truncate(sb.ToString(), maxlen);
        }
开发者ID:KnownSubset,项目名称:DicomSharp,代码行数:15,代码来源:StringUtils.cs

示例10: PromptUL

        public static String PromptUL(ByteBuffer bb, int maxlen)
        {
            if (bb.Length < 4) {
                return "";
            }

            var sb = new StringBuilder((int) bb.Length);
            bb.Rewind();
            sb.Append(bb.ReadInt32() & (int) (- (0x100000000 - 0xffffffffL)));
            while (bb.Remaining >= 4 && sb.Length < maxlen) {
                sb.Append('\\').Append(bb.ReadInt32() & (int) (- (0x100000000 - 0xffffffffL)));
            }

            return Truncate(sb.ToString(), maxlen);
        }
开发者ID:KnownSubset,项目名称:DicomSharp,代码行数:15,代码来源:StringUtils.cs

示例11: PromptOW

        public static String PromptOW(ByteBuffer bb, int maxlen)
        {
            int l = (int) bb.Length/2*5 - 1;
            if (l < 0) {
                return "";
            }

            var sb = new StringBuilder(l);
            bb.Rewind();
            sb.Append(String.Format("{0:X4}", bb.ReadInt16()));
            while (bb.Remaining >= 2 && sb.Length < maxlen) {
                sb.Append('\\');
                sb.Append(String.Format("{0:X4}", bb.ReadInt16()));
            }

            return Truncate(sb.ToString(), maxlen);
        }
开发者ID:KnownSubset,项目名称:DicomSharp,代码行数:17,代码来源:StringUtils.cs

示例12: PromptFD

        public static String PromptFD(ByteBuffer bb, int maxlen)
        {
            if (bb.Length < 8) {
                return "";
            }

            var sb = new StringBuilder((int) bb.Length);
            bb.Rewind();
            sb.Append(bb.ReadDouble());
            while (bb.Remaining >= 8 && sb.Length < maxlen) {
                sb.Append('\\').Append(bb.ReadDouble());
            }

            return Truncate(sb.ToString(), maxlen);
        }
开发者ID:KnownSubset,项目名称:DicomSharp,代码行数:15,代码来源:StringUtils.cs


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