1 /*
2 * Copyright (c) 2025 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 "hw_cast_data_source_descriptor.h"
17 #include "avsession_log.h"
18
19 namespace OHOS {
20 namespace AVSession {
21
~HwCastDataSourceDescriptor()22 HwCastDataSourceDescriptor::~HwCastDataSourceDescriptor()
23 {
24 SLOGI("destructor in");
25 }
26
ReadAt(const std::shared_ptr<CastEngine::CastSharedMemory> & mem,uint32_t length,int64_t pos)27 int32_t HwCastDataSourceDescriptor::ReadAt(const std::shared_ptr<CastEngine::CastSharedMemory> &mem,
28 uint32_t length, int64_t pos)
29 {
30 int32_t result = 0;
31 int32_t memorySize = mem->GetSize();
32 SLOGI("ReadAt size is = %{public}d length is %{public}d", memorySize, length);
33 if (callback_ != nullptr) {
34 result = callback_(mem.get(), length, pos);
35 } else {
36 SLOGE("no callback");
37 }
38 return result;
39 }
40
GetSize(int64_t & size)41 int32_t HwCastDataSourceDescriptor::GetSize(int64_t &size)
42 {
43 SLOGE("GetSize in");
44 size = size_;
45 return 0;
46 }
47
SetCallback(std::function<int32_t (void *,uint32_t,int64_t)> callback)48 void HwCastDataSourceDescriptor::SetCallback(std::function<int32_t(void*, uint32_t, int64_t)> callback)
49 {
50 callback_ = callback;
51 }
52
SetSize(int64_t size)53 void HwCastDataSourceDescriptor::SetSize(int64_t size)
54 {
55 size_ = size;
56 }
57
58 } // namespace AVSession
59 } // namespace OHOS