1/*
2 * Copyright 2017, 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 REMOTE_MEDIA_SOURCE_H_
18#define REMOTE_MEDIA_SOURCE_H_
19
20#include <media/IMediaSource.h>
21#include <media/MediaSource.h>
22#include <media/stagefright/foundation/ABase.h>
23
24namespace android {
25
26// IMediaSrouce wrapper to the MediaSource.
27class RemoteMediaSource : public BnMediaSource {
28public:
29    static sp<IMediaSource> wrap(
30            const sp<RemoteMediaExtractor> &extractor,
31            MediaTrack *source,
32            const sp<RefBase> &plugin);
33    virtual ~RemoteMediaSource();
34    virtual status_t start(MetaData *params = NULL);
35    virtual status_t stop();
36    virtual sp<MetaData> getFormat();
37    virtual status_t read(
38            MediaBufferBase **buffer,
39            const MediaSource::ReadOptions *options = NULL);
40    virtual status_t pause();
41    virtual status_t setStopTimeUs(int64_t stopTimeUs);
42
43private:
44    sp<RemoteMediaExtractor> mExtractor;
45    MediaTrack *mSource;
46    sp<RefBase> mExtractorPlugin;
47
48    explicit RemoteMediaSource(
49            const sp<RemoteMediaExtractor> &extractor,
50            MediaTrack *source,
51            const sp<RefBase> &plugin);
52
53    DISALLOW_EVIL_CONSTRUCTORS(RemoteMediaSource);
54};
55
56}  // namespace android
57
58#endif  // REMOTE_MEDIA_SOURCE_H_
59