1 /*
2 * Copyright (c) 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 * http://www.apache.org/licenses/LICENSE-2.0
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 */
13
14 #include "host_stream.h"
15
16 namespace OHOS::Camera {
17 class HostStreamImpl : public HostStream {
18 public:
19 VdiStreamIntent GetStreamType() const override;
20 HostStreamInfo GetStreamInfo() const override;
21 int GetStreamId() const override;
22 bool GetStreamState() const override;
23 void SetStreamState(bool state) override;
24 BufferCb GetBufferCb() const override;
25 explicit HostStreamImpl(const HostStreamInfo& info, BufferCb c = nullptr);
26 ~HostStreamImpl() override = default;
27 protected:
28 HostStreamInfo info_;
29 BufferCb callBack_;
30 };
31
HostStreamImpl(const HostStreamInfo & info,BufferCb c)32 HostStreamImpl::HostStreamImpl(const HostStreamInfo& info, BufferCb c) : info_(info), callBack_(c)
33 {
34 }
35
GetStreamType() const36 VdiStreamIntent HostStreamImpl::GetStreamType() const
37 {
38 return info_.type_;
39 }
40
GetStreamId() const41 int HostStreamImpl::GetStreamId() const
42 {
43 return info_.streamId_;
44 }
45
GetStreamState() const46 bool HostStreamImpl::GetStreamState() const
47 {
48 return info_.builed_;
49 }
50
SetStreamState(bool state)51 void HostStreamImpl::SetStreamState(bool state)
52 {
53 info_.builed_ = state;
54 return;
55 }
GetStreamInfo() const56 HostStreamInfo HostStreamImpl::GetStreamInfo() const
57 {
58 return info_;
59 }
60
GetBufferCb() const61 BufferCb HostStreamImpl::GetBufferCb() const
62 {
63 return callBack_;
64 }
65
Create(const HostStreamInfo & info,BufferCb c)66 std::unique_ptr<HostStream> HostStream::Create(const HostStreamInfo& info, BufferCb c)
67 {
68 return std::make_unique<HostStreamImpl>(info, c);
69 }
70 }
71