• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PLAYER_CLIENT_H
17 #define PLAYER_CLIENT_H
18 
19 #include <unistd.h>
20 #include <pthread.h>
21 #include <iunknown.h>
22 #include <iproxy_server.h>
23 #include <iproxy_client.h>
24 #include "format.h"
25 #include "media_log.h"
26 #include "player_type.h"
27 #include "liteipc_adapter.h"
28 #include "serializer.h"
29 #include "surface.h"
30 #include "source.h"
31 #include "player.h"
32 namespace OHOS {
33 namespace Media {
34 class Player::PlayerClient {
35 public:
GetInstance()36     static PlayerClient* GetInstance()
37     {
38         static PlayerClient client;
39         if (client.InitPlayerClient() == false) {
40             printf("InitPlayerClient failed\n");
41             return nullptr;
42         }
43         return &client;
44     }
45 
46     bool InitPlayerClient();
47     static void ClearIpcMsg(void *ipcMsg);
48     static int32_t PlayerCommonCallback(const IpcContext* context, void *ipcMsg, IpcIo *io, void *arg);
49 
50     static int Callback(void* owner, int code, IpcIo *reply);
51     int32_t SetSource(const Source &source);
52     int32_t Prepare();
53     int32_t Play();
54     bool IsPlaying();
55     int32_t Pause();
56     int32_t Stop();
57     int32_t Rewind(int64_t mSeconds, int32_t mode);
58     int32_t SetVolume(float leftVolume, float rightVolume);
59     int32_t SetSurface(Surface *surface);
60     int32_t SetLoop(bool loop);
61     bool IsSingleLooping();
62     int32_t GetCurrentPosition(int64_t &time) const;
63     int32_t GetDuration(int64_t &duration) const;
64     int32_t GetVideoWidth(int32_t &videoWidth);
65     int32_t GetVideoHeight(int32_t &videoHeight);
66     int32_t Reset();
67     int32_t Release();
68     void SetPlayerCallback(const std::shared_ptr<PlayerCallback> &cb);
69     int32_t GetPlayerState(int32_t &state) const;
70     int32_t SetPlaybackSpeed(float speed);
71     int32_t GetPlaybackSpeed(float &speed);
72     int32_t SetParameter(const Format &params);
73     int32_t SetAudioStreamType(int32_t type);
74     void GetAudioStreamType(int32_t &type);
75 
76 private:
PlayerClient()77     PlayerClient() : proxy_(nullptr), sid_(nullptr) {}
~PlayerClient()78     ~PlayerClient() {}
79     IClientProxy *proxy_;
80     SvcIdentity *sid_;
81 };
82 }
83 }
84 #endif