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// A 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
19// on demand, from an AC3 audio file.
20// Implementation
21
22#include "AC3AudioFileServerMediaSubsession.hh"
23#include "ByteStreamFileSource.hh"
24#include "AC3AudioStreamFramer.hh"
25#include "AC3AudioRTPSink.hh"
26
27AC3AudioFileServerMediaSubsession*
28AC3AudioFileServerMediaSubsession::createNew(UsageEnvironment& env,
29 char const* fileName,
30 Boolean reuseFirstSource) {
31 return new AC3AudioFileServerMediaSubsession(env, fileName, reuseFirstSource);
32}
33
34AC3AudioFileServerMediaSubsession
35::AC3AudioFileServerMediaSubsession(UsageEnvironment& env,
36 char const* fileName, Boolean reuseFirstSource)
37 : FileServerMediaSubsession(env, fileName, reuseFirstSource) {
38}
39
40AC3AudioFileServerMediaSubsession::~AC3AudioFileServerMediaSubsession() {
41}
42
43FramedSource* AC3AudioFileServerMediaSubsession
44::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) {
45 estBitrate = 48; // kbps, estimate
46
47 ByteStreamFileSource* fileSource = ByteStreamFileSource::createNew(envir(), fFileName);
48 if (fileSource == NULL) return NULL;
49
50 return AC3AudioStreamFramer::createNew(envir(), fileSource);
51}
52
53RTPSink* AC3AudioFileServerMediaSubsession
54::createNewRTPSink(Groupsock* rtpGroupsock,
55 unsigned char rtpPayloadTypeIfDynamic,
56 FramedSource* inputSource) {
57 AC3AudioStreamFramer* audioSource = (AC3AudioStreamFramer*)inputSource;
58 return AC3AudioRTPSink::createNew(envir(), rtpGroupsock,
59 rtpPayloadTypeIfDynamic,
60 audioSource->samplingRate());
61}
62