blob: 838e29f80bfda692e870d4e2ed457c03d5407eb8 [file] [log] [blame]
Chris Watkins99f31602015-03-20 13:06:33 -07001/*
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 Nelissen69d3d8a2016-03-07 13:20:01 -080023#include <utils/String8.h>
Chris Watkins99f31602015-03-20 13:06:33 -070024
25namespace android {
26
27class IMemory;
28
29// A binder interface for implementing a stagefright DataSource remotely.
30class IDataSource : public IInterface {
31public:
32 DECLARE_META_INTERFACE(DataSource);
33
34 // Get the memory that readAt writes into.
35 virtual sp<IMemory> getIMemory() = 0;
36 // Read up to |size| bytes into the memory returned by getIMemory(). Returns
37 // the number of bytes read, or -1 on error. |size| must not be larger than
38 // the buffer.
39 virtual ssize_t readAt(off64_t offset, size_t size) = 0;
40 // Get the size, or -1 if the size is unknown.
41 virtual status_t getSize(off64_t* size) = 0;
42 // This should be called before deleting |this|. The other methods may
43 // return errors if they're called after calling close().
44 virtual void close() = 0;
Wei Jia10551fc2016-01-27 14:26:51 -080045 // Get the flags of the source.
46 // Refer to DataSource:Flags for the definition of the flags.
47 virtual uint32_t getFlags() = 0;
Marco Nelissen69d3d8a2016-03-07 13:20:01 -080048 // get a description of the source, e.g. the url or filename it is based on
49 virtual String8 toString() = 0;
Chris Watkins99f31602015-03-20 13:06:33 -070050
51private:
52 DISALLOW_EVIL_CONSTRUCTORS(IDataSource);
53};
54
55// ----------------------------------------------------------------------------
56
57class BnDataSource : public BnInterface<IDataSource> {
58public:
59 virtual status_t onTransact(uint32_t code,
60 const Parcel& data,
61 Parcel* reply,
62 uint32_t flags = 0);
63};
64
65}; // namespace android
66
67#endif // ANDROID_IDATASOURCE_H