1 /* 2 * Copyright (c) 2022 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 OHOS_SESSION_STACK_H 17 #define OHOS_SESSION_STACK_H 18 19 #include <string> 20 21 #include "session_container.h" 22 23 namespace OHOS::AVSession { 24 class SessionStack : public SessionContainer { 25 public: 26 int32_t AddSession(pid_t pid, const std::string& abilityName, sptr<AVSessionItem>& item) override; 27 28 std::vector<sptr<AVSessionItem>> RemoveSession(pid_t pid) override; 29 30 sptr<AVSessionItem> RemoveSession(pid_t pid, const std::string& abilityName) override; 31 32 sptr<AVSessionItem> RemoveSession(const std::string& sessionId) override; 33 34 sptr<AVSessionItem> GetSession(pid_t pid, const std::string& abilityName) override; 35 36 std::vector<sptr<AVSessionItem>> GetSessionsByPid(pid_t pid) override; 37 38 bool PidHasSession(pid_t pid) override; 39 40 sptr<AVSessionItem> GetSessionById(const std::string& sessionId) override; 41 42 std::vector<sptr<AVSessionItem>> GetAllSessions() override; 43 44 void UpdateSessionSort(sptr<AVSessionItem>& item) override; 45 46 bool IsEmpty() override; 47 48 int32_t getAllSessionNum() override; 49 50 private: 51 std::map<std::pair<pid_t, std::string>, sptr<AVSessionItem>> sessions_; 52 std::list<sptr<AVSessionItem>> stack_; 53 std::recursive_mutex sessionStackLock_; 54 }; 55 } // namespace OHOS::AVSession 56 #endif // OHOS_SESSION_STACK_H 57