1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/omx-plugin/include/ics/utils/Flattenable.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* 1.5 + * Copyright (C) 2010 The Android Open Source Project 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 + 1.20 +#ifndef ANDROID_UTILS_FLATTENABLE_H 1.21 +#define ANDROID_UTILS_FLATTENABLE_H 1.22 + 1.23 + 1.24 +#include <stdint.h> 1.25 +#include <sys/types.h> 1.26 +#include <utils/Errors.h> 1.27 + 1.28 +namespace android { 1.29 + 1.30 +class Flattenable 1.31 +{ 1.32 +public: 1.33 + // size in bytes of the flattened object 1.34 + virtual size_t getFlattenedSize() const = 0; 1.35 + 1.36 + // number of file descriptors to flatten 1.37 + virtual size_t getFdCount() const = 0; 1.38 + 1.39 + // flattens the object into buffer. 1.40 + // size should be at least of getFlattenedSize() 1.41 + // file descriptors are written in the fds[] array but ownership is 1.42 + // not transfered (ie: they must be dupped by the caller of 1.43 + // flatten() if needed). 1.44 + virtual status_t flatten(void* buffer, size_t size, 1.45 + int fds[], size_t count) const = 0; 1.46 + 1.47 + // unflattens the object from buffer. 1.48 + // size should be equal to the value of getFlattenedSize() when the 1.49 + // object was flattened. 1.50 + // unflattened file descriptors are found in the fds[] array and 1.51 + // don't need to be dupped(). ie: the caller of unflatten doesn't 1.52 + // keep ownership. If a fd is not retained by unflatten() it must be 1.53 + // explicitly closed. 1.54 + virtual status_t unflatten(void const* buffer, size_t size, 1.55 + int fds[], size_t count) = 0; 1.56 + 1.57 +protected: 1.58 + virtual ~Flattenable() = 0; 1.59 + 1.60 +}; 1.61 + 1.62 +}; // namespace android 1.63 + 1.64 + 1.65 +#endif /* ANDROID_UTILS_FLATTENABLE_H */