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 MP3 audio track within a Matroska file. |
20 | // (Actually, MPEG-1 or MPEG-2 audio file should also work.) |
21 | // Implementation |
22 | |
23 | #include "FileServerMediaSubsession.hh" |
24 | #include "MP3AudioMatroskaFileServerMediaSubsession.hh" |
25 | #include "MatroskaDemuxedTrack.hh" |
26 | |
27 | MP3AudioMatroskaFileServerMediaSubsession* MP3AudioMatroskaFileServerMediaSubsession |
28 | ::createNew(MatroskaFileServerDemux& demux, MatroskaTrack* track, |
29 | Boolean generateADUs, Interleaving* interleaving) { |
30 | return new MP3AudioMatroskaFileServerMediaSubsession(demux, track, generateADUs, interleaving); |
31 | } |
32 | |
33 | MP3AudioMatroskaFileServerMediaSubsession |
34 | ::MP3AudioMatroskaFileServerMediaSubsession(MatroskaFileServerDemux& demux, MatroskaTrack* track, |
35 | Boolean generateADUs, Interleaving* interleaving) |
36 | : MP3AudioFileServerMediaSubsession(demux.envir(), demux.fileName(), False, generateADUs, interleaving), |
37 | fOurDemux(demux), fTrackNumber(track->trackNumber) { |
38 | fFileDuration = fOurDemux.fileDuration(); |
39 | } |
40 | |
41 | MP3AudioMatroskaFileServerMediaSubsession::~MP3AudioMatroskaFileServerMediaSubsession() { |
42 | } |
43 | |
44 | void MP3AudioMatroskaFileServerMediaSubsession |
45 | ::seekStreamSource(FramedSource* inputSource, double& seekNPT, double /*streamDuration*/, u_int64_t& /*numBytes*/) { |
46 | FramedSource* sourceMP3Stream; |
47 | ADUFromMP3Source* aduStream; |
48 | getBaseStreams(inputSource, sourceMP3Stream, aduStream); |
49 | |
50 | if (aduStream != NULL) aduStream->resetInput(); // because we're about to seek within its source |
51 | ((MatroskaDemuxedTrack*)sourceMP3Stream)->seekToTime(seekNPT); |
52 | } |
53 | |
54 | FramedSource* MP3AudioMatroskaFileServerMediaSubsession |
55 | ::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate) { |
56 | FramedSource* baseMP3Source = fOurDemux.newDemuxedTrack(clientSessionId, fTrackNumber); |
57 | return createNewStreamSourceCommon(baseMP3Source, 0, estBitrate); |
58 | } |
59 | |