Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 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 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 Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 26 | |
| 27 | // Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is |
| 28 | // global, and not in android:: |
| 29 | struct sockaddr_in; |
| 30 | |
| 31 | namespace android { |
| 32 | |
Wei Jia | 28288fb | 2017-12-15 13:45:29 -0800 | [diff] [blame] | 33 | struct ANativeWindowWrapper; |
Wei Jia | c5c79da | 2017-12-21 18:03:05 -0800 | [diff] [blame] | 34 | struct AVSyncSettings; |
| 35 | struct AudioPlaybackRate; |
| 36 | struct BufferingSettings; |
| 37 | class DataSource; |
Wei Jia | c263603 | 2018-02-01 09:15:25 -0800 | [diff] [blame] | 38 | struct DataSourceDesc; |
Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 39 | struct IStreamSource; |
Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 40 | struct MediaHTTPService; |
Wei Jia | c5c79da | 2017-12-21 18:03:05 -0800 | [diff] [blame] | 41 | class Parcel; |
Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 42 | |
| 43 | typedef MediaSource::ReadOptions::SeekMode MediaPlayer2SeekMode; |
| 44 | |
| 45 | class MediaPlayer2Engine: public RefBase |
| 46 | { |
| 47 | public: |
| 48 | virtual void disconnect() = 0; |
| 49 | |
Wei Jia | c263603 | 2018-02-01 09:15:25 -0800 | [diff] [blame] | 50 | virtual status_t setDataSource(const sp<DataSourceDesc>& source) = 0; |
Wei Jia | 28288fb | 2017-12-15 13:45:29 -0800 | [diff] [blame] | 51 | virtual status_t setVideoSurfaceTexture(const sp<ANativeWindowWrapper>& nww) = 0; |
Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 52 | 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 Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 79 | virtual status_t setNextPlayer(const sp<MediaPlayer2Engine>& next) = 0; |
| 80 | |
Wei Jia | 53692fa | 2017-12-11 10:33:46 -0800 | [diff] [blame] | 81 | // 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 |