blob: c75e35440ff8340d16b26200b73b130ae6b39783 [file] [log] [blame]
deadbeefe814a0d2017-02-26 02:15:091/*
2 * Copyright 2017 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
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef ORTC_RTPPARAMETERSCONVERSION_H_
12#define ORTC_RTPPARAMETERSCONVERSION_H_
deadbeefe814a0d2017-02-26 02:15:0913
14#include <memory>
15#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 04:47:3117#include "api/optional.h"
18#include "api/rtcerror.h"
19#include "api/rtpparameters.h"
20#include "media/base/codec.h"
21#include "pc/mediasession.h"
deadbeefe814a0d2017-02-26 02:15:0922
23namespace webrtc {
24
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.
29
30//***************************************************************************
31// Functions for converting from new webrtc:: structures to old cricket::
32// structures.
33//
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.
38//
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//***************************************************************************
43
44// Returns error on invalid input. Certain message types are only valid for
45// certain feedback types.
46RTCErrorOr<cricket::FeedbackParam> ToCricketFeedbackParam(
47 const RtcpFeedback& feedback);
48
49// Verifies that the codec kind is correct, and it has mandatory parameters
50// filled, with values in valid ranges.
51template <typename C>
52RTCErrorOr<C> ToCricketCodec(const RtpCodecParameters& codec);
53
54// Verifies that payload types aren't duplicated, in addition to normal
55// validation.
56template <typename C>
57RTCErrorOr<std::vector<C>> ToCricketCodecs(
58 const std::vector<RtpCodecParameters>& codecs);
59
60// Validates that header extension IDs aren't duplicated.
61RTCErrorOr<cricket::RtpHeaderExtensions> ToCricketRtpHeaderExtensions(
62 const std::vector<RtpHeaderExtensionParameters>& extensions);
63
64// SSRCs are allowed to be ommitted. This may be used for receive parameters
65// where SSRCs are unsignaled.
66RTCErrorOr<cricket::StreamParamsVec> ToCricketStreamParamsVec(
67 const std::vector<RtpEncodingParameters>& encodings);
68
69//*****************************************************************************
70// Functions for converting from old cricket:: structures to new webrtc::
71// structures. Unlike the above functions, these are permissive with regards to
72// input validation; it's assumed that any necessary validation already
73// occurred.
74//
75// These are expected to be used either to convert from audio/video engine
76// capabilities to RtpCapabilities, or to convert from already-parsed SDP
77// (in the form of cricket:: structures) to webrtc:: structures. The latter
78// functionality is not yet implemented.
79//*****************************************************************************
80
81// Returns empty value if |cricket_feedback| is a feedback type not
82// supported/recognized.
83rtc::Optional<RtcpFeedback> ToRtcpFeedback(
84 const cricket::FeedbackParam& cricket_feedback);
85
zhihuang24366392017-03-09 01:15:0686std::vector<RtpEncodingParameters> ToRtpEncodings(
87 const cricket::StreamParamsVec& stream_params);
88
89template <typename C>
90RtpCodecParameters ToRtpCodecParameters(const C& cricket_codec);
91
deadbeefe814a0d2017-02-26 02:15:0992template <typename C>
93RtpCodecCapability ToRtpCodecCapability(const C& cricket_codec);
94
95template <class C>
96RtpCapabilities ToRtpCapabilities(
97 const std::vector<C>& cricket_codecs,
98 const cricket::RtpHeaderExtensions& cricket_extensions);
99
zhihuang24366392017-03-09 01:15:06100template <class C>
101RtpParameters ToRtpParameters(
102 const std::vector<C>& cricket_codecs,
103 const cricket::RtpHeaderExtensions& cricket_extensions,
104 const cricket::StreamParamsVec& stream_params);
105
deadbeefe814a0d2017-02-26 02:15:09106} // namespace webrtc
107
Mirko Bonadei92ea95e2017-09-15 04:47:31108#endif // ORTC_RTPPARAMETERSCONVERSION_H_