@@ -556,6 +556,72 @@ class RTSPFormatADPCM : public RTSPFormatAudioTools {
556556 }
557557};
558558
559+ /* *
560+ * @brief MP3 format for RTSP
561+ * https://en.wikipedia.org/wiki/RTP_payload_formats
562+ * @ingroup rtsp
563+ * @author Phil Schatzmann
564+ */
565+ class RTSPFormatMP3 : public RTSPFormatAudioTools {
566+ public:
567+ // Provides the MP3 format information:
568+ // m=audio 0 RTP/AVP 14
569+ // a=rtpmap:14 MPEG/44100
570+ // See RFC 3551 for details
571+ const char *format (char *buffer, int len) override {
572+ TRACEI ();
573+ int payload_type = 14 ; // RTP/AVP 14 = MPEG audio (MP3)
574+ int sr = cfg.sample_rate ;
575+ snprintf (buffer, len,
576+ " s=%s\r\n "
577+ " c=IN IP4 0.0.0.0\r\n "
578+ " t=0 0\r\n "
579+ " m=audio 0 RTP/AVP %d\r\n "
580+ " a=rtpmap:%d MPEG/%d\r\n " ,
581+ name (), payload_type, payload_type, sr);
582+ return (const char *)buffer;
583+ }
584+ AudioInfo defaultConfig () {
585+ AudioInfo cfg (44100 , 2 , 16 ); // Typical MP3 config
586+ return cfg;
587+ }
588+ };
589+
590+ /* *
591+ * @brief AAC format for RTSP
592+ * https://en.wikipedia.org/wiki/RTP_payload_formats
593+ * See RFC 3640 for details
594+ * @ingroup rtsp
595+ * @author Phil Schatzmann
596+ */
597+ class RTSPFormatAAC : public RTSPFormatAudioTools {
598+ public:
599+ // Provides the AAC format information:
600+ // m=audio 0 RTP/AVP 96
601+ // a=rtpmap:96 MPEG4-GENERIC/44100/2
602+ // a=fmtp:96 streamtype=5; profile-level-id=1; mode=AAC-hbr; ...
603+ // For simplicity, only basic SDP lines are provided here
604+ const char *format (char *buffer, int len) override {
605+ TRACEI ();
606+ int payload_type = 96 ; // Dynamic payload type for AAC
607+ int sr = cfg.sample_rate ;
608+ int ch = cfg.channels ;
609+ snprintf (buffer, len,
610+ " s=%s\r\n "
611+ " c=IN IP4 0.0.0.0\r\n "
612+ " t=0 0\r\n "
613+ " m=audio 0 RTP/AVP %d\r\n "
614+ " a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n "
615+ " a=fmtp:%d streamtype=5; profile-level-id=1; mode=AAC-hbr;\r\n " ,
616+ name (), payload_type, payload_type, sr, ch, payload_type);
617+ return (const char *)buffer;
618+ }
619+ AudioInfo defaultConfig () {
620+ AudioInfo cfg (44100 , 2 , 16 ); // Typical AAC config
621+ return cfg;
622+ }
623+ };
624+
559625/* *
560626 * @brief We can write PCM data to the RTSPOutput. This is encoded by the
561627 * indicated encoder (e.g. SBCEncoder) and can be consumed by a RTSPServer.
0 commit comments