Index: webrtc/common_video/h264/profile_level_id.h |
diff --git a/webrtc/common_video/h264/profile_level_id.h b/webrtc/common_video/h264/profile_level_id.h |
index f69b7f6cdcd27dee0cd409f5a79b7c0769ca9c76..bb1c435926bcf4311dbe0c628644efc2acbd1262 100644 |
--- a/webrtc/common_video/h264/profile_level_id.h |
+++ b/webrtc/common_video/h264/profile_level_id.h |
@@ -11,6 +11,7 @@ |
#ifndef WEBRTC_COMMON_VIDEO_H264_PROFILE_LEVEL_ID_H_ |
#define WEBRTC_COMMON_VIDEO_H264_PROFILE_LEVEL_ID_H_ |
+#include <map> |
#include <string> |
#include "webrtc/base/optional.h" |
@@ -18,6 +19,9 @@ |
namespace webrtc { |
namespace H264 { |
+// Map containting SDP codec parameters. |
+typedef std::map<std::string, std::string> CodecParameterMap; |
+ |
enum Profile { |
kProfileConstrainedBaseline, |
kProfileBaseline, |
@@ -60,6 +64,13 @@ struct ProfileLevelId { |
// profile level id. |
rtc::Optional<ProfileLevelId> ParseProfileLevelId(const char* str); |
+// Parse profile level id that is represented as a string of 3 hex bytes |
+// contained in an SDP key-value map. A default profile level id will be |
+// returned if the profile-level-id key is missing. Nothing will be returned if |
+// the key is present but the string is invalid. |
+rtc::Optional<ProfileLevelId> ParseSdpProfileLevelId( |
+ const CodecParameterMap& params); |
+ |
// Given that a decoder supports up to a given frame size (in pixels) at up to a |
// given number of frames per second, return the highest H.264 level where it |
// can guarantee that it will be able to support all valid encoded streams that |
@@ -71,6 +82,27 @@ rtc::Optional<Level> SupportedLevel(int max_frame_pixel_count, float max_fps); |
rtc::Optional<std::string> ProfileLevelIdToString( |
const ProfileLevelId& profile_level_id); |
+// Generate codec parameters that will be used as answer in an SDP negotiation |
+// based on local supported parameters and remote offered parameters. Both |
+// |local_supported_params|, |remote_offered_params|, and |answer_params| |
+// represent sendrecv media descriptions, i.e they are a mix of both encode and |
+// decode capabilities. In theory, when the profile in |local_supported_params| |
+// represent a strict superset of the profile in |remote_offered_params|, we |
+// could limit the profile in |answer_params| to the profile in |
+// |remote_offered_params|. However, to simplify the code, each supported H264 |
+// profile should be listed explicitly in the list of local supported codecs, |
+// even if they are redundant. Then each local codec in the list should be |
+// tested one at a time against the remote codec, and only when the profiles are |
+// equal should this function be called. Therefore, this function does not need |
+// to handle profile intersection, and the profile of |local_supported_params| |
+// and |remote_offered_params| must be equal before calling this function. The |
+// parameters that are used when negotiating are the level part of |
+// profile-level-id and level-asymmetry-allowed. |
+void GenerateProfileLevelIdForAnswer( |
+ const CodecParameterMap& local_supported_params, |
+ const CodecParameterMap& remote_offered_params, |
+ CodecParameterMap* answer_params); |
+ |
} // namespace H264 |
} // namespace webrtc |