blob: c397e0aa7fbebb8878e412f95514859b27655858 [file] [log] [blame]
Sergey Silkin0e42cf72021-03-15 09:12:571/*
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
Florent Castelli8037fc62024-08-29 13:00:4014#include <optional>
15
Sergey Silkin0e42cf72021-03-15 09:12:5716#include "api/video/video_codec_constants.h"
17#include "api/video/video_codec_type.h"
18#include "common_video/h264/h264_bitstream_parser.h"
Qiu Jianlinddf60842023-12-11 08:21:0319#ifdef RTC_ENABLE_H265
20#include "common_video/h265/h265_bitstream_parser.h"
21#endif
Sergey Silkin0e42cf72021-03-15 09:12:5722#include "rtc_base/synchronization/mutex.h"
23
24namespace webrtc {
25class QpParser {
26 public:
Florent Castelli8037fc62024-08-29 13:00:4027 std::optional<uint32_t> Parse(VideoCodecType codec_type,
28 size_t spatial_idx,
29 const uint8_t* frame_data,
30 size_t frame_size);
Sergey Silkin0e42cf72021-03-15 09:12:5731
32 private:
33 // A thread safe wrapper for H264 bitstream parser.
34 class H264QpParser {
35 public:
Florent Castelli8037fc62024-08-29 13:00:4036 std::optional<uint32_t> Parse(const uint8_t* frame_data, size_t frame_size);
Sergey Silkin0e42cf72021-03-15 09:12:5737
38 private:
39 Mutex mutex_;
40 H264BitstreamParser bitstream_parser_ RTC_GUARDED_BY(mutex_);
41 };
42
43 H264QpParser h264_parsers_[kMaxSimulcastStreams];
Qiu Jianlinddf60842023-12-11 08:21:0344
45#ifdef RTC_ENABLE_H265
46 // A thread safe wrapper for H.265 bitstream parser.
47 class H265QpParser {
48 public:
Florent Castelli8037fc62024-08-29 13:00:4049 std::optional<uint32_t> Parse(const uint8_t* frame_data, size_t frame_size);
Qiu Jianlinddf60842023-12-11 08:21:0350
51 private:
52 Mutex mutex_;
53 H265BitstreamParser bitstream_parser_ RTC_GUARDED_BY(mutex_);
54 };
55
56 H265QpParser h265_parsers_[kMaxSimulcastStreams];
57#endif
Sergey Silkin0e42cf72021-03-15 09:12:5758};
59
60} // namespace webrtc
61
62#endif // MODULES_VIDEO_CODING_UTILITY_QP_PARSER_H_