summaryrefslogtreecommitdiff
path: root/media/bufferpool/2.0/types.hal
blob: 597e7b37226fb629ccbcfa29da0a56d5c0bfb3f9 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * Copyright (C) 2018 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 android.hardware.media.bufferpool@2.0;

enum ResultStatus : int32_t {
    OK                  = 0,

    NO_MEMORY           = 1,
    ALREADY_EXISTS      = 2,
    NOT_FOUND           = 3,
    CRITICAL_ERROR      = 4,
};

/**
 * Generic buffer for fast recycling for media/stagefright.
 *
 * During media pipeline buffer references are created, shared and
 * destroyed frequently. The underlying buffers are allocated on demand
 * by a buffer pool, and are recycled to the buffer pool when they are
 * no longer referenced by the clients.
 *
 * E.g. ion or gralloc buffer
 */
struct Buffer {
    uint32_t id;
    handle buffer;
};

/**
 * Buffer ownership status for the specified client.
 * Buffer transfer status for the specified buffer transafer transaction.
 * BufferStatus is posted along with BufferStatusMessage from a client to
 * the buffer pool for synchronization after status change.
 */
enum BufferStatus : int32_t {
    /** No longer used by the specified client. */
    NOT_USED            = 0,
    /** Buffer is acquired by the specified client. */
    USED                = 1,
    /** Buffer is sent by the specified client. */
    TRANSFER_TO         = 2,
    /** Buffer transfer is acked by the receiver client. */
    TRANSFER_FROM       = 3,
    /** Buffer transfer is timed out by receiver client. */
    TRANSFER_TIMEOUT    = 4,
    /** Buffer transfer is not acked by the receiver. */
    TRANSFER_LOST       = 5,
    /** Buffer fetch request from the client. */
    TRANSFER_FETCH      = 6,
    /** Buffer transaction succeeded. */
    TRANSFER_OK         = 7,
    /** Buffer transaction failure. */
    TRANSFER_ERROR      = 8,
    /** Buffer invalidation ack. */
    INVALIDATION_ACK    = 9,
};

/**
 * Buffer ownership status change message. This message is
 * sent via fmq to the buffer pool from client processes.
 */
struct BufferStatusMessage {
    /**
     * Transaction Id = (SenderId : sender local transaction Id)
     * Transaction Id is created from sender and posted via fmq within
     * TRANSFER_TO message.
     */
    uint64_t transactionId;
    uint32_t bufferId;
    BufferStatus newStatus;
    /** Used by the buffer pool. not by client. */
    int64_t connectionId;
    /** Valid only when TRANSFER_TO is posted. */
    int64_t targetConnectionId;
    /**
     * Used by the buffer pool, not by client.
     * Monotonic timestamp in Us since fixed point in time as decided
     * by the sender of the message
     */
    int64_t timestampUs;
};

/*
 * Buffer pool sends a buffer invalidation message to clients in order to
 * ensure fast reclamation of the buffers. Clients must free the invalidated
 * buffers as soon as possible upon receiving the message.
 */
struct BufferInvalidationMessage {
    uint32_t messageId;
    /**
     * Buffers from fromBufferId to toBufferId must be invalidated.
     * fromBufferId is inclusive, but toBufferId is not inclusive.
     * If fromBufferId > toBufferID, wrap happens. In that case
     * the wrap is based on UINT32_MAX.
     */
    uint32_t fromBufferId;
    uint32_t toBufferId;
};