Robert Shih | 2568eb9 | 2018-09-19 10:00:46 -0700 | [diff] [blame] | 1 | /* |
| 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 Shih | 2568eb9 | 2018-09-19 10:00:46 -0700 | [diff] [blame] | 20 | #include "NdkMediaDataSourceCallbacksPriv.h" |
| 21 | #include <media/DataSource.h> |
Marco Nelissen | 5dcf85a | 2018-10-11 09:49:02 -0700 | [diff] [blame] | 22 | #include <media/NdkMediaErrorPriv.h> |
Robert Shih | 2568eb9 | 2018-09-19 10:00:46 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | ssize_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 | |
| 33 | ssize_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 | |
| 38 | void DataSource_close(void *userdata) { |
| 39 | DataSource *source = static_cast<DataSource *>(userdata); |
| 40 | source->close(); |
| 41 | } |
| 42 | |
Robert Shih | ca198ce | 2018-09-22 16:31:55 -0700 | [diff] [blame] | 43 | ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset) { |
| 44 | off64_t size = -1; |
| 45 | DataSource *source = static_cast<DataSource *>(userdata); |
Robert Shih | ea38886 | 2018-11-20 02:11:30 -0800 | [diff] [blame] | 46 | source->getAvailableSize(offset, &size); |
| 47 | return size; |
Robert Shih | ca198ce | 2018-09-22 16:31:55 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Robert Shih | 2568eb9 | 2018-09-19 10:00:46 -0700 | [diff] [blame] | 50 | } // namespace android |