Java Code Examples for com.google.android.exoplayer2.C#STREAM_TYPE_DEFAULT

The following examples show how to use com.google.android.exoplayer2.C#STREAM_TYPE_DEFAULT . 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: Util.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 2
Source File: DefaultAudioSink.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
  int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
  int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
  @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT;
  int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback.
  return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize,
      MODE_STATIC, audioSessionId);
}
 
Example 3
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 4
Source File: DefaultAudioSink.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
  int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
  int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
  @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT;
  int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback.
  return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize,
      MODE_STATIC, audioSessionId);
}
 
Example 5
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 6
Source File: DefaultAudioSink.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
  int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
  int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
  @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT;
  int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback.
  return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize,
      MODE_STATIC, audioSessionId);
}
 
Example 7
Source File: AudioTrack.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * @param audioCapabilities The audio capabilities for playback on this device. May be null if the
 *     default capabilities (no encoded audio passthrough support) should be assumed.
 * @param audioProcessors An array of {@link AudioProcessor}s that will process PCM audio before
 *     output. May be empty.
 * @param listener Listener for audio track events.
 */
public AudioTrack(AudioCapabilities audioCapabilities, AudioProcessor[] audioProcessors,
    Listener listener) {
  this.audioCapabilities = audioCapabilities;
  channelMappingAudioProcessor = new ChannelMappingAudioProcessor();
  availableAudioProcessors = new AudioProcessor[audioProcessors.length + 2];
  availableAudioProcessors[0] = new ResamplingAudioProcessor();
  availableAudioProcessors[1] = channelMappingAudioProcessor;
  System.arraycopy(audioProcessors, 0, availableAudioProcessors, 2, audioProcessors.length);
  this.listener = listener;
  releasingConditionVariable = new ConditionVariable(true);
  if (Util.SDK_INT >= 18) {
    try {
      getLatencyMethod =
          android.media.AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
    } catch (NoSuchMethodException e) {
      // There's no guarantee this method exists. Do nothing.
    }
  }
  if (Util.SDK_INT >= 23) {
    audioTrackUtil = new AudioTrackUtilV23();
  } else if (Util.SDK_INT >= 19) {
    audioTrackUtil = new AudioTrackUtilV19();
  } else {
    audioTrackUtil = new AudioTrackUtil();
  }
  playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
  volume = 1.0f;
  startMediaTimeState = START_NOT_SET;
  streamType = C.STREAM_TYPE_DEFAULT;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  drainingAudioProcessorIndex = C.INDEX_UNSET;
  this.audioProcessors = new AudioProcessor[0];
  outputBuffers = new ByteBuffer[0];
}
 
Example 8
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 9
Source File: DefaultAudioSink.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
  int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
  int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
  @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT;
  int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback.
  return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize,
      MODE_STATIC, audioSessionId);
}
 
Example 10
Source File: Util.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 11
Source File: DefaultAudioSink.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static AudioTrack initializeKeepSessionIdAudioTrack(int audioSessionId) {
  int sampleRate = 4000; // Equal to private AudioTrack.MIN_SAMPLE_RATE.
  int channelConfig = AudioFormat.CHANNEL_OUT_MONO;
  @C.PcmEncoding int encoding = C.ENCODING_PCM_16BIT;
  int bufferSize = 2; // Use a two byte buffer, as it is not actually used for playback.
  return new AudioTrack(C.STREAM_TYPE_DEFAULT, sampleRate, channelConfig, encoding, bufferSize,
      MODE_STATIC, audioSessionId);
}