blob: 5a725ea6eda1fcb8add678cbc30e691b189a7fcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* Copyright (c) 2012 Yoann Blein
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <Swiften/ScreenSharing/VP8RTPParser.h>
#include <Swiften/ScreenSharing/VP8Decoder.h>
namespace Swift {
VP8RTPParser::VP8RTPParser(VP8Decoder* decoder)
: decoder(decoder), firstPacket(true)
{
}
void VP8RTPParser::newPayloadReceived(const uint8_t* data, size_t len, bool hasMarker)
{
// Payload descriptor
uint8_t req = data[0];
if (firstPacket && !(req & SBit)) { /* Error */ }
size_t headerSize;
// Payload header
if (firstPacket) {
firstPacket = false;
uint8_t o1 = data[1];
showFrame = (o1 & 1);
isKeyFrame = (o1 & HBit);
o1 >>= Size0BitShift;
frameSize = o1 + 8 * data[2] + 2048 * data[3];
headerSize = 4;
} else {
headerSize = 1;
}
buffer.insert(buffer.end(), data + headerSize, data + len);
if (hasMarker || buffer.size() >= frameSize) {
// Frame received
decoder->decodeFrame(buffer);
buffer.clear();
firstPacket = true;
}
}
}
|