@tomgiee/tsdp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/src/builder/media-builder.d.ts +221 -0
- package/dist/src/builder/media-builder.d.ts.map +1 -0
- package/dist/src/builder/media-builder.js +385 -0
- package/dist/src/builder/session-builder.d.ts +195 -0
- package/dist/src/builder/session-builder.d.ts.map +1 -0
- package/dist/src/builder/session-builder.js +366 -0
- package/dist/src/index.d.ts +67 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +250 -0
- package/dist/src/parser/attribute-parser.d.ts +100 -0
- package/dist/src/parser/attribute-parser.d.ts.map +1 -0
- package/dist/src/parser/attribute-parser.js +217 -0
- package/dist/src/parser/field-parser.d.ts +124 -0
- package/dist/src/parser/field-parser.d.ts.map +1 -0
- package/dist/src/parser/field-parser.js +335 -0
- package/dist/src/parser/media-parser.d.ts +45 -0
- package/dist/src/parser/media-parser.d.ts.map +1 -0
- package/dist/src/parser/media-parser.js +157 -0
- package/dist/src/parser/primitive-parser.d.ts +138 -0
- package/dist/src/parser/primitive-parser.d.ts.map +1 -0
- package/dist/src/parser/primitive-parser.js +316 -0
- package/dist/src/parser/scanner.d.ts +142 -0
- package/dist/src/parser/scanner.d.ts.map +1 -0
- package/dist/src/parser/scanner.js +284 -0
- package/dist/src/parser/session-parser.d.ts +35 -0
- package/dist/src/parser/session-parser.d.ts.map +1 -0
- package/dist/src/parser/session-parser.js +207 -0
- package/dist/src/parser/time-parser.d.ts +74 -0
- package/dist/src/parser/time-parser.d.ts.map +1 -0
- package/dist/src/parser/time-parser.js +168 -0
- package/dist/src/serializer/attribute-serializer.d.ts +18 -0
- package/dist/src/serializer/attribute-serializer.d.ts.map +1 -0
- package/dist/src/serializer/attribute-serializer.js +34 -0
- package/dist/src/serializer/field-serializer.d.ts +112 -0
- package/dist/src/serializer/field-serializer.d.ts.map +1 -0
- package/dist/src/serializer/field-serializer.js +212 -0
- package/dist/src/serializer/media-serializer.d.ts +31 -0
- package/dist/src/serializer/media-serializer.d.ts.map +1 -0
- package/dist/src/serializer/media-serializer.js +83 -0
- package/dist/src/serializer/session-serializer.d.ts +29 -0
- package/dist/src/serializer/session-serializer.d.ts.map +1 -0
- package/dist/src/serializer/session-serializer.js +99 -0
- package/dist/src/serializer/time-serializer.d.ts +46 -0
- package/dist/src/serializer/time-serializer.d.ts.map +1 -0
- package/dist/src/serializer/time-serializer.js +86 -0
- package/dist/src/types/attributes.d.ts +318 -0
- package/dist/src/types/attributes.d.ts.map +1 -0
- package/dist/src/types/attributes.js +225 -0
- package/dist/src/types/errors.d.ts +129 -0
- package/dist/src/types/errors.d.ts.map +1 -0
- package/dist/src/types/errors.js +186 -0
- package/dist/src/types/fields.d.ts +100 -0
- package/dist/src/types/fields.d.ts.map +1 -0
- package/dist/src/types/fields.js +48 -0
- package/dist/src/types/media.d.ts +148 -0
- package/dist/src/types/media.d.ts.map +1 -0
- package/dist/src/types/media.js +137 -0
- package/dist/src/types/network.d.ts +136 -0
- package/dist/src/types/network.d.ts.map +1 -0
- package/dist/src/types/network.js +130 -0
- package/dist/src/types/primitives.d.ts +193 -0
- package/dist/src/types/primitives.d.ts.map +1 -0
- package/dist/src/types/primitives.js +195 -0
- package/dist/src/types/session.d.ts +122 -0
- package/dist/src/types/session.d.ts.map +1 -0
- package/dist/src/types/session.js +81 -0
- package/dist/src/types/time.d.ts +129 -0
- package/dist/src/types/time.d.ts.map +1 -0
- package/dist/src/types/time.js +84 -0
- package/dist/src/utils/address-parser.d.ts +100 -0
- package/dist/src/utils/address-parser.d.ts.map +1 -0
- package/dist/src/utils/address-parser.js +338 -0
- package/dist/src/utils/format-validators.d.ts +77 -0
- package/dist/src/utils/format-validators.d.ts.map +1 -0
- package/dist/src/utils/format-validators.js +504 -0
- package/dist/src/utils/line-reader.d.ts +84 -0
- package/dist/src/utils/line-reader.d.ts.map +1 -0
- package/dist/src/utils/line-reader.js +169 -0
- package/dist/src/utils/time-converter.d.ts +99 -0
- package/dist/src/utils/time-converter.d.ts.map +1 -0
- package/dist/src/utils/time-converter.js +195 -0
- package/dist/src/validator/media-validator.d.ts +27 -0
- package/dist/src/validator/media-validator.d.ts.map +1 -0
- package/dist/src/validator/media-validator.js +241 -0
- package/dist/src/validator/semantic-validator.d.ts +47 -0
- package/dist/src/validator/semantic-validator.d.ts.map +1 -0
- package/dist/src/validator/semantic-validator.js +207 -0
- package/dist/src/validator/session-validator.d.ts +36 -0
- package/dist/src/validator/session-validator.d.ts.map +1 -0
- package/dist/src/validator/session-validator.js +280 -0
- package/dist/tests/integration/round-trip.test.d.ts +5 -0
- package/dist/tests/integration/round-trip.test.d.ts.map +1 -0
- package/dist/tests/integration/round-trip.test.js +320 -0
- package/dist/tests/integration/voip-examples.test.d.ts +5 -0
- package/dist/tests/integration/voip-examples.test.d.ts.map +1 -0
- package/dist/tests/integration/voip-examples.test.js +361 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/media-builder.test.js +524 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/session-builder.test.js +367 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/attribute-parser.test.js +319 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/field-parser.test.js +355 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/media-parser.test.js +241 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/primitive-parser.test.js +261 -0
- package/dist/tests/unit/parser/scanner.test.d.ts +5 -0
- package/dist/tests/unit/parser/scanner.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/scanner.test.js +241 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/session-parser.test.js +346 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/time-parser.test.js +173 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.js +78 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/field-serializer.test.js +159 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/media-serializer.test.js +155 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/session-serializer.test.js +317 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/time-serializer.test.js +115 -0
- package/dist/tests/unit/types/errors.test.d.ts +5 -0
- package/dist/tests/unit/types/errors.test.d.ts.map +1 -0
- package/dist/tests/unit/types/errors.test.js +127 -0
- package/dist/tests/unit/types/network.test.d.ts +5 -0
- package/dist/tests/unit/types/network.test.d.ts.map +1 -0
- package/dist/tests/unit/types/network.test.js +132 -0
- package/dist/tests/unit/types/primitives.test.d.ts +5 -0
- package/dist/tests/unit/types/primitives.test.d.ts.map +1 -0
- package/dist/tests/unit/types/primitives.test.js +108 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts +5 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/address-parser.test.js +203 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts +5 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/format-validators.test.js +224 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts +5 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/line-reader.test.js +157 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts +5 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/time-converter.test.js +190 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/media-validator.test.js +313 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/semantic-validator.test.js +262 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/session-validator.test.js +447 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thomas Giesler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# TSDP - TypeScript SDP Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/tsdp)
|
|
4
|
+
[](https://github.com/tomgie/tsdp/actions/workflows/ci.yml)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
> **Note:** This project was developed with assistance from [Claude](https://claude.ai).
|
|
8
|
+
|
|
9
|
+
A complete, RFC 8866-compliant SDP (Session Description Protocol) library for TypeScript/JavaScript applications.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Full RFC 8866 compliance
|
|
14
|
+
- Type-safe with branded types
|
|
15
|
+
- Fluent builder APIs
|
|
16
|
+
- Comprehensive validation
|
|
17
|
+
- Parse and serialize SDP
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install tsdp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Parsing SDP
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { parseSessionDescription, validateSdp } from 'tsdp';
|
|
31
|
+
|
|
32
|
+
const sdpString = `v=0
|
|
33
|
+
o=alice 2890844526 2890842807 IN IP4 192.168.1.1
|
|
34
|
+
s=Call
|
|
35
|
+
c=IN IP4 192.168.1.100
|
|
36
|
+
t=0 0
|
|
37
|
+
m=audio 49170 RTP/AVP 0 8
|
|
38
|
+
a=rtpmap:0 PCMU/8000
|
|
39
|
+
a=rtpmap:8 PCMA/8000
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const session = parseSessionDescription(sdpString);
|
|
43
|
+
const result = validateSdp(session);
|
|
44
|
+
|
|
45
|
+
if (!result.valid) {
|
|
46
|
+
console.error(result.errors);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Building SDP
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { SessionBuilder, serializeSessionDescription } from 'tsdp';
|
|
54
|
+
|
|
55
|
+
const session = new SessionBuilder()
|
|
56
|
+
.origin('alice', '123456789', '123456789', '192.168.1.1')
|
|
57
|
+
.sessionName('Phone Call')
|
|
58
|
+
.connection('192.168.1.100')
|
|
59
|
+
.addMediaBuilder((b) =>
|
|
60
|
+
b
|
|
61
|
+
.type('audio')
|
|
62
|
+
.port(49170)
|
|
63
|
+
.protocol('RTP/AVP')
|
|
64
|
+
.formats(['0', '8'])
|
|
65
|
+
.rtpmap(0, 'PCMU', 8000)
|
|
66
|
+
.rtpmap(8, 'PCMA', 8000)
|
|
67
|
+
.ptime(20)
|
|
68
|
+
.sendrecv()
|
|
69
|
+
)
|
|
70
|
+
.build();
|
|
71
|
+
|
|
72
|
+
const sdpString = serializeSessionDescription(session);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Validation Options
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { validateSdp } from 'tsdp';
|
|
79
|
+
|
|
80
|
+
const result = validateSdp(session, {
|
|
81
|
+
allowDeprecatedKeyField: true,
|
|
82
|
+
requireSessionConnection: false,
|
|
83
|
+
skipSemanticValidation: false,
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### Core Functions
|
|
90
|
+
|
|
91
|
+
- `parseSessionDescription(input: string)` - Parse SDP string to session object
|
|
92
|
+
- `serializeSessionDescription(session)` - Serialize session object to SDP string
|
|
93
|
+
- `validateSdp(session, options?)` - Validate session with optional configuration
|
|
94
|
+
|
|
95
|
+
### Builders
|
|
96
|
+
|
|
97
|
+
- `SessionBuilder` - Fluent builder for session descriptions
|
|
98
|
+
- `MediaBuilder` - Fluent builder for media descriptions
|
|
99
|
+
- `audioBuilder()` - Pre-configured audio media builder
|
|
100
|
+
- `videoBuilder()` - Pre-configured video media builder
|
|
101
|
+
|
|
102
|
+
### Types
|
|
103
|
+
|
|
104
|
+
- `SessionDescription` - Complete SDP session
|
|
105
|
+
- `MediaDescription` - Media stream description
|
|
106
|
+
- `Attribute` - SDP attribute (property or value)
|
|
107
|
+
- `ValidationResult` - Validation result with errors
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Install dependencies
|
|
113
|
+
pnpm install
|
|
114
|
+
|
|
115
|
+
# Run tests
|
|
116
|
+
pnpm test
|
|
117
|
+
|
|
118
|
+
# Build
|
|
119
|
+
pnpm build
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media builder for SDP (RFC 8866)
|
|
3
|
+
*
|
|
4
|
+
* Provides a fluent builder API for creating SDP media descriptions.
|
|
5
|
+
*/
|
|
6
|
+
import { MediaDescription } from '../types/media';
|
|
7
|
+
import { Attribute } from '../types/attributes';
|
|
8
|
+
/**
|
|
9
|
+
* Fluent builder for creating SDP media descriptions
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const media = new MediaBuilder()
|
|
14
|
+
* .type('audio')
|
|
15
|
+
* .port(49170)
|
|
16
|
+
* .protocol('RTP/AVP')
|
|
17
|
+
* .formats(['0', '8'])
|
|
18
|
+
* .rtpmap(0, 'PCMU', 8000)
|
|
19
|
+
* .rtpmap(8, 'PCMA', 8000)
|
|
20
|
+
* .build();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class MediaBuilder {
|
|
24
|
+
private _type?;
|
|
25
|
+
private _port?;
|
|
26
|
+
private _protocol?;
|
|
27
|
+
private _formats;
|
|
28
|
+
private _information?;
|
|
29
|
+
private _connections;
|
|
30
|
+
private _bandwidths;
|
|
31
|
+
private _key?;
|
|
32
|
+
private _attributes;
|
|
33
|
+
/**
|
|
34
|
+
* Set the media type
|
|
35
|
+
*
|
|
36
|
+
* @param type - Media type ('audio', 'video', 'text', 'application', 'message', 'image')
|
|
37
|
+
*/
|
|
38
|
+
type(type: 'audio' | 'video' | 'text' | 'application' | 'message' | 'image' | string): this;
|
|
39
|
+
/**
|
|
40
|
+
* Set the port
|
|
41
|
+
*
|
|
42
|
+
* @param port - Port number (0-65535)
|
|
43
|
+
*/
|
|
44
|
+
port(port: number): this;
|
|
45
|
+
/**
|
|
46
|
+
* Set the port range
|
|
47
|
+
*
|
|
48
|
+
* @param base - Base port number
|
|
49
|
+
* @param count - Number of ports
|
|
50
|
+
*/
|
|
51
|
+
portRange(base: number, count: number): this;
|
|
52
|
+
/**
|
|
53
|
+
* Disable this media stream (set port to 0)
|
|
54
|
+
*/
|
|
55
|
+
disabled(): this;
|
|
56
|
+
/**
|
|
57
|
+
* Set the transport protocol
|
|
58
|
+
*
|
|
59
|
+
* @param proto - Protocol (e.g., 'RTP/AVP', 'RTP/SAVP', 'RTP/SAVPF', 'udp', 'TCP/RTP/AVP')
|
|
60
|
+
*/
|
|
61
|
+
protocol(proto: string): this;
|
|
62
|
+
/**
|
|
63
|
+
* Set the formats (payload types for RTP)
|
|
64
|
+
*
|
|
65
|
+
* @param formats - Array of format strings
|
|
66
|
+
*/
|
|
67
|
+
formats(formats: string[]): this;
|
|
68
|
+
/**
|
|
69
|
+
* Add a single format
|
|
70
|
+
*/
|
|
71
|
+
addFormat(format: string): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set the media information/title
|
|
74
|
+
*/
|
|
75
|
+
information(info: string): this;
|
|
76
|
+
/**
|
|
77
|
+
* Add a connection
|
|
78
|
+
*
|
|
79
|
+
* @param address - Connection address (IPv4, IPv6, or FQDN)
|
|
80
|
+
* @param addrType - Address type, auto-detected if not provided
|
|
81
|
+
*/
|
|
82
|
+
connection(address: string, addrType?: 'IP4' | 'IP6'): this;
|
|
83
|
+
/**
|
|
84
|
+
* Add a connection with multicast TTL
|
|
85
|
+
*/
|
|
86
|
+
connectionMulticast(address: string, ttl: number, addrType?: 'IP4' | 'IP6'): this;
|
|
87
|
+
/**
|
|
88
|
+
* Add bandwidth information
|
|
89
|
+
*
|
|
90
|
+
* @param type - Bandwidth type ('CT' or 'AS')
|
|
91
|
+
* @param kbps - Bandwidth in kilobits per second
|
|
92
|
+
*/
|
|
93
|
+
addBandwidth(type: 'CT' | 'AS' | string, kbps: number): this;
|
|
94
|
+
/**
|
|
95
|
+
* Set AS (Application Specific) bandwidth
|
|
96
|
+
*/
|
|
97
|
+
bandwidth(kbps: number): this;
|
|
98
|
+
/**
|
|
99
|
+
* Set encryption key (OBSOLETE per RFC 8866)
|
|
100
|
+
*
|
|
101
|
+
* @param keyValue - The key value (e.g., "clear:password" or "base64:encoded")
|
|
102
|
+
*/
|
|
103
|
+
key(keyValue: string): this;
|
|
104
|
+
/**
|
|
105
|
+
* Add an attribute
|
|
106
|
+
*/
|
|
107
|
+
addAttribute(attr: Attribute): this;
|
|
108
|
+
/**
|
|
109
|
+
* Add a custom property attribute
|
|
110
|
+
*/
|
|
111
|
+
addPropertyAttribute(name: string): this;
|
|
112
|
+
/**
|
|
113
|
+
* Add a custom value attribute
|
|
114
|
+
*/
|
|
115
|
+
addValueAttribute(name: string, value: string): this;
|
|
116
|
+
/**
|
|
117
|
+
* Set direction to sendrecv
|
|
118
|
+
*/
|
|
119
|
+
sendrecv(): this;
|
|
120
|
+
/**
|
|
121
|
+
* Set direction to recvonly
|
|
122
|
+
*/
|
|
123
|
+
recvonly(): this;
|
|
124
|
+
/**
|
|
125
|
+
* Set direction to sendonly
|
|
126
|
+
*/
|
|
127
|
+
sendonly(): this;
|
|
128
|
+
/**
|
|
129
|
+
* Set direction to inactive
|
|
130
|
+
*/
|
|
131
|
+
inactive(): this;
|
|
132
|
+
/**
|
|
133
|
+
* Add an rtpmap attribute
|
|
134
|
+
*
|
|
135
|
+
* @param payloadType - RTP payload type (0-127)
|
|
136
|
+
* @param encodingName - Encoding name (e.g., 'PCMU', 'H264')
|
|
137
|
+
* @param clockRate - Clock rate (e.g., 8000, 90000)
|
|
138
|
+
* @param encodingParams - Optional encoding parameters (e.g., 2 for stereo)
|
|
139
|
+
*/
|
|
140
|
+
rtpmap(payloadType: number, encodingName: string, clockRate: number, encodingParams?: number): this;
|
|
141
|
+
/**
|
|
142
|
+
* Add an fmtp attribute
|
|
143
|
+
*
|
|
144
|
+
* @param format - Format/payload type
|
|
145
|
+
* @param parameters - Format-specific parameters
|
|
146
|
+
*/
|
|
147
|
+
fmtp(format: string | number, parameters: string): this;
|
|
148
|
+
/**
|
|
149
|
+
* Set the ptime attribute
|
|
150
|
+
*
|
|
151
|
+
* @param milliseconds - Packet time in milliseconds
|
|
152
|
+
*/
|
|
153
|
+
ptime(milliseconds: number): this;
|
|
154
|
+
/**
|
|
155
|
+
* Set the maxptime attribute
|
|
156
|
+
*
|
|
157
|
+
* @param milliseconds - Maximum packet time in milliseconds
|
|
158
|
+
*/
|
|
159
|
+
maxptime(milliseconds: number): this;
|
|
160
|
+
/**
|
|
161
|
+
* Set the framerate attribute (for video)
|
|
162
|
+
*/
|
|
163
|
+
framerate(fps: number): this;
|
|
164
|
+
/**
|
|
165
|
+
* Set the quality attribute (for video, 0-10)
|
|
166
|
+
*/
|
|
167
|
+
quality(q: number): this;
|
|
168
|
+
/**
|
|
169
|
+
* Add mid attribute (media identification)
|
|
170
|
+
*/
|
|
171
|
+
mid(id: string): this;
|
|
172
|
+
/**
|
|
173
|
+
* Add ice-ufrag attribute
|
|
174
|
+
*/
|
|
175
|
+
iceUfrag(ufrag: string): this;
|
|
176
|
+
/**
|
|
177
|
+
* Add ice-pwd attribute
|
|
178
|
+
*/
|
|
179
|
+
icePwd(pwd: string): this;
|
|
180
|
+
/**
|
|
181
|
+
* Add fingerprint attribute
|
|
182
|
+
*/
|
|
183
|
+
fingerprint(hashFunc: string, fingerprint: string): this;
|
|
184
|
+
/**
|
|
185
|
+
* Add setup attribute
|
|
186
|
+
*/
|
|
187
|
+
setup(role: 'active' | 'passive' | 'actpass' | 'holdconn'): this;
|
|
188
|
+
/**
|
|
189
|
+
* Add RTCP attribute
|
|
190
|
+
*/
|
|
191
|
+
rtcp(port: number, address?: string): this;
|
|
192
|
+
/**
|
|
193
|
+
* Add rtcp-mux attribute
|
|
194
|
+
*/
|
|
195
|
+
rtcpMux(): this;
|
|
196
|
+
/**
|
|
197
|
+
* Add rtcp-rsize attribute
|
|
198
|
+
*/
|
|
199
|
+
rtcpRsize(): this;
|
|
200
|
+
/**
|
|
201
|
+
* Build the media description
|
|
202
|
+
*
|
|
203
|
+
* @throws BuilderError if required fields are missing
|
|
204
|
+
*/
|
|
205
|
+
build(): MediaDescription;
|
|
206
|
+
private detectAddressType;
|
|
207
|
+
private parseAddress;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a new media builder
|
|
211
|
+
*/
|
|
212
|
+
export declare function mediaBuilder(): MediaBuilder;
|
|
213
|
+
/**
|
|
214
|
+
* Create an audio media builder pre-configured for audio
|
|
215
|
+
*/
|
|
216
|
+
export declare function audioBuilder(): MediaBuilder;
|
|
217
|
+
/**
|
|
218
|
+
* Create a video media builder pre-configured for video
|
|
219
|
+
*/
|
|
220
|
+
export declare function videoBuilder(): MediaBuilder;
|
|
221
|
+
//# sourceMappingURL=media-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-builder.d.ts","sourceRoot":"","sources":["../../../src/builder/media-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAkD,MAAM,gBAAgB,CAAC;AAElG,OAAO,EACL,SAAS,EAUV,MAAM,qBAAqB,CAAC;AAiB7B;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAC,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAC,CAAO;IACrB,OAAO,CAAC,SAAS,CAAC,CAAW;IAC7B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAM;IACnB,OAAO,CAAC,WAAW,CAAmB;IAEtC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAK3F;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5C;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GA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