rtp_parameters_conversion.h 4.1 KB

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