• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.media.benchmark.library;
18 import android.media.MediaCodec;
19 import java.nio.ByteBuffer;
20 /**
21  * interfaces that can be used to implement
22  * sending of buffers to external and receive using callbacks
23  */
24 public class IBufferXfer {
25   static class BufferXferInfo {
26       public ByteBuffer buf;
27       public int idx;
28       public Object obj;
29       int flag;
30       int bytesRead;
31       long presentationTimeUs;
32   }
33 
34   public interface IReceiveBuffer {
35       // Implemented by sender to get buffers back
receiveBuffer(BufferXferInfo info)36       boolean receiveBuffer(BufferXferInfo info);
37       // Establishes a connection between the buffer sender and receiver.
38       // Implemented by the entity that sends the buffers to receiver.
39       // the receiverInterface is the interface of the receiver.
40       // The sender uses this interface to send buffers.
connect(IBufferXfer.ISendBuffer receiverInterface)41       boolean connect(IBufferXfer.ISendBuffer receiverInterface);
42   }
43   // Implemented by an entity that does not own the buffers and only
44   // wants to manage the buffers. ( Usually the receiver)
45   // The receiver uses returnIface to return the buffers to sender
46   public interface ISendBuffer {
sendBuffer(IBufferXfer.IReceiveBuffer returnIface, BufferXferInfo info)47       boolean sendBuffer(IBufferXfer.IReceiveBuffer returnIface,
48                               BufferXferInfo info);
49   }
50 }
51