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 StreamIntent 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 HostStreamImpl(const HostStreamInfo& type, 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) :
33 info_(info),
34 callBack_(c)
35 {
36 }
37
GetStreamType() const38 StreamIntent HostStreamImpl::GetStreamType() const
39 {
40 return info_.type_;
41 }
42
GetStreamId() const43 int HostStreamImpl::GetStreamId() const
44 {
45 return info_.streamId_;
46 }
47
GetStreamState() const48 bool HostStreamImpl::GetStreamState() const
49 {
50 return info_.builed_;
51 }
52
SetStreamState(bool state)53 void HostStreamImpl::SetStreamState(bool state)
54 {
55 info_.builed_ = state;
56 return;
57 }
GetStreamInfo() const58 HostStreamInfo HostStreamImpl::GetStreamInfo() const
59 {
60 return info_;
61 }
62
GetBufferCb() const63 BufferCb HostStreamImpl::GetBufferCb() const
64 {
65 return callBack_;
66 }
67
Create(const HostStreamInfo & info,BufferCb c)68 std::unique_ptr<HostStream> HostStream::Create(const HostStreamInfo& info, BufferCb c)
69 {
70 return std::make_unique<HostStreamImpl>(info, c);
71 }
72 }
73