MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / read_thread

Function read_thread

fftools/ffplay.c:2878–3225  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2876
2877/* this thread gets the stream from the disk or the network */
2878static int read_thread(void *arg)
2879{
2880 VideoState *is = arg;
2881 AVFormatContext *ic = NULL;
2882 int err, i, ret;
2883 int st_index[AVMEDIA_TYPE_NB];
2884 AVPacket *pkt = NULL;
2885 int64_t stream_start_time;
2886 char metadata_description[96];
2887 int pkt_in_play_range = 0;
2888 const AVDictionaryEntry *t;
2889 SDL_mutex *wait_mutex = SDL_CreateMutex();
2890 int scan_all_pmts_set = 0;
2891 int64_t pkt_ts;
2892
2893 if (!wait_mutex) {
2894 av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError());
2895 ret = AVERROR(ENOMEM);
2896 goto fail;
2897 }
2898
2899 memset(st_index, -1, sizeof(st_index));
2900 is->eof = 0;
2901
2902 pkt = av_packet_alloc();
2903 if (!pkt) {
2904 av_log(NULL, AV_LOG_FATAL, "Could not allocate packet.\n");
2905 ret = AVERROR(ENOMEM);
2906 goto fail;
2907 }
2908 ic = avformat_alloc_context();
2909 if (!ic) {
2910 av_log(NULL, AV_LOG_FATAL, "Could not allocate context.\n");
2911 ret = AVERROR(ENOMEM);
2912 goto fail;
2913 }
2914 ic->interrupt_callback.callback = decode_interrupt_cb;
2915 ic->interrupt_callback.opaque = is;
2916 if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
2917 av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
2918 scan_all_pmts_set = 1;
2919 }
2920 err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
2921 if (err < 0) {
2922 print_error(is->filename, err);
2923 ret = -1;
2924 goto fail;
2925 }
2926 if (scan_all_pmts_set)
2927 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
2928 remove_avoptions(&format_opts, codec_opts);
2929
2930 ret = check_avoptions(format_opts);
2931 if (ret < 0)
2932 goto fail;
2933 is->ic = ic;
2934
2935 if (genpts)

Callers

nothing calls this directly

Calls 15

av_logFunction · 0.85
av_packet_allocFunction · 0.85
avformat_alloc_contextFunction · 0.85
av_dict_getFunction · 0.85
av_dict_setFunction · 0.85
avformat_open_inputFunction · 0.85
print_errorFunction · 0.85
remove_avoptionsFunction · 0.85
check_avoptionsFunction · 0.85
av_dict_freeFunction · 0.85

Tested by

no test coverage detected