1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved.
18// RTP sink for Vorbis audio
19// C++ header
20
21#ifndef _VORBIS_AUDIO_RTP_SINK_HH
22#define _VORBIS_AUDIO_RTP_SINK_HH
23
24#ifndef _AUDIO_RTP_SINK_HH
25#include "AudioRTPSink.hh"
26#endif
27
28class VorbisAudioRTPSink: public AudioRTPSink {
29public:
30 static VorbisAudioRTPSink*
31 createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat,
32 u_int32_t rtpTimestampFrequency, unsigned numChannels,
33 // The following headers provide the 'configuration' information, for the SDP description:
34 u_int8_t* identificationHeader, unsigned identificationHeaderSize,
35 u_int8_t* commentHeader, unsigned commentHeaderSize,
36 u_int8_t* setupHeader, unsigned setupHeaderSize,
37 u_int32_t identField = 0xFACADE);
38
39 static VorbisAudioRTPSink*
40 createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat,
41 u_int32_t rtpTimestampFrequency, unsigned numChannels,
42 char const* configStr);
43 // an optional variant of "createNew()" that takes a Base-64-encoded 'configuration' string,
44 // rather than the raw configuration headers as parameter.
45
46protected:
47 VorbisAudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
48 u_int8_t rtpPayloadFormat, u_int32_t rtpTimestampFrequency, unsigned numChannels,
49 u_int8_t* identificationHeader, unsigned identificationHeaderSize,
50 u_int8_t* commentHeader, unsigned commentHeaderSize,
51 u_int8_t* setupHeader, unsigned setupHeaderSize,
52 u_int32_t identField);
53 // called only by createNew()
54
55 virtual ~VorbisAudioRTPSink();
56
57private: // redefined virtual functions:
58 virtual char const* auxSDPLine(); // for the "a=fmtp:" SDP line
59
60 virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
61 unsigned char* frameStart,
62 unsigned numBytesInFrame,
63 struct timeval framePresentationTime,
64 unsigned numRemainingBytes);
65 virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
66 unsigned numBytesInFrame) const;
67 virtual unsigned specialHeaderSize() const;
68 virtual unsigned frameSpecificHeaderSize() const;
69
70private:
71 u_int32_t fIdent; // "Ident" field used by this stream. (Only the low 24 bits of this are used.)
72 char* fFmtpSDPLine;
73};
74
75
76// A general function used by both "VorbisAudioRTPSink" and "TheoraVideoRTPSink" to construct
77// a Base64-encoded 'config' string (for SDP) from "identification", "comment", "setup" headers.
78// (Note: The result string was heap-allocated, and the caller should delete[] it afterwards.)
79
80char* generateVorbisOrTheoraConfigStr(u_int8_t* identificationHeader, unsigned identificationHeaderSize,
81 u_int8_t* commentHeader, unsigned commentHeaderSize,
82 u_int8_t* setupHeader, unsigned setupHeaderSize,
83 u_int32_t identField);
84
85#endif
86