Bug 1864652 - Expose settings for Global Privacy Control. r=geckoview-reviewers,ohall...
[gecko.git] / third_party / libwebrtc / pc / rtp_parameters_conversion.h
blob2cc39dd0e698fab962a6a5f2273d2eae6f3150a2
1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
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 */
11 #ifndef PC_RTP_PARAMETERS_CONVERSION_H_
12 #define PC_RTP_PARAMETERS_CONVERSION_H_
14 #include <vector>
16 #include "absl/types/optional.h"
17 #include "api/rtc_error.h"
18 #include "api/rtp_parameters.h"
19 #include "media/base/codec.h"
20 #include "media/base/stream_params.h"
21 #include "pc/session_description.h"
23 namespace webrtc {
25 // NOTE: Some functions are templated for convenience, such that template-based
26 // code dealing with AudioContentDescription and VideoContentDescription can
27 // use this easily. Such methods are usable with cricket::AudioCodec and
28 // cricket::VideoCodec.
30 //***************************************************************************
31 // Functions for converting from new webrtc:: structures to old cricket::
32 // structures.
34 // As the return values imply, all of these functions do validation of the
35 // parameters and return an error if they're invalid. It's expected that any
36 // default values (such as video clock rate of 90000) have been filled by the
37 // time the webrtc:: structure is being converted to the cricket:: one.
39 // These are expected to be used when parameters are passed into an RtpSender
40 // or RtpReceiver, and need to be validated and converted so they can be
41 // applied to the media engine level.
42 //***************************************************************************
44 // Returns error on invalid input. Certain message types are only valid for
45 // certain feedback types.
46 RTCErrorOr<cricket::FeedbackParam> ToCricketFeedbackParam(
47 const RtcpFeedback& feedback);
49 // Verifies that the codec kind is correct, and it has mandatory parameters
50 // filled, with values in valid ranges.
51 RTCErrorOr<cricket::Codec> ToCricketCodec(const RtpCodecParameters& codec);
53 // Verifies that payload types aren't duplicated, in addition to normal
54 // validation.
55 RTCErrorOr<std::vector<cricket::Codec>> ToCricketCodecs(
56 const std::vector<RtpCodecParameters>& codecs);
58 // SSRCs are allowed to be ommitted. This may be used for receive parameters
59 // where SSRCs are unsignaled.
60 RTCErrorOr<cricket::StreamParamsVec> ToCricketStreamParamsVec(
61 const std::vector<RtpEncodingParameters>& encodings);
63 //*****************************************************************************
64 // Functions for converting from old cricket:: structures to new webrtc::
65 // structures. Unlike the above functions, these are permissive with regards to
66 // input validation; it's assumed that any necessary validation already
67 // occurred.
69 // These are expected to be used either to convert from audio/video engine
70 // capabilities to RtpCapabilities, or to convert from already-parsed SDP
71 // (in the form of cricket:: structures) to webrtc:: structures. The latter
72 // functionality is not yet implemented.
73 //*****************************************************************************
75 // Returns empty value if `cricket_feedback` is a feedback type not
76 // supported/recognized.
77 absl::optional<RtcpFeedback> ToRtcpFeedback(
78 const cricket::FeedbackParam& cricket_feedback);
80 std::vector<RtpEncodingParameters> ToRtpEncodings(
81 const cricket::StreamParamsVec& stream_params);
83 RtpCodecParameters ToRtpCodecParameters(const cricket::Codec& cricket_codec);
84 RtpCodecCapability ToRtpCodecCapability(const cricket::Codec& cricket_codec);
86 RtpCapabilities ToRtpCapabilities(
87 const std::vector<cricket::Codec>& cricket_codecs,
88 const cricket::RtpHeaderExtensions& cricket_extensions);
90 RtpParameters ToRtpParameters(
91 const std::vector<cricket::Codec>& cricket_codecs,
92 const cricket::RtpHeaderExtensions& cricket_extensions,
93 const cricket::StreamParamsVec& stream_params);
95 } // namespace webrtc
97 #endif // PC_RTP_PARAMETERS_CONVERSION_H_