blob: 08cbef692ab5777f94f1345326ffed455f0ef9e6 [file] [log] [blame]
Marco Nelissenb2487f02015-09-01 13:23:23 -07001/*
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 Nelissena48a51c2016-02-25 10:52:54 -080021#include <utils/Vector.h>
22
Marco Nelissenb2487f02015-09-01 13:23:23 -070023#include <media/stagefright/DataSource.h>
24#include <media/stagefright/MediaExtractor.h>
Andy Hungd49dbd62016-07-07 14:20:35 -070025#include <media/stagefright/RemoteDataSource.h>
Marco Nelissenb2487f02015-09-01 13:23:23 -070026#include "MediaExtractorService.h"
27
28namespace android {
29
Marco Nelissenb2487f02015-09-01 13:23:23 -070030sp<IMediaExtractor> MediaExtractorService::makeExtractor(
31 const sp<IDataSource> &remoteSource, const char *mime) {
Marco Nelissenebab3582015-11-04 09:56:21 -080032 ALOGV("@@@ MediaExtractorService::makeExtractor for %s", mime);
Marco Nelissenb2487f02015-09-01 13:23:23 -070033
34 sp<DataSource> localSource = DataSource::CreateFromIDataSource(remoteSource);
35
Marco Nelissen69d3d8a2016-03-07 13:20:01 -080036 sp<IMediaExtractor> ret = MediaExtractor::CreateFromService(localSource, mime);
Marco Nelissenb2487f02015-09-01 13:23:23 -070037
Marco Nelissenebab3582015-11-04 09:56:21 -080038 ALOGV("extractor service created %p (%s)",
Marco Nelissenb2487f02015-09-01 13:23:23 -070039 ret.get(),
40 ret == NULL ? "" : ret->name());
41
Marco Nelissena48a51c2016-02-25 10:52:54 -080042 if (ret != NULL) {
Marco Nelissena3214692016-05-06 10:57:20 -070043 registerMediaExtractor(ret, localSource, mime);
Marco Nelissena48a51c2016-02-25 10:52:54 -080044 }
45
Marco Nelissenb2487f02015-09-01 13:23:23 -070046 return ret;
47}
48
Andy Hungd49dbd62016-07-07 14:20:35 -070049sp<IDataSource> MediaExtractorService::makeIDataSource(int fd, int64_t offset, int64_t length)
50{
51 sp<DataSource> source = DataSource::CreateFromFd(fd, offset, length);
52 return source.get() != nullptr ? source->asIDataSource() : nullptr;
53}
54
Marco Nelissena48a51c2016-02-25 10:52:54 -080055status_t MediaExtractorService::dump(int fd, const Vector<String16>& args) {
Marco Nelissen69d3d8a2016-03-07 13:20:01 -080056 return dumpExtractors(fd, args);
Marco Nelissena48a51c2016-02-25 10:52:54 -080057}
58
Marco Nelissenb2487f02015-09-01 13:23:23 -070059status_t MediaExtractorService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
60 uint32_t flags)
61{
62 return BnMediaExtractorService::onTransact(code, data, reply, flags);
63}
64
65} // namespace android