| 1 | /********** | 
|---|
| 2 | This library is free software; you can redistribute it and/or modify it under | 
|---|
| 3 | the terms of the GNU Lesser General Public License as published by the | 
|---|
| 4 | Free Software Foundation; either version 3 of the License, or (at your | 
|---|
| 5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) | 
|---|
| 6 |  | 
|---|
| 7 | This library is distributed in the hope that it will be useful, but WITHOUT | 
|---|
| 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 
|---|
| 9 | FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for | 
|---|
| 10 | more details. | 
|---|
| 11 |  | 
|---|
| 12 | You should have received a copy of the GNU Lesser General Public License | 
|---|
| 13 | along with this library; if not, write to the Free Software Foundation, Inc., | 
|---|
| 14 | 51 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 |  | 
|---|
| 28 | class VorbisAudioRTPSink: public AudioRTPSink { | 
|---|
| 29 | public: | 
|---|
| 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* , unsigned , | 
|---|
| 35 | u_int8_t* , unsigned , | 
|---|
| 36 | u_int8_t* , unsigned , | 
|---|
| 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 |  | 
|---|
| 46 | protected: | 
|---|
| 47 | VorbisAudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs, | 
|---|
| 48 | u_int8_t rtpPayloadFormat, u_int32_t rtpTimestampFrequency, unsigned numChannels, | 
|---|
| 49 | u_int8_t* , unsigned , | 
|---|
| 50 | u_int8_t* , unsigned , | 
|---|
| 51 | u_int8_t* , unsigned , | 
|---|
| 52 | u_int32_t identField); | 
|---|
| 53 | // called only by createNew() | 
|---|
| 54 |  | 
|---|
| 55 | virtual ~VorbisAudioRTPSink(); | 
|---|
| 56 |  | 
|---|
| 57 | private: // 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 () const; | 
|---|
| 68 | virtual unsigned () const; | 
|---|
| 69 |  | 
|---|
| 70 | private: | 
|---|
| 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 |  | 
|---|
| 80 | char* generateVorbisOrTheoraConfigStr(u_int8_t* , unsigned , | 
|---|
| 81 | u_int8_t* , unsigned , | 
|---|
| 82 | u_int8_t* , unsigned , | 
|---|
| 83 | u_int32_t identField); | 
|---|
| 84 |  | 
|---|
| 85 | #endif | 
|---|
| 86 |  | 
|---|