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> |
Marco Nelissen | 69d3d8a | 2016-03-07 13:20:01 -0800 | [diff] [blame] | 23 | #include <utils/String8.h> |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | class IMemory; |
Wei Jia | 2a5e49c | 2016-07-07 10:02:51 -0700 | [diff] [blame] | 28 | class DecryptHandle; |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 29 | |
| 30 | // A binder interface for implementing a stagefright DataSource remotely. |
| 31 | class IDataSource : public IInterface { |
| 32 | public: |
| 33 | DECLARE_META_INTERFACE(DataSource); |
| 34 | |
| 35 | // Get the memory that readAt writes into. |
| 36 | virtual sp<IMemory> getIMemory() = 0; |
| 37 | // Read up to |size| bytes into the memory returned by getIMemory(). Returns |
Chong Zhang | 026d520 | 2017-07-26 14:14:16 -0700 | [diff] [blame] | 38 | // the number of bytes read, or negative value on error (eg. |
| 39 | // ERROR_END_OF_STREAM indicating EOS. This is needed by CallbackDataSource |
| 40 | // to properly handle reading of last chunk). |size| must not be larger than |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 41 | // the buffer. |
| 42 | virtual ssize_t readAt(off64_t offset, size_t size) = 0; |
| 43 | // Get the size, or -1 if the size is unknown. |
| 44 | virtual status_t getSize(off64_t* size) = 0; |
| 45 | // This should be called before deleting |this|. The other methods may |
| 46 | // return errors if they're called after calling close(). |
| 47 | virtual void close() = 0; |
Wei Jia | 10551fc | 2016-01-27 14:26:51 -0800 | [diff] [blame] | 48 | // Get the flags of the source. |
| 49 | // Refer to DataSource:Flags for the definition of the flags. |
| 50 | virtual uint32_t getFlags() = 0; |
Marco Nelissen | 69d3d8a | 2016-03-07 13:20:01 -0800 | [diff] [blame] | 51 | // get a description of the source, e.g. the url or filename it is based on |
| 52 | virtual String8 toString() = 0; |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | DISALLOW_EVIL_CONSTRUCTORS(IDataSource); |
| 56 | }; |
| 57 | |
| 58 | // ---------------------------------------------------------------------------- |
| 59 | |
| 60 | class BnDataSource : public BnInterface<IDataSource> { |
| 61 | public: |
| 62 | virtual status_t onTransact(uint32_t code, |
| 63 | const Parcel& data, |
| 64 | Parcel* reply, |
| 65 | uint32_t flags = 0); |
| 66 | }; |
| 67 | |
| 68 | }; // namespace android |
| 69 | |
| 70 | #endif // ANDROID_IDATASOURCE_H |