blob: 796c11b37742f2fa133fdf4b4fe4ff40c513af33 [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//#define LOG_NDEBUG 0
18#define LOG_TAG "NdkMediaDataSourceCallbacks"
19
Robert Shiha303ec82018-09-19 16:29:43 -070020#include "NdkMediaErrorPriv.h"
Robert Shih2568eb92018-09-19 10:00:46 -070021#include "NdkMediaDataSourceCallbacksPriv.h"
22#include <media/DataSource.h>
23
24namespace android {
25
26ssize_t DataSource_getSize(void *userdata) {
27 DataSource *source = static_cast<DataSource *>(userdata);
28 off64_t size = -1;
29 source->getSize(&size);
30 return size;
31}
32
33ssize_t DataSource_readAt(void *userdata, off64_t offset, void * buf, size_t size) {
34 DataSource *source = static_cast<DataSource *>(userdata);
35 return source->readAt(offset, buf, size);
36}
37
38void DataSource_close(void *userdata) {
39 DataSource *source = static_cast<DataSource *>(userdata);
40 source->close();
41}
42
Robert Shihca198ce2018-09-22 16:31:55 -070043ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset) {
44 off64_t size = -1;
45 DataSource *source = static_cast<DataSource *>(userdata);
46 status_t err = source->getAvailableSize(offset, &size);
47 return err == OK ? size : -1;
48}
49
Robert Shih2568eb92018-09-19 10:00:46 -070050} // namespace android