/* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.tv.tuner.util; import java.util.Locale; /** * Utility class for tuner status messages. */ public class StatusTextUtils { private static final int PACKETS_PER_SEC_YELLOW = 1500; private static final int PACKETS_PER_SEC_RED = 1000; private static final int AUDIO_POSITION_MS_RATE_DIFF_YELLOW = 100; private static final int AUDIO_POSITION_MS_RATE_DIFF_RED = 200; private static final String COLOR_RED = "red"; private static final String COLOR_YELLOW = "yellow"; private static final String COLOR_GREEN = "green"; private static final String COLOR_GRAY = "gray"; private StatusTextUtils() { } /** * Returns tuner status warning message in HTML. * *
This is only called for debuging and always shown in english.
*/ public static String getStatusWarningInHTML(long packetsPerSec, int videoFrameDrop, int bytesInQueue, long audioPositionUs, long audioPositionUsRate, long audioPtsUs, long audioPtsUsRate, long videoPtsUs, long videoPtsUsRate) { StringBuffer buffer = new StringBuffer(); // audioPosition should go in rate of 1000ms. long audioPositionMsRate = audioPositionUsRate / 1000; String audioPositionColor; if (Math.abs(audioPositionMsRate - 1000) > AUDIO_POSITION_MS_RATE_DIFF_RED) { audioPositionColor = COLOR_RED; } else if (Math.abs(audioPositionMsRate - 1000) > AUDIO_POSITION_MS_RATE_DIFF_YELLOW) { audioPositionColor = COLOR_YELLOW; } else { audioPositionColor = COLOR_GRAY; } buffer.append(String.format(Locale.US, "", audioPositionColor)); buffer.append( String.format(Locale.US, "audioPositionMs: %d (%d)