Skip to content

Commit c4077ca

Browse files
committed
Fix/Change: proper fix for 'fe' query attribute now follows numbering in WebIF #158
1 parent a9e2547 commit c4077ca

28 files changed

+105
-84
lines changed

src/Defs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ class FeID : public TypeID {
7070
FeID(int id=-1) : TypeID(id) {}
7171
};
7272

73+
class FeIndex : public TypeID {
74+
public:
75+
FeIndex(int index=-1) : TypeID(index) {}
76+
};
77+
7378
class StreamID : public TypeID {
7479
public:
7580
StreamID(int id=-1) : TypeID(id) {}

src/HeaderVector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include <Defs.h>
2424

25+
#include <string_view>
26+
2527
class HeaderVector {
2628
// =========================================================================
2729
// -- Constructors and destructor ------------------------------------------

src/HttpcServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ void HttpcServer::processStreamingRequest(SocketClient &client) {
159159
const std::string sessionID = headers.getFieldParameter("Session");
160160
const StreamID streamID = params.getIntParameter("stream");
161161
// Find the FeID with requesed StreamID
162-
const FeID feID = _streamManager.findFrontendIDWithStreamID(streamID);
162+
const auto [feIndex, feID] = _streamManager.findFrontendIDWithStreamID(streamID);
163163

164164
const std::string method = client.getMethod();
165165
std::string httpcReply;
166166
if (sessionID.empty() && method == "OPTIONS") {
167167
methodOptions("", cseq, httpcReply);
168168
} else if (sessionID.empty() && method == "DESCRIBE") {
169-
methodDescribe("", cseq, feID, httpcReply);
169+
methodDescribe("", cseq, feIndex, httpcReply);
170170
} else {
171171
int clientID;
172172
SpStream stream = _streamManager.findStreamAndClientIDFor(client, clientID);
@@ -201,7 +201,7 @@ void HttpcServer::processStreamingRequest(SocketClient &client) {
201201
} else if (method == "OPTIONS") {
202202
methodOptions(sessionID, cseq, httpcReply);
203203
} else if (method == "DESCRIBE") {
204-
methodDescribe(sessionID, cseq, feID, httpcReply);
204+
methodDescribe(sessionID, cseq, feIndex, httpcReply);
205205
} else {
206206
// method not supported
207207
SI_LOG_ERROR("@#1: Method not allowed: @#2", method, client.getRawMessage());

src/HttpcServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class HttpcServer :
107107
virtual void methodOptions(const std::string &UNUSED(sessionID), int UNUSED(cseq), std::string &UNUSED(htmlBody)) {}
108108

109109
/// RTSP Method
110-
virtual void methodDescribe(const std::string &UNUSED(sessionID), int UNUSED(cseq), FeID UNUSED(id), std::string &UNUSED(htmlBody)) {}
110+
virtual void methodDescribe(const std::string &UNUSED(sessionID), int UNUSED(cseq), FeIndex UNUSED(index), std::string &UNUSED(htmlBody)) {}
111111

112112
/// Process the data received from @c SocketClient
113113
virtual bool process(SocketClient &client) final;

src/RtspServer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void RtspServer::methodOptions(
169169
}
170170

171171
void RtspServer::methodDescribe(
172-
const std::string &sessionID, const int cseq, const FeID id, std::string &htmlBody) {
172+
const std::string &sessionID, const int cseq, const FeIndex feIndex, std::string &htmlBody) {
173173
static const char *RTSP_DESCRIBE =
174174
"@#1" \
175175
"CSeq: @#2\r\n" \
@@ -196,20 +196,20 @@ void RtspServer::methodDescribe(
196196
std::size_t streamsSetup = 0;
197197

198198
// Lambda Expression 'setupDescribeMediaLevelString'
199-
const auto setupDescribeMediaLevelString = [&](const FeID id) {
200-
const std::string mediaLevel = _streamManager.getDescribeMediaLevelString(id);
199+
const auto setupDescribeMediaLevelString = [&](const FeIndex feIndex) {
200+
const std::string mediaLevel = _streamManager.getDescribeMediaLevelString(feIndex);
201201
if (mediaLevel.size() > 5) {
202202
++streamsSetup;
203203
desc += mediaLevel;
204204
}
205205
};
206-
// Check if there is a specific Frontend ID requested
207-
if (id == -1) {
206+
// Check if there is a specific Frontend ID index requested
207+
if (feIndex == -1) {
208208
for (std::size_t i = 0; i < _streamManager.getMaxStreams(); ++i) {
209209
setupDescribeMediaLevelString(i);
210210
}
211211
} else {
212-
setupDescribeMediaLevelString(id);
212+
setupDescribeMediaLevelString(feIndex);
213213
}
214214

215215
// check if we are in session, then we need to send the Session ID

src/RtspServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class RtspServer :
6666
virtual void methodOptions(const std::string &sessionID, int cseq, std::string &htmlBody) final;
6767

6868
///
69-
virtual void methodDescribe(const std::string &sessionID, int cseq, FeID id, std::string &htmlBody) final;
69+
virtual void methodDescribe(const std::string &sessionID, int cseq, FeIndex index, std::string &htmlBody) final;
7070

7171
// =====================================================================
7272
// -- Data members -----------------------------------------------------

src/Stream.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ FeID Stream::getFeID() const {
7575
return _device->getFeID();
7676
}
7777

78+
int Stream::getFeIndex() const {
79+
return _device->getFeIndex();
80+
}
81+
7882
StreamClient &Stream::getStreamClient(int clientID) const {
7983
return _client[clientID];
8084
}

src/Stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class Stream :
8888

8989
virtual FeID getFeID() const final;
9090

91+
virtual int getFeIndex() const final;
92+
9193
virtual StreamClient &getStreamClient(int clientID) const final;
9294

9395
virtual input::SpDevice getInputDevice() const final;

src/StreamInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class StreamInterface {
4949
/// Get the FeID of the Frontend used for this stream
5050
virtual FeID getFeID() const = 0;
5151

52+
/// Get the index of this Frontend used for this stream
53+
virtual int getFeIndex() const = 0;
54+
5255
///
5356
virtual StreamClient &getStreamClient(int clientID) const = 0;
5457

src/StreamManager.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,30 @@ std::string StreamManager::getRTSPDescribeString() const {
125125
return StringConverter::stringFormat("@#1,@#2,@#3", dvb_s2, dvb_t + dvb_t2, dvb_c + dvb_c2);
126126
}
127127

128-
FeID StreamManager::findFrontendIDWithStreamID(const StreamID id) const {
128+
std::tuple<FeIndex, FeID> StreamManager::findFrontendIDWithStreamID(const StreamID id) const {
129129
for (SpStream stream : _streamVector) {
130130
if (stream->getStreamID() == id) {
131-
return stream->getFeID();
131+
return { stream->getFeIndex(), stream->getFeID() };
132132
}
133133
}
134-
return FeID();
134+
return { FeIndex(), FeID() };
135135
}
136136

137-
std::pair<FeID, StreamID> StreamManager::findFrontendID(const TransportParamVector& params) const {
137+
std::tuple<FeIndex, FeID, StreamID> StreamManager::findFrontendID(const TransportParamVector& params) const {
138138
const StreamID streamID = params.getIntParameter("stream");
139-
const FeID feID = params.getIntParameter("fe");
139+
FeID feID = params.getIntParameter("fe");
140140
// Did we find StreamID an NO FrondendID
141141
if (streamID != -1 && feID == -1) {
142-
return { findFrontendIDWithStreamID(streamID), streamID };
142+
const auto [index, feID] = findFrontendIDWithStreamID(streamID);
143+
return { index, feID, streamID };
143144
}
144145
// Is the requested FrondendID in range, then return this
145146
if (feID >= 1 && feID <= static_cast<int>(_streamVector.size())) {
146-
// We start with FeID = 0, therefore we subtract 1 from transport parameter 'fe='
147-
return { feID - 1, streamID};
147+
// The vector starts at 0, therefore we subtract 1 from transport parameter 'fe='/'FeID'
148+
return { feID - 1, feID, streamID };
148149
}
149-
// Out of range, return -1, -1
150-
return { FeID(), StreamID() };
150+
// Out of range, return -1, -1, -1
151+
return { FeIndex(), FeID(), StreamID() };
151152
}
152153

153154
SpStream StreamManager::findStreamAndClientIDFor(SocketClient &socketClient, int &clientID) {
@@ -156,8 +157,8 @@ SpStream StreamManager::findStreamAndClientIDFor(SocketClient &socketClient, int
156157
HeaderVector headers = socketClient.getHeaders();
157158
TransportParamVector params = socketClient.getTransportParameters();
158159

159-
// Now find FrontendID and/or StreamID of this message
160-
const auto [feID, streamID] = findFrontendID(params);
160+
// Now find index for FrontendID and/or StreamID of this message
161+
const auto [feIndex, feID, streamID] = findFrontendID(params);
161162

162163
std::string sessionID = headers.getFieldParameter("Session");
163164
bool newSession = false;
@@ -179,8 +180,8 @@ SpStream StreamManager::findStreamAndClientIDFor(SocketClient &socketClient, int
179180
}
180181
}
181182

182-
// if no FeID, then we have to find a suitable one
183-
if (feID == -1) {
183+
// if no index, then we have to find a suitable one
184+
if (feIndex == -1) {
184185
SI_LOG_INFO("Found FrondtendID: x (fe=x) StreamID: x SessionID: @#1", sessionID);
185186
for (SpStream stream : _streamVector) {
186187
if (stream->findClientIDFor(socketClient, newSession, sessionID, clientID)) {
@@ -189,11 +190,11 @@ SpStream StreamManager::findStreamAndClientIDFor(SocketClient &socketClient, int
189190
}
190191
}
191192
} else {
192-
SI_LOG_INFO("Found FrondtendID: @#1 (fe=@#2) StreamID: @#3 SessionID: @#4", feID, feID + 1, streamID, sessionID);
193+
SI_LOG_INFO("Found FrondtendID: @#1 (fe=@#2) StreamID: @#3 SessionID: @#4", feID, feID, streamID, sessionID);
193194
// Did we find the StreamClient?
194-
if (_streamVector[feID.getID()]->findClientIDFor(socketClient, newSession, sessionID, clientID)) {
195-
_streamVector[feID.getID()]->getStreamClient(clientID).setSessionID(sessionID);
196-
return _streamVector[feID.getID()];
195+
if (_streamVector[feIndex]->findClientIDFor(socketClient, newSession, sessionID, clientID)) {
196+
_streamVector[feIndex]->getStreamClient(clientID).setSessionID(sessionID);
197+
return _streamVector[feIndex];
197198
}
198199
// No, Then try to search in other Streams
199200
for (SpStream stream : _streamVector) {
@@ -217,14 +218,14 @@ void StreamManager::checkForSessionTimeout() {
217218
}
218219
}
219220

220-
std::string StreamManager::getDescribeMediaLevelString(const FeID id) const {
221+
std::string StreamManager::getDescribeMediaLevelString(const FeIndex feIndex) const {
221222
assert(!_streamVector.empty());
222-
return _streamVector[id.getID()]->getDescribeMediaLevelString();
223+
return _streamVector[feIndex.getID()]->getDescribeMediaLevelString();
223224
}
224225

225226
#ifdef LIBDVBCSA
226-
input::dvb::SpFrontendDecryptInterface StreamManager::getFrontendDecryptInterface(const FeID id) {
227-
return _streamVector[id.getID()]->getFrontendDecryptInterface();
227+
input::dvb::SpFrontendDecryptInterface StreamManager::getFrontendDecryptInterface(const FeIndex feIndex) {
228+
return _streamVector[feIndex.getID()]->getFrontendDecryptInterface();
228229
}
229230
#endif
230231

0 commit comments

Comments
 (0)