• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 HISTREAMER_PIPELINE_COMMON_MEDIA_STAT_STUB_H
17 #define HISTREAMER_PIPELINE_COMMON_MEDIA_STAT_STUB_H
18 
19 #include <cstdint>
20 #include <atomic>
21 #include <vector>
22 
23 #include "pipeline/core/event.h"
24 
25 namespace OHOS {
26 namespace Media {
27 class MediaStatStub {
28 public:
29     struct MediaStat {
30         std::string reporter;
31         std::atomic<bool> completeEventReceived {false};
MediaStatMediaStat32         explicit MediaStat(std::string rep) : reporter(std::move(rep))
33         {
34         }
MediaStatMediaStat35         MediaStat(const MediaStat& other)
36             : reporter(other.reporter), completeEventReceived(other.completeEventReceived.load())
37         {
38         }
39         MediaStat& operator=(const MediaStat& other)
40         {
41             reporter = other.reporter;
42             completeEventReceived = other.completeEventReceived.load();
43             return *this;
44         }
45     };
46 
47     MediaStatStub() = default;
48     void Reset();
49     void Append(const std::string& reporter);
50     void ReceiveEvent(const Event& event);
51     bool IsEventCompleteAllReceived();
52 
53 private:
54     std::vector<MediaStat> mediaStats_;
55 };
56 } // Media
57 } // OHOS
58 #endif // HISTREAMER_PIPELINE_COMMON_MEDIA_STAT_STUB_H
59