[Android] libmedia-libmediaplayerservice 框架

@startuml

package libmedia{
    class MediaPlayer{
        <font size=20 color="red">1</font>  <font color="green"> status_t        setListener(const sp<MediaPlayerListener>& listener);
        <font size=20 color="red">2</font>  <font color="green"> status_t        getVideoWidth(int *w);
        <font size=20 color="red">3</font>  <font color="green"> status_t        getVideoHeight(int *h);
        <font size=20 color="blue">1~42</font>  <font color="green"> wrapper_IMediaPlayer();
        <font size=20 color="#00FFFF">1~7</font>  <font color="green"> wrapper_IMediaPlayerService();
    }

    class JAVAMediaPlayer{
        <font size=20>1</font>  <font color="grey" size=15>void setOnCompletionListener(MediaPlayer.OnCompletionListener listener) </font>
        <font size=20>2</font>  <font color="grey" size=15>void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener listener) </font>
        <font size=20>3</font>  <font color="grey" size=15>void setOnErrorListener(MediaPlayer.OnErrorListener listener) </font>
        <font size=20>4</font>  <font color="grey" size=15>void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener listener) </font>
        <font size=20>5</font>  <font color="grey" size=15>void setOnPreparedListener(MediaPlayer.OnPreparedListener listener) </font>
        <font size=20>6</font>  <font color="green" size=15>void setDataSource(String path) </font>
        <font size=20>7</font>  <font color="green" size=15>void setDataSource(Context context, Uri uri, Map<string, string=""> headers) </font>
        <font size=20>8</font>  <font color="green" size=15>void prepareAsync() </font>
        <font size=20>9</font>  <font color="green" size=15>void setSurface(Surface surface) </font>
        <font size=20>10</font>  <font color="green" size=15>void setDisplay(SurfaceHolder sh) </font>
        <font size=20>11</font>  <font color="green" size=15>void start() </font>
        <font size=20>12</font>  <font color="green" size=15>void pause() </font>
        <font size=20>13</font>  <font color="green" size=15>boolean isPlaying() </font>
        <font size=20>14</font>  <font color="green" size=15>void stop() </font>
        <font size=20>15</font>  <font color="green" size=15>void reset() </font>
        <font size=20>16</font>  <font color="green" size=15>void release() </font>
        <font size=20>17</font>  <font color="green" size=15>int getCurrentPosition() </font>
        <font size=20>18</font>  <font color="green" size=15>int getDuration() </font>
        <font size=20>19</font>  <font color="green" size=15>int getVideoHeight() </font>
        <font size=20>20</font>  <font color="green" size=15>int getVideoWidth() </font>
        <font size=20>21</font>  <font color="green" size=15>void seekTo(int msec) </font>
        <font size=20>22</font>  <font color="grey" size=15>void setOnInfoListener(MediaPlayer.OnInfoListener listener) </font>
        <font size=20>23</font>  <font color="grey" size=15>void setOnVideoSizeChangedListener(MediaPlayer.OnVideoSizeChangedListener listener) </font>
        <font size=20>24</font>  <font color="green" size=15>void setPlaybackParams(PlaybackParams params) </font>
        <font size=20>25</font>  <font color="green" size=15>void setAudioStreamType(int streamtype) </font>
        <font size=20>26</font>  <font color="red" size=15>void setScreenOnWhilePlaying(boolean screenOn) </font>
        <font size=20>27</font>  <font color="green" size=15>void setVolume(float leftVolume, float rightVolume) </font>
        <font size=20>28</font>  <font color="green" size=15>void setLooping(boolean looping) </font>
    }

    class JNIMediaPlayer {
        <font size=20>6,7</font> <font color="green" size=15>void android_media_MediaPlayer_setDataSourceAndHeaders(JNIEnv *env, jobject thiz, jobject httpServiceBinderObj, jstring path,jobjectArray keys, jobjectArray values) </font> <font size=20 color="blue">2</font>
        <font size=20>8</font> <font color="green" size=15>void android_media_MediaPlayer_prepareAsync(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">6,9</font>
        <font size=20>9,10</font> <font color="green" size=15>void android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface) </font> <font size=20 color="blue">6</font>
        <font size=20>11</font> <font color="green" size=15>void android_media_MediaPlayer_start(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">10</font>
        <font size=20>12</font> <font color="green" size=15>void android_media_MediaPlayer_pause(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">12</font>
        <font size=20>13</font> <font color="green" size=15>jboolean android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">13</font>
        <font size=20>14</font> <font color="green" size=15>void android_media_MediaPlayer_stop(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">11</font>
        <font size=20>15</font> <font color="green" size=15>void android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">22</font>
        <font size=20>16</font> <font color="green" size=15>void android_media_MediaPlayer_release(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">1</font>,<font size=20 color="red">1</font>
        <font size=20>17</font> <font color="green" size=15>void jint android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">19</font>
        <font size=20>18</font> <font color="green" size=15>jint android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) </font> <font size=20 color="blue">20</font>
        <font size=20>19</font> <font color="green" size=15>jint android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)(JNIEnv *env, jobject thiz) </font> <font size=20 color="red">2</font>
        <font size=20>20</font> <font color="green" size=15>jint android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)(JNIEnv *env, jobject thiz) </font> <font size=20 color="red">3</font>
        <font size=20>21</font> <font color="green" size=15>void android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jlong msec, jint mode) </font> <font size=20 color="blue">18</font>
        <font size=20>24</font> <font color="green" size=15>void android_media_MediaPlayer_setPlaybackParams(JNIEnv *env, jobject thiz, jobject params) </font> <font size=20 color="blue">14</font>
        <font size=20>25</font> <font color="green" size=15>void android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype) </font> <font size=20 color="blue">23</font>
        <font size=20>27</font> <font color="green" size=15>void android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume) </font> <font size=20 color="blue">25</font>
        <font size=20>28</font> <font color="green" size=15>void android_media_MediaPlayer_setLooping(JNIEnv *env, jobject thiz, jboolean looping) </font> <font size=20 color="blue">24</font>
    }

    JAVAMediaPlayer ...> JNIMediaPlayer
    JNIMediaPlayer ...> MediaPlayer
}

