| 305 | } |
| 306 | |
| 307 | SrtMainLoop::SrtMainLoop(const string& srt_uri, bool input_echoback, const string& input_spec, const vector<string>& output_spec) |
| 308 | { |
| 309 | // Now prepare all media |
| 310 | // They use pointers instead of real variables |
| 311 | // so that the creation time can be delayed |
| 312 | // up to this moment, and the parameters prepared |
| 313 | // before passing to the constructors. |
| 314 | |
| 315 | // Start with output media so that they are ready when |
| 316 | // the data come in. |
| 317 | |
| 318 | for (string spec: output_spec) |
| 319 | { |
| 320 | Verb() << "Setting up output: " << spec; |
| 321 | unique_ptr<TargetMedium> m { new TargetMedium }; |
| 322 | m->Setup(Target::Create(spec)); |
| 323 | m_output_media.push_back(std::move(m)); |
| 324 | } |
| 325 | |
| 326 | |
| 327 | // Start with SRT. |
| 328 | |
| 329 | UriParser srtspec(srt_uri); |
| 330 | string transtype = srtspec["transtype"].deflt("live"); |
| 331 | |
| 332 | SrtModel m(srtspec.host(), srtspec.portno(), srtspec.parameters()); |
| 333 | |
| 334 | // Just to keep it unchanged. |
| 335 | string id = m_srtspec["streamid"]; |
| 336 | |
| 337 | Verb() << "Establishing SRT connection: " << srt_uri; |
| 338 | |
| 339 | ::g_pending_model = &m; |
| 340 | m.Establish((id)); |
| 341 | |
| 342 | ::g_program_established = true; |
| 343 | ::g_pending_model = nullptr; |
| 344 | |
| 345 | Verb() << "... Established. configuring other pipes:"; |
| 346 | |
| 347 | // Once it's ready, use it to initialize the medium. |
| 348 | bool file_mode = (transtype == "file"); |
| 349 | if (g_chunksize == 0) |
| 350 | { |
| 351 | if (file_mode) |
| 352 | g_chunksize = g_default_file_chunksize; |
| 353 | else |
| 354 | g_chunksize = g_default_live_chunksize; |
| 355 | |
| 356 | Verb() << "DEFAULT CHUNKSIZE used: " << g_chunksize; |
| 357 | } |
| 358 | |
| 359 | m_srt_relay.reset(new SrtRelay); |
| 360 | m_srt_relay->StealFrom(m); |
| 361 | |
| 362 | m_srt_source.Setup(m_srt_relay.get(), g_chunksize); |
| 363 | |
| 364 | // Now check the input medium |
nothing calls this directly
no test coverage detected