OStreamOnDemandSMS.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) Massimo Cora' 2006 <maxcvs@email.it>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 
00020 #include "OStreamOnDemandSMS.hh"
00021 
00022 
00023 
00024 OStreamOnDemandSMS::OStreamOnDemandSMS( UsageEnvironment& env, bool reuseFirstSource, 
00025                                                                            BaseInputVideo *input_video,
00026                                                                            int encoding_type,
00027                                                                            int audio_port,
00028                                                                            int stream_id ) 
00029                                    : OnDemandServerMediaSubsession( env, reuseFirstSource ),
00030                                         _encoding_type( encoding_type ),
00031                                         _input_video( input_video ),
00032                                         _stream_id( stream_id ),
00033                                         _audio_port( audio_port )
00034 {
00035         
00036 }
00037 
00038 OStreamOnDemandSMS *
00039 OStreamOnDemandSMS::createNew( UsageEnvironment& env, bool reuseFirstSource, BaseInputVideo *input_video,
00040                                                            int audio_port, int encoding_type, int stream_id /* = 0 */ ) 
00041 {
00042         return new OStreamOnDemandSMS( env, reuseFirstSource, input_video, audio_port, encoding_type, stream_id );
00043 }
00044 
00045 OStreamOnDemandSMS::~OStreamOnDemandSMS()
00046 {
00047         DEBUG_PRINT ("deletion!!!!!! OStreamOnDemandSMS::~OStreamOnDemandSMS()");
00048         // WARNING !
00049         // _rtp_sink_inst and _video_source_inst will be responsible of their destroying
00050 }
00051 
00052 FramedSource* OStreamOnDemandSMS::createNewStreamSource( unsigned /*clientSessionId*/,
00053                                                                                                                                          unsigned& estBitrate ) 
00054 {
00055         FramedSource *framed_source;
00056         estBitrate = 64; // kbps, estimate
00057 
00058         
00059         
00060         switch ( _encoding_type ) {
00061                 case OSTREAM_ENCODING_MJPEG:
00062                         framed_source = MJPEGVideoSource::createNew( envir(), _input_video, _stream_id );
00063                         break;
00064                 
00065                 case OSTREAM_ENCODING_H263P:
00066                         framed_source = H263plusVideoSource::createNew( envir(), _input_video, _stream_id );
00067                         break;
00068                 
00069                 case OSTREAM_ENCODING_MP3:
00070                         {
00071 //                              FramedSource *as_mp3 = MP3FileSource::createNew( envir(), "/mnt/win/tmp/test.mp3");
00072 //                              FramedSource *as_mp3 = MP3FileSource::createNew( envir(), "e:\\tmp\\test.mp3");
00073 
00074                                 // grab from microphone
00075                                 FramedSource *as_pcm = AudioInputDevice::createNew( envir(), _audio_port, 16, 2, 44100, 20);
00076                                 FramedSource *as_mp3 = MP3FromPCM::createNew( envir(), as_pcm );
00077 #ifdef STREAM_USING_MP3_ADU
00078                                 FramedSource *as_adu = ADUFromMP3Source::createNew( envir(), as_mp3 );
00079                                 framed_source = as_adu;
00080 #else
00081                                 framed_source = as_mp3;
00082 #endif
00083                         }
00084                         break;
00085 
00086                 default:
00087                         framed_source = NULL;
00088                         break;
00089         }
00090         
00091         return framed_source;
00092 }
00093   
00094 
00095 //--------------------------------------------------------------------------
00096 //
00097 
00098 RTPSink* OStreamOnDemandSMS::createNewRTPSink(Groupsock* rtpGroupsock,
00099                                     unsigned char rtpPayloadTypeIfDynamic,
00100                                         FramedSource* inputSource) 
00101 {
00102         RTPSink* rtp_sink;
00103         // ugly but we need rtpGroupsock, which we cannot have outsite OStreamOnDemandSMS
00104         switch ( _encoding_type ) {
00105                 case OSTREAM_ENCODING_MJPEG:
00106                         DEBUG_PRINT("case OSTREAM_ENCODING_MJPEG:\n");
00107                         rtp_sink = JPEGVideoRTPSink::createNew( envir(), rtpGroupsock );
00108                         break;
00109                 
00110                 case OSTREAM_ENCODING_H263P:
00111                         DEBUG_PRINT("case OSTREAM_ENCODING_H263P:\n");
00112                         rtp_sink = H263plusVideoRTPSink::createNew( envir(), rtpGroupsock, 96 );
00113                         break;
00114 
00115                 case OSTREAM_ENCODING_MP3:
00116                         DEBUG_PRINT("case OSTREAM_ENCODING_MP3\n");
00117 #ifdef STREAM_USING_MP3_ADU
00118                         rtp_sink = MP3ADURTPSink::createNew( envir(), rtpGroupsock, 97 );
00119 #else
00120                         rtp_sink = MPEG1or2AudioRTPSink::createNew( envir(), rtpGroupsock );
00121 #endif
00122                         break;
00123 
00124                 default:
00125                         rtp_sink = NULL;
00126                         break;
00127         }
00128         
00129         return rtp_sink;
00130 }
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 

Generated on Tue Dec 26 10:32:38 2006 for Omnimeeting by  doxygen 1.4.7