|
|
|
|
/*
|
|
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
|
|
|
|
|
* Description: NxMediaPlayerManager class implement
|
|
|
|
|
* Author: NxPlayer software group
|
|
|
|
|
* Create: 2019-11-21
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NX_MEDIAPLAYER_INTERFACE_H
|
|
|
|
|
#define NX_MEDIAPLAYER_INTERFACE_H
|
|
|
|
|
|
|
|
|
|
#include <utils/RefBase.h>
|
|
|
|
|
#include <utils/KeyedVector.h>
|
|
|
|
|
#include <utils/Mutex.h>
|
|
|
|
|
#include <binder/Parcel.h>
|
|
|
|
|
#include <system/window.h>
|
|
|
|
|
#include <android/hardware/graphics/bufferqueue/2.0/IGraphicBufferProducer.h>
|
|
|
|
|
|
|
|
|
|
using HGraphicBufferProducer = ::android::hardware::graphics::bufferqueue::V2_0::IGraphicBufferProducer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
enum NxPlayerType {
|
|
|
|
|
NX_TYPE_PLAYER = 0,
|
|
|
|
|
NX_TYPE_BDPLAYER = 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const int NX_SVR_PLAYER_INVALID_HDL = 0;
|
|
|
|
|
|
|
|
|
|
using NotifyCallbackF = void (*)(void *cookie, int msg, int ext1, int ext2, const Parcel *obj);
|
|
|
|
|
|
|
|
|
|
struct NxPlayerRate {
|
|
|
|
|
float speed;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct NxPlayerBufferingSettings {
|
|
|
|
|
int mInitialMarkMs;
|
|
|
|
|
int mResumePlaybackMarkMs;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum NxPlayerSeekMode {
|
|
|
|
|
NX_PLAYER_SEEK_NONE = 0x0,
|
|
|
|
|
/* search the previous nearest I frame from the seek position */ /* < CNcomment: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>seek λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I ֡ */
|
|
|
|
|
NX_PLAYER_SEEK_PRE_KEY,
|
|
|
|
|
/* search the next nearest I frame from the seek position */ /* < CNcomment: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>seek λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I ֡ */
|
|
|
|
|
NX_PLAYER_SEEK_NXT_KEY,
|
|
|
|
|
/* search the nearest I frame from the seek position */ /* < CNcomment: <20><><EFBFBD><EFBFBD>seek λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I ֡ */
|
|
|
|
|
NX_PLAYER_SEEK_CLOSEST_KEY,
|
|
|
|
|
/* search the nearest frame from the seek position */ /* < CNcomment: <20><><EFBFBD><EFBFBD>seek λ<><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡ */
|
|
|
|
|
NX_PLAYER_SEEK_CLOSEST_ANY,
|
|
|
|
|
NX_PLAYER_SEEK_BUTT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const int CMD_SET_SUB_SURFACE = 5328; // set subtitle surface
|
|
|
|
|
|
|
|
|
|
class NxMediaPlayerInterface : public RefBase {
|
|
|
|
|
public:
|
|
|
|
|
NxMediaPlayerInterface() : m_cookie(nullptr), m_notify(nullptr) {}
|
|
|
|
|
~NxMediaPlayerInterface() override {}
|
|
|
|
|
|
|
|
|
|
virtual status_t initCheck() = 0;
|
|
|
|
|
virtual status_t setDataSource(const char *url, const KeyedVector<String8, String8> *headers) = 0;
|
|
|
|
|
virtual status_t setDataSource(int fd, int64_t offset, int64_t length) = 0;
|
|
|
|
|
virtual status_t setVideoSurfaceTexture(const sp<HGraphicBufferProducer> &bufferProducer,
|
|
|
|
|
sp<ANativeWindow> &nativeWindow, int isSurfaceView) = 0;
|
|
|
|
|
virtual status_t prepareAsync() = 0;
|
|
|
|
|
virtual status_t start() = 0;
|
|
|
|
|
virtual status_t stop() = 0;
|
|
|
|
|
virtual status_t pause() = 0;
|
|
|
|
|
virtual bool isPlaying() = 0;
|
|
|
|
|
virtual status_t getPlaybackSettings(NxPlayerRate *rate) = 0;
|
|
|
|
|
virtual status_t setPlaybackSettings(const NxPlayerRate &rate) = 0;
|
|
|
|
|
virtual status_t seekTo(int msec, NxPlayerSeekMode mode = NxPlayerSeekMode::NX_PLAYER_SEEK_PRE_KEY) = 0;
|
|
|
|
|
virtual status_t getCurrentPosition(int *msec) = 0;
|
|
|
|
|
virtual status_t getDuration(int *msec) = 0;
|
|
|
|
|
virtual status_t reset() = 0;
|
|
|
|
|
virtual status_t setLooping(int loop) = 0;
|
|
|
|
|
virtual status_t setVolume(float leftVolume, float rightVolume) = 0;
|
|
|
|
|
virtual status_t invoke(const Parcel &request, Parcel *reply) = 0;
|
|
|
|
|
virtual status_t setParameter(int key, const Parcel &request) = 0;
|
|
|
|
|
virtual status_t getParameter(int key, Parcel *reply) = 0;
|
|
|
|
|
virtual status_t getMetadata(Parcel *records) = 0;
|
|
|
|
|
virtual status_t getTrackInfo(Parcel *reply) = 0;
|
|
|
|
|
virtual status_t setSubSurface(const sp<HGraphicBufferProducer> &bufferProducer) = 0;
|
|
|
|
|
virtual status_t getDefaultBufferingSettings(NxPlayerBufferingSettings *buffering) = 0;
|
|
|
|
|
virtual status_t getBufferingSettings(NxPlayerBufferingSettings *buffering) = 0;
|
|
|
|
|
virtual status_t setBufferingSettings(const NxPlayerBufferingSettings &buffering) = 0;
|
|
|
|
|
virtual status_t setAudioStreamType(int streamType) = 0;
|
|
|
|
|
virtual status_t dump(int fd, const Vector<String16> &args) = 0;
|
|
|
|
|
virtual status_t setUID(int uid) = 0;
|
|
|
|
|
virtual status_t notifyAt(int64_t mediaTimeUs) = 0;
|
|
|
|
|
/* 16: uuid length */
|
|
|
|
|
virtual status_t prepareDrm(const uint8_t uuid[16], const Vector<uint8_t>& drmSessionId) = 0;
|
|
|
|
|
virtual status_t releaseDrm() = 0;
|
|
|
|
|
virtual void notifyFunc(int msg, int ext1, int ext2, const Parcel *obj = nullptr) = 0;
|
|
|
|
|
void setNotifyCallback(void *cookiePara, NotifyCallbackF notifyFunc)
|
|
|
|
|
{
|
|
|
|
|
Mutex::Autolock autoLock(m_notifyLock);
|
|
|
|
|
m_cookie = cookiePara;
|
|
|
|
|
m_notify = notifyFunc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sendEvent(int msg, int ext1 = 0, int ext2 = 0, const Parcel *obj = nullptr)
|
|
|
|
|
{
|
|
|
|
|
Mutex::Autolock autoLock(m_notifyLock);
|
|
|
|
|
if (m_notify != nullptr) {
|
|
|
|
|
m_notify(m_cookie, msg, ext1, ext2, obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
virtual bool isLooping() = 0;
|
|
|
|
|
|
|
|
|
|
using CreateNxMediaPlayerInterfaeInstanceFunc = NxMediaPlayerInterface *(*)(int);
|
|
|
|
|
using DestroyNxMediaPlayerInterfaeInstanceFunc = void (*)(NxMediaPlayerInterface *, int);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Mutex m_notifyLock;
|
|
|
|
|
void *m_cookie;
|
|
|
|
|
NotifyCallbackF m_notify;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|