1 /* 2 * Copyright (C) 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_DRM_V1_0_TYPECONVERT 18 #define ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT 19 20 #include <android/hardware/drm/1.0/types.h> 21 #include <media/stagefright/MediaErrors.h> 22 #include <utils/Vector.h> 23 24 namespace android { 25 namespace hardware { 26 namespace drm { 27 namespace V1_0 { 28 namespace implementation { 29 30 using ::android::hardware::hidl_vec; 31 32 template<typename T> const hidl_vec<T> toHidlVec(const Vector<T> &Vector) { 33 hidl_vec<T> vec; 34 vec.setToExternal(const_cast<T *>(Vector.array()), Vector.size()); 35 return vec; 36 } 37 38 template<typename T> hidl_vec<T> toHidlVec(Vector<T> &Vector) { 39 hidl_vec<T> vec; 40 vec.setToExternal(Vector.editArray(), Vector.size()); 41 return vec; 42 } 43 44 template<typename T> const Vector<T> toVector(const hidl_vec<T> &vec) { 45 Vector<T> vector; 46 vector.appendArray(vec.data(), vec.size()); 47 return *const_cast<const Vector<T> *>(&vector); 48 } 49 50 template<typename T> Vector<T> toVector(hidl_vec<T> &vec) { 51 Vector<T> vector; 52 vector.appendArray(vec.data(), vec.size()); 53 return vector; 54 } 55 56 template<typename T, size_t SIZE> const Vector<T> toVector( 57 const hidl_array<T, SIZE> &array) { 58 Vector<T> vector; 59 vector.appendArray(array.data(), array.size()); 60 return vector; 61 } 62 63 template<typename T, size_t SIZE> Vector<T> toVector( 64 hidl_array<T, SIZE> &array) { 65 Vector<T> vector; 66 vector.appendArray(array.data(), array.size()); 67 return vector; 68 } 69 70 Status toStatus(status_t legacyStatus); 71 72 } // namespace implementation 73 } // namespace V1_0 74 } // namespace drm 75 } // namespace hardware 76 } // namespace android 77 78 #endif // ANDROID_HARDWARE_DRM_V1_0_TYPECONVERT 79