This change removes dependency on IMediaExtractor/Source binder interfaces from MediaExtractor implementations. Wrapper classes, RemoteXXX and CallbackXXX, have been added to convert the implementations to binder objects or the other way around. Test: build, boot, and play mp4 video file Bug: 65851881 Change-Id: I351fb7bbaf8e0154295ccf258f85b8b2f2a4b8fbgugelfrei
parent
161101b0f9
commit
ba8128f9db
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <media/stagefright/CallbackMediaSource.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
CallbackMediaSource::CallbackMediaSource(const sp<IMediaSource> &source)
|
||||||
|
:mSource(source) {}
|
||||||
|
|
||||||
|
CallbackMediaSource::~CallbackMediaSource() {}
|
||||||
|
|
||||||
|
status_t CallbackMediaSource::start(MetaData *params) {
|
||||||
|
return mSource->start(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t CallbackMediaSource::stop() {
|
||||||
|
return mSource->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<MetaData> CallbackMediaSource::getFormat() {
|
||||||
|
return mSource->getFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t CallbackMediaSource::read(MediaBuffer **buffer, const ReadOptions *options) {
|
||||||
|
return mSource->read(buffer, reinterpret_cast<const MediaSource::ReadOptions*>(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t CallbackMediaSource::pause() {
|
||||||
|
return mSource->pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t CallbackMediaSource::setBuffers(const Vector<MediaBuffer *> &buffers) {
|
||||||
|
return mSource->setBuffers(buffers);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace android
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <media/stagefright/RemoteMediaExtractor.h>
|
||||||
|
#include <media/stagefright/MediaSource.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
RemoteMediaExtractor::RemoteMediaExtractor(const sp<MediaExtractor> &extractor)
|
||||||
|
:mExtractor(extractor) {}
|
||||||
|
|
||||||
|
RemoteMediaExtractor::~RemoteMediaExtractor() {}
|
||||||
|
|
||||||
|
size_t RemoteMediaExtractor::countTracks() {
|
||||||
|
return mExtractor->countTracks();
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<IMediaSource> RemoteMediaExtractor::getTrack(size_t index) {
|
||||||
|
sp<MediaSource> source = mExtractor->getTrack(index);
|
||||||
|
return (source.get() == nullptr) ? nullptr : source->asIMediaSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<MetaData> RemoteMediaExtractor::getTrackMetaData(size_t index, uint32_t flags) {
|
||||||
|
return mExtractor->getTrackMetaData(index, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<MetaData> RemoteMediaExtractor::getMetaData() {
|
||||||
|
return mExtractor->getMetaData();
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaExtractor::getMetrics(Parcel *reply) {
|
||||||
|
return mExtractor->getMetrics(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RemoteMediaExtractor::flags() const {
|
||||||
|
return mExtractor->flags();
|
||||||
|
}
|
||||||
|
|
||||||
|
char* RemoteMediaExtractor::getDrmTrackInfo(size_t trackID, int * len) {
|
||||||
|
return mExtractor->getDrmTrackInfo(trackID, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteMediaExtractor::setUID(uid_t uid) {
|
||||||
|
return mExtractor->setUID(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaExtractor::setMediaCas(const HInterfaceToken &casToken) {
|
||||||
|
return mExtractor->setMediaCas(casToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * RemoteMediaExtractor::name() {
|
||||||
|
return mExtractor->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteMediaExtractor::release() {
|
||||||
|
return mExtractor->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// static
|
||||||
|
sp<IMediaExtractor> RemoteMediaExtractor::wrap(const sp<MediaExtractor> &extractor) {
|
||||||
|
if (extractor.get() == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return new RemoteMediaExtractor(extractor);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace android
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <media/stagefright/RemoteMediaSource.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
RemoteMediaSource::RemoteMediaSource(const sp<MediaSource> &source)
|
||||||
|
:mSource(source) {}
|
||||||
|
|
||||||
|
RemoteMediaSource::~RemoteMediaSource() {}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::start(MetaData *params) {
|
||||||
|
return mSource->start(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::stop() {
|
||||||
|
return mSource->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<MetaData> RemoteMediaSource::getFormat() {
|
||||||
|
return mSource->getFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::read(MediaBuffer **buffer, const ReadOptions *options) {
|
||||||
|
return mSource->read(buffer, reinterpret_cast<const MediaSource::ReadOptions*>(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::pause() {
|
||||||
|
return mSource->pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::setBuffers(const Vector<MediaBuffer *> &buffers) {
|
||||||
|
return mSource->setBuffers(buffers);
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t RemoteMediaSource::setStopTimeUs(int64_t stopTimeUs) {
|
||||||
|
return mSource->setStopTimeUs(stopTimeUs);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// static
|
||||||
|
sp<IMediaSource> RemoteMediaSource::wrap(const sp<MediaSource> &source) {
|
||||||
|
if (source.get() == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return new RemoteMediaSource(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace android
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CALLBACK_MEDIA_SOURCE_H_
|
||||||
|
#define CALLBACK_MEDIA_SOURCE_H_
|
||||||
|
|
||||||
|
#include <media/stagefright/MediaSource.h>
|
||||||
|
#include <media/stagefright/foundation/ABase.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
// A stagefright MediaSource that wraps a binder IMediaSource.
|
||||||
|
class CallbackMediaSource : public MediaSource {
|
||||||
|
public:
|
||||||
|
explicit CallbackMediaSource(const sp<IMediaSource> &source);
|
||||||
|
virtual ~CallbackMediaSource();
|
||||||
|
virtual status_t start(MetaData *params = NULL);
|
||||||
|
virtual status_t stop();
|
||||||
|
virtual sp<MetaData> getFormat();
|
||||||
|
virtual status_t read(
|
||||||
|
MediaBuffer **buffer, const ReadOptions *options = NULL);
|
||||||
|
virtual status_t pause();
|
||||||
|
virtual status_t setBuffers(const Vector<MediaBuffer *> &buffers);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sp<IMediaSource> mSource;
|
||||||
|
|
||||||
|
DISALLOW_EVIL_CONSTRUCTORS(CallbackMediaSource);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace android
|
||||||
|
|
||||||
|
#endif // CALLBACK_MEDIA_SOURCE_H_
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REMOTE_MEDIA_EXTRACTOR_H_
|
||||||
|
#define REMOTE_MEDIA_EXTRACTOR_H_
|
||||||
|
|
||||||
|
#include <media/IMediaExtractor.h>
|
||||||
|
#include <media/stagefright/MediaExtractor.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
// IMediaExtractor wrapper to the MediaExtractor.
|
||||||
|
class RemoteMediaExtractor : public BnMediaExtractor {
|
||||||
|
public:
|
||||||
|
static sp<IMediaExtractor> wrap(const sp<MediaExtractor> &extractor);
|
||||||
|
|
||||||
|
virtual ~RemoteMediaExtractor();
|
||||||
|
virtual size_t countTracks();
|
||||||
|
virtual sp<IMediaSource> getTrack(size_t index);
|
||||||
|
virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags = 0);
|
||||||
|
virtual sp<MetaData> getMetaData();
|
||||||
|
virtual status_t getMetrics(Parcel *reply);
|
||||||
|
virtual uint32_t flags() const;
|
||||||
|
virtual char* getDrmTrackInfo(size_t trackID, int * len);
|
||||||
|
virtual void setUID(uid_t uid);
|
||||||
|
virtual status_t setMediaCas(const HInterfaceToken &casToken);
|
||||||
|
virtual const char * name();
|
||||||
|
virtual void release();
|
||||||
|
|
||||||
|
private:
|
||||||
|
sp<MediaExtractor> mExtractor;
|
||||||
|
|
||||||
|
explicit RemoteMediaExtractor(const sp<MediaExtractor> &extractor);
|
||||||
|
|
||||||
|
DISALLOW_EVIL_CONSTRUCTORS(RemoteMediaExtractor);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace android
|
||||||
|
|
||||||
|
#endif // REMOTE_MEDIA_EXTRACTOR_H_
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017, The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REMOTE_MEDIA_SOURCE_H_
|
||||||
|
#define REMOTE_MEDIA_SOURCE_H_
|
||||||
|
|
||||||
|
#include <media/IMediaSource.h>
|
||||||
|
#include <media/stagefright/MediaSource.h>
|
||||||
|
#include <media/stagefright/foundation/ABase.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
|
||||||
|
// IMediaSrouce wrapper to the MediaSource.
|
||||||
|
class RemoteMediaSource : public BnMediaSource {
|
||||||
|
public:
|
||||||
|
static sp<IMediaSource> wrap(const sp<MediaSource> &source);
|
||||||
|
virtual ~RemoteMediaSource();
|
||||||
|
virtual status_t start(MetaData *params = NULL);
|
||||||
|
virtual status_t stop();
|
||||||
|
virtual sp<MetaData> getFormat();
|
||||||
|
virtual status_t read(
|
||||||
|
MediaBuffer **buffer, const ReadOptions *options = NULL);
|
||||||
|
virtual status_t pause();
|
||||||
|
virtual status_t setBuffers(const Vector<MediaBuffer *> &buffers);
|
||||||
|
virtual status_t setStopTimeUs(int64_t stopTimeUs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sp<MediaSource> mSource;
|
||||||
|
|
||||||
|
explicit RemoteMediaSource(const sp<MediaSource> &source);
|
||||||
|
|
||||||
|
DISALLOW_EVIL_CONSTRUCTORS(RemoteMediaSource);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace android
|
||||||
|
|
||||||
|
#endif // REMOTE_MEDIA_SOURCE_H_
|
Loading…
Reference in new issue