package libmediaplayerservice{
    class MediaPlayerService{

    }

    class Client{

    }

    class AudioOutput{

    }

    class MediaPlayerBase{

    }

    class NuPlayerDriver{
        wrapper of NuPlayer
    }

    class NuPlayer{
        Audio 喂给 AudioTrack ,  Video 喂给其他模块
    }

    class Source{
        demux
    }

    class PlusPlayerDriver{

    }

    class PlusPlayer{

    }

    MediaPlayerService "n" --> Client
    Client --> AudioOutput
    Client --> MediaPlayerBase
    MediaPlayerBase <|-- NuPlayerDriver
    NuPlayerDriver --> NuPlayer
    NuPlayer --> Source
    MediaPlayerBase <|-- PlusPlayerDriver
    PlusPlayerDriver --> PlusPlayer

}

package libaudioclient{

}

package Interface{
    abstract class IMediaPlayer{

        <font size=20 color="blue">1</font> {abstract} <font color="green"> void            disconnect() = 0;
        <font size=20 color="blue">2</font> {abstract} <font color="green"> status_t        setDataSource(const sp<IMediaHTTPService> &httpService,const char *url,const KeyedVector<String8, String8>* headers) = 0; </font>
        <font size=20 color="blue">3</font> {abstract} <font color="grey"> status_t        setDataSource(int fd, int64_t offset, int64_t length) = 0;
        <font size=20 color="blue">4</font> {abstract} <font color="grey"> status_t        setDataSource(const sp<IStreamSource>& source) = 0;
        <font size=20 color="blue">5</font> {abstract} <font color="grey"> status_t        setDataSource(const sp<IDataSource>& source) = 0;
        <font size=20 color="blue">6</font> {abstract} <font color="green"> status_t        setVideoSurfaceTexture(const sp<IGraphicBufferProducer>& bufferProducer) = 0;
        <font size=20 color="blue">7</font> {abstract} <font color="grey"> status_t        getBufferingSettings(BufferingSettings* buffering /* nonnull */) = 0;
        <font size=20 color="blue">8</font> {abstract} <font color="grey"> status_t        setBufferingSettings(const BufferingSettings& buffering) = 0;
        <font size=20 color="blue">9</font> {abstract} <font color="green"> status_t        prepareAsync() = 0;
        <font size=20 color="blue">10</font> {abstract} <font color="green"> status_t        start() = 0;
        <font size=20 color="blue">11</font> {abstract} <font color="green"> status_t        stop() = 0;
        <font size=20 color="blue">12</font> {abstract} <font color="green"> status_t        pause() = 0;
        <font size=20 color="blue">13</font> {abstract} <font color="green"> status_t        isPlaying(bool* state) = 0;
        <font size=20 color="blue">14</font> {abstract} <font color="green"> status_t        setPlaybackSettings(const AudioPlaybackRate& rate) = 0;
        <font size=20 color="blue">15</font> {abstract} <font color="grey"> status_t        getPlaybackSettings(AudioPlaybackRate* rate /* nonnull */) = 0;
        <font size=20 color="blue">16</font> {abstract} <font color="grey"> status_t        setSyncSettings(const AVSyncSettings& sync, float videoFpsHint) = 0;
        <font size=20 color="blue">17</font> {abstract} <font color="grey"> status_t        getSyncSettings(AVSyncSettings* sync /* nonnull */,float* videoFps /* nonnull */) = 0;
        <font size=20 color="blue">18</font> {abstract} <font color="green"> status_t        seekTo(int msec,MediaPlayerSeekMode mode = MediaPlayerSeekMode::SEEK_PREVIOUS_SYNC) = 0;
        <font size=20 color="blue">19</font> {abstract} <font color="green"> status_t        getCurrentPosition(int* msec) = 0;
        <font size=20 color="blue">20</font> {abstract} <font color="green"> status_t        getDuration(int* msec) = 0;
        <font size=20 color="blue">21</font> {abstract} <font color="grey"> status_t        notifyAt(int64_t mediaTimeUs) = 0;
        <font size=20 color="blue">22</font> {abstract} <font color="green"> status_t        reset() = 0;
        <font size=20 color="blue">23</font> {abstract} <font color="green"> status_t        setAudioStreamType(audio_stream_type_t type) = 0;
        <font size=20 color="blue">24</font> {abstract} <font color="green"> status_t        setLooping(int loop) = 0;
        <font size=20 color="blue">25</font> {abstract} <font color="green"> status_t        setVolume(float leftVolume, float rightVolume) = 0;
        <font size=20 color="blue">26</font> {abstract} <font color="grey"> status_t        setAuxEffectSendLevel(float level) = 0;
        <font size=20 color="blue">27</font> {abstract} <font color="grey"> status_t        attachAuxEffect(int effectId) = 0;
        <font size=20 color="blue">28</font> {abstract} <font color="grey"> status_t        setParameter(int key, const Parcel& request) = 0;
        <font size=20 color="blue">29</font> {abstract} <font color="grey"> status_t        getParameter(int key, Parcel* reply) = 0;
        <font size=20 color="blue">30</font> {abstract} <font color="grey"> status_t        setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
        <font size=20 color="blue">31</font> {abstract} <font color="grey"> status_t        getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0;
        <font size=20 color="blue">32</font> {abstract} <font color="grey"> status_t        setNextPlayer(const sp<IMediaPlayer>& next) = 0;
        <font size=20 color="blue">33</font> {abstract} <font color="grey"> media::VolumeShaper::Status applyVolumeShaper(const sp<media::VolumeShaper::Configuration>& configuration,const sp<media::VolumeShaper::Operation>& operation) = 0;
        <font size=20 color="blue">34</font> {abstract} <font color="grey"> sp<media::VolumeShaper::State> getVolumeShaperState(int id) = 0;
        'Modular DRM'
        <font size=20 color="blue">35</font> {abstract} <font color="grey"> status_t        prepareDrm(const uint8_t uuid[16],const Vector<uint8_t>& drmSessionId) = 0;
        <font size=20 color="blue">36</font> {abstract} <font color="grey"> status_t        releaseDrm() = 0;
        <font size=20 color="blue">37</font> {abstract} <font color="grey"> status_t        invoke(const Parcel& request, Parcel *reply) = 0;
        <font size=20 color="blue">38</font> {abstract} <font color="grey"> status_t        setMetadataFilter(const Parcel& filter) = 0;
        <font size=20 color="blue">39</font> {abstract} <font color="grey"> status_t        getMetadata(bool update_only,bool apply_filter,Parcel *metadata) = 0;
        'AudioRouting'
        <font size=20 color="blue">40</font> {abstract} <font color="grey"> status_t        setOutputDevice(audio_port_handle_t deviceId) = 0;
        <font size=20 color="blue">41</font> {abstract} <font color="grey"> status_t        getRoutedDeviceId(audio_port_handle_t *deviceId) = 0;
        <font size=20 color="blue">42</font> {abstract} <font color="grey"> status_t        enableAudioDeviceCallback(bool enabled) = 0;
    }
    abstract class IMediaPlayerClient{
        处理来自Client的回调
        {abstract}  void notify(int msg, int ext1, int ext2, const Parcel *obj) = 0;
    }
    class IMediaDeathNotifier{
        提供接口给MediaPlayer获取 mediaplayserservice 服务, 目前是 "media.player"
        getMediaPlayerService();
    }
    abstract class IMediaPlayerService{
        创建一个 IMediaPlayer 给MediaPlayer
        IMediaPlayerService.h

        <font size=20 color="#00FFFF">1</font> {abstract} <font color="grey"> sp<IMediaRecorder> createMediaRecorder(const String16 &opPackageName) = 0;
        <font size=20 color="#00FFFF">2</font> {abstract} <font color="grey"> sp<IMediaMetadataRetriever> createMetadataRetriever() = 0;
        <font size=20 color="#00FFFF">3</font> {abstract} <font color="green"> sp<IMediaPlayer> create(const sp<IMediaPlayerClient>& client,audio_session_t audioSessionId = AUDIO_SESSION_ALLOCATE) = 0;
        <font size=20 color="#00FFFF">4</font> {abstract} <font color="grey"> sp<IMediaCodecList> getCodecList() const = 0;
        <font size=20 color="#00FFFF">5</font> {abstract} <font color="grey"> sp<IRemoteDisplay> listenForRemoteDisplay(const String16 &opPackageName,const sp<IRemoteDisplayClient>& client, const String8& iface) = 0;
        <font size=20 color="#00FFFF">6</font> {abstract} <font color="grey"> void addBatteryData(uint32_t params) = 0;
        <font size=20 color="#00FFFF">7</font> {abstract} <font color="grey"> status_t pullBatteryData(Parcel* reply) = 0;
    }
}

MediaPlayer ...> IMediaDeathNotifier
IMediaDeathNotifier ...> libmediaplayerservice
MediaPlayer ...> IMediaPlayerService
IMediaPlayerService ...> MediaPlayerService
MediaPlayer ...> IMediaPlayer
IMediaPlayer "RPC"...> Client
MediaPlayer <... IMediaPlayerClient
IMediaPlayerClient <..."RPC" Client
'IMediaDeathNotifier ...> libmediaplayerservice'
'libmedia ...> IMediaDeathNotifier'
AudioOutput --> libaudioclient


@enduml

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值