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 
24 namespace android {
25 
26 // IMediaSrouce wrapper to the MediaSource.
27 class RemoteMediaSource : public BnMediaSource {
28 public:
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 bool supportNonblockingRead();
41     virtual status_t pause();
42     virtual status_t setStopTimeUs(int64_t stopTimeUs);
43 
44 private:
45     sp<RemoteMediaExtractor> mExtractor;
46     MediaTrack *mTrack;
47     sp<RefBase> mExtractorPlugin;
48 
49     explicit RemoteMediaSource(
50             const sp<RemoteMediaExtractor> &extractor,
51             MediaTrack *source,
52             const sp<RefBase> &plugin);
53 
54     DISALLOW_EVIL_CONSTRUCTORS(RemoteMediaSource);
55 };
56 
57 }  // namespace android
58 
59 #endif  // REMOTE_MEDIA_SOURCE_H_
60