• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 #pragma once
18 
19 #include <media/stagefright/bqhelper/GraphicBufferSource.h>
20 #include <media/stagefright/foundation/ABase.h>
21 
22 #include <media/stagefright/aidlpersistentsurface/IAidlNodeWrapper.h>
23 
24 #include <utils/Errors.h>
25 
26 #include <aidl/android/media/BnAidlBufferSource.h>
27 
28 namespace android::media {
29 
30 /*
31  * This class is used to feed codec encoders from a Surface via BufferQueue or
32  * HW producer using AIDL binder interfaces.
33  *
34  * See media/stagefright/bqhelper/GraphicBufferSource.h for documentation.
35  */
36 class AidlGraphicBufferSource : public GraphicBufferSource {
37 public:
38     AidlGraphicBufferSource() = default;
39     virtual ~AidlGraphicBufferSource() = default;
40 
41     // For IAidlBufferSource interface
42     // ------------------------------
43 
44     // When we can start handling buffers.  If we already have buffers of data
45     // sitting in the BufferQueue, this will send them to the codec.
46     ::ndk::ScopedAStatus onStart();
47 
48     // When the codec is meant to return all buffers back to the client for
49     // them to be freed. Do NOT submit any more buffers to the component.
50     ::ndk::ScopedAStatus onStop();
51 
52     // When we are shutting down.
53     ::ndk::ScopedAStatus onRelease();
54 
55     // Rest of the interface in GraphicBufferSource.
56 
57     // IAidlGraphicBufferSource interface
58     // ------------------------------
59 
60     // Configure the buffer source to be used with a codec2 aidl node given
61     // parameters.
62     status_t configure(
63         const sp<IAidlNodeWrapper> &aidlNode,
64         int32_t dataSpace,
65         int32_t bufferCount,
66         uint32_t frameWidth,
67         uint32_t frameHeight,
68         uint64_t consumerUsage);
69 
70     // Rest of the interface in GraphicBufferSource.
71 
72 private:
73     DISALLOW_EVIL_CONSTRUCTORS(AidlGraphicBufferSource);
74 };
75 
76 }  // namespace android::media
77