Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 FILE_SOURCE_H_ |
| 18 | |
| 19 | #define FILE_SOURCE_H_ |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | |
Marco Nelissen | 42057ce | 2019-09-23 12:15:57 -0700 | [diff] [blame] | 23 | #include <datasource/ClearFileSource.h> |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 24 | #include <media/stagefright/MediaErrors.h> |
| 25 | #include <utils/threads.h> |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 26 | #include <drm/DrmManagerClient.h> |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | |
Dongwon Kang | 1e1bcaa | 2018-08-01 12:44:46 -0700 | [diff] [blame] | 30 | class FileSource : public ClearFileSource { |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 31 | public: |
| 32 | FileSource(const char *filename); |
Glenn Kasten | 2301acc | 2014-01-17 10:21:00 -0800 | [diff] [blame] | 33 | // FileSource takes ownership and will close the fd |
Andreas Huber | 03475f5 | 2009-11-16 15:34:01 -0800 | [diff] [blame] | 34 | FileSource(int fd, int64_t offset, int64_t length); |
Andreas Huber | 34769bc | 2009-10-23 10:22:30 -0700 | [diff] [blame] | 35 | |
James Dong | c7fc37a | 2010-11-16 14:04:54 -0800 | [diff] [blame] | 36 | virtual ssize_t readAt(off64_t offset, void *data, size_t size); |
Andreas Huber | 34769bc | 2009-10-23 10:22:30 -0700 | [diff] [blame] | 37 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 38 | virtual sp<DecryptHandle> DrmInitialization(const char *mime); |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 39 | |
Andy Hung | d49dbd6 | 2016-07-07 14:20:35 -0700 | [diff] [blame] | 40 | static bool requiresDrm(int fd, int64_t offset, int64_t length, const char *mime); |
| 41 | |
Andreas Huber | 34769bc | 2009-10-23 10:22:30 -0700 | [diff] [blame] | 42 | protected: |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 43 | virtual ~FileSource(); |
| 44 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 45 | private: |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 46 | /*for DRM*/ |
Gloria Wang | b5ce361 | 2011-02-24 16:40:57 -0800 | [diff] [blame] | 47 | sp<DecryptHandle> mDecryptHandle; |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 48 | DrmManagerClient *mDrmManagerClient; |
| 49 | int64_t mDrmBufOffset; |
Patrik Lindgren | d066bc8 | 2014-12-22 09:06:21 +0100 | [diff] [blame] | 50 | ssize_t mDrmBufSize; |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 51 | unsigned char *mDrmBuf; |
| 52 | |
Dongwon Kang | 1e1bcaa | 2018-08-01 12:44:46 -0700 | [diff] [blame] | 53 | ssize_t readAtDRM_l(off64_t offset, void *data, size_t size); |
Gloria Wang | dcd25ef | 2010-06-22 13:55:38 -0700 | [diff] [blame] | 54 | |
Andreas Huber | 20111aa | 2009-07-14 16:56:47 -0700 | [diff] [blame] | 55 | FileSource(const FileSource &); |
| 56 | FileSource &operator=(const FileSource &); |
| 57 | }; |
| 58 | |
| 59 | } // namespace android |
| 60 | |
| 61 | #endif // FILE_SOURCE_H_ |
| 62 | |