From 80ad7ffa61844c418b036956509377b92dce46f0 Mon Sep 17 00:00:00 2001 From: Anna Tsukanova Date: Thu, 25 Apr 2024 10:50:00 +0300 Subject: [PATCH] feat: add new removeLineByKey method as a PoC --- src/model/media-description.ts | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/model/media-description.ts b/src/model/media-description.ts index d53b0d7..091bed4 100644 --- a/src/model/media-description.ts +++ b/src/model/media-description.ts @@ -126,4 +126,48 @@ export abstract class MediaDescription implements SdpBlock { // If it didn't match anything else, see if IceInfo wants it. return this.iceInfo.addLine(line); } + + /** + * Remove a line from the media description by key. + * + * @param key - The key of the line to be removed. + * @returns True if a line was removed; false otherwise. + */ + removeLineByKey(key: keyof MediaDescription): boolean { + if (key === 'bandwidth' && this.bandwidth) { + delete this.bandwidth; + return true; + } + if (key === 'mid' && this.mid) { + delete this.mid; + return true; + } + if (key === 'fingerprint' && this.fingerprint) { + delete this.fingerprint; + return true; + } + if (key === 'setup' && this.setup) { + delete this.setup; + return true; + } + if (key === 'connection' && this.connection) { + delete this.connection; + return true; + } + if (key === 'content' && this.content) { + delete this.content; + return true; + } + + // The 'otherLines' key would represent any other line in otherLines. + if (key === 'otherLines') { + // Here we can implement logic to handle removal from otherLines if needed. + + // For now, we can just return false to indicate no action taken. + return false; + } + + // If the key is not found, return false. + return false; + } }