Chromium Code Reviews| Index: remoting/protocol/sdp_helper.h |
| diff --git a/remoting/protocol/sdp_helper.h b/remoting/protocol/sdp_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1b5d34786a42196748a932039926f7eed04b53e1 |
| --- /dev/null |
| +++ b/remoting/protocol/sdp_helper.h |
| @@ -0,0 +1,62 @@ |
| +// Find the line in form of "a=rtpmap:<payload_type> <codec>/.." with the |
| +// specified |codec|. Sets |line_num| to line number and |payload_type| to the |
| +// payload type from that line. Returns false if the codec wasn't found. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_PROTOCOL_SDP_HELPER_H_ |
| +#define REMOTING_PROTOCOL_SDP_HELPER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| + |
| +namespace remoting { |
| +namespace protocol { |
| + |
| +// SdpHelper is used to process SDP session descriptions generated by WebRTC, |
|
Jamie
2016/11/28 21:02:52
Maybe define SDP the first time you use it.
Sergey Ulanov
2016/11/28 22:45:08
Done.
|
| +// and particularly to configure desired video and audio codecs. |
| +// |
| +// It also normalizes the SDP message to make sure the text used for HMAC |
| +// signatures verifications is the same that was signed on the sending side. |
|
Jamie
2016/11/28 21:02:52
s/signatures verifications/signature verification/
Sergey Ulanov
2016/11/28 22:45:08
Done.
|
| +// This is necessary because WebRTC generates SDP with CRLF line endings which |
| +// are sometimes converted to LF after passing the signaling channel. |
| +class SdpHelper { |
|
Jamie
2016/11/28 21:02:52
*Helper is a bit generic as a name. If this encaps
Sergey Ulanov
2016/11/28 22:45:09
Done.
|
| + public: |
| + explicit SdpHelper(const std::string& sdp); |
| + ~SdpHelper(); |
| + |
| + bool has_audio() const { return has_audio_; } |
| + bool has_video() const { return has_video_; } |
| + |
| + // Returns string representation of the SDP. The result always has |
|
Jamie
2016/11/28 21:02:52
s/SDP/SDP message/
Sergey Ulanov
2016/11/28 22:45:08
Done.
|
| + // line-endings normalized and empty lines removed. |
|
Jamie
2016/11/28 21:02:52
Be specific about what the normalized line-endings
Sergey Ulanov
2016/11/28 22:45:08
The client normalizes with LF, so changing it to C
|
| + std::string ToString() const; |
| + |
| + // Adds specified parameters for the |codec|. Returns false if the |codec| is |
| + // not listed anywhere in SDP. |
|
Jamie
2016/11/28 21:02:52
s/SDP/the SDP message/
Sergey Ulanov
2016/11/28 22:45:09
Done.
|
| + bool AddCodecParameter(const std::string& codec, |
| + const std::string& parameters_to_add); |
| + |
| + private: |
| + // Find the line in form of "a=rtpmap:<payload_type> <codec>/.." with the |
|
Jamie
2016/11/28 21:02:52
s/in form of/of the form/
Sergey Ulanov
2016/11/28 22:45:08
Done.
|
| + // specified |codec|. Sets |line_num| to line number and |payload_type| to the |
| + // payload type from that line. Returns false if the codec wasn't found. |
| + bool FindCodec(const std::string& codec, |
| + int* line_num, |
| + std::string* payload_type) const; |
| + |
| + std::vector<std::string> sdp_lines_; |
| + |
| + bool has_audio_ = false; |
| + bool has_video_ = false; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SdpHelper); |
| +}; |
| + |
| +} // namespace protocol |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_PROTOCOL_SDP_HELPER_H_ |