@@ -1217,6 +1217,27 @@ srs_error_t SrsOriginHub::on_dvr_request_sh()
1217
1217
return err;
1218
1218
}
1219
1219
1220
+ srs_error_t SrsOriginHub::on_hls_request_sh ()
1221
+ {
1222
+ srs_error_t err = srs_success;
1223
+
1224
+ SrsSharedPtrMessage* cache_sh_video = source->meta ->vsh ();
1225
+ if (cache_sh_video) {
1226
+ if ((err = hls->on_video (cache_sh_video, source->meta ->vsh_format ())) != srs_success) {
1227
+ return srs_error_wrap (err, " hls video" );
1228
+ }
1229
+ }
1230
+
1231
+ SrsSharedPtrMessage* cache_sh_audio = source->meta ->ash ();
1232
+ if (cache_sh_audio) {
1233
+ if ((err = hls->on_audio (cache_sh_audio, source->meta ->ash_format ())) != srs_success) {
1234
+ return srs_error_wrap (err, " hls audio" );
1235
+ }
1236
+ }
1237
+
1238
+ return err;
1239
+ }
1240
+
1220
1241
srs_error_t SrsOriginHub::on_reload_vhost_forward (string vhost)
1221
1242
{
1222
1243
srs_error_t err = srs_success;
@@ -1225,7 +1246,7 @@ srs_error_t SrsOriginHub::on_reload_vhost_forward(string vhost)
1225
1246
return err;
1226
1247
}
1227
1248
1228
- // TODO: FIXME: maybe should ignore when publish already stopped?
1249
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1229
1250
1230
1251
// forwarders
1231
1252
destroy_forwarders ();
@@ -1251,7 +1272,9 @@ srs_error_t SrsOriginHub::on_reload_vhost_dash(string vhost)
1251
1272
if (req_->vhost != vhost) {
1252
1273
return err;
1253
1274
}
1254
-
1275
+
1276
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1277
+
1255
1278
dash->on_unpublish ();
1256
1279
1257
1280
// Don't start DASH when source is not active.
@@ -1295,47 +1318,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_hls(string vhost)
1295
1318
if (req_->vhost != vhost) {
1296
1319
return err;
1297
1320
}
1298
-
1299
- // TODO: FIXME: maybe should ignore when publish already stopped?
1300
-
1301
- hls->on_unpublish ();
1302
-
1303
- // Don't start HLS when source is not active.
1304
- if (!is_active) {
1305
- return err;
1306
- }
1307
-
1308
- if ((err = hls->on_publish ()) != srs_success) {
1309
- return srs_error_wrap (err, " hls publish failed" );
1310
- }
1311
- srs_trace (" vhost %s hls reload success" , vhost.c_str ());
1312
1321
1313
- SrsRtmpFormat* format = source->format_ ;
1314
-
1315
- // when publish, don't need to fetch sequence header, which is old and maybe corrupt.
1316
- // when reload, we must fetch the sequence header from source cache.
1317
- // notice the source to get the cached sequence header.
1318
- // when reload to start hls, hls will never get the sequence header in stream,
1319
- // use the SrsLiveSource.on_hls_start to push the sequence header to HLS.
1320
- SrsSharedPtrMessage* cache_sh_video = source->meta ->vsh ();
1321
- if (cache_sh_video) {
1322
- if ((err = format->on_video (cache_sh_video)) != srs_success) {
1323
- return srs_error_wrap (err, " format on_video" );
1324
- }
1325
- if ((err = hls->on_video (cache_sh_video, format)) != srs_success) {
1326
- return srs_error_wrap (err, " hls on_video" );
1327
- }
1328
- }
1329
-
1330
- SrsSharedPtrMessage* cache_sh_audio = source->meta ->ash ();
1331
- if (cache_sh_audio) {
1332
- if ((err = format->on_audio (cache_sh_audio)) != srs_success) {
1333
- return srs_error_wrap (err, " format on_audio" );
1334
- }
1335
- if ((err = hls->on_audio (cache_sh_audio, format)) != srs_success) {
1336
- return srs_error_wrap (err, " hls on_audio" );
1337
- }
1338
- }
1322
+ hls->async_reload ();
1339
1323
1340
1324
return err;
1341
1325
}
@@ -1347,8 +1331,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_hds(string vhost)
1347
1331
if (req_->vhost != vhost) {
1348
1332
return err;
1349
1333
}
1350
-
1351
- // TODO: FIXME: maybe should ignore when publish already stopped?
1334
+
1335
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1352
1336
1353
1337
#ifdef SRS_HDS
1354
1338
hds->on_unpublish ();
@@ -1374,8 +1358,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_dvr(string vhost)
1374
1358
if (req_->vhost != vhost) {
1375
1359
return err;
1376
1360
}
1377
-
1378
- // TODO: FIXME: maybe should ignore when publish already stopped?
1361
+
1362
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1379
1363
1380
1364
// cleanup dvr
1381
1365
dvr->on_unpublish ();
@@ -1411,8 +1395,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_transcode(string vhost)
1411
1395
if (req_->vhost != vhost) {
1412
1396
return err;
1413
1397
}
1414
-
1415
- // TODO: FIXME: maybe should ignore when publish already stopped?
1398
+
1399
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1416
1400
1417
1401
encoder->on_unpublish ();
1418
1402
@@ -1436,8 +1420,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_exec(string vhost)
1436
1420
if (req_->vhost != vhost) {
1437
1421
return err;
1438
1422
}
1439
-
1440
- // TODO: FIXME: maybe should ignore when publish already stopped?
1423
+
1424
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1441
1425
1442
1426
ng_exec->on_unpublish ();
1443
1427
0 commit comments