1 /** 2 * Copyright (C) 2022 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 #ifndef STREAM_SCHEDULER_H 18 #define STREAM_SCHEDULER_H 19 20 #include <BaseNode.h> 21 #include <IImsMediaThread.h> 22 #include <StreamSchedulerCallback.h> 23 #include <ImsMediaCondition.h> 24 #include <list> 25 #include <atomic> 26 27 class StreamScheduler : public IImsMediaThread, public StreamSchedulerCallback 28 { 29 public: 30 StreamScheduler(); 31 virtual ~StreamScheduler(); 32 void RegisterNode(BaseNode* pNode); 33 void DeRegisterNode(BaseNode* pNode); 34 void Start(); 35 void Stop(); 36 void Awake(); onAwakeScheduler()37 virtual void onAwakeScheduler() { this->Awake(); } 38 virtual void* run(); IsThreadRunning()39 bool IsThreadRunning() { return mIsRunning; } GetNumRegisteredNodes()40 uint32_t GetNumRegisteredNodes() { return mListRegisteredNode.size(); } 41 42 private: 43 bool RunRegisteredNode(); 44 std::list<BaseNode*> mListRegisteredNode; 45 ImsMediaCondition mConditionMain; 46 ImsMediaCondition mConditionExit; 47 std::mutex mMutex; 48 std::atomic<bool> mIsRunning; 49 }; 50 51 #endif