package com.foxx.androidcast.stats;

/*********************************************************************
 * SessionStatsEventMapper.java
 * Created at: Tue 19 May 2026 19:43:06 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class SessionStatsEventMapper
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (2 commits, 51 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	68ccd134a6f5d7b70bf0aeae86a303a50fb5e3666e427c658fb338b55e75881c
**********************************************************************/
import com.foxx.androidcast.network.CastProtocol;

/** Maps cast protocol message types to session journal event types. */
public final class SessionStatsEventMapper {
  public static final String KF = "kf";
  public static final String VIDEO = "video";
  public static final String AUDIO = "audio";
  public static final String META = "meta";
  public static final String SERVICE = "service";
  public static final String UNKNOWN = "unknown";
  public static final String GENERAL = "general";

  private SessionStatsEventMapper() {}

  /** Returns journal type for an app-layer message, or null if it should not be logged. */
  public static String eventTypeForMessage(byte type, boolean keyFrame) {
    switch (type) {
      case CastProtocol.MSG_VIDEO_FRAME:
        return keyFrame ? KF : VIDEO;
      case CastProtocol.MSG_AUDIO_FRAME:
        return AUDIO;
      case CastProtocol.MSG_STREAM_CONFIG:
      case CastProtocol.MSG_AUDIO_CONFIG:
      case CastProtocol.MSG_NETWORK_STATS:
      case CastProtocol.MSG_NETWORK_CONTROL:
        return META;
      case CastProtocol.MSG_HELLO:
      case CastProtocol.MSG_AUTH:
      case CastProtocol.MSG_AUTH_OK:
      case CastProtocol.MSG_AUTH_FAIL:
      case CastProtocol.MSG_CAST_SETTINGS:
      case CastProtocol.MSG_RECEIVER_CAST_SETTINGS:
      case CastProtocol.MSG_CODEC_CAPS:
      case CastProtocol.MSG_CODEC_SELECTED:
      case CastProtocol.MSG_GOODBYE:
      case CastProtocol.MSG_AUDIO_CONSENT:
        return SERVICE;
      default:
        return UNKNOWN;
    }
  }
}
