• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <utils/String8.h>
18 
19 #include <media/omx/1.0/WOmxBufferSource.h>
20 #include <media/omx/1.0/Conversion.h>
21 
22 namespace android {
23 namespace hardware {
24 namespace media {
25 namespace omx {
26 namespace V1_0 {
27 namespace utils {
28 
29 // LWOmxBufferSource
LWOmxBufferSource(sp<IOmxBufferSource> const & base)30 LWOmxBufferSource::LWOmxBufferSource(sp<IOmxBufferSource> const& base) :
31     mBase(base) {
32 }
33 
onOmxExecuting()34 ::android::binder::Status LWOmxBufferSource::onOmxExecuting() {
35     return toBinderStatus(mBase->onOmxExecuting());
36 }
37 
onOmxIdle()38 ::android::binder::Status LWOmxBufferSource::onOmxIdle() {
39     return toBinderStatus(mBase->onOmxIdle());
40 }
41 
onOmxLoaded()42 ::android::binder::Status LWOmxBufferSource::onOmxLoaded() {
43     return toBinderStatus(mBase->onOmxLoaded());
44 }
45 
onInputBufferAdded(int32_t bufferId)46 ::android::binder::Status LWOmxBufferSource::onInputBufferAdded(
47         int32_t bufferId) {
48     return toBinderStatus(mBase->onInputBufferAdded(
49             static_cast<uint32_t>(bufferId)));
50 }
51 
onInputBufferEmptied(int32_t bufferId,OMXFenceParcelable const & fenceParcel)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));
64     native_handle_close(fenceNh);
65     native_handle_delete(fenceNh);
66     return status;
67 }
68 
69 // TWOmxBufferSource
TWOmxBufferSource(sp<IOMXBufferSource> const & base)70 TWOmxBufferSource::TWOmxBufferSource(sp<IOMXBufferSource> const& base) :
71     mBase(base) {
72 }
73 
onOmxExecuting()74 Return<void> TWOmxBufferSource::onOmxExecuting() {
75     mBase->onOmxExecuting();
76     return Void();
77 }
78 
onOmxIdle()79 Return<void> TWOmxBufferSource::onOmxIdle() {
80     mBase->onOmxIdle();
81     return Void();
82 }
83 
onOmxLoaded()84 Return<void> TWOmxBufferSource::onOmxLoaded() {
85     mBase->onOmxLoaded();
86     return Void();
87 }
88 
onInputBufferAdded(uint32_t buffer)89 Return<void> TWOmxBufferSource::onInputBufferAdded(uint32_t buffer) {
90     mBase->onInputBufferAdded(int32_t(buffer));
91     return Void();
92 }
93 
onInputBufferEmptied(uint32_t buffer,hidl_handle const & fence)94 Return<void> TWOmxBufferSource::onInputBufferEmptied(
95         uint32_t buffer, hidl_handle const& fence) {
96     OMXFenceParcelable fenceParcelable;
97     if (!convertTo(&fenceParcelable, fence)) {
98         return Void();
99     }
100     mBase->onInputBufferEmptied(int32_t(buffer), fenceParcelable);
101     return Void();
102 }
103 
104 }  // namespace utils
105 }  // namespace V1_0
106 }  // namespace omx
107 }  // namespace media
108 }  // namespace hardware
109 }  // namespace android
110