blob: 65fb0aacfab98fd3d84371dda1c493725d0a2896 [file] [log] [blame]
Robert Shih2568eb92018-09-19 10:00:46 -07001/*
2 * Copyright 2018, 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 A_MEDIA_DATA_SOURCE_CALLBACKS_H
18
19#define A_MEDIA_DATA_SOURCE_CALLBACKS_H
20
21#include <media/DataSource.h>
22#include <media/NdkMediaDataSource.h>
23#include <media/NdkMediaError.h>
24#include <sys/types.h>
25
26namespace android {
27
28ssize_t DataSource_getSize(void *userdata);
29
30ssize_t DataSource_readAt(void *userdata, off64_t offset, void * buf, size_t size);
31
32void DataSource_close(void *userdata);
33
34static inline AMediaDataSource* convertDataSourceToAMediaDataSource(const sp<DataSource> &source) {
35 if (source == NULL) {
36 return NULL;
37 }
38 AMediaDataSource *mSource = AMediaDataSource_new();
39 AMediaDataSource_setUserdata(mSource, source.get());
40 AMediaDataSource_setReadAt(mSource, DataSource_readAt);
41 AMediaDataSource_setGetSize(mSource, DataSource_getSize);
42 AMediaDataSource_setClose(mSource, DataSource_close);
43 return mSource;
44}
45
46} // namespace android
47
48#endif // A_MEDIA_DATA_SOURCE_CALLBACKS_H