• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018, 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 INPUT_SURFACE_WRAPPER_H_
18 #define INPUT_SURFACE_WRAPPER_H_
19 
20 #include <codec2/hidl/client.h>
21 
22 namespace android {
23 
24 /**
25  * Wrapper interface around InputSurface.
26  */
27 class InputSurfaceWrapper {
28 public:
29     virtual ~InputSurfaceWrapper() = default;
30 
31     /**
32      * Connect the surface with |comp| and start pushing buffers. A surface can
33      * connect to at most one component at a time.
34      *
35      * \return OK               successfully connected to |comp|
36      * \return ALREADY_EXISTS   already connected to another component.
37      */
38     virtual status_t connect(
39             const std::shared_ptr<Codec2Client::Component> &comp) = 0;
40 
41     /**
42      * Disconnect the surface from the component if any.
43      */
44     virtual void disconnect() = 0;
45 
46     /**
47      * Ref: GraphicBufferSource::signalEndOfInputStream.
48      */
49     virtual status_t signalEndOfInputStream() = 0;
50 
51     /// Input Surface configuration
52     struct Config {
53         // IN PARAMS (GBS)
54         float mMinFps; // minimum fps (repeat frame to achieve this)
55         float mMaxFps; // max fps (via frame drop)
56         float mCaptureFps; // capture fps
57         bool mSuspended; // suspended
58         int64_t mTimeOffsetUs; // time offset (input => codec)
59         int64_t mSuspendAtUs; // suspend/resume time
60         int64_t mStartAtUs; // start time
61         bool mStopped; // stopped
62         int64_t mStopAtUs; // stop time
63 
64         // OUT PARAMS (GBS)
65         int64_t mInputDelayUs; // delay between encoder input and surface input
66 
67         // IN PARAMS (CODEC WRAPPER)
68         float mFixedAdjustedFps; // fixed fps via PTS manipulation
69         float mMinAdjustedFps; // minimum fps via PTS manipulation
70     };
71 
72     /**
73      * Configures input surface.
74      *
75      * \param config configuration. This can be updated during this call to provide output
76      *               parameters, but not to provide configured parameters (to avoid continually
77      *               reconfiguring)
78      */
79     virtual status_t configure(Config &config) = 0;
80 };
81 
82 }  // namespace android
83 
84 #endif  // INPUT_SURFACE_WRAPPER_H_
85