00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _OSTREAMBUFFEREDSINK_H_
00021 #define _OSTREAMBUFFEREDSINK_H_
00022
00023 #include <liveMedia.hh>
00024 #include <MediaSink.hh>
00025
00026
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