Read description.

@param tv the tag value
@throws IOException exception
@throws NumberFormatException exception
168496
private void readDescription(TagValue tv) throws NumberFormatException, IOException {
    int index = 128;
    int tagCount = tv.getBytesBigEndian(index, 4);
    index += 4;
    for (int i = 0; i < tagCount; i++) {
      int signature = tv.getBytesBigEndian(index, 4);
      int tagOffset = tv.getBytesBigEndian(index + 4, 4);
      if (Integer.toHexString(signature).equals("64657363")) {
        String typedesc = Integer.toHexString(tv.getBytesBigEndian(tagOffset, 4));
        if (typedesc.equals("64657363")) {
          int size = tv.getBytesBigEndian(tagOffset + 8, 4) - 1;
          String s = "";
          int j = 0;
          int begin = tagOffset + 12;
          while (begin + j < begin + size) {
            int unicode_char = tv.getBytesBigEndian(begin + j, 1);
            s += Character.toString((char) unicode_char);
            j++;
          }
          description = s;
        } else {
          description = "";
        }
      }
      index += 12;
    }
  }
94782
@SuppressWarnings ({"unchecked", "rawtypes"})
    private Tag readTagPayload(TagType type, String name, int depth) throws IOException {
        switch (type) {
            case TAG_END:
                if (depth == 0) {
                    throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
                } else {
                    return new EndTag();
                }

            case TAG_BYTE:
                return new ByteTag(name, is.readByte());

            case TAG_SHORT:
                return new ShortTag(name, is.readShort());

            case TAG_INT:
                return new IntTag(name, is.readInt());

            case TAG_LONG:
                return new LongTag(name, is.readLong());

            case TAG_FLOAT:
                return new FloatTag(name, is.readFloat());

            case TAG_DOUBLE:
                return new DoubleTag(name, is.readDouble());

            case TAG_BYTE_ARRAY:
                int length = is.readInt();
                byte[] bytes = new byte[length];
                is.readFully(bytes);
                return new ByteArrayTag(name, bytes);

            case TAG_STRING:
                length = is.readShort();
                bytes = new byte[length];
                is.readFully(bytes);
                return new StringTag(name, new String(bytes, NBTConstants.CHARSET.name()));

            case TAG_LIST:
                TagType childType = TagType.getById(is.readByte());
                length = is.readInt();

                Class<? extends Tag> clazz = childType.getTagClass();
                List<Tag> tagList = new ArrayList<Tag>(length);
                for (int i = 0; i < length; i++) {
                    Tag tag = readTagPayload(childType, "", depth + 1);
                    if (tag instanceof EndTag) {
                        throw new IOException("TAG_End not permitted in a list.");
                    } else if (!clazz.isInstance(tag)) {
                        throw new IOException("Mixed tag types within a list.");
                    }
                    tagList.add(tag);
                }

                return new ListTag(name, clazz, tagList);

            case TAG_COMPOUND:
                CompoundMap compoundTagList = new CompoundMap();
                while (true) {
                    Tag tag = readTag(depth + 1);
                    if (tag instanceof EndTag) {
                        break;
                    } else {
                        compoundTagList.put(tag);
                    }
                }

                return new CompoundTag(name, compoundTagList);

            case TAG_INT_ARRAY:
                length = is.readInt();
                int[] ints = new int[length];
                for (int i = 0; i < length; i++) {
                    ints[i] = is.readInt();
                }
                return new IntArrayTag(name, ints);

            case TAG_SHORT_ARRAY:
                length = is.readInt();
                short[] shorts = new short[length];
                for (int i = 0; i < length; i++) {
                    shorts[i] = is.readShort();
                }
                return new ShortArrayTag(name, shorts);

            default:
                throw new IOException("Invalid tag type: " + type + ".");
        }
    }
423703
public int readInt()
        throws IOException
    {
        int tag = is.read();

        if (tag != 'I')
            throw expect("integer", tag);

        int b32 = is.read();
        int b24 = is.read();
        int b16 = is.read();
        int b8 = is.read();

        return (b32 << 24) + (b24 << 16) + (b16 << 8) + b8;
    }
496669
public int readInt()
        throws IOException
    {
        int tag = read();

        switch (tag) {
            case 'T':
                return 1;
            case 'F':
                return 0;
            case 'I':
                return parseInt();
            case 'L':
                return (int) parseLong();
            case 'D':
                return (int) parseDouble();

            default:
                throw expect("int", tag);
        }
    }
690762
public TVInfo getTVInfo(int tvID, String language, String... appendToResponse) throws MovieDbException {
        TmdbParameters parameters = new TmdbParameters();
        parameters.add(Param.ID, tvID);
        parameters.add(Param.LANGUAGE, language);
        parameters.add(Param.APPEND, appendToResponse);

        URL url = new ApiUrl(apiKey, MethodBase.TV).buildUrl(parameters);
        String webpage = httpTools.getRequest(url);

        try {
            return MAPPER.readValue(webpage, TVInfo.class);
        } catch (IOException ex) {
            throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Info", url, ex);
        }
    }
909997
public int readTag() throws IOException
    {
        if (!buffer.hasRemaining())
        {
            lastTag = 0;
            return 0;
        }

        final int tag = readRawVarint32();
        if (tag >>> TAG_TYPE_BITS == 0)
        {
            // If we actually read zero, that's not a valid tag.
            throw ProtobufException.invalidTag();
        }
        lastTag = tag;
        return tag;
    }
1147002
@Override
    public void play(final String uri) {
        Log.d(TAG, "Start playing "+uri);
        notifyVideoUnavailable(REASON_BUFFERING);
        isWeb = false;
        TvInputPlayer.Callback callback = new TvInputPlayer.Callback() {
            @Override
            public void onPrepared() {
                notifyVideoAvailable();
                setOverlayEnabled(false);
            }

            @Override
            public void onPlayerStateChanged(boolean playWhenReady, int state) {

            }

            @Override
            public void onPlayWhenReadyCommitted() {

            }

            @Override
            public void onPlayerError(ExoPlaybackException e) {
                Log.e(TAG, e.getMessage()+"");
                if(e.getMessage().contains("Extractor")) {
                    Log.d(TAG, "Cannot play the stream, try loading it as a website");
                    Log.d(TAG, "Open "+uri);
                    //Pretend this is a website
                    loadUrl(uri);
                    isWeb = true;
                    setOverlayEnabled(false);
                    notifyVideoAvailable();
                    isWeb = true;
                    setOverlayEnabled(false);
                    setOverlayEnabled(true);
                    isWeb = true;
                }
            }

            @Override
            public void onDrawnToSurface(Surface surface) {

            }

            @Override
            public void onText(String text) {

            }
        };
        try {
            tvInputPlayer.removeCallback(callback);
        } catch(NullPointerException e) {
            Log.w(TAG, "exoplayer.removeCallback error "+e.getMessage());
        }
        tvInputPlayer.addCallback(callback);
        tvInputPlayer.setSurface(mSurface);
        Log.d(TAG, "Play "+uri+"; "+uri.indexOf("file:///"));
        if(uri.contains("file:///")) {
            Log.i(TAG, "Is a local file");
            //Find appropriate extractor

            DataSource dataSource=new DefaultUriDataSource(getApplicationContext(), TvInputPlayer.getUserAgent(getApplicationContext()));
            ExtractorSampleSource extractorSampleSource=new ExtractorSampleSource(Uri.parse(uri),dataSource,
                    new DefaultAllocator(TvInputPlayer.BUFFER_SEGMENT_SIZE), TvInputPlayer.BUFFER_SEGMENTS * TvInputPlayer.BUFFER_SEGMENT_SIZE,
                    new Mp4Extractor(), new Mp3Extractor());
            TrackRenderer audio=new MediaCodecAudioTrackRenderer(extractorSampleSource, MediaCodecSelector.DEFAULT);
            TrackRenderer video=new MediaCodecVideoTrackRenderer(getApplicationContext(),extractorSampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
            tvInputPlayer.prepare(audio, video, new DummyTrackRenderer());
        } else {
            try {
                tvInputPlayer.prepare(getApplicationContext(), Uri.parse(uri), TvInputPlayer.SOURCE_TYPE_HLS);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        tvInputPlayer.setPlayWhenReady(true);
    }
453766
void read(RecordInput rin, String tag) throws IOException {
    // number of elements
    int numElems = rin.readInt(tag);
    for (int i=0; i<numElems; i++) {
      typeInfos.add(genericReadTypeInfo(rin, tag));
    }
  }
926626
private void readVersion(TagValue tv) {
    int maj = tv.getBytesBigEndian(8, 1); // Major version
    int min = (tv.getBytesBigEndian(9, 1) & 0xF0) >> 4; // Minor version (in the first 4 bits of the
                                                        // byte)
    version = maj + "." + min;
  }
619416
protected void readHeader() throws IOException {
        StringBuilder id = new StringBuilder(8);
        for (int i = 0; i < 6; i++) {
            id.append((char)in.read());
        }
        if (!id.toString().startsWith("GIF8")) {
            throw new IOException("Gif signature nor found.");
        }
        
        readLSD();
        if (gctFlag) {
            m_global_table = readColorTable(m_gbpc);
        }
    }
329345
protected void readTag(int tag)
        throws IOException
    {
        int length = (is.read() << 8) + is.read();
        is.skip(length);
    }
129539
private void readData()
        throws IOException
    {
        while (!isClosed) {
            int code = is.read();

            switch (code) {
                case ' ':
                case '\t':
                case '\n':
                case '\r':
                    break;

                case 'C': {
                    int channel = (is.read() << 8) + is.read();

                    inputReady[channel] = true;
                    return;
                }

                case 'E': {
                    int channel = (is.read() << 8) + is.read();
                    int status = (is.read() << 8) + is.read();

                    inputReady[channel] = true;

                    return;
                }

                case -1:
                    close();
                    return;

                default:
                    // An error in the protocol.  Kill the connection.
                    close();
                    return;
            }
        }

        return;
    }
167511
private void readElementDeclaration() throws IOException, XmlPullParserException {
        read(START_ELEMENT);
        skip();
        readName();
        readContentSpec();
        skip();
        read('>');
    }
577631
@Override
    public ITag readTag() {
        ITag tag = null;
        if (log.isTraceEnabled()) {
            log.trace("Read tag - prevFrameSize {} audio: {} video: {}", new Object[] { prevFrameSize, audioCount, videoCount });
        }
        // ensure there are frames before proceeding
        if (!frames.isEmpty()) {
            try {
                lock.acquire();
                //log.debug("Read tag");
                //empty-out the pre-streaming tags first
                if (!firstTags.isEmpty()) {
                    //log.debug("Returning pre-tag");
                    // Return first tags before media data
                    return firstTags.removeFirst();
                }
                //get the current frame
                MP4Frame frame = frames.get(currentFrame);
                if (frame != null) {
                    log.debug("Playback #{} {}", currentFrame, frame);
                    int sampleSize = frame.getSize();
                    int time = (int) Math.round(frame.getTime() * 1000.0);
                    //log.debug("Read tag - dst: {} base: {} time: {}", new Object[]{frameTs, baseTs, time});
                    long samplePos = frame.getOffset();
                    //log.debug("Read tag - samplePos {}", samplePos);
                    //determine frame type and packet body padding
                    byte type = frame.getType();
                    //assume video type
                    int pad = 5;
                    if (type == TYPE_AUDIO) {
                        pad = 2;
                    }
                    //create a byte buffer of the size of the sample
                    ByteBuffer data = ByteBuffer.allocate(sampleSize + pad);
                    try {
                        //prefix is different for keyframes
                        if (type == TYPE_VIDEO) {
                            if (frame.isKeyFrame()) {
                                //log.debug("Writing keyframe prefix");
                                data.put(PREFIX_VIDEO_KEYFRAME);
                            } else {
                                //log.debug("Writing interframe prefix");
                                data.put(PREFIX_VIDEO_FRAME);
                            }
                            // match the sample with its ctts / mdhd adjustment time
                            int timeOffset = prevVideoTS != -1 ? time - prevVideoTS : 0;
                            data.put((byte) ((timeOffset >>> 16) & 0xff));
                            data.put((byte) ((timeOffset >>> 8) & 0xff));
                            data.put((byte) (timeOffset & 0xff));
                            if (log.isTraceEnabled()) {
                                byte[] prefix = new byte[5];
                                int p = data.position();
                                data.position(0);
                                data.get(prefix);
                                data.position(p);
                                log.trace("{}", prefix);
                            }
                            // track video frame count
                            videoCount++;
                            prevVideoTS = time;
                        } else {
                            //log.debug("Writing audio prefix");
                            data.put(PREFIX_AUDIO_FRAME);
                            // track audio frame count
                            audioCount++;
                        }
                        // do we need to add the mdat offset to the sample position?
                        dataSource.position(samplePos);
                        // read from the channel
                        dataSource.read(data);
                    } catch (IOException e) {
                        log.error("Error on channel position / read", e);
                    }
                    // chunk the data
                    IoBuffer payload = IoBuffer.wrap(data.array());
                    // create the tag
                    tag = new Tag(type, time, payload.limit(), payload, prevFrameSize);
                    //log.debug("Read tag - type: {} body size: {}", (type == TYPE_AUDIO ? "Audio" : "Video"), tag.getBodySize());
                    // increment the frame number
                    currentFrame++;
                    // set the frame / tag size
                    prevFrameSize = tag.getBodySize();
                }
            } catch (InterruptedException e) {
                log.warn("Exception acquiring lock", e);
            } finally {
                lock.release();
            }
        } else {
            log.warn("No frames are available for the requested item");
        }
        //log.debug("Tag: {}", tag);
        return tag;
    }
1286239
private static int readLEInt(InputStream in) throws IOException {
		int i = in.read() & 0xFF;
		i |= (in.read() & 0xFF) << 8;
		i |= (in.read() & 0xFF) << 16;
		i |= (in.read() & 0xFF) << 24;
		return i;
	}
1083063
function readNumber(bf, numfmt) {
  var value = new Uint8Array(bf);
  if (numfmt === NUMFMT_UINT32) {
    // uint32
    return uint32BEtoNumber(value);
  } else if (numfmt === NUMFMT_UINT64) {
    // uint64
    return uint64BEtoNumber(value);
  } else if (numfmt === NUMFMT_UINT16) {
    // uint16
    return uint16BEtoNumber(value);
  } else if (numfmt === NUMFMT_UINT8) {
    // uint8
    return uint8BEtoNumber(value);
  }
  return 0;

  // return struct.unpack(this._number_format, bf)[0];
}
778490
private Tag readTag(int depth) throws IOException {
        int typeId = is.readByte() & 0xFF;
        TagType type = TagType.getById(typeId);

        String name;
        if (type != TagType.TAG_END) {
            int nameLength = is.readShort() & 0xFFFF;
            byte[] nameBytes = new byte[nameLength];
            is.readFully(nameBytes);
            name = new String(nameBytes, NBTConstants.CHARSET.name());
        } else {
            name = "";
        }

        return readTagPayload(type, name, depth);
    }