MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / read_thread

Method read_thread

src/server/ffplay/stream_handler.cpp:562–1009  ·  view source on GitHub ↗

this thread gets the stream from the disk or the network */

Source from the content-addressed store, hash-verified

560
561/* this thread gets the stream from the disk or the network */
562int StreamHandler::read_thread(void *arg) {
563#ifdef PROFILING_SH
564 if (!debugfile.is_open()) {
565 debugfile.open("profiling_read_thread.txt");
566 }
567#endif
568
569 VideoState *is = (VideoState*) arg;
570 AVFormatContext* ic = is->ic;
571
572 int err, i, ret;
573 int st_index[AVMEDIA_TYPE_NB];
574 AVPacket pkt1, *pkt = &pkt1;
575 int64_t stream_start_time;
576 int pkt_in_play_range = 0;
577 AVDictionaryEntry *t;
578 SDL_mutex *wait_mutex = SDL_CreateMutex();
579 int scan_all_pmts_set = 0;
580 int64_t pkt_ts;
581
582 if (!wait_mutex) {
583 av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError());
584 ret = AVERROR(ENOMEM);
585 goto fail;
586 }
587
588 memset(st_index, -1, sizeof(st_index));
589 is->last_video_stream = is->video_stream = -1;
590 is->last_audio_stream = is->audio_stream = -1;
591 is->last_subtitle_stream = is->subtitle_stream = -1;
592 is->eof = 0;
593
594 if (ic == 0) {
595 ic = avformat_alloc_context();
596 if (!ic) {
597 av_log(NULL, AV_LOG_FATAL, "Could not allocate context.\n");
598 ret = AVERROR(ENOMEM);
599 goto fail;
600 }
601
602 ic->interrupt_callback.callback = decode_interrupt_cb;
603 ic->interrupt_callback.opaque = is;
604 is->ic = ic;
605 }
606
607 if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
608 av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
609 scan_all_pmts_set = 1;
610 }
611
612 // Open the input file or stream.
613 err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
614 if (err < 0) {
615 print_error(is->filename, err);
616 ret = -1;
617 goto fail;
618 }
619

Callers

nothing calls this directly

Calls 13

nowFunction · 0.85
quitFunction · 0.85
print_errorFunction · 0.70
is_realtimeFunction · 0.70
sendGlobalStatusUpdateFunction · 0.50
openMethod · 0.45
setTitleMethod · 0.45
setArtistMethod · 0.45
setDurationMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected