use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class EventLogger method getEventString.
private String getEventString(EventTime eventTime, String eventName, @Nullable String eventDescription, @Nullable Throwable throwable) {
String eventString = eventName + " [" + getEventTimeString(eventTime);
if (throwable instanceof PlaybackException) {
eventString += ", errorCode=" + ((PlaybackException) throwable).getErrorCodeName();
}
if (eventDescription != null) {
eventString += ", " + eventDescription;
}
@Nullable String throwableString = Log.getThrowableString(throwable);
if (!TextUtils.isEmpty(throwableString)) {
eventString += "\n " + throwableString.replace("\n", "\n ") + '\n';
}
eventString += "]";
return eventString;
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class EventLogger method onTracksChanged.
@Override
public void onTracksChanged(EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
MappedTrackInfo mappedTrackInfo = trackSelector != null ? trackSelector.getCurrentMappedTrackInfo() : null;
if (mappedTrackInfo == null) {
logd(eventTime, "tracks", "[]");
return;
}
logd("tracks [" + getEventTimeString(eventTime));
// Log tracks associated to renderers.
int rendererCount = mappedTrackInfo.getRendererCount();
for (int rendererIndex = 0; rendererIndex < rendererCount; rendererIndex++) {
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
TrackSelection trackSelection = trackSelections.get(rendererIndex);
if (rendererTrackGroups.length == 0) {
logd(" " + mappedTrackInfo.getRendererName(rendererIndex) + " []");
} else {
logd(" " + mappedTrackInfo.getRendererName(rendererIndex) + " [");
for (int groupIndex = 0; groupIndex < rendererTrackGroups.length; groupIndex++) {
TrackGroup trackGroup = rendererTrackGroups.get(groupIndex);
String adaptiveSupport = getAdaptiveSupportString(trackGroup.length, mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, /* includeCapabilitiesExceededTracks= */
false));
logd(" Group:" + trackGroup.id + ", adaptive_supported=" + adaptiveSupport + " [");
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
@Capabilities int capabilities = mappedTrackInfo.getCapabilities(rendererIndex, groupIndex, trackIndex);
String formatSupport = getFormatSupportString(getFormatSupport(capabilities));
String hardwareAccelerationSupport = getHardwareAccelerationSupport(capabilities) == HARDWARE_ACCELERATION_SUPPORTED ? ", accelerated=YES" : "";
String decoderSupport = getDecoderSupport(capabilities) == DECODER_SUPPORT_FALLBACK ? ", fallback=YES" : "";
logd(" " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport + hardwareAccelerationSupport + decoderSupport);
}
logd(" ]");
}
// Log metadata for at most one of the tracks selected for the renderer.
if (trackSelection != null) {
for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
if (metadata != null) {
logd(" Metadata [");
printMetadata(metadata, " ");
logd(" ]");
break;
}
}
}
logd(" ]");
}
}
// Log tracks not associated with a renderer.
TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
if (unassociatedTrackGroups.length > 0) {
logd(" Unmapped [");
for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
logd(" Group:" + groupIndex + " [");
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
String status = getTrackStatusString(false);
String formatSupport = getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
logd(" " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
}
logd(" ]");
}
logd(" ]");
}
logd("]");
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method updateSessions_ofSameWindow_withAd_afterWithoutMediaPeriodId_createsNewSession.
@Test
public void updateSessions_ofSameWindow_withAd_afterWithoutMediaPeriodId_createsNewSession() {
Timeline timeline = new FakeTimeline();
MediaPeriodId mediaPeriodId = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* adGroupIndex= */
0, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0);
EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
0, /* mediaPeriodId= */
null);
EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
0, mediaPeriodId);
sessionManager.updateSessions(eventTime1);
sessionManager.updateSessions(eventTime2);
ArgumentCaptor<String> contentSessionId = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> adSessionId = ArgumentCaptor.forClass(String.class);
verify(mockListener).onSessionCreated(eq(eventTime1), contentSessionId.capture());
verify(mockListener).onSessionCreated(eq(eventTime2), adSessionId.capture());
verify(mockListener).onSessionActive(eventTime1, contentSessionId.getValue());
verifyNoMoreInteractions(mockListener);
assertThat(contentSessionId).isNotEqualTo(adSessionId);
assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId)).isEqualTo(adSessionId.getValue());
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method updateSessions_ofOtherWindow_createsNewSession.
@Test
public void updateSessions_ofOtherWindow_createsNewSession() {
Timeline timeline = new FakeTimeline(/* windowCount= */
2);
EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
0, /* mediaPeriodId= */
null);
EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
1, /* mediaPeriodId= */
null);
sessionManager.updateSessions(eventTime1);
sessionManager.updateSessions(eventTime2);
ArgumentCaptor<String> sessionId1 = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> sessionId2 = ArgumentCaptor.forClass(String.class);
verify(mockListener).onSessionCreated(eq(eventTime1), sessionId1.capture());
verify(mockListener).onSessionCreated(eq(eventTime2), sessionId2.capture());
verify(mockListener).onSessionActive(eventTime1, sessionId1.getValue());
verifyNoMoreInteractions(mockListener);
assertThat(sessionId1).isNotEqualTo(sessionId2);
}
use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method positionDiscontinuity_toNewWindow_finishesOnlyPastSessions.
@Test
public void positionDiscontinuity_toNewWindow_finishesOnlyPastSessions() {
Timeline timeline = new FakeTimeline(/* windowCount= */
4);
EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
0, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
1, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
1));
EventTime eventTime3 = createEventTime(timeline, /* windowIndex= */
2, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
2), /* windowSequenceNumber= */
2));
EventTime eventTime4 = createEventTime(timeline, /* windowIndex= */
3, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
3), /* windowSequenceNumber= */
3));
sessionManager.updateSessionsWithTimelineChange(eventTime1);
sessionManager.updateSessions(eventTime1);
sessionManager.updateSessions(eventTime2);
sessionManager.updateSessions(eventTime3);
sessionManager.updateSessions(eventTime4);
String sessionId1 = sessionManager.getSessionForMediaPeriodId(timeline, eventTime1.mediaPeriodId);
String sessionId2 = sessionManager.getSessionForMediaPeriodId(timeline, eventTime2.mediaPeriodId);
sessionManager.updateSessionsWithDiscontinuity(eventTime3, Player.DISCONTINUITY_REASON_SEEK);
verify(mockListener).onSessionCreated(eventTime1, sessionId1);
verify(mockListener).onSessionActive(eventTime1, sessionId1);
verify(mockListener).onSessionCreated(eventTime2, sessionId2);
verify(mockListener).onSessionCreated(eq(eventTime3), anyString());
verify(mockListener).onSessionCreated(eq(eventTime4), anyString());
verify(mockListener).onSessionFinished(eventTime3, sessionId1, /* automaticTransitionToNextPlayback= */
false);
verify(mockListener).onSessionFinished(eventTime3, sessionId2, /* automaticTransitionToNextPlayback= */
false);
verify(mockListener).onSessionActive(eq(eventTime3), anyString());
verifyNoMoreInteractions(mockListener);
}
Aggregations