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 20 #include "NdkMediaDataSourceCallbacksPriv.h" 21 #include <media/DataSource.h> 22 #include <media/NdkMediaErrorPriv.h> 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 43 ssize_t DataSource_getAvailableSize(void *userdata, off64_t offset) { 44 off64_t size = -1; 45 DataSource *source = static_cast<DataSource *>(userdata); 46 source->getAvailableSize(offset, &size); 47 return size; 48 } 49 50 } // namespace android 51