Skip to content

Commit 00d3a23

Browse files
smokhovxlz
authored andcommitted
docs: Primarily add proper copyright headers and minor editorializing.
1 parent a2debee commit 00d3a23

File tree

9 files changed

+207
-52
lines changed

9 files changed

+207
-52
lines changed

tools/streamer_recorder/PracticalSocket.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* C++ sockets on Unix and Windows
3-
* Copyright (C) 2002
3+
* Copyright (C) 2002 Michael J. Donahoo and Kenneth L. Calvert
4+
* http://cs.ecs.baylor.edu/%7Edonahoo/practical/CSockets/practical/
5+
* Modified code forked from https://github.com/chenxiaoqino/udp-image-streaming
46
*
57
* This program is free software; you can redistribute it and/or modify
68
* it under the terms of the GNU General Public License as published by
@@ -60,14 +62,14 @@ const char *SocketException::what() const throw() {
6062
}
6163

6264
// Function to fill in address structure given an address and port
63-
static void fillAddr(const string &address, unsigned short port,
65+
static void fillAddr(const string &address, unsigned short port,
6466
sockaddr_in &addr) {
6567
memset(&addr, 0, sizeof(addr)); // Zero out address structure
6668
addr.sin_family = AF_INET; // Internet address
6769

6870
hostent *host; // Resolve name
6971
if ((host = gethostbyname(address.c_str())) == NULL) {
70-
// strerror() will not work for gethostbyname() and hstrerror()
72+
// strerror() will not work for gethostbyname() and hstrerror()
7173
// is supposedly obsolete
7274
throw SocketException("Failed to resolve name (gethostbyname())");
7375
}
@@ -169,13 +171,13 @@ unsigned short Socket::resolveService(const string &service,
169171

170172
if ((serv = getservbyname(service.c_str(), protocol.c_str())) == NULL)
171173
return atoi(service.c_str()); /* Service is port number */
172-
else
174+
else
173175
return ntohs(serv->s_port); /* Found port (network byte order) by name */
174176
}
175177

176178
// CommunicatingSocket Code
177179

178-
CommunicatingSocket::CommunicatingSocket(int type, int protocol)
180+
CommunicatingSocket::CommunicatingSocket(int type, int protocol)
179181
throw(SocketException) : Socket(type, protocol) {
180182
}
181183

@@ -194,14 +196,14 @@ void CommunicatingSocket::connect(const string &foreignAddress,
194196
}
195197
}
196198

197-
void CommunicatingSocket::send(const void *buffer, int bufferLen)
199+
void CommunicatingSocket::send(const void *buffer, int bufferLen)
198200
throw(SocketException) {
199201
if (::send(sockDesc, (raw_type *) buffer, bufferLen, 0) < 0) {
200202
throw SocketException("Send failed (send())", true);
201203
}
202204
}
203205

204-
int CommunicatingSocket::recv(void *buffer, int bufferLen)
206+
int CommunicatingSocket::recv(void *buffer, int bufferLen)
205207
throw(SocketException) {
206208
int rtn;
207209
if ((rtn = ::recv(sockDesc, (raw_type *) buffer, bufferLen, 0)) < 0) {
@@ -211,7 +213,7 @@ int CommunicatingSocket::recv(void *buffer, int bufferLen)
211213
return rtn;
212214
}
213215

214-
string CommunicatingSocket::getForeignAddress()
216+
string CommunicatingSocket::getForeignAddress()
215217
throw(SocketException) {
216218
sockaddr_in addr;
217219
unsigned int addr_len = sizeof(addr);
@@ -234,8 +236,8 @@ unsigned short CommunicatingSocket::getForeignPort() throw(SocketException) {
234236

235237
// TCPSocket Code
236238

237-
TCPSocket::TCPSocket()
238-
throw(SocketException) : CommunicatingSocket(SOCK_STREAM,
239+
TCPSocket::TCPSocket()
240+
throw(SocketException) : CommunicatingSocket(SOCK_STREAM,
239241
IPPROTO_TCP) {
240242
}
241243

@@ -249,14 +251,14 @@ TCPSocket::TCPSocket(int newConnSD) : CommunicatingSocket(newConnSD) {
249251

250252
// TCPServerSocket Code
251253

252-
TCPServerSocket::TCPServerSocket(unsigned short localPort, int queueLen)
254+
TCPServerSocket::TCPServerSocket(unsigned short localPort, int queueLen)
253255
throw(SocketException) : Socket(SOCK_STREAM, IPPROTO_TCP) {
254256
setLocalPort(localPort);
255257
setListen(queueLen);
256258
}
257259

258-
TCPServerSocket::TCPServerSocket(const string &localAddress,
259-
unsigned short localPort, int queueLen)
260+
TCPServerSocket::TCPServerSocket(const string &localAddress,
261+
unsigned short localPort, int queueLen)
260262
throw(SocketException) : Socket(SOCK_STREAM, IPPROTO_TCP) {
261263
setLocalAddressAndPort(localAddress, localPort);
262264
setListen(queueLen);
@@ -284,23 +286,23 @@ UDPSocket::UDPSocket() throw(SocketException) : CommunicatingSocket(SOCK_DGRAM,
284286
setBroadcast();
285287
}
286288

287-
UDPSocket::UDPSocket(unsigned short localPort) throw(SocketException) :
289+
UDPSocket::UDPSocket(unsigned short localPort) throw(SocketException) :
288290
CommunicatingSocket(SOCK_DGRAM, IPPROTO_UDP) {
289291
setLocalPort(localPort);
290292
setBroadcast();
291293
}
292294

293-
UDPSocket::UDPSocket(const string &localAddress, unsigned short localPort)
295+
UDPSocket::UDPSocket(const string &localAddress, unsigned short localPort)
294296
throw(SocketException) : CommunicatingSocket(SOCK_DGRAM, IPPROTO_UDP) {
295297
setLocalAddressAndPort(localAddress, localPort);
296298
setBroadcast();
297299
}
298300

299301
void UDPSocket::setBroadcast() {
300-
// If this fails, we'll hear about it when we try to send. This will allow
302+
// If this fails, we'll hear about it when we try to send. This will allow
301303
// system that cannot broadcast to continue if they don't plan to broadcast
302304
int broadcastPermission = 1;
303-
setsockopt(sockDesc, SOL_SOCKET, SO_BROADCAST,
305+
setsockopt(sockDesc, SOL_SOCKET, SO_BROADCAST,
304306
(raw_type *) &broadcastPermission, sizeof(broadcastPermission));
305307
}
306308

@@ -321,8 +323,8 @@ void UDPSocket::disconnect() throw(SocketException) {
321323
}
322324
}
323325

324-
void UDPSocket::sendTo(const void *buffer, int bufferLen,
325-
const string &foreignAddress, unsigned short foreignPort)
326+
void UDPSocket::sendTo(const void *buffer, int bufferLen,
327+
const string &foreignAddress, unsigned short foreignPort)
326328
throw(SocketException) {
327329
sockaddr_in destAddr;
328330
fillAddr(foreignAddress, foreignPort, destAddr);
@@ -339,7 +341,7 @@ int UDPSocket::recvFrom(void *buffer, int bufferLen, string &sourceAddress,
339341
sockaddr_in clntAddr;
340342
socklen_t addrLen = sizeof(clntAddr);
341343
int rtn;
342-
if ((rtn = recvfrom(sockDesc, (raw_type *) buffer, bufferLen, 0,
344+
if ((rtn = recvfrom(sockDesc, (raw_type *) buffer, bufferLen, 0,
343345
(sockaddr *) &clntAddr, (socklen_t *) &addrLen)) < 0) {
344346
throw SocketException("Receive failed (recvfrom())", true);
345347
}
@@ -350,7 +352,7 @@ int UDPSocket::recvFrom(void *buffer, int bufferLen, string &sourceAddress,
350352
}
351353

352354
void UDPSocket::setMulticastTTL(unsigned char multicastTTL) throw(SocketException) {
353-
if (setsockopt(sockDesc, IPPROTO_IP, IP_MULTICAST_TTL,
355+
if (setsockopt(sockDesc, IPPROTO_IP, IP_MULTICAST_TTL,
354356
(raw_type *) &multicastTTL, sizeof(multicastTTL)) < 0) {
355357
throw SocketException("Multicast TTL set failed (setsockopt())", true);
356358
}
@@ -361,8 +363,8 @@ void UDPSocket::joinGroup(const string &multicastGroup) throw(SocketException) {
361363

362364
multicastRequest.imr_multiaddr.s_addr = inet_addr(multicastGroup.c_str());
363365
multicastRequest.imr_interface.s_addr = htonl(INADDR_ANY);
364-
if (setsockopt(sockDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP,
365-
(raw_type *) &multicastRequest,
366+
if (setsockopt(sockDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP,
367+
(raw_type *) &multicastRequest,
366368
sizeof(multicastRequest)) < 0) {
367369
throw SocketException("Multicast group join failed (setsockopt())", true);
368370
}
@@ -373,8 +375,8 @@ void UDPSocket::leaveGroup(const string &multicastGroup) throw(SocketException)
373375

374376
multicastRequest.imr_multiaddr.s_addr = inet_addr(multicastGroup.c_str());
375377
multicastRequest.imr_interface.s_addr = htonl(INADDR_ANY);
376-
if (setsockopt(sockDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP,
377-
(raw_type *) &multicastRequest,
378+
if (setsockopt(sockDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP,
379+
(raw_type *) &multicastRequest,
378380
sizeof(multicastRequest)) < 0) {
379381
throw SocketException("Multicast group leave failed (setsockopt())", true);
380382
}

tools/streamer_recorder/ProtonectSR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of the OpenKinect Project. http://www.openkinect.org
33
*
4-
* Copyright (c) 2011 individual OpenKinect contributors. See the CONTRIB file
4+
* Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
55
* for details.
66
*
77
* This code is licensed to you under the terms of the Apache License, version

tools/streamer_recorder/blender_viewer/scripts/main.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
#
2+
# This file is part of the OpenKinect Project. http://www.openkinect.org
3+
#
4+
# Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
5+
# for details.
6+
#
7+
# This code is licensed to you under the terms of the Apache License, version
8+
# 2.0, or, at your option, the terms of the GNU General Public License,
9+
# version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
# or the following URLs:
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
# http://www.gnu.org/licenses/gpl-2.0.txt
13+
#
14+
# If you redistribute this file in source form, modified or unmodified, you
15+
# may:
16+
# 1) Leave this header intact and distribute it under the same terms,
17+
# accompanying it with the APACHE20 and GPL20 files, or
18+
# 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
# 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
# In all cases you must keep the copyright notice intact and include a copy
21+
# of the CONTRIB file.
22+
#
23+
# Binary distributions must follow the binary distribution requirements of
24+
# either License.
25+
#
26+
127
from bge import (
228
logic,
329
texture,
@@ -6,7 +32,7 @@
632
import socket
733
import bgl
834

9-
# # add cv2 lib (requires numpy higher version than current in blender)
35+
# add cv2 lib (requires numpy higher version than current in blender)
1036
import sys
1137
sys.path.append('/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages')
1238
import numpy
@@ -94,11 +120,9 @@ def run(controller):
94120
logic.texture.source = source
95121
logic.texture.refresh(False)
96122

97-
98123
except socket.timeout:
99124
pass
100125

101-
102126
def end(controller):
103127
"""
104128
called when ending BGE (e.g. to properly close network connections)

tools/streamer_recorder/include/PracticalSocket.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
* C++ sockets on Unix and Windows
3-
* Copyright (C) 2002
3+
* Copyright (C) 2002 Michael J. Donahoo and Kenneth L. Calvert
4+
* http://cs.ecs.baylor.edu/%7Edonahoo/practical/CSockets/practical/
5+
* Code forked from https://github.com/chenxiaoqino/udp-image-streaming
46
*
57
* This program is free software; you can redistribute it and/or modify
68
* it under the terms of the GNU General Public License as published by

tools/streamer_recorder/include/config.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* This file is part of the OpenKinect Project. http://www.openkinect.org
3+
*
4+
* Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
5+
* for details.
6+
*
7+
* This code is licensed to you under the terms of the Apache License, version
8+
* 2.0, or, at your option, the terms of the GNU General Public License,
9+
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
* or the following URLs:
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.gnu.org/licenses/gpl-2.0.txt
13+
*
14+
* If you redistribute this file in source form, modified or unmodified, you
15+
* may:
16+
* 1) Leave this header intact and distribute it under the same terms,
17+
* accompanying it with the APACHE20 and GPL20 files, or
18+
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
* In all cases you must keep the copyright notice intact and include a copy
21+
* of the CONTRIB file.
22+
*
23+
* Binary distributions must follow the binary distribution requirements of
24+
* either License.
25+
*/
26+
127
#define FRAME_HEIGHT 720
228
#define FRAME_WIDTH 1280
329
#define FRAME_INTERVAL (1000/30)

tools/streamer_recorder/include/recorder.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* This file is part of the OpenKinect Project. http://www.openkinect.org
3+
*
4+
* Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
5+
* for details.
6+
*
7+
* This code is licensed to you under the terms of the Apache License, version
8+
* 2.0, or, at your option, the terms of the GNU General Public License,
9+
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
* or the following URLs:
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.gnu.org/licenses/gpl-2.0.txt
13+
*
14+
* If you redistribute this file in source form, modified or unmodified, you
15+
* may:
16+
* 1) Leave this header intact and distribute it under the same terms,
17+
* accompanying it with the APACHE20 and GPL20 files, or
18+
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
* In all cases you must keep the copyright notice intact and include a copy
21+
* of the CONTRIB file.
22+
*
23+
* Binary distributions must follow the binary distribution requirements of
24+
* either License.
25+
*/
26+
127
#ifndef RECORDER_H
228
#define RECORDER_H
329

tools/streamer_recorder/include/streamer.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
/*
2+
* This file is part of the OpenKinect Project. http://www.openkinect.org
3+
*
4+
* Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
5+
* for details.
6+
*
7+
* This code is licensed to you under the terms of the Apache License, version
8+
* 2.0, or, at your option, the terms of the GNU General Public License,
9+
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
* or the following URLs:
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.gnu.org/licenses/gpl-2.0.txt
13+
*
14+
* If you redistribute this file in source form, modified or unmodified, you
15+
* may:
16+
* 1) Leave this header intact and distribute it under the same terms,
17+
* accompanying it with the APACHE20 and GPL20 files, or
18+
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
* In all cases you must keep the copyright notice intact and include a copy
21+
* of the CONTRIB file.
22+
*
23+
* Binary distributions must follow the binary distribution requirements of
24+
* either License.
25+
*/
26+
127
#ifndef STREAMER_H
228
#define STREAMER_H
329

@@ -17,8 +43,8 @@ class Streamer
1743
private:
1844
// frame related parameters
1945
int jpegqual; // Compression Parameter
20-
vector < int > compression_params;
21-
vector < uchar > encoded;
46+
vector<int> compression_params;
47+
vector<unsigned char> encoded;
2248
int total_pack;
2349
int ibuf[1];
2450

tools/streamer_recorder/recorder.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1+
/*
2+
* This file is part of the OpenKinect Project. http://www.openkinect.org
3+
*
4+
* Copyright (c) 2017 individual OpenKinect contributors. See the CONTRIB file
5+
* for details.
6+
*
7+
* This code is licensed to you under the terms of the Apache License, version
8+
* 2.0, or, at your option, the terms of the GNU General Public License,
9+
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
* or the following URLs:
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.gnu.org/licenses/gpl-2.0.txt
13+
*
14+
* If you redistribute this file in source form, modified or unmodified, you
15+
* may:
16+
* 1) Leave this header intact and distribute it under the same terms,
17+
* accompanying it with the APACHE20 and GPL20 files, or
18+
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
* In all cases you must keep the copyright notice intact and include a copy
21+
* of the CONTRIB file.
22+
*
23+
* Binary distributions must follow the binary distribution requirements of
24+
* either License.
25+
*/
26+
127
#include "recorder.h"
228
#include <cstdlib>
329
#include <iomanip>
430

5-
631
Recorder::Recorder() : timeStamps(MAX_FRAME_ID)
732
{
833
}
@@ -31,7 +56,7 @@ void Recorder::registTimeStamp()
3156
timeStamps[frameID] = Recorder::getMilliSpan(t_start);
3257
// printf("Elapsed time = %u ms \n", timeStamps[frameID]);
3358

34-
frameID ++;
59+
frameID++;
3560
}
3661

3762
void Recorder::initialize()

0 commit comments

Comments
 (0)