1/*
2 * Copyright 2016, 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_HARDWARE_MEDIA_OMX_V1_0_OMX_H
18#define ANDROID_HARDWARE_MEDIA_OMX_V1_0_OMX_H
19
20#include <hidl/MQDescriptor.h>
21#include <hidl/Status.h>
22
23#include "../../include/OMXNodeInstance.h"
24
25#include <android/hardware/media/omx/1.0/IOmx.h>
26#include <media/vndk/xmlparser/1.0/MediaCodecsXmlParser.h>
27
28namespace android {
29
30struct OMXMaster;
31
32namespace hardware {
33namespace media {
34namespace omx {
35namespace V1_0 {
36namespace implementation {
37
38using ::android::hardware::media::omx::V1_0::IOmx;
39using ::android::hardware::media::omx::V1_0::IOmxNode;
40using ::android::hardware::media::omx::V1_0::IOmxObserver;
41using ::android::hardware::media::omx::V1_0::Status;
42using ::android::hidl::base::V1_0::IBase;
43using ::android::hardware::hidl_death_recipient;
44using ::android::hardware::hidl_array;
45using ::android::hardware::hidl_memory;
46using ::android::hardware::hidl_string;
47using ::android::hardware::hidl_vec;
48using ::android::hardware::Return;
49using ::android::hardware::Void;
50using ::android::sp;
51using ::android::wp;
52
53using ::android::OMXMaster;
54using ::android::OmxNodeOwner;
55using ::android::OMXNodeInstance;
56
57struct Omx : public IOmx, public hidl_death_recipient, public OmxNodeOwner {
58    Omx();
59    virtual ~Omx();
60
61    // Methods from IOmx
62    Return<void> listNodes(listNodes_cb _hidl_cb) override;
63    Return<void> allocateNode(
64            const hidl_string& name,
65            const sp<IOmxObserver>& observer,
66            allocateNode_cb _hidl_cb) override;
67    Return<void> createInputSurface(createInputSurface_cb _hidl_cb) override;
68
69    // Method from hidl_death_recipient
70    void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
71
72    // Method from OmxNodeOwner
73    virtual status_t freeNode(sp<OMXNodeInstance> const& instance) override;
74
75protected:
76    OMXMaster* mMaster;
77    Mutex mLock;
78    KeyedVector<wp<IBase>, sp<OMXNodeInstance> > mLiveNodes;
79    KeyedVector<OMXNodeInstance*, wp<IBase> > mNode2Observer;
80    MediaCodecsXmlParser mParser;
81};
82
83extern "C" IOmx* HIDL_FETCH_IOmx(const char* name);
84
85}  // namespace implementation
86}  // namespace V1_0
87}  // namespace omx
88}  // namespace media
89}  // namespace hardware
90}  // namespace android
91
92#endif  // ANDROID_HARDWARE_MEDIA_OMX_V1_0_OMX_H
93