blob: 749d83c356ff79e0e89f11e9048bf341889de011 [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 Jia57aeffd2018-02-15 16:01:14 -080051 virtual status_t prepareNextDataSource(const sp<DataSourceDesc>& source) = 0;
52 virtual status_t playNextDataSource(int64_t srcId) = 0;
Wei Jia28288fb2017-12-15 13:45:29 -080053 virtual status_t setVideoSurfaceTexture(const sp<ANativeWindowWrapper>& nww) = 0;
Wei Jia53692fa2017-12-11 10:33:46 -080054 virtual status_t getBufferingSettings(
55 BufferingSettings* buffering /* nonnull */) = 0;
56 virtual status_t setBufferingSettings(const BufferingSettings& buffering) = 0;
57 virtual status_t prepareAsync() = 0;
58 virtual status_t start() = 0;
59 virtual status_t stop() = 0;
60 virtual status_t pause() = 0;
61 virtual status_t isPlaying(bool* state) = 0;
62 virtual status_t setPlaybackSettings(const AudioPlaybackRate& rate) = 0;
63 virtual status_t getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */) = 0;
64 virtual status_t setSyncSettings(const AVSyncSettings& sync, float videoFpsHint) = 0;
65 virtual status_t getSyncSettings(AVSyncSettings* sync /* nonnull */,
66 float* videoFps /* nonnull */) = 0;
67 virtual status_t seekTo(
68 int msec,
69 MediaPlayer2SeekMode mode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC) = 0;
70 virtual status_t getCurrentPosition(int* msec) = 0;
71 virtual status_t getDuration(int* msec) = 0;
72 virtual status_t notifyAt(int64_t mediaTimeUs) = 0;
73 virtual status_t reset() = 0;
74 virtual status_t setAudioStreamType(audio_stream_type_t type) = 0;
75 virtual status_t setLooping(int loop) = 0;
76 virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
77 virtual status_t setAuxEffectSendLevel(float level) = 0;
78 virtual status_t attachAuxEffect(int effectId) = 0;
79 virtual status_t setParameter(int key, const Parcel& request) = 0;
80 virtual status_t getParameter(int key, Parcel* reply) = 0;
Wei Jia53692fa2017-12-11 10:33:46 -080081 virtual status_t setNextPlayer(const sp<MediaPlayer2Engine>& next) = 0;
82
Wei Jia53692fa2017-12-11 10:33:46 -080083 // Modular DRM
84 virtual status_t prepareDrm(const uint8_t uuid[16],
85 const Vector<uint8_t>& drmSessionId) = 0;
86 virtual status_t releaseDrm() = 0;
87
88 // Invoke a generic method on the player by using opaque parcels
89 // for the request and reply.
90 // @param request Parcel that must start with the media player
91 // interface token.
92 // @param[out] reply Parcel to hold the reply data. Cannot be null.
93 // @return OK if the invocation was made successfully.
94 virtual status_t invoke(const Parcel& request, Parcel *reply) = 0;
95
96 // Set a new metadata filter.
97 // @param filter A set of allow and drop rules serialized in a Parcel.
98 // @return OK if the invocation was made successfully.
99 virtual status_t setMetadataFilter(const Parcel& filter) = 0;
100
101 // Retrieve a set of metadata.
102 // @param update_only Include only the metadata that have changed
103 // since the last invocation of getMetadata.
104 // The set is built using the unfiltered
105 // notifications the native player sent to the
106 // MediaPlayer2Manager during that period of
107 // time. If false, all the metadatas are considered.
108 // @param apply_filter If true, once the metadata set has been built based
109 // on the value update_only, the current filter is
110 // applied.
111 // @param[out] metadata On exit contains a set (possibly empty) of metadata.
112 // Valid only if the call returned OK.
113 // @return OK if the invocation was made successfully.
114 virtual status_t getMetadata(bool update_only,
115 bool apply_filter,
116 Parcel *metadata) = 0;
117
118 // AudioRouting
119 virtual status_t setOutputDevice(audio_port_handle_t deviceId) = 0;
120 virtual status_t getRoutedDeviceId(audio_port_handle_t *deviceId) = 0;
121 virtual status_t enableAudioDeviceCallback(bool enabled) = 0;
122};
123
124}; // namespace android
125
126#endif // ANDROID_MEDIAPLAYER2ENGINE_H