MCPcopy Create free account
hub / github.com/RetroShare/RetroShare / receiveEncodedData

Method receiveEncodedData

plugins/VOIP/gui/VideoProcessor.cpp:235–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void VideoProcessor::receiveEncodedData(const RsVOIPDataChunk& chunk)
236{
237 static const int HEADER_SIZE = 4 ;
238
239 // read frame type. Use first 4 bytes to give info about content.
240 //
241 // Byte Meaning Values
242 // 00 Codec CODEC_ID_JPEG_VIDEO Basic Jpeg codec
243 // CODEC_ID_DDWT_VIDEO Differential wavelet compression
244 //
245 // 01 Unused Might be useful later
246 //
247 // 0203 Flags Codec specific flags.
248 //
249
250 if(chunk.size < HEADER_SIZE)
251 {
252 std::cerr << "JPEGVideoDecoder::decodeData(): Too small a data packet. size=" << chunk.size << std::endl;
253 return ;
254 }
255
256 uint32_t codid = ((unsigned char *)chunk.data)[0] + (((unsigned char *)chunk.data)[1] << 8) ;
257 //uint16_t flags = ((unsigned char *)chunk.data)[2] + (((unsigned char *)chunk.data)[3] << 8) ;
258
259 VideoCodec *codec ;
260
261 switch(codid)
262 {
263 case VIDEO_PROCESSOR_CODEC_ID_JPEG_VIDEO: codec = &_jpeg_video_codec ;
264 break ;
265 case VIDEO_PROCESSOR_CODEC_ID_MPEG_VIDEO: codec = &_mpeg_video_codec ;
266 break ;
267 default:
268 codec = NULL ;
269 }
270
271 if(codec == NULL)
272 {
273 std::cerr << "Unknown decoding codec: " << codid << std::endl;
274 return ;
275 }
276
277 {
278 RS_STACK_MUTEX(vpMtx) ;
279 _total_encoded_size_in += chunk.size ;
280
281 time_t now = time(NULL) ;
282
283 if(now > _last_bw_estimate_in_TS)
284 {
285 _estimated_bandwidth_in = uint32_t(0.75*_estimated_bandwidth_in + 0.25 * (_total_encoded_size_in / (float)(now - _last_bw_estimate_in_TS))) ;
286
287 _total_encoded_size_in = 0 ;
288 _last_bw_estimate_in_TS = now ;
289
290#ifdef DEBUG_VIDEO_OUTPUT_DEVICE
291 std::cerr << "new bw estimate (in): " << _estimated_bandwidth_in << std::endl;
292#endif

Callers 2

on_Tick_timeoutMethod · 0.80
addVideoDataMethod · 0.80

Calls 2

decodeDataMethod · 0.80
showFrameMethod · 0.80

Tested by

no test coverage detected