xref: /aosp_15_r20/external/webrtc/media/base/sdp_video_format_utils.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2019 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 MEDIA_BASE_SDP_VIDEO_FORMAT_UTILS_H_
12 #define MEDIA_BASE_SDP_VIDEO_FORMAT_UTILS_H_
13 
14 #include "absl/types/optional.h"
15 #include "api/video_codecs/sdp_video_format.h"
16 
17 namespace webrtc {
18 // Generate codec parameters that will be used as answer in an SDP negotiation
19 // based on local supported parameters and remote offered parameters. Both
20 // `local_supported_params`, `remote_offered_params`, and `answer_params`
21 // represent sendrecv media descriptions, i.e they are a mix of both encode and
22 // decode capabilities. In theory, when the profile in `local_supported_params`
23 // represent a strict superset of the profile in `remote_offered_params`, we
24 // could limit the profile in `answer_params` to the profile in
25 // `remote_offered_params`. However, to simplify the code, each supported H264
26 // profile should be listed explicitly in the list of local supported codecs,
27 // even if they are redundant. Then each local codec in the list should be
28 // tested one at a time against the remote codec, and only when the profiles are
29 // equal should this function be called. Therefore, this function does not need
30 // to handle profile intersection, and the profile of `local_supported_params`
31 // and `remote_offered_params` must be equal before calling this function. The
32 // parameters that are used when negotiating are the level part of
33 // profile-level-id and level-asymmetry-allowed.
34 void H264GenerateProfileLevelIdForAnswer(
35     const SdpVideoFormat::Parameters& local_supported_params,
36     const SdpVideoFormat::Parameters& remote_offered_params,
37     SdpVideoFormat::Parameters* answer_params);
38 
39 // Parse max frame rate from SDP FMTP line. absl::nullopt is returned if the
40 // field is missing or not a number.
41 absl::optional<int> ParseSdpForVPxMaxFrameRate(
42     const SdpVideoFormat::Parameters& params);
43 
44 // Parse max frame size from SDP FMTP line. absl::nullopt is returned if the
45 // field is missing or not a number. Please note that the value is stored in sub
46 // blocks but the returned value is in total number of pixels.
47 absl::optional<int> ParseSdpForVPxMaxFrameSize(
48     const SdpVideoFormat::Parameters& params);
49 
50 }  // namespace webrtc
51 
52 #endif  // MEDIA_BASE_SDP_VIDEO_FORMAT_UTILS_H_
53