blob: f132ff93376b58327d218e3f6b2899257c407a93 [file] [log] [blame]
Sergey Silkin0e42cf72021-03-15 10:12:57 +01001/*
2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_
12#define MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_
13
14#include "absl/types/optional.h"
15#include "api/video/video_codec_constants.h"
16#include "api/video/video_codec_type.h"
17#include "common_video/h264/h264_bitstream_parser.h"
18#include "rtc_base/synchronization/mutex.h"
19
20namespace webrtc {
21class QpParser {
22 public:
23 absl::optional<uint32_t> Parse(VideoCodecType codec_type,
24 size_t spatial_idx,
25 const uint8_t* frame_data,
26 size_t frame_size);
27
28 private:
29 // A thread safe wrapper for H264 bitstream parser.
30 class H264QpParser {
31 public:
32 absl::optional<uint32_t> Parse(const uint8_t* frame_data,
33 size_t frame_size);
34
35 private:
36 Mutex mutex_;
37 H264BitstreamParser bitstream_parser_ RTC_GUARDED_BY(mutex_);
38 };
39
40 H264QpParser h264_parsers_[kMaxSimulcastStreams];
41};
42
43} // namespace webrtc
44
45#endif // MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_