import RTSPClient from "../RTSPClient" ; import { RTPPacket } from "../util" ; import * as transform from "sdp-transform" ; import { Writable } from "stream" ; import { EOL } from "os" ; interface Details { codec : string ; mediaSource : transform . MediaDescription ; rtpChannel : number ; rtcpChannel : number ; } export default class ONVIFMetadataTransport { client : RTSPClient ; stream : Writable ; xml : string ; constructor ( client , stream , details ) { this . client = client ; this . stream = stream ; this . xml = "" ; client . on ( "data" , ( channel , data , packet ) => { if ( channel == details . rtpChannel ) { this . processRTPPacket ( packet ) ; } } ) ; } processRTPPacket ( packet ) { this . xml = this . xml . concat ( packet . payload . toString ( ) ) ; if ( packet . marker == 1 ) { this . stream . write ( this . xml ) ; this . stream . write ( EOL + EOL ) ; this . xml = "" ; } } }