Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 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_IDATASOURCE_H |
| 18 | #define ANDROID_IDATASOURCE_H |
| 19 | |
| 20 | #include <binder/IInterface.h> |
| 21 | #include <media/stagefright/foundation/ABase.h> |
| 22 | #include <utils/Errors.h> |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | class IMemory; |
| 27 | |
| 28 | // A binder interface for implementing a stagefright DataSource remotely. |
| 29 | class IDataSource : public IInterface { |
| 30 | public: |
| 31 | DECLARE_META_INTERFACE(DataSource); |
| 32 | |
| 33 | // Get the memory that readAt writes into. |
| 34 | virtual sp<IMemory> getIMemory() = 0; |
| 35 | // Read up to |size| bytes into the memory returned by getIMemory(). Returns |
| 36 | // the number of bytes read, or -1 on error. |size| must not be larger than |
| 37 | // the buffer. |
| 38 | virtual ssize_t readAt(off64_t offset, size_t size) = 0; |
| 39 | // Get the size, or -1 if the size is unknown. |
| 40 | virtual status_t getSize(off64_t* size) = 0; |
| 41 | // This should be called before deleting |this|. The other methods may |
| 42 | // return errors if they're called after calling close(). |
| 43 | virtual void close() = 0; |
| 44 | |
| 45 | private: |
| 46 | DISALLOW_EVIL_CONSTRUCTORS(IDataSource); |
| 47 | }; |
| 48 | |
| 49 | // ---------------------------------------------------------------------------- |
| 50 | |
| 51 | class BnDataSource : public BnInterface<IDataSource> { |
| 52 | public: |
| 53 | virtual status_t onTransact(uint32_t code, |
| 54 | const Parcel& data, |
| 55 | Parcel* reply, |
| 56 | uint32_t flags = 0); |
| 57 | }; |
| 58 | |
| 59 | }; // namespace android |
| 60 | |
| 61 | #endif // ANDROID_IDATASOURCE_H |