@@ -1228,6 +1228,27 @@ srs_error_t SrsOriginHub::on_dvr_request_sh()
1228
1228
return err;
1229
1229
}
1230
1230
1231
+ srs_error_t SrsOriginHub::on_hls_request_sh ()
1232
+ {
1233
+ srs_error_t err = srs_success;
1234
+
1235
+ SrsSharedPtrMessage* cache_sh_video = source->meta ->vsh ();
1236
+ if (cache_sh_video) {
1237
+ if ((err = hls->on_video (cache_sh_video, source->meta ->vsh_format ())) != srs_success) {
1238
+ return srs_error_wrap (err, " hls video" );
1239
+ }
1240
+ }
1241
+
1242
+ SrsSharedPtrMessage* cache_sh_audio = source->meta ->ash ();
1243
+ if (cache_sh_audio) {
1244
+ if ((err = hls->on_audio (cache_sh_audio, source->meta ->ash_format ())) != srs_success) {
1245
+ return srs_error_wrap (err, " hls audio" );
1246
+ }
1247
+ }
1248
+
1249
+ return err;
1250
+ }
1251
+
1231
1252
srs_error_t SrsOriginHub::on_reload_vhost_forward (string vhost)
1232
1253
{
1233
1254
srs_error_t err = srs_success;
@@ -1236,7 +1257,7 @@ srs_error_t SrsOriginHub::on_reload_vhost_forward(string vhost)
1236
1257
return err;
1237
1258
}
1238
1259
1239
- // TODO: FIXME: maybe should ignore when publish already stopped?
1260
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1240
1261
1241
1262
// forwarders
1242
1263
destroy_forwarders ();
@@ -1262,7 +1283,9 @@ srs_error_t SrsOriginHub::on_reload_vhost_dash(string vhost)
1262
1283
if (req_->vhost != vhost) {
1263
1284
return err;
1264
1285
}
1265
-
1286
+
1287
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1288
+
1266
1289
dash->on_unpublish ();
1267
1290
1268
1291
// Don't start DASH when source is not active.
@@ -1306,47 +1329,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_hls(string vhost)
1306
1329
if (req_->vhost != vhost) {
1307
1330
return err;
1308
1331
}
1309
-
1310
- // TODO: FIXME: maybe should ignore when publish already stopped?
1311
-
1312
- hls->on_unpublish ();
1313
-
1314
- // Don't start HLS when source is not active.
1315
- if (!is_active) {
1316
- return err;
1317
- }
1318
-
1319
- if ((err = hls->on_publish ()) != srs_success) {
1320
- return srs_error_wrap (err, " hls publish failed" );
1321
- }
1322
- srs_trace (" vhost %s hls reload success" , vhost.c_str ());
1323
1332
1324
- SrsRtmpFormat* format = source->format_ ;
1325
-
1326
- // when publish, don't need to fetch sequence header, which is old and maybe corrupt.
1327
- // when reload, we must fetch the sequence header from source cache.
1328
- // notice the source to get the cached sequence header.
1329
- // when reload to start hls, hls will never get the sequence header in stream,
1330
- // use the SrsLiveSource.on_hls_start to push the sequence header to HLS.
1331
- SrsSharedPtrMessage* cache_sh_video = source->meta ->vsh ();
1332
- if (cache_sh_video) {
1333
- if ((err = format->on_video (cache_sh_video)) != srs_success) {
1334
- return srs_error_wrap (err, " format on_video" );
1335
- }
1336
- if ((err = hls->on_video (cache_sh_video, format)) != srs_success) {
1337
- return srs_error_wrap (err, " hls on_video" );
1338
- }
1339
- }
1340
-
1341
- SrsSharedPtrMessage* cache_sh_audio = source->meta ->ash ();
1342
- if (cache_sh_audio) {
1343
- if ((err = format->on_audio (cache_sh_audio)) != srs_success) {
1344
- return srs_error_wrap (err, " format on_audio" );
1345
- }
1346
- if ((err = hls->on_audio (cache_sh_audio, format)) != srs_success) {
1347
- return srs_error_wrap (err, " hls on_audio" );
1348
- }
1349
- }
1333
+ hls->async_reload ();
1350
1334
1351
1335
return err;
1352
1336
}
@@ -1358,8 +1342,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_hds(string vhost)
1358
1342
if (req_->vhost != vhost) {
1359
1343
return err;
1360
1344
}
1361
-
1362
- // TODO: FIXME: maybe should ignore when publish already stopped?
1345
+
1346
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1363
1347
1364
1348
#ifdef SRS_HDS
1365
1349
hds->on_unpublish ();
@@ -1385,8 +1369,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_dvr(string vhost)
1385
1369
if (req_->vhost != vhost) {
1386
1370
return err;
1387
1371
}
1388
-
1389
- // TODO: FIXME: maybe should ignore when publish already stopped?
1372
+
1373
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1390
1374
1391
1375
// cleanup dvr
1392
1376
dvr->on_unpublish ();
@@ -1422,8 +1406,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_transcode(string vhost)
1422
1406
if (req_->vhost != vhost) {
1423
1407
return err;
1424
1408
}
1425
-
1426
- // TODO: FIXME: maybe should ignore when publish already stopped?
1409
+
1410
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1427
1411
1428
1412
encoder->on_unpublish ();
1429
1413
@@ -1447,8 +1431,8 @@ srs_error_t SrsOriginHub::on_reload_vhost_exec(string vhost)
1447
1431
if (req_->vhost != vhost) {
1448
1432
return err;
1449
1433
}
1450
-
1451
- // TODO: FIXME: maybe should ignore when publish already stopped?
1434
+
1435
+ // TODO: FIXME: Must do async reload, see SrsHls::async_reload.
1452
1436
1453
1437
ng_exec->on_unpublish ();
1454
1438
0 commit comments