Documentation ¶
Index ¶
Constants ¶
const ( ProfileConstrainedBaseline byte = 1 ProfileBaseline = 2 ProfileMain = 3 ProfileConstrainedHigh = 4 ProfileHigh = 5 // All values are equal to ten times the level number, except level 1b which is // special. Level1_b byte = 0 Level1 = 10 Level1_1 = 11 Level1_2 = 12 Level1_3 = 13 Level2 = 20 Level2_1 = 21 Level2_2 = 22 Level3 = 30 Level3_1 = 31 Level3_2 = 32 Level4 = 40 Level4_1 = 41 Level4_2 = 42 Level5 = 50 Level5_1 = 51 Level5_2 = 52 )
const ConstraintSet3Flag byte = 0x10
ConstraintSet3Flag for level_idc=11 and profile_idc=0x42, 0x4D, or 0x58, the constraint set3 flag specifies if level 1b or level 1.1 is used.
Variables ¶
var DefaultProfileLevelId = ProfileLevelId{ Profile: ProfileConstrainedBaseline, Level: Level3_1, }
DefaultProfileLevelId.
TODO: The default should really be profile Baseline and level 1 according to the spec: https://tools.ietf.org/html/rfc6184#section-8.1. In order to not break backwards compatibility with older versions of WebRTC where external codecs don"t have any parameters, use profile ConstrainedBaseline level 3_1 instead. This workaround will only be done in an interim period to allow external clients to update their code.
var ProfilePatterns = []ProfilePattern{ {0x42, NewBitPattern("x1xx0000"), ProfileConstrainedBaseline}, {0x4D, NewBitPattern("1xxx0000"), ProfileConstrainedBaseline}, {0x58, NewBitPattern("11xx0000"), ProfileConstrainedBaseline}, {0x42, NewBitPattern("x0xx0000"), ProfileBaseline}, {0x58, NewBitPattern("10xx0000"), ProfileBaseline}, {0x4D, NewBitPattern("0x0x0000"), ProfileMain}, {0x64, NewBitPattern("00000000"), ProfileHigh}, {0x64, NewBitPattern("00001100"), ProfileConstrainedHigh}, }
ProfilePatterns is from https://tools.ietf.org/html/rfc6184#section-8.1.
Functions ¶
func GenerateProfileLevelIdForAnswer ¶
func GenerateProfileLevelIdForAnswer( localSupportedParams, remoteOfferedParams RtpParameter, ) (str string, err error)
GenerateProfileLevelIdForAnswer 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 and remote_offered_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 the answer 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 func be called. Therefore, this func does not need to handle profile intersection, and the profile of local_supported_params and remote_offered_params must be equal before calling this func. The parameters that are used when negotiating are the level part of profile-level-id and level-asymmetry-allowed.
@returns Canonical string representation as three hex bytes of the profile level id, or null if no one of the params have profile-level-id.
func IsSameProfile ¶
IsSameProfile returns true if the parameters have the same H264 profile, i.e. the same H264 profile (Baseline, High, etc).
Types ¶
type BitPattern ¶
type BitPattern struct {
// contains filtered or unexported fields
}
BitPattern is class for matching bit patterns such as "x1xx0000" where "x" is allowed to be either 0 or 1.
func NewBitPattern ¶
func NewBitPattern(str string) BitPattern
type ProfileLevelId ¶
func NewProfileLevelId ¶
func NewProfileLevelId(profile, level byte) ProfileLevelId
func ParseProfileLevelId ¶
func ParseProfileLevelId(str string) (profileLevelId *ProfileLevelId)
ParseProfileLevelId parse profile level id that is represented as a string of 3 hex bytes. Nothing will be returned if the string is not a recognized H264 profile level id.
@param str - profile-level-id value as a string of 3 hex bytes.
func ParseSdpProfileLevelId ¶
func ParseSdpProfileLevelId(profileLevelIdStr string) *ProfileLevelId
ParseSdpProfileLevelId parse profile level id that is represented as a string of 3 hex bytes. A default profile level id will be returned if profile level id is empty.
func (ProfileLevelId) String ¶
func (profileLevelId ProfileLevelId) String() string
String returns canonical string representation as three hex bytes of the profile level id, or returns nothing for invalid profile level ids.
type ProfilePattern ¶
type ProfilePattern struct {
// contains filtered or unexported fields
}
ProfilePattern is class for converting between profile_idc/profile_iop to Profile.
func NewProfilePattern ¶
func NewProfilePattern( profileIdc byte, profileIop BitPattern, profile byte, ) ProfilePattern