1 /*
2 * Copyright (c) 2020-2021 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 #include "liteplayer_comm.h"
17 #include <sys/time.h>
18 #include <unistd.h>
19 #ifdef __LITE__
20 #include <los_ld_elflib.h>
21 #else
22 #include <dlfcn.h>
23 #endif
24 #include "liteplayer.h"
25
26 using OHOS::Media::PlayerControl;
27
28 const long long AV_NS2MS_SCALE = 1000000LL;
29 const long long AV_SEC2MS_SCALE = 1000LL;
30
PlayerControlOnEvent(void * priv,EventCbType event,int32_t ext1,int32_t ext2)31 int32_t PlayerControlOnEvent(void* priv, EventCbType event, int32_t ext1, int32_t ext2)
32 {
33 PlayerControl *player = reinterpret_cast<PlayerControl *>(priv);
34 if (player == nullptr) {
35 return -1;
36 }
37 return player->OnPlayControlEvent(priv, event);
38 }
39
PlayerControlGetCurRelativeTime()40 uint64_t PlayerControlGetCurRelativeTime()
41 {
42 struct timespec ts = { 0, 0 };
43 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
44 uint64_t curTime = (static_cast<uint64_t>(ts.tv_sec)) * AV_SEC2MS_SCALE +
45 (static_cast<uint64_t>(ts.tv_nsec)) / AV_NS2MS_SCALE;
46 return curTime;
47 }
48
49