@@ -175,15 +175,17 @@ class streamStat{
175175 viewers = rlx.getInt (" viewers" , entry);
176176 inputs = rlx.getInt (" inputs" , entry);
177177 outputs = rlx.getInt (" outputs" , entry);
178+ tags = rlx.getPointer (" tags" , entry);
178179 }
179180 bool operator ==(const streamStat &b) const {
180- return (status == b.status && viewers == b.viewers && inputs == b.inputs && outputs == b.outputs );
181+ return (status == b.status && viewers == b.viewers && inputs == b.inputs && outputs == b.outputs && tags == b. tags );
181182 }
182183 bool operator !=(const streamStat &b) const {return !(*this == b);}
183184 uint8_t status;
184185 uint64_t viewers;
185186 uint64_t inputs;
186187 uint64_t outputs;
188+ std::string tags;
187189};
188190
189191void Controller::handleWebSocket (HTTP::Parser &H, Socket::Connection &C){
@@ -292,6 +294,7 @@ void Controller::handleWebSocket(HTTP::Parser &H, Socket::Connection &C){
292294 tmp[1u ].append (tmpStat.viewers );
293295 tmp[1u ].append (tmpStat.inputs );
294296 tmp[1u ].append (tmpStat.outputs );
297+ tmp[1u ].append (tmpStat.tags );
295298 W.sendFrame (tmp.toString ());
296299 }
297300 }
@@ -305,6 +308,7 @@ void Controller::handleWebSocket(HTTP::Parser &H, Socket::Connection &C){
305308 tmp[1u ].append (0u );
306309 tmp[1u ].append (0u );
307310 tmp[1u ].append (0u );
311+ tmp[1u ].append (" " );
308312 W.sendFrame (tmp.toString ());
309313 strmRemove.erase (strm);
310314 lastStrmStat.erase (strm);
@@ -1164,6 +1168,69 @@ void Controller::handleAPICommands(JSON::Value &Request, JSON::Value &Response){
11641168 }
11651169 }
11661170
1171+ if (Request.isMember (" tag_stream" )){
1172+ if (Request[" tag_stream" ].isObject ()){
1173+ jsonForEach (Request[" tag_stream" ], it){
1174+ if (it->isString ()){
1175+ Controller::stream_tag (it.key (), it->asStringRef ());
1176+ }else if (it->isArray ()){
1177+ jsonForEach (*it, jt){
1178+ if (jt->isString ()){
1179+ Controller::stream_tag (it.key (), jt->asStringRef ());
1180+ }
1181+ }
1182+ }
1183+ }
1184+ }
1185+ }
1186+
1187+ if (Request.isMember (" untag_stream" )){
1188+ if (Request[" untag_stream" ].isObject ()){
1189+ jsonForEach (Request[" untag_stream" ], it){
1190+ if (it->isString ()){
1191+ Controller::stream_untag (it.key (), it->asStringRef ());
1192+ }else if (it->isArray ()){
1193+ jsonForEach (*it, jt){
1194+ if (jt->isString ()){
1195+ Controller::stream_untag (it.key (), jt->asStringRef ());
1196+ }
1197+ }
1198+ }
1199+ }
1200+ }
1201+ }
1202+
1203+ if (Request.isMember (" stream_tags" )){
1204+ JSON::Value & rT = Response[" stream_tags" ];
1205+ if (Request[" stream_tags" ].isArray ()){
1206+ jsonForEach (Request[" stream_tags" ], it){
1207+ if (it->isString ()){
1208+ std::set<std::string> tags = Controller::stream_tags (it->asStringRef ());
1209+ JSON::Value & tRef = rT[it->asStringRef ()];
1210+ for (std::set<std::string>::iterator ti = tags.begin (); ti != tags.end (); ++ti){tRef.append (*ti);}
1211+ }
1212+ }
1213+ }else if (Request[" stream_tags" ].isObject ()){
1214+ jsonForEach (Request[" stream_tags" ], it){
1215+ std::set<std::string> tags = Controller::stream_tags (it.key ());
1216+ JSON::Value & tRef = rT[it.key ()];
1217+ for (std::set<std::string>::iterator ti = tags.begin (); ti != tags.end (); ++ti){tRef.append (*ti);}
1218+ }
1219+ }else if (Request[" stream_tags" ].isString () && Request[" stream_tags" ].asStringRef ().size ()){
1220+ std::set<std::string> tags = Controller::stream_tags (Request[" stream_tags" ].asStringRef ());
1221+ JSON::Value & tRef = rT[Request[" stream_tags" ].asStringRef ()];
1222+ for (std::set<std::string>::iterator ti = tags.begin (); ti != tags.end (); ++ti){tRef.append (*ti);}
1223+ }else {
1224+ JSON::Value nullPkt, resp;
1225+ Controller::fillActive (nullPkt, resp);
1226+ jsonForEach (resp, it){
1227+ std::set<std::string> tags = Controller::stream_tags (it->asStringRef ());
1228+ JSON::Value & tRef = rT[it->asStringRef ()];
1229+ for (std::set<std::string>::iterator ti = tags.begin (); ti != tags.end (); ++ti){tRef.append (*ti);}
1230+ }
1231+ }
1232+ }
1233+
11671234 if (Request.isMember (" push_start" )){
11681235 std::string stream;
11691236 std::string target;
0 commit comments