| 1 |
/* |
| 2 |
* SRT - Secure, Reliable, Transport |
| 3 |
* Copyright (c) 2018 Haivision Systems Inc. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <iostream> |
| 12 |
#include <string> |
| 13 |
#include <iomanip> |
| 14 |
|
| 15 |
#include <udt.h> |
| 16 |
#include <utilities.h> |
| 17 |
#include <packet.h> |
| 18 |
#include <crypto.h> |
| 19 |
#include <common.h> |
| 20 |
|
| 21 |
using namespace srt; |
| 22 |
|
| 23 |
void ShowDistance(int32_t s1, int32_t s2) |
| 24 |
{ |
| 25 |
using namespace std; |
| 26 |
|
| 27 |
cout << "s1=" << s1 << "s2=" << s2 << " DISTANCE:\n"; |
| 28 |
cout << "seqcmp -> " << CSeqNo::seqcmp(s1, s2) << endl; |
| 29 |
cout << "seqoff -> " << CSeqNo::seqoff(s2, s1) << endl; |
| 30 |
} |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
using namespace std; |
| 35 |
|
| 36 |
cout << "PacketBoundary: " << hex << MSGNO_PACKET_BOUNDARY::mask << endl; |
| 37 |
|
| 38 |
cout << "PB_FIRST: " << hex << PacketBoundaryBits(PB_FIRST) << endl; |
| 39 |
cout << "PB_LAST: " << hex << PacketBoundaryBits(PB_LAST) << endl; |
| 40 |
cout << "PB_SOLO: " << hex << PacketBoundaryBits(PB_SOLO) << endl; |
| 41 |
|
| 42 |
cout << "inorder: " << hex << MSGNO_PACKET_INORDER::mask << " (1 << " << dec << MSGNO_PACKET_INORDER::offset << ")" << endl; |
| 43 |
cout << "msgno-seq mask: " << hex << MSGNO_SEQ::mask << endl; |
| 44 |
cout << "3 wrapped into enckeyspec: " << hex << setw(8) << setfill('0') << MSGNO_ENCKEYSPEC::wrap(3) << " - mask: " << MSGNO_ENCKEYSPEC::mask << endl; |
| 45 |
|
| 46 |
cout << "SrtVersion test: 2.3.8 == 0x020308 -- SrtVersion(2, 3, 8) == 0x" << hex << setw(8) << setfill('0') << SrtVersion(2, 3, 8) << endl; |
| 47 |
|
| 48 |
cout << "SEQNO_CONTROL::mask: " << hex << SEQNO_CONTROL::mask << " SEQNO 0x80050000 has control = " << SEQNO_CONTROL::unwrap(0x80050000) |
| 49 |
<< " type = " << SEQNO_MSGTYPE::unwrap(0x80050000) << endl; |
| 50 |
|
| 51 |
cout << "Creating array of bytes: 10, 11, 20, 25 - FormatBinaryString: "; |
| 52 |
uint8_t array[4] = { 10, 11, 20, 25 }; |
| 53 |
cout << FormatBinaryString(array, 4) << endl; |
| 54 |
|
| 55 |
cout << "-------------------------------\n"; |
| 56 |
cout << "SEQUENCES:\n"; |
| 57 |
int32_t s1 = 100, s2 = 200; |
| 58 |
ShowDistance(s1, s2); |
| 59 |
|
| 60 |
cout << "GO BACK BY -150:\n"; |
| 61 |
s1 = CSeqNo::decseq(s1, 150); |
| 62 |
s2 = CSeqNo::decseq(s2, 150); |
| 63 |
ShowDistance(s1, s2); |
| 64 |
|
| 65 |
return 0; |
| 66 |
} |