this thread gets the stream from the disk or the network */
| 2876 | |
| 2877 | /* this thread gets the stream from the disk or the network */ |
| 2878 | static 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) |
nothing calls this directly
no test coverage detected