• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <unordered_map>
18 
19 #include "l2cap/cid.h"
20 #include "l2cap/internal/channel_impl.h"
21 #include "l2cap/internal/data_controller.h"
22 #include "l2cap/internal/data_pipeline_manager.h"
23 #include "l2cap/internal/sender.h"
24 #include "os/log.h"
25 
26 namespace bluetooth {
27 namespace l2cap {
28 namespace internal {
29 
AttachChannel(Cid cid,std::shared_ptr<ChannelImpl> channel,ChannelMode mode)30 void DataPipelineManager::AttachChannel(Cid cid, std::shared_ptr<ChannelImpl> channel, ChannelMode mode) {
31   ASSERT(sender_map_.find(cid) == sender_map_.end());
32   sender_map_.emplace(std::piecewise_construct, std::forward_as_tuple(cid),
33                       std::forward_as_tuple(handler_, link_, scheduler_.get(), channel, mode));
34 }
35 
DetachChannel(Cid cid)36 void DataPipelineManager::DetachChannel(Cid cid) {
37   ASSERT(sender_map_.find(cid) != sender_map_.end());
38   sender_map_.erase(cid);
39   scheduler_->RemoveChannel(cid);
40   scheduler_->SetChannelTxPriority(cid, false);
41 }
42 
GetDataController(Cid cid)43 DataController* DataPipelineManager::GetDataController(Cid cid) {
44   if (sender_map_.find(cid) == sender_map_.end()) {
45     return nullptr;
46   };
47   return sender_map_.find(cid)->second.GetDataController();
48 }
49 
OnPacketSent(Cid cid)50 void DataPipelineManager::OnPacketSent(Cid cid) {
51   ASSERT(sender_map_.find(cid) != sender_map_.end());
52   sender_map_.find(cid)->second.OnPacketSent();
53 }
54 
UpdateClassicConfiguration(Cid cid,classic::internal::ChannelConfigurationState config)55 void DataPipelineManager::UpdateClassicConfiguration(Cid cid, classic::internal::ChannelConfigurationState config) {
56   ASSERT(sender_map_.find(cid) != sender_map_.end());
57   sender_map_.find(cid)->second.UpdateClassicConfiguration(config);
58 }
59 
SetChannelTxPriority(Cid cid,bool high_priority)60 void DataPipelineManager::SetChannelTxPriority(Cid cid, bool high_priority) {
61   ASSERT(sender_map_.find(cid) != sender_map_.end());
62   scheduler_->SetChannelTxPriority(cid, high_priority);
63 }
64 
65 }  // namespace internal
66 }  // namespace l2cap
67 }  // namespace bluetooth
68