Java Code Examples for com.google.android.exoplayer2.util.Log#i()
The following examples show how to use
com.google.android.exoplayer2.util.Log#i() .
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: SsaDecoder.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Parses the header of the subtitle. * * @param data A {@link ParsableByteArray} from which the header should be read. */ private void parseHeader(ParsableByteArray data) { @Nullable String currentLine; while ((currentLine = data.readLine()) != null) { if ("[Script Info]".equalsIgnoreCase(currentLine)) { parseScriptInfo(data); } else if ("[V4+ Styles]".equalsIgnoreCase(currentLine)) { styles = parseStyles(data); } else if ("[V4 Styles]".equalsIgnoreCase(currentLine)) { Log.i(TAG, "[V4 Styles] are not supported"); } else if ("[Events]".equalsIgnoreCase(currentLine)) { // We've reached the [Events] section, so the header is over. return; } } }
Example 2
Source File: FrameworkMediaDrm.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * If the LA_URL tag is missing, injects a mock LA_URL value to avoid causing the CDM to throw * when creating the key request. The LA_URL attribute is optional but some Android PlayReady * implementations are known to require it. Does nothing it the provided {@code data} already * contains an LA_URL value. */ private static byte[] addLaUrlAttributeIfMissing(byte[] data) { ParsableByteArray byteArray = new ParsableByteArray(data); // See https://docs.microsoft.com/en-us/playready/specifications/specifications for more // information about the init data format. int length = byteArray.readLittleEndianInt(); int objectRecordCount = byteArray.readLittleEndianShort(); int recordType = byteArray.readLittleEndianShort(); if (objectRecordCount != 1 || recordType != 1) { Log.i(TAG, "Unexpected record count or type. Skipping LA_URL workaround."); return data; } int recordLength = byteArray.readLittleEndianShort(); String xml = byteArray.readString(recordLength, Charset.forName(C.UTF16LE_NAME)); if (xml.contains("<LA_URL>")) { // LA_URL already present. Do nothing. return data; } // This PlayReady object record does not include an LA_URL. We add a mock value for it. int endOfDataTagIndex = xml.indexOf("</DATA>"); if (endOfDataTagIndex == -1) { Log.w(TAG, "Could not find the </DATA> tag. Skipping LA_URL workaround."); } String xmlWithMockLaUrl = xml.substring(/* beginIndex= */ 0, /* endIndex= */ endOfDataTagIndex) + MOCK_LA_URL + xml.substring(/* beginIndex= */ endOfDataTagIndex); int extraBytes = MOCK_LA_URL.length() * UTF_16_BYTES_PER_CHARACTER; ByteBuffer newData = ByteBuffer.allocate(length + extraBytes); newData.order(ByteOrder.LITTLE_ENDIAN); newData.putInt(length + extraBytes); newData.putShort((short) objectRecordCount); newData.putShort((short) recordType); newData.putShort((short) (xmlWithMockLaUrl.length() * UTF_16_BYTES_PER_CHARACTER)); newData.put(xmlWithMockLaUrl.getBytes(Charset.forName(C.UTF16LE_NAME))); return newData.array(); }
Example 3
Source File: SsaStyle.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Parses the position from a style override, returns null if no position is found. * * <p>The attribute is expected to be in the form {@code \pos(x,y)} or {@code * \move(x1,y1,x2,y2,startTime,endTime)} (startTime and endTime are optional). In the case of * {@code \move()}, this returns {@code (x2, y2)} (i.e. the end position of the move). * * @param styleOverride The string to parse. * @return The parsed position, or null if no position is found. */ @Nullable private static PointF parsePosition(String styleOverride) { Matcher positionMatcher = POSITION_PATTERN.matcher(styleOverride); Matcher moveMatcher = MOVE_PATTERN.matcher(styleOverride); boolean hasPosition = positionMatcher.find(); boolean hasMove = moveMatcher.find(); String x; String y; if (hasPosition) { if (hasMove) { Log.i( TAG, "Override has both \\pos(x,y) and \\move(x1,y1,x2,y2); using \\pos values. override='" + styleOverride + "'"); } x = positionMatcher.group(1); y = positionMatcher.group(2); } else if (hasMove) { x = moveMatcher.group(1); y = moveMatcher.group(2); } else { return null; } return new PointF( Float.parseFloat(Assertions.checkNotNull(x).trim()), Float.parseFloat(Assertions.checkNotNull(y).trim())); }
Example 4
Source File: ExoPlayerImpl.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void release() { Log.i(TAG, "Release " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "] [" + ExoPlayerLibraryInfo.registeredModules() + "]"); mediaSource = null; internalPlayer.release(); eventHandler.removeCallbacksAndMessages(null); playbackInfo = getResetPlaybackInfo( /* resetPosition= */ false, /* resetState= */ false, /* resetError= */ false, /* playbackState= */ Player.STATE_IDLE); }
Example 5
Source File: FrameworkMediaDrm.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * If the LA_URL tag is missing, injects a mock LA_URL value to avoid causing the CDM to throw * when creating the key request. The LA_URL attribute is optional but some Android PlayReady * implementations are known to require it. Does nothing it the provided {@code data} already * contains an LA_URL value. */ private static byte[] addLaUrlAttributeIfMissing(byte[] data) { ParsableByteArray byteArray = new ParsableByteArray(data); // See https://docs.microsoft.com/en-us/playready/specifications/specifications for more // information about the init data format. int length = byteArray.readLittleEndianInt(); int objectRecordCount = byteArray.readLittleEndianShort(); int recordType = byteArray.readLittleEndianShort(); if (objectRecordCount != 1 || recordType != 1) { Log.i(TAG, "Unexpected record count or type. Skipping LA_URL workaround."); return data; } int recordLength = byteArray.readLittleEndianShort(); String xml = byteArray.readString(recordLength, Charset.forName(C.UTF16LE_NAME)); if (xml.contains("<LA_URL>")) { // LA_URL already present. Do nothing. return data; } // This PlayReady object record does not include an LA_URL. We add a mock value for it. int endOfDataTagIndex = xml.indexOf("</DATA>"); if (endOfDataTagIndex == -1) { Log.w(TAG, "Could not find the </DATA> tag. Skipping LA_URL workaround."); } String xmlWithMockLaUrl = xml.substring(/* beginIndex= */ 0, /* endIndex= */ endOfDataTagIndex) + MOCK_LA_URL + xml.substring(/* beginIndex= */ endOfDataTagIndex); int extraBytes = MOCK_LA_URL.length() * UTF_16_BYTES_PER_CHARACTER; ByteBuffer newData = ByteBuffer.allocate(length + extraBytes); newData.order(ByteOrder.LITTLE_ENDIAN); newData.putInt(length + extraBytes); newData.putShort((short) objectRecordCount); newData.putShort((short) recordType); newData.putShort((short) (xmlWithMockLaUrl.length() * UTF_16_BYTES_PER_CHARACTER)); newData.put(xmlWithMockLaUrl.getBytes(Charset.forName(C.UTF16LE_NAME))); return newData.array(); }
Example 6
Source File: ExoPlayerImpl.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void release(boolean async) { Log.i(TAG, "Release " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "] [" + ExoPlayerLibraryInfo.registeredModules() + "]"); mediaSource = null; internalPlayer.release(); eventHandler.removeCallbacksAndMessages(null); playbackInfo = getResetPlaybackInfo( /* resetPosition= */ false, /* resetState= */ false, /* playbackState= */ Player.STATE_IDLE); }
Example 7
Source File: FrameworkMediaDrm.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * If the LA_URL tag is missing, injects a mock LA_URL value to avoid causing the CDM to throw * when creating the key request. The LA_URL attribute is optional but some Android PlayReady * implementations are known to require it. Does nothing it the provided {@code data} already * contains an LA_URL value. */ private static byte[] addLaUrlAttributeIfMissing(byte[] data) { ParsableByteArray byteArray = new ParsableByteArray(data); // See https://docs.microsoft.com/en-us/playready/specifications/specifications for more // information about the init data format. int length = byteArray.readLittleEndianInt(); int objectRecordCount = byteArray.readLittleEndianShort(); int recordType = byteArray.readLittleEndianShort(); if (objectRecordCount != 1 || recordType != 1) { Log.i(TAG, "Unexpected record count or type. Skipping LA_URL workaround."); return data; } int recordLength = byteArray.readLittleEndianShort(); String xml = byteArray.readString(recordLength, Charset.forName(C.UTF16LE_NAME)); if (xml.contains("<LA_URL>")) { // LA_URL already present. Do nothing. return data; } // This PlayReady object record does not include an LA_URL. We add a mock value for it. int endOfDataTagIndex = xml.indexOf("</DATA>"); if (endOfDataTagIndex == -1) { Log.w(TAG, "Could not find the </DATA> tag. Skipping LA_URL workaround."); } String xmlWithMockLaUrl = xml.substring(/* beginIndex= */ 0, /* endIndex= */ endOfDataTagIndex) + MOCK_LA_URL + xml.substring(/* beginIndex= */ endOfDataTagIndex); int extraBytes = MOCK_LA_URL.length() * UTF_16_BYTES_PER_CHARACTER; ByteBuffer newData = ByteBuffer.allocate(length + extraBytes); newData.order(ByteOrder.LITTLE_ENDIAN); newData.putInt(length + extraBytes); newData.putShort((short) objectRecordCount); newData.putShort((short) recordType); newData.putShort((short) (xmlWithMockLaUrl.length() * UTF_16_BYTES_PER_CHARACTER)); newData.put(xmlWithMockLaUrl.getBytes(Charset.forName(C.UTF16LE_NAME))); return newData.array(); }
Example 8
Source File: ExoPlayerImpl.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void release(boolean async) { Log.i(TAG, "Release " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "] [" + ExoPlayerLibraryInfo.registeredModules() + "]"); mediaSource = null; internalPlayer.release(); eventHandler.removeCallbacksAndMessages(null); playbackInfo = getResetPlaybackInfo( /* resetPosition= */ false, /* resetState= */ false, /* playbackState= */ Player.STATE_IDLE); }
Example 9
Source File: ExoPlayerImpl.java From MediaSDK with Apache License 2.0 | 4 votes |
/** * Constructs an instance. Must be called from a thread that has an associated {@link Looper}. * * @param renderers The {@link Renderer}s that will be used by the instance. * @param trackSelector The {@link TrackSelector} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance. * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance. * @param clock The {@link Clock} that will be used by the instance. * @param looper The {@link Looper} which must be used for all calls to the player and which is * used to call listeners on. */ @SuppressLint("HandlerLeak") public ExoPlayerImpl( Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl, BandwidthMeter bandwidthMeter, Clock clock, Looper looper) { Log.i(TAG, "Init " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "]"); Assertions.checkState(renderers.length > 0); this.renderers = Assertions.checkNotNull(renderers); this.trackSelector = Assertions.checkNotNull(trackSelector); this.playWhenReady = false; this.repeatMode = Player.REPEAT_MODE_OFF; this.shuffleModeEnabled = false; this.listeners = new CopyOnWriteArrayList<>(); emptyTrackSelectorResult = new TrackSelectorResult( new RendererConfiguration[renderers.length], new TrackSelection[renderers.length], null); period = new Timeline.Period(); playbackParameters = PlaybackParameters.DEFAULT; seekParameters = SeekParameters.DEFAULT; playbackSuppressionReason = PLAYBACK_SUPPRESSION_REASON_NONE; eventHandler = new Handler(looper) { @Override public void handleMessage(Message msg) { ExoPlayerImpl.this.handleEvent(msg); } }; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ 0, emptyTrackSelectorResult); pendingListenerNotifications = new ArrayDeque<>(); internalPlayer = new ExoPlayerImplInternal( renderers, trackSelector, emptyTrackSelectorResult, loadControl, bandwidthMeter, playWhenReady, repeatMode, shuffleModeEnabled, eventHandler, clock); internalPlayerHandler = new Handler(internalPlayer.getPlaybackLooper()); }
Example 10
Source File: ExoPlayerImpl.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Constructs an instance. Must be called from a thread that has an associated {@link Looper}. * * @param renderers The {@link Renderer}s that will be used by the instance. * @param trackSelector The {@link TrackSelector} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance. * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance. * @param clock The {@link Clock} that will be used by the instance. * @param looper The {@link Looper} which must be used for all calls to the player and which is * used to call listeners on. */ @SuppressLint("HandlerLeak") public ExoPlayerImpl( Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl, BandwidthMeter bandwidthMeter, Clock clock, Looper looper) { Log.i(TAG, "Init " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "]"); Assertions.checkState(renderers.length > 0); this.renderers = Assertions.checkNotNull(renderers); this.trackSelector = Assertions.checkNotNull(trackSelector); this.playWhenReady = false; this.repeatMode = Player.REPEAT_MODE_OFF; this.shuffleModeEnabled = false; this.listeners = new CopyOnWriteArrayList<>(); emptyTrackSelectorResult = new TrackSelectorResult( new RendererConfiguration[renderers.length], new TrackSelection[renderers.length], null); period = new Timeline.Period(); playbackParameters = PlaybackParameters.DEFAULT; seekParameters = SeekParameters.DEFAULT; playbackSuppressionReason = PLAYBACK_SUPPRESSION_REASON_NONE; eventHandler = new Handler(looper) { @Override public void handleMessage(Message msg) { ExoPlayerImpl.this.handleEvent(msg); } }; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ 0, emptyTrackSelectorResult); pendingListenerNotifications = new ArrayDeque<>(); internalPlayer = new ExoPlayerImplInternal( renderers, trackSelector, emptyTrackSelectorResult, loadControl, bandwidthMeter, playWhenReady, repeatMode, shuffleModeEnabled, eventHandler, clock); internalPlayerHandler = new Handler(internalPlayer.getPlaybackLooper()); }
Example 11
Source File: ExoPlayerImpl.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Constructs an instance. Must be called from a thread that has an associated {@link Looper}. * * @param renderers The {@link Renderer}s that will be used by the instance. * @param trackSelector The {@link TrackSelector} that will be used by the instance. * @param loadControl The {@link LoadControl} that will be used by the instance. * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance. * @param clock The {@link Clock} that will be used by the instance. * @param looper The {@link Looper} which must be used for all calls to the player and which is * used to call listeners on. */ @SuppressLint("HandlerLeak") public ExoPlayerImpl( Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl, BandwidthMeter bandwidthMeter, Clock clock, Looper looper) { Log.i(TAG, "Init " + Integer.toHexString(System.identityHashCode(this)) + " [" + ExoPlayerLibraryInfo.VERSION_SLASHY + "] [" + Util.DEVICE_DEBUG_INFO + "]"); Assertions.checkState(renderers.length > 0); this.renderers = Assertions.checkNotNull(renderers); this.trackSelector = Assertions.checkNotNull(trackSelector); this.playWhenReady = false; this.repeatMode = Player.REPEAT_MODE_OFF; this.shuffleModeEnabled = false; this.listeners = new CopyOnWriteArrayList<>(); emptyTrackSelectorResult = new TrackSelectorResult( new RendererConfiguration[renderers.length], new TrackSelection[renderers.length], null); period = new Timeline.Period(); playbackParameters = PlaybackParameters.DEFAULT; seekParameters = SeekParameters.DEFAULT; playbackSuppressionReason = PLAYBACK_SUPPRESSION_REASON_NONE; eventHandler = new Handler(looper) { @Override public void handleMessage(Message msg) { ExoPlayerImpl.this.handleEvent(msg); } }; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ 0, emptyTrackSelectorResult); pendingListenerNotifications = new ArrayDeque<>(); internalPlayer = new ExoPlayerImplInternal( renderers, trackSelector, emptyTrackSelectorResult, loadControl, bandwidthMeter, playWhenReady, repeatMode, shuffleModeEnabled, eventHandler, clock); internalPlayerHandler = new Handler(internalPlayer.getPlaybackLooper()); }