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 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
27MP3AudioMatroskaFileServerMediaSubsession* MP3AudioMatroskaFileServerMediaSubsession
28::createNew(MatroskaFileServerDemux& demux, MatroskaTrack* track,
29 Boolean generateADUs, Interleaving* interleaving) {
30 return new MP3AudioMatroskaFileServerMediaSubsession(demux, track, generateADUs, interleaving);
31}
32
33MP3AudioMatroskaFileServerMediaSubsession
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
41MP3AudioMatroskaFileServerMediaSubsession::~MP3AudioMatroskaFileServerMediaSubsession() {
42}
43
44void 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
54FramedSource* MP3AudioMatroskaFileServerMediaSubsession
55::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate) {
56 FramedSource* baseMP3Source = fOurDemux.newDemuxedTrack(clientSessionId, fTrackNumber);
57 return createNewStreamSourceCommon(baseMP3Source, 0, estBitrate);
58}
59