Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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_TAG "MediaExtractorService" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | #include <utils/Log.h> |
| 20 | |
Marco Nelissen | a48a51c | 2016-02-25 10:52:54 -0800 | [diff] [blame] | 21 | #include <utils/Vector.h> |
| 22 | |
Dongwon Kang | d91dc5a | 2017-10-10 00:07:09 -0700 | [diff] [blame] | 23 | #include <media/DataSource.h> |
Dongwon Kang | d91dc5a | 2017-10-10 00:07:09 -0700 | [diff] [blame] | 24 | #include <media/stagefright/DataSourceFactory.h> |
| 25 | #include <media/stagefright/InterfaceUtils.h> |
| 26 | #include <media/stagefright/MediaExtractorFactory.h> |
Andy Hung | d49dbd6 | 2016-07-07 14:20:35 -0700 | [diff] [blame] | 27 | #include <media/stagefright/RemoteDataSource.h> |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 28 | #include "MediaExtractorService.h" |
| 29 | |
| 30 | namespace android { |
| 31 | |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 32 | sp<IMediaExtractor> MediaExtractorService::makeExtractor( |
| 33 | const sp<IDataSource> &remoteSource, const char *mime) { |
Marco Nelissen | ebab358 | 2015-11-04 09:56:21 -0800 | [diff] [blame] | 34 | ALOGV("@@@ MediaExtractorService::makeExtractor for %s", mime); |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 35 | |
Dongwon Kang | d91dc5a | 2017-10-10 00:07:09 -0700 | [diff] [blame] | 36 | sp<DataSource> localSource = CreateDataSourceFromIDataSource(remoteSource); |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 37 | |
Dongwon Kang | 5e1897b | 2017-06-29 15:21:53 -0700 | [diff] [blame] | 38 | sp<IMediaExtractor> extractor = MediaExtractorFactory::CreateFromService(localSource, mime); |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 39 | |
Marco Nelissen | ebab358 | 2015-11-04 09:56:21 -0800 | [diff] [blame] | 40 | ALOGV("extractor service created %p (%s)", |
Dongwon Kang | ba8128f | 2017-08-07 18:51:24 -0700 | [diff] [blame] | 41 | extractor.get(), |
| 42 | extractor == nullptr ? "" : extractor->name()); |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 43 | |
Dongwon Kang | ba8128f | 2017-08-07 18:51:24 -0700 | [diff] [blame] | 44 | if (extractor != nullptr) { |
Dongwon Kang | 5e1897b | 2017-06-29 15:21:53 -0700 | [diff] [blame] | 45 | registerMediaExtractor(extractor, localSource, mime); |
| 46 | return extractor; |
Marco Nelissen | a48a51c | 2016-02-25 10:52:54 -0800 | [diff] [blame] | 47 | } |
Dongwon Kang | ba8128f | 2017-08-07 18:51:24 -0700 | [diff] [blame] | 48 | return nullptr; |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Andy Hung | d49dbd6 | 2016-07-07 14:20:35 -0700 | [diff] [blame] | 51 | sp<IDataSource> MediaExtractorService::makeIDataSource(int fd, int64_t offset, int64_t length) |
| 52 | { |
Dongwon Kang | d91dc5a | 2017-10-10 00:07:09 -0700 | [diff] [blame] | 53 | sp<DataSource> source = DataSourceFactory::CreateFromFd(fd, offset, length); |
| 54 | return CreateIDataSourceFromDataSource(source); |
Andy Hung | d49dbd6 | 2016-07-07 14:20:35 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Marco Nelissen | a48a51c | 2016-02-25 10:52:54 -0800 | [diff] [blame] | 57 | status_t MediaExtractorService::dump(int fd, const Vector<String16>& args) { |
Marco Nelissen | c96ca43 | 2018-01-19 08:14:40 -0800 | [diff] [blame] | 58 | return MediaExtractorFactory::dump(fd, args) || dumpExtractors(fd, args); |
Marco Nelissen | a48a51c | 2016-02-25 10:52:54 -0800 | [diff] [blame] | 59 | } |
| 60 | |
Marco Nelissen | b2487f0 | 2015-09-01 13:23:23 -0700 | [diff] [blame] | 61 | status_t MediaExtractorService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, |
| 62 | uint32_t flags) |
| 63 | { |
| 64 | return BnMediaExtractorService::onTransact(code, data, reply, flags); |
| 65 | } |
| 66 | |
| 67 | } // namespace android |