Skip to content

Commit 8479336

Browse files
committed
no change: only code reformat
1 parent ad66272 commit 8479336

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3356
-3036
lines changed

common.cpp

+66-61
Original file line numberDiff line numberDiff line change
@@ -9,83 +9,87 @@
99
#include <vdr/tools.h>
1010
#include "common.h"
1111

12-
uint16_t ts_pid(const uint8_t *bufP)
13-
{
14-
return (uint16_t)(((bufP[1] & 0x1f) << 8) + bufP[2]);
12+
uint16_t ts_pid(const uint8_t *bufP) {
13+
return (uint16_t) (((bufP[1] & 0x1f) << 8) + bufP[2]);
1514
}
1615

17-
uint8_t payload(const uint8_t *bufP)
18-
{
19-
if (!(bufP[3] & 0x10)) // no payload?
20-
return 0;
21-
22-
if (bufP[3] & 0x20) { // adaptation field?
23-
if (bufP[4] > 183) // corrupted data?
16+
uint8_t payload(const uint8_t *bufP) {
17+
if (!(bufP[3] & 0x10)) {// no payload?
2418
return 0;
25-
else
26-
return (uint8_t)((184 - 1) - bufP[4]);
27-
}
19+
}
20+
21+
if (bufP[3] & 0x20) { // adaptation field?
22+
if (bufP[4] > 183) { // corrupted data?
23+
return 0;
24+
} else {
25+
return (uint8_t) ((184 - 1) - bufP[4]);
26+
}
27+
}
2828

29-
return 184;
29+
return 184;
3030
}
3131

32-
const char *id_pid(const u_short pidP)
33-
{
34-
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
35-
if (pidP == section_filter_table[i].pid)
36-
return section_filter_table[i].tag;
37-
}
38-
return "---";
32+
const char *id_pid(const u_short pidP) {
33+
for (int i = 0; i < SECTION_FILTER_TABLE_SIZE; ++i) {
34+
if (pidP==section_filter_table[i].pid) {
35+
return section_filter_table[i].tag;
36+
}
37+
}
38+
return "---";
3939
}
4040

41-
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP)
42-
{
43-
// Wait for data
44-
struct timeval tv;
45-
tv.tv_sec = 0;
46-
tv.tv_usec = usecsP;
47-
// Use select
48-
fd_set infd;
49-
fd_set outfd;
50-
fd_set errfd;
51-
FD_ZERO(&infd);
52-
FD_ZERO(&outfd);
53-
FD_ZERO(&errfd);
54-
FD_SET(descriptorP, &errfd);
55-
if (selectWriteP)
56-
FD_SET(descriptorP, &outfd);
57-
else
58-
FD_SET(descriptorP, &infd);
59-
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
60-
// Check if error
61-
ERROR_IF_RET(retval < 0, "select()", return retval);
62-
return retval;
41+
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP) {
42+
// Wait for data
43+
struct timeval tv;
44+
tv.tv_sec = 0;
45+
tv.tv_usec = usecsP;
46+
// Use select
47+
fd_set infd;
48+
fd_set outfd;
49+
fd_set errfd;
50+
FD_ZERO(&infd);
51+
FD_ZERO(&outfd);
52+
FD_ZERO(&errfd);
53+
FD_SET(descriptorP, &errfd);
54+
55+
if (selectWriteP) {
56+
FD_SET(descriptorP, &outfd);
57+
} else {
58+
FD_SET(descriptorP, &infd);
59+
}
60+
61+
int retval = select(descriptorP + 1, &infd, &outfd, &errfd, &tv);
62+
63+
// Check if error
64+
ERROR_IF_RET(retval < 0, "select()", return retval);
65+
return retval;
6366
}
6467

65-
cString ChangeCase(const cString &strP, bool upperP)
66-
{
67-
cString res(strP);
68-
char *p = (char *)*res;
69-
while (p && *p) {
68+
cString ChangeCase(const cString &strP, bool upperP) {
69+
cString res(strP);
70+
char *p = (char *) *res;
71+
72+
while (p && *p) {
7073
*p = upperP ? toupper(*p) : tolower(*p);
7174
++p;
72-
}
73-
return res;
75+
}
76+
return res;
7477
}
7578

7679
const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE_SIZE] =
77-
{
78-
/* description tag pid tid mask */
79-
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
80-
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
81-
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
82-
{trNOOP("EIT (0x4E/0x4F/0x5X/0x6X)"), "EIT", 0x12, 0x40, 0xC0},
83-
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
84-
};
85-
86-
std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) {
80+
{
81+
/* description tag pid tid mask */
82+
{trNOOP("PAT (0x00)"), "PAT", 0x00, 0x00, 0xFF},
83+
{trNOOP("NIT (0x40)"), "NIT", 0x10, 0x40, 0xFF},
84+
{trNOOP("SDT (0x42)"), "SDT", 0x11, 0x42, 0xFF},
85+
{trNOOP("EIT (0x4E/0x4F/0x5X/0x6X)"), "EIT", 0x12, 0x40, 0xC0},
86+
{trNOOP("TDT (0x70)"), "TDT", 0x14, 0x70, 0xFF},
87+
};
88+
89+
std::string ReplaceAll(std::string str, const std::string &from, const std::string &to) {
8790
size_t start_pos = 0;
88-
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
91+
92+
while ((start_pos = str.find(from, start_pos))!=std::string::npos) {
8993
str.replace(start_pos, from.length(), to);
9094
start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
9195
}
@@ -97,6 +101,7 @@ void printBacktrace() {
97101

98102
cBackTrace::BackTrace(stringList, 0, false);
99103
esyslog("[iptv] Backtrace size: %d", stringList.Size());
104+
100105
for (int i = 0; i < stringList.Size(); ++i) {
101106
esyslog("[iptv] ==> %s", stringList[i]);
102107
}

common.h

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@
55
*
66
*/
77

8-
#ifndef __IPTV_COMMON_H
9-
#define __IPTV_COMMON_H
8+
#pragma once
109

1110
#include <string>
1211
#include <vdr/tools.h>
1312
#include <vdr/config.h>
1413
#include <vdr/i18n.h>
1514

1615
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
17-
1816
#define IPTV_BUFFER_SIZE KILOBYTE(2048)
19-
2017
#define IPTV_DVR_FILENAME "/tmp/vdr-iptv%d.dvr"
21-
2218
#define IPTV_SOURCE_CHARACTER 'I'
2319

2420
#define IPTV_DEVICE_INFO_ALL 0
@@ -27,10 +23,8 @@
2723
#define IPTV_DEVICE_INFO_FILTERS 3
2824
#define IPTV_DEVICE_INFO_PROTOCOL 4
2925
#define IPTV_DEVICE_INFO_BITRATE 5
30-
3126
#define IPTV_STATS_ACTIVE_PIDS_COUNT 10
3227
#define IPTV_STATS_ACTIVE_FILTERS_COUNT 10
33-
3428
#define SECTION_FILTER_TABLE_SIZE 5
3529

3630
#define ERROR_IF_FUNC(exp, errstr, func, ret) \
@@ -45,7 +39,6 @@
4539
} while (0)
4640

4741
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
48-
4942
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );
5043

5144
#define DELETE_POINTER(ptr) \
@@ -64,7 +57,7 @@ uint8_t payload(const uint8_t *bufP);
6457
const char *id_pid(const u_short pidP);
6558
int select_single_desc(int descriptorP, const int usecsP, const bool selectWriteP);
6659
cString ChangeCase(const cString &strP, bool upperP);
67-
std::string ReplaceAll(std::string str, const std::string& from, const std::string& to);
60+
std::string ReplaceAll(std::string str, const std::string &from, const std::string &to);
6861
void printBacktrace();
6962

7063
struct section_filter_table_type {
@@ -79,5 +72,3 @@ extern const section_filter_table_type section_filter_table[SECTION_FILTER_TABLE
7972

8073
extern const char VERSION[];
8174

82-
#endif // __IPTV_COMMON_H
83-

config.cpp

+33-32
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,48 @@
1010

1111
cIptvConfig IptvConfig;
1212

13-
cIptvConfig::cIptvConfig(void)
14-
: traceModeM(eTraceModeNormal),
15-
protocolBasePortM(4321),
16-
useBytesM(1),
17-
sectionFilteringM(1),
18-
threadQueueSize(32),
19-
ytdlpPath("/usr/local/bin/yt-dlp")
20-
{
21-
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i)
22-
disabledFiltersM[i] = -1;
23-
memset(configDirectoryM, 0, sizeof(configDirectoryM));
24-
memset(resourceDirectoryM, 0, sizeof(resourceDirectoryM));
13+
cIptvConfig::cIptvConfig()
14+
: traceModeM(eTraceModeNormal),
15+
protocolBasePortM(4321),
16+
useBytesM(1),
17+
sectionFilteringM(1),
18+
threadQueueSize(32),
19+
ytdlpPath("/usr/local/bin/yt-dlp") {
20+
21+
for (unsigned int i = 0; i < ARRAY_SIZE(disabledFiltersM); ++i) {
22+
disabledFiltersM[i] = -1;
23+
}
24+
25+
memset(configDirectoryM, 0, sizeof(configDirectoryM));
26+
memset(resourceDirectoryM, 0, sizeof(resourceDirectoryM));
2527
}
2628

27-
unsigned int cIptvConfig::GetDisabledFiltersCount(void) const
28-
{
29-
unsigned int n = 0;
30-
while ((n < ARRAY_SIZE(disabledFiltersM) && (disabledFiltersM[n] != -1)))
29+
unsigned int cIptvConfig::GetDisabledFiltersCount() const {
30+
unsigned int n = 0;
31+
32+
while ((n < ARRAY_SIZE(disabledFiltersM) && (disabledFiltersM[n]!=-1))) {
3133
n++;
32-
return n;
34+
}
35+
36+
return n;
3337
}
3438

35-
int cIptvConfig::GetDisabledFilters(unsigned int indexP) const
36-
{
37-
return (indexP < ARRAY_SIZE(disabledFiltersM)) ? disabledFiltersM[indexP] : -1;
39+
int cIptvConfig::GetDisabledFilters(unsigned int indexP) const {
40+
return (indexP < ARRAY_SIZE(disabledFiltersM)) ? disabledFiltersM[indexP] : -1;
3841
}
3942

40-
void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP)
41-
{
42-
if (indexP < ARRAY_SIZE(disabledFiltersM))
43-
disabledFiltersM[indexP] = numberP;
43+
void cIptvConfig::SetDisabledFilters(unsigned int indexP, int numberP) {
44+
if (indexP < ARRAY_SIZE(disabledFiltersM)) {
45+
disabledFiltersM[indexP] = numberP;
46+
}
4447
}
4548

46-
void cIptvConfig::SetConfigDirectory(const char *directoryP)
47-
{
48-
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
49-
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
49+
void cIptvConfig::SetConfigDirectory(const char *directoryP) {
50+
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
51+
ERROR_IF(!realpath(directoryP, configDirectoryM), "Cannot canonicalize configuration directory");
5052
}
5153

52-
void cIptvConfig::SetResourceDirectory(const char *directoryP)
53-
{
54-
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
55-
ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory");
54+
void cIptvConfig::SetResourceDirectory(const char *directoryP) {
55+
debug1("%s (%s)", __PRETTY_FUNCTION__, directoryP);
56+
ERROR_IF(!realpath(directoryP, resourceDirectoryM), "Cannot canonicalize resource directory");
5657
}

0 commit comments

Comments
 (0)