Java Code Examples for com.google.android.exoplayer.util.Util#printByteArray()

The following examples show how to use com.google.android.exoplayer.util.Util#printByteArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AC3ReaderATSC.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
@Override
public void consume(ParsableByteArray data, long pesTimeUs, boolean startOfPacket) {
    Util.printByteArray("AC3 reader !!!!!!!!!!", data.data, 0, 30);
    data.setPosition(1);
    if (!hasMediaFormat()) {
        parseAudioDescriptor(data);
    }
    else {
        data.skip(audiodesclen);
    }

    // move to access unit
    if (writingSample())
        appendData(data, data.bytesLeft());

    // ISO/IEC 13818-1 [1] specifies a fixed value for BSn (3584 bytes)

}
 
Example 2
Source File: UdpUnicastDataSource.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public int read(byte[] buffer, int offset, int readLength) throws IOException {
    if (readLength > rcvBufferSize) {
        rcvBufferSize = readLength+1;
        socket.setReceiveBufferSize(rcvBufferSize);
    }
    DatagramPacket packet = new DatagramPacket(buffer, offset, readLength);
    socket.receive(packet);
    Log.i(TAG, ">>>> read "+packet.getLength() + " MMMMMMMMMMM " + readLength);
    Util.printByteArray(TAG, packet.getData(), offset, 50);
    Util.findThisByte("sync interval ", (byte) 0x47, packet.getData());
    return packet.getLength();
}
 
Example 3
Source File: H264Reader.java    From Exoplayer_VLC with Apache License 2.0 4 votes vote down vote up
@Override
public void consume(ParsableByteArray data, long pesTimeUs, boolean startOfPacket) {
  while (data.bytesLeft() > 0) {
    int offset = data.getPosition();
    int limit = data.limit();
    byte[] dataArray = data.data;

    // Append the data to the buffer.
    appendData(data, data.bytesLeft());

      final String tag = ">>>>>> HLS h264 reader";
      //Log.d(tag, " data len " + limit );


    // Scan the appended data, processing NAL units as they are encountered
    while (offset < limit) {
      int nextNalUnitOffset = Mp4Util.findNalUnit(dataArray, offset, limit, prefixFlags);
      if (nextNalUnitOffset < limit) {
        // We've seen the start of a NAL unit.

          Util.printByteArray(tag , dataArray, nextNalUnitOffset,20);

        // This is the length to the start of the unit. It may be negative if the NAL unit
        // actually started in previously consumed data.
        int lengthToNalUnit = nextNalUnitOffset - offset;
        if (lengthToNalUnit > 0) {
          feedNalUnitTargetBuffersData(dataArray, offset, nextNalUnitOffset);
        }

        int nalUnitType = Mp4Util.getNalUnitType(dataArray, nextNalUnitOffset);
        int nalUnitOffsetInData = nextNalUnitOffset - limit;
        if (nalUnitType == NAL_UNIT_TYPE_AUD) {
          if (writingSample()) {
            if (isKeyframe && !hasMediaFormat() && sps.isCompleted() && pps.isCompleted()) {
              parseMediaFormat(sps, pps);
            }
            commitSample(isKeyframe, nalUnitOffsetInData);
          }
          startSample(pesTimeUs, nalUnitOffsetInData);
          isKeyframe = false;
        } else if (nalUnitType == NAL_UNIT_TYPE_IDR) {
          isKeyframe = true;
        }

        // If the length to the start of the unit is negative then we wrote too many bytes to the
        // NAL buffers. Discard the excess bytes when notifying that the unit has ended.
        feedNalUnitTargetEnd(pesTimeUs, lengthToNalUnit < 0 ? -lengthToNalUnit : 0);
        // Notify the start of the next NAL unit.
        feedNalUnitTargetBuffersStart(nalUnitType);
        // Continue scanning the data.
        offset = nextNalUnitOffset + 4;
      } else {
        feedNalUnitTargetBuffersData(dataArray, offset, limit);
        offset = limit;
      }
    }
  }
}