SDP in-place line modification library
npm install sdp-linesThis is a simple
SDP library
designed for in-place modification of sdp lines.


SDP parsing in browsers is relatively brittle (and not currently compliant
with the latest SDP RFC: 4566). This
library has been developed as an __interim__ approach for dealing with SDP
generated by a browser.
It follows the following rules:
- The order of SDP lines is never modified (in order = out order)
- SDP lines are not modified unless a specific tweak requires modifying the
line. That is, a line is not parsed and regenerated unless a particular
modification operation requires it.
- Any new lines added to the SDP are added either after existing lines of
the same time (for instance a lines), or if no other lines exist within
the relevant scope, then immediately after the line type specified in the
4566 RFC.
To be completed.
If you are looking for an SDP parser which works with an intermediate JS
object format, then any of the libraries below will do what you need:
- https://github.com/clux/sdp-transform
- https://github.com/legastero/sdp
- https://github.com/buildar/getting_started_with_webrtc
The following standard documents are related to SDP with regards to WebRTC:
-
-
-
The modify method is used to apply a change to the underlying data. When
a line matches the specified regex, the modifier function is invoked with
the following function signature:
``js`
function modifier(line, match, type, payload) {
// return the line to reinject back into the sdp
return line;
}
The arguments to the following are as follows:
- line: the full line that matched the regexmatch
- : the match result from executing the regextype
- : the line type which is specified prior to the = (e.g. a)payload`: the payload of the line (after the = character)
-
In the sample modifier above, we simply return the line unchanged, but
we can reformat the line or replace it entirely.
Convert back to a string representation
Copyright (c) 2013 Damon Oehlman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.