@@ -28,11 +28,37 @@ pub enum RdpsndServerMessage {
2828 Error ( Box < dyn RdpsndError > ) ,
2929}
3030
31+ /// Handler for the server side of the Audio Output Virtual Channel (`RDPSND`).
32+ ///
33+ /// Implementations supply the list of audio formats the server offers, decide
34+ /// which format to use once the client replies, and produce the audio waves to
35+ /// stream (via [`RdpsndServer::wave`]).
3136pub trait RdpsndServerHandler : Send + core:: fmt:: Debug {
37+ /// The audio formats the server advertises in the Server Audio Formats and
38+ /// Version PDU (MS-RDPEA 2.2.2.1).
3239 fn get_formats ( & self ) -> & [ pdu:: AudioFormat ] ;
3340
41+ /// Called once the client has replied with the formats it accepts
42+ /// (`client_format`, the Client Audio Formats and Version PDU). Returns the
43+ /// `wFormatNo` to stamp on every subsequent Wave/Wave2 PDU, or [`None`] if
44+ /// no offered format is acceptable (no audio is then streamed).
45+ ///
46+ /// **The returned index addresses `client_format.formats` — the formats the
47+ /// client just echoed back — NOT the server's own [`get_formats`] list.**
48+ /// The client resolves each wave's format as `ClientFormats[wFormatNo]`
49+ /// against the list *it* sent, and a compliant client rejects any
50+ /// `wFormatNo >= client_format.formats.len()`, silently dropping all audio.
51+ /// The client's list is its accepted subset of the server's formats, so the
52+ /// two lists generally differ in both length and ordering; an index into
53+ /// [`get_formats`] only happens to work when the chosen format sits at the
54+ /// same position in both. Pick the format you intend to send, then return
55+ /// its position within `client_format.formats`.
56+ ///
57+ /// [`get_formats`]: RdpsndServerHandler::get_formats
3458 fn start ( & mut self , client_format : & ClientAudioFormatPdu ) -> Option < u16 > ;
3559
60+ /// Called when the audio stream is torn down (e.g. the client closed the
61+ /// channel or the session ended).
3662 fn stop ( & mut self ) ;
3763}
3864
0 commit comments