OStreamBufferedSink.hh

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) Massimo Cora' 2006 <maxcvs@gmail.com>
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 #ifndef _OSTREAMBUFFEREDSINK_H_
00021 #define _OSTREAMBUFFEREDSINK_H_
00022 
00023 #include <liveMedia.hh>
00024 #include <MediaSink.hh>
00025 
00026 // opencv
00027 #include <cv.h>
00028 #include <highgui.h>
00029 
00030 #include "OStreamConfig.hh"
00031 #include "OStreamVideoDecoder.hh"
00032 
00041 typedef bool (on_packet_video_received_cb)( IplImage* image, int stream_id, const void* client_data );
00042 
00052 typedef bool (on_packet_audio_received_cb)( unsigned char* audio_buf, int audio_buf_size, 
00053                                                                                    int stream_id, const void* client_data );
00054 
00062 class OStreamBufferedSink : public MediaSink
00063 {
00064 public:
00079         static OStreamBufferedSink* createNew( UsageEnvironment& env,
00080                                                 on_packet_video_received_cb* fv, const void *vid_callback_data,
00081                                                 on_packet_audio_received_cb* fa, const void *aud_callback_data,
00082                                                 const char* subsession_codec,                           
00083                                                 int stream_id,
00084                                                 const char* receiving_iface,
00085                                                 unsigned int buffer_size = 200000 );
00086 
00087 protected:
00092         OStreamBufferedSink( UsageEnvironment& env,     
00093                                                 on_packet_video_received_cb* fv, const void *vid_callback_data,
00094                                                 on_packet_audio_received_cb* fa, const void *aud_callback_data,
00095                                                 const char* subsession_codec,
00096                                                 int stream_id,
00097                                                 const char* receiving_iface,
00098                                                 unsigned buffer_size );
00099         virtual ~OStreamBufferedSink();
00100 
00102         static void afterGettingFrame( void* clientData, unsigned frameSize,
00103                                                 unsigned numTruncatedBytes,
00104                                                 struct timeval presentationTime,
00105                                                 unsigned durationInMicroseconds );
00106         
00108         virtual void afterGettingFrame1( unsigned frameSize,
00109                                                 struct timeval presentationTime );
00110         
00112         on_packet_video_received_cb* f_on_packet_video_received_cb;
00113         
00115         on_packet_audio_received_cb* f_on_packet_audio_received_cb;
00116 
00117 private:
00119         bool parse_codec_str ();
00120 
00122         virtual Boolean continuePlaying();
00123 
00124 private:
00126         unsigned char* _packet_buffer;  
00127         
00129         unsigned int _packet_buffer_size;
00130         
00132         char* _subsession_codec_str;
00133         
00135         ostream_decoding_type _subsession_codec_id;
00136         
00138         int _stream_id;
00139 
00144         OStreamVideoDecoder* _video_decoder;
00145         
00147         const void *_callback_video_data_packet_receiver;
00148         
00150         const void *_callback_audio_data_packet_receiver;
00151 };
00152 
00153 
00154 #endif  //_OSTREAMBUFFEREDSINK_H_
00155 

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