| 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 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 | |
| 27 | MPEG1or2VideoFileServerMediaSubsession* |
| 28 | MPEG1or2VideoFileServerMediaSubsession::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 | |
| 37 | MPEG1or2VideoFileServerMediaSubsession |
| 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 | |
| 47 | MPEG1or2VideoFileServerMediaSubsession |
| 48 | ::~MPEG1or2VideoFileServerMediaSubsession() { |
| 49 | } |
| 50 | |
| 51 | FramedSource* 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 | |
| 64 | RTPSink* MPEG1or2VideoFileServerMediaSubsession |
| 65 | ::createNewRTPSink(Groupsock* rtpGroupsock, |
| 66 | unsigned char /*rtpPayloadTypeIfDynamic*/, |
| 67 | FramedSource* /*inputSource*/) { |
| 68 | return MPEG1or2VideoRTPSink::createNew(envir(), rtpGroupsock); |
| 69 | } |
| 70 | |