blob: 1e6431e801c9fd43e90b0c7c15c72a3594c81fbb [file] [log] [blame]
Dan Stozab9b08832014-03-13 11:55:57 -07001/*
2 * Copyright 2014 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#ifndef ANDROID_MONITORED_PRODUCER_H
18#define ANDROID_MONITORED_PRODUCER_H
19
20#include <gui/IGraphicBufferProducer.h>
21
22namespace android {
23
Dan Stozaf0eaf252014-03-21 13:05:51 -070024class IProducerListener;
Dan Stozab9b08832014-03-13 11:55:57 -070025class NativeHandle;
26class SurfaceFlinger;
27
28// MonitoredProducer wraps an IGraphicBufferProducer so that SurfaceFlinger will
29// be notified upon its destruction
Dan Stozab3d0bdf2014-04-07 16:33:59 -070030class MonitoredProducer : public IGraphicBufferProducer {
Dan Stozab9b08832014-03-13 11:55:57 -070031public:
Dan Stozab3d0bdf2014-04-07 16:33:59 -070032 MonitoredProducer(const sp<IGraphicBufferProducer>& producer,
Dan Stozab9b08832014-03-13 11:55:57 -070033 const sp<SurfaceFlinger>& flinger);
34 virtual ~MonitoredProducer();
35
36 // From IGraphicBufferProducer
37 virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
38 virtual status_t setBufferCount(int bufferCount);
39 virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
40 uint32_t w, uint32_t h, uint32_t format, uint32_t usage);
41 virtual status_t detachBuffer(int slot);
42 virtual status_t attachBuffer(int* outSlot,
43 const sp<GraphicBuffer>& buffer);
44 virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
45 QueueBufferOutput* output);
46 virtual void cancelBuffer(int slot, const sp<Fence>& fence);
47 virtual int query(int what, int* value);
Dan Stozaf0eaf252014-03-21 13:05:51 -070048 virtual status_t connect(const sp<IProducerListener>& token, int api,
Dan Stozab9b08832014-03-13 11:55:57 -070049 bool producerControlledByApp, QueueBufferOutput* output);
50 virtual status_t disconnect(int api);
51 virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
Dan Stozab3d0bdf2014-04-07 16:33:59 -070052 virtual IBinder* onAsBinder();
Dan Stozab9b08832014-03-13 11:55:57 -070053
54private:
Dan Stozab3d0bdf2014-04-07 16:33:59 -070055 sp<IGraphicBufferProducer> mProducer;
Dan Stozab9b08832014-03-13 11:55:57 -070056 sp<SurfaceFlinger> mFlinger;
57};
58
59}; // namespace android
60
61#endif // ANDROID_MONITORED_PRODUCER_H