blob: 2d1a24bb17e75a330aacebd7c522ee7f618d081b [file] [log] [blame]
Wei Jia53692fa2017-12-11 10:33:46 -08001/*
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 ANDROID_MEDIAPLAYER2ENGINE_H
18#define ANDROID_MEDIAPLAYER2ENGINE_H
19
20#include <utils/RefBase.h>
21#include <binder/Parcel.h>
22#include <utils/KeyedVector.h>
23#include <system/audio.h>
24
25#include <media/MediaSource.h>
Wei Jia53692fa2017-12-11 10:33:46 -080026
27// Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is
28// global, and not in android::
29struct sockaddr_in;
30
31namespace android {
32
Wei Jia28288fb2017-12-15 13:45:29 -080033struct ANativeWindowWrapper;
Wei Jiac5c79da2017-12-21 18:03:05 -080034struct AVSyncSettings;
35struct AudioPlaybackRate;
36struct BufferingSettings;
37class DataSource;
Wei Jiac2636032018-02-01 09:15:25 -080038struct DataSourceDesc;
Wei Jia53692fa2017-12-11 10:33:46 -080039struct IStreamSource;
Wei Jia53692fa2017-12-11 10:33:46 -080040struct MediaHTTPService;
Wei Jiac5c79da2017-12-21 18:03:05 -080041class Parcel;
Wei Jia53692fa2017-12-11 10:33:46 -080042
43typedef MediaSource::ReadOptions::SeekMode MediaPlayer2SeekMode;
44
45class MediaPlayer2Engine: public RefBase
46{
47public:
48 virtual void disconnect() = 0;
49
Wei Jiac2636032018-02-01 09:15:25 -080050 virtual status_t setDataSource(const sp<DataSourceDesc>& source) = 0;
Wei Jia28288fb2017-12-15 13:45:29 -080051 virtual status_t setVideoSurfaceTexture(const sp<ANativeWindowWrapper>& nww) = 0;
Wei Jia53692fa2017-12-11 10:33:46 -080052 virtual status_t getBufferingSettings(
53 BufferingSettings* buffering /* nonnull */) = 0;
54 virtual status_t setBufferingSettings(const BufferingSettings& buffering) = 0;
55 virtual status_t prepareAsync() = 0;
56 virtual status_t start() = 0;
57 virtual status_t stop() = 0;
58 virtual status_t pause() = 0;
59 virtual status_t isPlaying(bool* state) = 0;
60 virtual status_t setPlaybackSettings(const AudioPlaybackRate& rate) = 0;
61 virtual status_t getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */) = 0;
62 virtual status_t setSyncSettings(const AVSyncSettings& sync, float videoFpsHint) = 0;
63 virtual status_t getSyncSettings(AVSyncSettings* sync /* nonnull */,
64 float* videoFps /* nonnull */) = 0;
65 virtual status_t seekTo(
66 int msec,
67 MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC) = 0;
68 virtual status_t getCurrentPosition(int* msec) = 0;
69 virtual status_t getDuration(int* msec) = 0;
70 virtual status_t notifyAt(int64_t mediaTimeUs) = 0;
71 virtual status_t reset() = 0;
72 virtual status_t setAudioStreamType(audio_stream_type_t type) = 0;
73 virtual status_t setLooping(int loop) = 0;
74 virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
75 virtual status_t setAuxEffectSendLevel(float level) = 0;
76 virtual status_t attachAuxEffect(int effectId) = 0;
77 virtual status_t setParameter(int key, const Parcel& request) = 0;
78 virtual status_t getParameter(int key, Parcel* reply) = 0;
Wei Jia53692fa2017-12-11 10:33:46 -080079 virtual status_t setNextPlayer(const sp<MediaPlayer2Engine>& next) = 0;
80
Wei Jia53692fa2017-12-11 10:33:46 -080081 // Modular DRM
82 virtual status_t prepareDrm(const uint8_t uuid[16],
83 const Vector<uint8_t>& drmSessionId) = 0;
84 virtual status_t releaseDrm() = 0;
85
86 // Invoke a generic method on the player by using opaque parcels
87 // for the request and reply.
88 // @param request Parcel that must start with the media player
89 // interface token.
90 // @param[out] reply Parcel to hold the reply data. Cannot be null.
91 // @return OK if the invocation was made successfully.
92 virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
93
94 // Set a new metadata filter.
95 // @param filter A set of allow and drop rules serialized in a Parcel.
96 // @return OK if the invocation was made successfully.
97 virtual status_t setMetadataFilter(const Parcel& filter) = 0;
98
99 // Retrieve a set of metadata.
100 // @param update_only Include only the metadata that have changed
101 // since the last invocation of getMetadata.
102 // The set is built using the unfiltered
103 // notifications the native player sent to the
104 // MediaPlayer2Manager during that period of
105 // time. If false, all the metadatas are considered.
106 // @param apply_filter If true, once the metadata set has been built based
107 // on the value update_only, the current filter is
108 // applied.
109 // @param[out] metadata On exit contains a set (possibly empty) of metadata.
110 // Valid only if the call returned OK.
111 // @return OK if the invocation was made successfully.
112 virtual status_t getMetadata(bool update_only,
113 bool apply_filter,
114 Parcel *metadata) = 0;
115
116 // AudioRouting
117 virtual status_t setOutputDevice(audio_port_handle_t deviceId) = 0;
118 virtual status_t getRoutedDeviceId(audio_port_handle_t *deviceId) = 0;
119 virtual status_t enableAudioDeviceCallback(bool enabled) = 0;
120};
121
122}; // namespace android
123
124#endif // ANDROID_MEDIAPLAYER2ENGINE_H