blob: 86a57da2a81f603d7efd8b6d90acb1678ce57a8a [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 Shih2568eb92018-09-19 10:00:46 -070020#include "NdkMediaDataSourceCallbacksPriv.h"
21#include <media/DataSource.h>
Marco Nelissen5dcf85a2018-10-11 09:49:02 -070022#include <media/NdkMediaErrorPriv.h>
Robert Shih2568eb92018-09-19 10:00:46 -070023
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);
Robert Shihea388862018-11-20 02:11:30 -080046 source->getAvailableSize(offset, &size);
47 return size;
Robert Shihca198ce2018-09-22 16:31:55 -070048}
49
Robert Shih2568eb92018-09-19 10:00:46 -070050} // namespace android