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
21 #include <utils/Vector.h>
22
23 #include <media/stagefright/DataSource.h>
24 #include <media/stagefright/MediaExtractor.h>
25 #include <media/stagefright/RemoteDataSource.h>
26 #include "MediaExtractorService.h"
27
28 namespace android {
29
makeExtractor(const sp<IDataSource> & remoteSource,const char * mime)30 sp<IMediaExtractor> MediaExtractorService::makeExtractor(
31 const sp<IDataSource> &remoteSource, const char *mime) {
32 ALOGV("@@@ MediaExtractorService::makeExtractor for %s", mime);
33
34 sp<DataSource> localSource = DataSource::CreateFromIDataSource(remoteSource);
35
36 sp<IMediaExtractor> ret = MediaExtractor::CreateFromService(localSource, mime);
37
38 ALOGV("extractor service created %p (%s)",
39 ret.get(),
40 ret == NULL ? "" : ret->name());
41
42 if (ret != NULL) {
43 registerMediaExtractor(ret, localSource, mime);
44 }
45
46 return ret;
47 }
48
makeIDataSource(int fd,int64_t offset,int64_t length)49 sp<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
dump(int fd,const Vector<String16> & args)55 status_t MediaExtractorService::dump(int fd, const Vector<String16>& args) {
56 return dumpExtractors(fd, args);
57 }
58
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)59 status_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
66