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 | // 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 | |
27 | AC3AudioFileServerMediaSubsession* |
28 | AC3AudioFileServerMediaSubsession::createNew(UsageEnvironment& env, |
29 | char const* fileName, |
30 | Boolean reuseFirstSource) { |
31 | return new AC3AudioFileServerMediaSubsession(env, fileName, reuseFirstSource); |
32 | } |
33 | |
34 | AC3AudioFileServerMediaSubsession |
35 | ::AC3AudioFileServerMediaSubsession(UsageEnvironment& env, |
36 | char const* fileName, Boolean reuseFirstSource) |
37 | : FileServerMediaSubsession(env, fileName, reuseFirstSource) { |
38 | } |
39 | |
40 | AC3AudioFileServerMediaSubsession::~AC3AudioFileServerMediaSubsession() { |
41 | } |
42 | |
43 | FramedSource* 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 | |
53 | RTPSink* 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 | |