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  *
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 TRANSPORT_FACTORY_H
17 #define TRANSPORT_FACTORY_H
18 
19 #include <stdint.h>
20 #include "dispatcher.h"
21 #include "raw_address.h"
22 #include "transport_def.h"
23 
24 namespace OHOS {
25 namespace bluetooth {
26 /**
27  * @brief This TransportFactory class provides a set of methods that create rfcomm transport and l2cap transport.
28  */
29 class TransportFactory {
30 public:
31     /**
32      * @brief Create a Rfcomm transport object.
33      *
34      * @param addr remote device address.
35      * @param scn server channel number.
36      * @param mtu mtu
37      * @param observer the callback to the upper layer.
38      * @return std::unique_ptr<DataTransport>
39      */
40     static std::unique_ptr<DataTransport> CreateRfcommTransport(const RawAddress *addr, uint8_t scn, uint16_t mtu,
41         DataTransportObserver &observer, utility::Dispatcher &dispatcher);
42 
43     /**
44      * @brief Create a L2CAP transport object.
45      *
46      * @param createInfo  create info struct.
47      * @return std::unique_ptr<DataTransport>
48      */
49     static std::unique_ptr<DataTransport> CreateL2capTransport(L2capTransportInfo &createInfo);
50 };
51 }  // namespace bluetooth
52 }  // namespace OHOS
53 #endif  // TRANSPORT_FACTORY_H