MeidaPlayer的接口和架构分析

MeidaPlayer.h

MediaPlayerListener::notify用来通知client,反馈server发生的情况,使client做出相应的反应。

主要定义了一个播放器状态机。

 

//播放器状态机

class MediaPlayer : public BnMediaPlayerClient,

                    public virtual IMediaDeathNotifier

{

public:

    MediaPlayer();

    ~MediaPlayer();

            void            died();

            void            disconnect();

 

            status_t        setDataSource(

                    const char *url,

                    const KeyedVector<String8, String8> *headers);

 

            status_t        setDataSource(int fd, int64_t offset, int64_t length);

            status_t        setVideoSurface(const sp<Surface>& surface);

            status_t        setListener(const sp<MediaPlayerListener>& listener);

            status_t        prepare();

            status_t        prepareAsync();

            status_t        start();

            status_t        stop();

            status_t        pause();

            bool            isPlaying();

            status_t        getVideoWidth(int *w);

            status_t        getVideoHeight(int *h);

            status_t        seekTo(int msec);

            status_t        getCurrentPosition(int *msec);

            status_t        getDuration(int *msec);

            status_t        reset();

            status_t        setAudioStreamType(int type);

            status_t        setLooping(int loop);

            bool            isLooping();

            status_t        setVolume(float leftVolume, float rightVolume);

            void            notify(int msg, int ext1, int ext2);

    static  sp<IMemory>     decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);

    static  sp<IMemory>     decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);

            status_t        invoke(const Parcel& request, Parcel *reply);

            status_t        setMetadataFilter(const Parcel& filter);

            status_t        getMetadata(bool update_only, bool apply_filter, Parcel *metadata);

            status_t        suspend();

            status_t        resume();

            status_t        setAudioSessionId(int sessionId);

            int             getAudioSessionId();

            status_t        setAuxEffectSendLevel(float level);

            status_t        attachAuxEffect(int effectId);

private:

            void            clear_l();

            status_t        seekTo_l(int msec);

            status_t        prepareAsync_l();

            status_t        getDuration_l(int *msec);

            status_t        setDataSource(const sp<IMediaPlayer>& player);

 

    sp<IMediaPlayer>            mPlayer;

    thread_id_t                 mLockThreadId;

    Mutex                       mLock;

    Mutex                       mNotifyLock;

    Condition                   mSignal;

    sp<MediaPlayerListener>     mListener;

    void*                       mCookie;

    media_player_states         mCurrentState;

    int                         mDuration;

    int                         mCurrentPosition;

    int                         mSeekPosition;

    bool                        mPrepareSync;

    status_t                    mPrepareStatus;

    int                         mStreamType;

    bool                        mLoop;

    float                       mLeftVolume;

    float                       mRightVolume;

    int                         mVideoWidth;

    int                         mVideoHeight;

    int                         mAudioSessionId;

    float                       mSendLevel;

};

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值