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 a MPEG-1 or 2 Elementary Stream video file.
20// Implementation
21
22#include "MPEG1or2VideoFileServerMediaSubsession.hh"
23#include "MPEG1or2VideoRTPSink.hh"
24#include "ByteStreamFileSource.hh"
25#include "MPEG1or2VideoStreamFramer.hh"
26
27MPEG1or2VideoFileServerMediaSubsession*
28MPEG1or2VideoFileServerMediaSubsession::createNew(UsageEnvironment& env,
29 char const* fileName,
30 Boolean reuseFirstSource,
31 Boolean iFramesOnly,
32 double vshPeriod) {
33 return new MPEG1or2VideoFileServerMediaSubsession(env, fileName, reuseFirstSource,
34 iFramesOnly, vshPeriod);
35}
36
37MPEG1or2VideoFileServerMediaSubsession
38::MPEG1or2VideoFileServerMediaSubsession(UsageEnvironment& env,
39 char const* fileName,
40 Boolean reuseFirstSource,
41 Boolean iFramesOnly,
42 double vshPeriod)
43 : FileServerMediaSubsession(env, fileName, reuseFirstSource),
44 fIFramesOnly(iFramesOnly), fVSHPeriod(vshPeriod) {
45}
46
47MPEG1or2VideoFileServerMediaSubsession
48::~MPEG1or2VideoFileServerMediaSubsession() {
49}
50
51FramedSource* MPEG1or2VideoFileServerMediaSubsession
52::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) {
53 estBitrate = 500; // kbps, estimate
54
55 ByteStreamFileSource* fileSource
56 = ByteStreamFileSource::createNew(envir(), fFileName);
57 if (fileSource == NULL) return NULL;
58 fFileSize = fileSource->fileSize();
59
60 return MPEG1or2VideoStreamFramer
61 ::createNew(envir(), fileSource, fIFramesOnly, fVSHPeriod);
62}
63
64RTPSink* MPEG1or2VideoFileServerMediaSubsession
65::createNewRTPSink(Groupsock* rtpGroupsock,
66 unsigned char /*rtpPayloadTypeIfDynamic*/,
67 FramedSource* /*inputSource*/) {
68 return MPEG1or2VideoRTPSink::createNew(envir(), rtpGroupsock);
69}
70