summaryrefslogtreecommitdiffstats
path: root/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java
blob: d1d0728fac169ccf9f28e6372ed74f0141a97fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.gecko.media;

import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodec.CryptoInfo;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Handler;
import android.view.Surface;
import java.nio.ByteBuffer;

// A wrapper interface that mimics the new {@link android.media.MediaCodec}
// asynchronous mode API in Lollipop.
public interface AsyncCodec {
  public interface Callbacks {
    void onInputBufferAvailable(AsyncCodec codec, int index);

    void onOutputBufferAvailable(AsyncCodec codec, int index, BufferInfo info);

    void onError(AsyncCodec codec, int error);

    void onOutputFormatChanged(AsyncCodec codec, MediaFormat format);
  }

  public abstract void setCallbacks(Callbacks callbacks, Handler handler);

  public abstract void configure(
      MediaFormat format, Surface surface, MediaCrypto crypto, int flags);

  public abstract boolean isAdaptivePlaybackSupported(String mimeType);

  public abstract boolean isTunneledPlaybackSupported(final String mimeType);

  public abstract void start();

  public abstract void stop();

  public abstract void flush();

  // Must be called after flush().
  public abstract void resumeReceivingInputs();

  public abstract void release();

  public abstract ByteBuffer getInputBuffer(int index);

  public abstract MediaFormat getInputFormat();

  public abstract ByteBuffer getOutputBuffer(int index);

  public abstract void queueInputBuffer(
      int index, int offset, int size, long presentationTimeUs, int flags);

  public abstract void setBitrate(int bps);

  public abstract void queueSecureInputBuffer(
      int index, int offset, CryptoInfo info, long presentationTimeUs, int flags);

  public abstract void releaseOutputBuffer(int index, boolean render);
}