blob: 7cca5bd52f531937f71862cc719b335bc93a9c04 [file] [log] [blame]
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -08001/*
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
Pawin Vongmasa0d3a5ed2017-02-22 03:19:35 -080017#include <utils/String8.h>
18
Pawin Vongmasaac7d4122017-03-01 05:48:42 -080019#include <media/omx/1.0/WOmxBufferSource.h>
20#include <media/omx/1.0/Conversion.h>
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080021
22namespace android {
23namespace hardware {
24namespace media {
25namespace omx {
26namespace V1_0 {
27namespace utils {
28
29// LWOmxBufferSource
30LWOmxBufferSource::LWOmxBufferSource(sp<IOmxBufferSource> const& base) :
31 mBase(base) {
32}
33
34::android::binder::Status LWOmxBufferSource::onOmxExecuting() {
35 return toBinderStatus(mBase->onOmxExecuting());
36}
37
38::android::binder::Status LWOmxBufferSource::onOmxIdle() {
39 return toBinderStatus(mBase->onOmxIdle());
40}
41
42::android::binder::Status LWOmxBufferSource::onOmxLoaded() {
43 return toBinderStatus(mBase->onOmxLoaded());
44}
45
46::android::binder::Status LWOmxBufferSource::onInputBufferAdded(
47 int32_t bufferId) {
48 return toBinderStatus(mBase->onInputBufferAdded(
49 static_cast<uint32_t>(bufferId)));
50}
51
52::android::binder::Status LWOmxBufferSource::onInputBufferEmptied(
53 int32_t bufferId, OMXFenceParcelable const& fenceParcel) {
54 hidl_handle fence;
55 native_handle_t* fenceNh;
56 if (!wrapAs(&fence, &fenceNh, fenceParcel)) {
57 return ::android::binder::Status::fromExceptionCode(
58 ::android::binder::Status::EX_BAD_PARCELABLE,
59 "Invalid fence");
60 }
61 ::android::binder::Status status = toBinderStatus(
62 mBase->onInputBufferEmptied(
63 static_cast<uint32_t>(bufferId), fence));
Pawin Vongmasa8ff40182017-02-07 02:22:34 -080064 native_handle_close(fenceNh);
65 native_handle_delete(fenceNh);
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080066 return status;
67}
68
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080069// TWOmxBufferSource
70TWOmxBufferSource::TWOmxBufferSource(sp<IOMXBufferSource> const& base) :
71 mBase(base) {
72}
73
74Return<void> TWOmxBufferSource::onOmxExecuting() {
Pawin Vongmasa8ff40182017-02-07 02:22:34 -080075 mBase->onOmxExecuting();
76 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080077}
78
79Return<void> TWOmxBufferSource::onOmxIdle() {
Pawin Vongmasa8ff40182017-02-07 02:22:34 -080080 mBase->onOmxIdle();
81 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080082}
83
84Return<void> TWOmxBufferSource::onOmxLoaded() {
Pawin Vongmasa8ff40182017-02-07 02:22:34 -080085 mBase->onOmxLoaded();
86 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080087}
88
89Return<void> TWOmxBufferSource::onInputBufferAdded(uint32_t buffer) {
Pawin Vongmasa8ff40182017-02-07 02:22:34 -080090 mBase->onInputBufferAdded(int32_t(buffer));
91 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080092}
93
94Return<void> TWOmxBufferSource::onInputBufferEmptied(
95 uint32_t buffer, hidl_handle const& fence) {
96 OMXFenceParcelable fenceParcelable;
97 if (!convertTo(&fenceParcelable, fence)) {
Pawin Vongmasa223b8e32017-02-22 20:32:25 -080098 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -080099 }
Pawin Vongmasa8ff40182017-02-07 02:22:34 -0800100 mBase->onInputBufferEmptied(int32_t(buffer), fenceParcelable);
101 return Void();
Pawin Vongmasaeeac97b2017-01-18 05:03:07 -0800102}
103
104} // namespace utils
105} // namespace V1_0
106} // namespace omx
107} // namespace media
108} // namespace hardware
109} // namespace android