• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 CODEC_BASE_H_
18 
19 #define CODEC_BASE_H_
20 
21 #include <stdint.h>
22 #include <media/IOMX.h>
23 
24 #include <media/stagefright/foundation/AHandler.h>
25 
26 namespace android {
27 
28 struct ABuffer;
29 struct PersistentSurface;
30 
31 struct CodecBase : public AHandler {
32     enum {
33         kWhatFillThisBuffer      = 'fill',
34         kWhatDrainThisBuffer     = 'drai',
35         kWhatEOS                 = 'eos ',
36         kWhatShutdownCompleted   = 'scom',
37         kWhatFlushCompleted      = 'fcom',
38         kWhatOutputFormatChanged = 'outC',
39         kWhatError               = 'erro',
40         kWhatComponentAllocated  = 'cAll',
41         kWhatComponentConfigured = 'cCon',
42         kWhatInputSurfaceCreated = 'isfc',
43         kWhatInputSurfaceAccepted = 'isfa',
44         kWhatSignaledInputEOS    = 'seos',
45         kWhatBuffersAllocated    = 'allc',
46         kWhatOutputFramesRendered = 'outR',
47     };
48 
49     virtual void setNotificationMessage(const sp<AMessage> &msg) = 0;
50 
51     virtual void initiateAllocateComponent(const sp<AMessage> &msg) = 0;
52     virtual void initiateConfigureComponent(const sp<AMessage> &msg) = 0;
53     virtual void initiateCreateInputSurface() = 0;
54     virtual void initiateSetInputSurface(
55             const sp<PersistentSurface> &surface) = 0;
56     virtual void initiateStart() = 0;
57     virtual void initiateShutdown(bool keepComponentAllocated = false) = 0;
58 
59     // require an explicit message handler
60     virtual void onMessageReceived(const sp<AMessage> &msg) = 0;
61 
setSurfaceCodecBase62     virtual status_t setSurface(const sp<Surface> &surface) { return INVALID_OPERATION; }
63 
64     virtual void signalFlush() = 0;
65     virtual void signalResume() = 0;
66 
67     virtual void signalRequestIDRFrame() = 0;
68     virtual void signalSetParameters(const sp<AMessage> &msg) = 0;
69     virtual void signalEndOfInputStream() = 0;
70 
71     struct PortDescription : public RefBase {
72         virtual size_t countBuffers() = 0;
73         virtual IOMX::buffer_id bufferIDAt(size_t index) const = 0;
74         virtual sp<ABuffer> bufferAt(size_t index) const = 0;
75 
76     protected:
77         PortDescription();
78         virtual ~PortDescription();
79 
80     private:
81         DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
82     };
83 
84 protected:
85     CodecBase();
86     virtual ~CodecBase();
87 
88 private:
89     DISALLOW_EVIL_CONSTRUCTORS(CodecBase);
90 };
91 
92 }  // namespace android
93 
94 #endif  // CODEC_BASE_H_
95 
96