Skip to content

Commit 19d5688

Browse files
committed
rework on stream thread handling
1 parent f26aa0d commit 19d5688

14 files changed

+467
-465
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ SOFILE = libvdr-$(PLUGIN).so
5757

5858
### Libraries
5959

60-
LIBS = $(shell curl-config --libs) -lssl -lcrypto
60+
LIBS = $(shell curl-config --libs) -lssl -lcrypto -lpthread
6161

6262
### Includes and Defines (add further entries here):
6363

@@ -82,8 +82,8 @@ OBJS = $(PLUGIN).o common.o config.o device.o pidscanner.o \
8282
protocolcurl.o protocolext.o protocolfile.o protocolhttp.o \
8383
protocoludp.o sectionfilter.o setup.o sidscanner.o socket.o \
8484
protocolm3u.o protocolradio.o protocolstream.o \
85-
m3u8handler.o process.o process_unix.o ffmpeghandler.o streambasehandler.o \
86-
vlchandler.o source.o statistics.o streamer.o radioimage.o
85+
m3u8handler.o process.o process_unix.o streambasehandler.o \
86+
source.o statistics.o streamer.o radioimage.o
8787

8888
### The main target:
8989

ffmpeghandler.cpp

-233
This file was deleted.

ffmpeghandler.h

-21
This file was deleted.

protocolm3u.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
#include "protocolm3u.h"
44
#include "common.h"
55
#include "config.h"
6-
#include "ffmpeghandler.h"
7-
#include "vlchandler.h"
6+
#include "streambasehandler.h"
87
#include "log.h"
98

10-
cIptvProtocolM3U::cIptvProtocolM3U() : isActiveM(false), handler(nullptr) {
9+
cIptvProtocolM3U::cIptvProtocolM3U() : isActiveM(false), handler("M3U") {
1110
debug1("%s", __PRETTY_FUNCTION__);
1211
}
1312

@@ -16,14 +15,12 @@ cIptvProtocolM3U::~cIptvProtocolM3U() {
1615

1716
// Drop open handles
1817
cIptvProtocolM3U::Close();
19-
20-
delete handler;
21-
handler = nullptr;
18+
handler.stop();
2219
}
2320

2421
int cIptvProtocolM3U::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) {
2522
// debug16("%s (, %u)", __PRETTY_FUNCTION__, bufferLenP);
26-
return handler->popPackets(bufferAddrP, bufferLenP);
23+
return handler.popPackets(bufferAddrP, bufferLenP);
2724
}
2825

2926
bool cIptvProtocolM3U::Open() {
@@ -69,8 +66,11 @@ bool cIptvProtocolM3U::Open() {
6966
}
7067
}
7168

69+
handler.setChannelId(channelId);
70+
handler.setHandlerType(handlerType);
71+
7272
m3u8Handler.printStream(streams);
73-
handler->streamVideo(streams);
73+
handler.streamVideo(streams);
7474
}
7575

7676
return true;
@@ -80,9 +80,7 @@ bool cIptvProtocolM3U::Close() {
8080
debug1("%s", __PRETTY_FUNCTION__);
8181

8282
isActiveM = false;
83-
if (handler != nullptr) {
84-
handler->stop();
85-
}
83+
handler.stop();
8684

8785
return true;
8886
}
@@ -132,7 +130,9 @@ cIptvProtocolM3U::SetSource(SourceParameter parameter) {
132130
}
133131

134132
channelId = parameter.channelNumber;
133+
handlerType = parameter.handlerType;
135134

135+
/*
136136
if (handler != nullptr) {
137137
handler->stop();
138138
}
@@ -145,7 +145,7 @@ cIptvProtocolM3U::SetSource(SourceParameter parameter) {
145145
} else if (parameter.handlerType == 'V') {
146146
handler = new VlcHandler(channelId);
147147
}
148-
148+
*/
149149
return true;
150150
}
151151

protocolm3u.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class cIptvProtocolM3U : public cIptvProtocolIf {
1414
bool isActiveM;
1515
int useYtdlp;
1616
M3u8Handler m3u8Handler;
17-
StreamBaseHandler* handler;
17+
StreamBaseHandler handler;
18+
char handlerType;
1819

1920
public:
2021
cIptvProtocolM3U();

0 commit comments

Comments
 (0)