You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.2 KiB
111 lines
4.2 KiB
4 months ago
|
/*
|
||
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
|
||
|
* Description: NxMediaPlayerManager class implement
|
||
|
* Author: NxPlayer software group
|
||
|
* Create: 2019-11-21
|
||
|
*/
|
||
|
|
||
|
#ifndef ANDROID_MEDIAPLAYER_WRAPPER_H
|
||
|
#define ANDROID_MEDIAPLAYER_WRAPPER_H
|
||
|
|
||
|
#include <utils/RefBase.h>
|
||
|
#include <gui/IGraphicBufferProducer.h>
|
||
|
#include <gui/Surface.h>
|
||
|
#include <gui/ISurfaceComposer.h>
|
||
|
#include <private/gui/ComposerService.h>
|
||
|
#include <gui/bufferqueue/2.0/B2HGraphicBufferProducer.h>
|
||
|
#include <securec.h>
|
||
|
#include "NxMediaPlayerInterface.h"
|
||
|
#include "MediaPlayerInterface.h"
|
||
|
|
||
|
namespace android {
|
||
|
class NxMediaPlayerWrapper : public MediaPlayerHWInterface {
|
||
|
public:
|
||
|
NxMediaPlayerWrapper();
|
||
|
~NxMediaPlayerWrapper() override;
|
||
|
|
||
|
status_t initCheck() override;
|
||
|
status_t setUID(uid_t uid) override;
|
||
|
|
||
|
status_t setDataSource(
|
||
|
const sp<IMediaHTTPService> &httpService, const char *url, const KeyedVector<String8, String8> *headers) override;
|
||
|
status_t setDataSource(int fd, int64_t offset, int64_t length) override;
|
||
|
status_t setDataSource(const sp<IStreamSource> &source) override;
|
||
|
|
||
|
status_t setVideoSurfaceTexture(
|
||
|
const sp<IGraphicBufferProducer> &bufferProducer) override;
|
||
|
|
||
|
status_t prepare() override;
|
||
|
status_t prepareAsync() override;
|
||
|
status_t start() override;
|
||
|
status_t stop() override;
|
||
|
status_t pause() override;
|
||
|
bool isPlaying() override;
|
||
|
status_t getPlaybackSettings(AudioPlaybackRate *rate) override;
|
||
|
status_t setPlaybackSettings(const AudioPlaybackRate &rate) override;
|
||
|
status_t getDefaultBufferingSettings(BufferingSettings *buffering);
|
||
|
status_t getBufferingSettings(BufferingSettings *buffering) override;
|
||
|
status_t setBufferingSettings(const BufferingSettings &buffering) override;
|
||
|
status_t seekTo(int msec, MediaPlayerSeekMode mode = MediaPlayerSeekMode::SEEK_PREVIOUS_SYNC) override;
|
||
|
status_t getCurrentPosition(int *msec) override;
|
||
|
status_t getDuration(int *msec) override;
|
||
|
status_t reset() override;
|
||
|
status_t setLooping(int loop) override;
|
||
|
status_t setVolume(float leftVolume, float rightVolume) override;
|
||
|
player_type playerType() override;
|
||
|
status_t invoke(const Parcel &request, Parcel *reply) override;
|
||
|
|
||
|
status_t setAudioStreamType(audio_stream_type_t streamType) override;
|
||
|
status_t setParameter(int key, const Parcel &request) override;
|
||
|
status_t getParameter(int key, Parcel *reply) override;
|
||
|
|
||
|
status_t getMetadata(
|
||
|
const media::Metadata::Filter &ids, Parcel *records) override;
|
||
|
|
||
|
status_t dump(int fd, const Vector<String16> &args) const override;
|
||
|
status_t getTrackInfo(Parcel *reply);
|
||
|
status_t notifyAt(int64_t mediaTimeUs) override;
|
||
|
/* 16: uuid length */
|
||
|
status_t prepareDrm(const uint8_t uuid[16], const Vector<uint8_t>& drmSessionId) override;
|
||
|
status_t releaseDrm() override;
|
||
|
|
||
|
/* NxMedia extend */
|
||
|
status_t AddTimeTextSource(const char *filepath, const char *mimeType);
|
||
|
int SetTimeTextFlag(int flags);
|
||
|
|
||
|
status_t updateVideoPosition(int x, int y, int width, int height);
|
||
|
|
||
|
void notifyFunc(int msg, int ext1, int ext2, const Parcel *obj = nullptr);
|
||
|
static void notify(void *cookie, int msg, int ext1, int ext2, const Parcel *obj = nullptr);
|
||
|
bool isLooping();
|
||
|
|
||
|
private:
|
||
|
status_t AttachNewPlayer(NxMediaPlayerInterface *player);
|
||
|
NxMediaPlayerInterface *createPlayer(NotifyCallbackF notifyFunc);
|
||
|
sp<NxMediaPlayerInterface> getPlayer(const char *url);
|
||
|
void ClearL();
|
||
|
status_t SeekToL(int msec) const;
|
||
|
status_t PrepareAsyncL() const;
|
||
|
status_t GetDurationL(int *msec) const;
|
||
|
status_t ResetL();
|
||
|
status_t setSubSurface(const Parcel &request, Parcel *reply __unused);
|
||
|
void disconnectSubNativeWindow();
|
||
|
NxMediaPlayerInterface *m_player;
|
||
|
void *m_libHandle; /* loaded library handle */
|
||
|
NxMediaPlayerInterface::CreateNxMediaPlayerInterfaeInstanceFunc m_createInstance;
|
||
|
NxMediaPlayerInterface::DestroyNxMediaPlayerInterfaeInstanceFunc m_destroyInstance;
|
||
|
Mutex m_lock;
|
||
|
MediaPlayerSeekMode m_seekMode;
|
||
|
bool m_prepareSync;
|
||
|
bool m_loop;
|
||
|
|
||
|
sp<ANativeWindow> m_nativeWindow;
|
||
|
int m_isSurfaceView;
|
||
|
int m_instIdx; /* instance number */
|
||
|
static int g_nextInstIdx;
|
||
|
sp<ANativeWindow> m_subWindow;
|
||
|
};
|
||
|
};
|
||
|
#endif
|
||
|
|