npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

h264-profile-level-id

v2.0.0

Published

TypeScript utility to process H264 profile-level-id values

Downloads

111,769

Readme

h264-profile-level-id

TypeScript utility to process H264 profile-level-id values based on Google's libwebrtc C++ code:

$ npm install h264-profile-level-id

API

import {
  // H264 Profile enum
  Profile,
  // H264 Level enum
  Level,
  // Class.
  ProfileLevelId,
  // Functions.
  parseProfileLevelId,
  profileLevelIdToString,
  profileToString,
  levelToString,
  parseSdpProfileLevelId,
  isSameProfile,
  generateProfileLevelIdStringForAnswer
} from 'h264-profile-level-id';
enum Profile
{
  ConstrainedBaseline = 1,
  Baseline = 2,
  Main = 3,
  ConstrainedHigh = 4,
  High = 5,
  PredictiveHigh444 = 6
}
enum Level
{
  L1_b = 0,
  L1 = 10,
  L1_1 = 11,
  L1_2 = 12,
  L1_3 = 13,
  L2 = 20,
  L2_1 = 21,
  L2_2 = 22,
  L3 = 30,
  L3_1 = 31,
  L3_2 = 32,
  L4 = 40,
  L4_1 = 41,
  L4_2 = 42,
  L5 = 50,
  L5_1 = 51,
  L5_2 = 52
}

class ProfileLevelId

Class containing both H264 profile and level.

const profile_level_id = new ProfileLevelId(Profile.Main, Level.L3_1);

console.log('profile:%d, level:%d', profile_level_id.profile, profile_level_id.level);
// => profile:3, level:31

Both profile and level members are public.

function parseProfileLevelId(str: string): ProfileLevelId | undefined

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.

function profileLevelIdToString(profile_level_id: ProfileLevelId): string | undefined

Return canonical string representation as three hex bytes of the profile level id, or returns nothing for invalid profile level ids.

function profileToString(profile: Profile): string | undefined

Return a human friendly name for the given profile.

function levelToString(level: Level): string | undefined

Return a human friendly name for the given level.

function parseSdpProfileLevelId(params: any = {}): ProfileLevelId \ undefined

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.

function isSameProfile(params1: any = {}, params2: any = {}): boolean

Return true if the parameters have the same H264 profile, i.e. the same H264 profile (Baseline, High, etc).

function generateProfileLevelIdForAnswer(local_supported_params: any = {}, remote_offered_params: any = {}): string | undefined

Generate a profile level id that is represented as a string of 3 hex bytes suitable for an answer in an SDP negotiation based on local supported parameters and remote offered parameters. The parameters that are used when negotiating are the level part of profile-level-id and level-asymmetry-allowed.

NOTE: This function is just intended to manage H264 profile levels ids with same profile (otherwise it will throw). Use isSameProfile() API before this one.

Usage examples

See the unit tests.

Author

License

ISC